12 define(
"HCU_DISPLAY_AS_HTML", 0);
13 define(
"HCU_DISPLAY_AS_JS", 1);
14 define(
"HCU_DISPLAY_AS_RAW", 2);
25 function __construct($Flang) {
26 if ( !$Flang ) $Flang =
"en_US";
27 $includeFile =
"hcuTranslate." . $Flang .
".i";
29 include(dirname(__FILE__) .
'/../includes/' . $includeFile );
31 $this->js_find = $js_find;
32 $this->js_replace = $js_replace;
33 $this->lowerChar = $lowerChar;
34 $this->upperChar = $upperChar;
35 $this->messages = $messages;
39 $this->html_decode = ($html_decode == 1 ? 1 : 0);
43 $this->langName = $langName;
51 function msg($s, $displayType = HCU_DISPLAY_AS_RAW) {
69 if (isset($this->messages[$s])) {
70 if ($displayType == HCU_DISPLAY_AS_JS) {
71 return $this->js_msg($s);
72 } elseif ($displayType == HCU_DISPLAY_AS_RAW) {
73 return html_entity_decode($this->messages[$s], ENT_QUOTES,
'UTF-8');
75 return $this->messages[$s];
78 error_log(
"HCU Message error in " . $_SERVER[
'PHP_SELF'] .
": $this->lang,message:'$s'");
82 if (isset($this->messages[$s])) {
83 $js_msg = $this->messages[$s];
84 $js_msg = str_replace(
90 error_log(
"HCU Message error in " . $_SERVER[
'PHP_SELF'] .
": $this->lang,message:'$s'");
93 function combo_msg($s, $displayType = HCU_DISPLAY_AS_HTML, $find=
"", $replace=
"") {
94 if (isset($this->messages[$s])) {
95 $combo_msg = $this->messages[$s];
96 $combo_msg = str_replace($find,$replace,$combo_msg);
97 if ($displayType == HCU_DISPLAY_AS_JS) {
99 # html entities to unicode for MSIE javascript 101 $combo_msg = str_replace(
105 } elseif ($displayType == HCU_DISPLAY_AS_RAW) {
106 return html_entity_decode($combo_msg, ENT_QUOTES,
'UTF-8');
110 error_log(
"HCU Message error in " . $_SERVER[
'PHP_SELF'] .
": $this->lang,message:'$s'");
118 function message_decode() {
120 $copyMessage = $this->messages;
122 if ($this->html_decode == 1) {
124 array_walk($copyMessage,
function(&$value, $key) {
125 $value = html_entity_decode($value, ENT_COMPAT,
'UTF-8');