1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17: 18: 19: 20: 21:
22:
23: 24: 25: 26: 27: 28: 29:
30: final class xajaxLanguageManager
31: {
32: 33: 34: 35: 36:
37: private $aMessages;
38:
39: 40: 41: 42: 43:
44: private $sLanguage;
45:
46: 47: 48: 49: 50:
51: private function __construct()
52: {
53: $this->aMessages = array();
54:
55: $this->aMessages['en'] = array(
56: 'LOGHDR:01' => '** xajax Error Log - ',
57: 'LOGHDR:02' => " **\n",
58: 'LOGHDR:03' => "\n\n\n",
59: 'LOGERR:01' => "** Logging Error **\n\nxajax was unable to write to the error log file:\n",
60: 'LOGMSG:01' => "** PHP Error Messages: **",
61: 'CMPRSJS:RDERR:01' => 'The xajax uncompressed Javascript file could not be found in the <b>',
62: 'CMPRSJS:RDERR:02' => '</b> folder. Error ',
63: 'CMPRSJS:WTERR:01' => 'The xajax compressed javascript file could not be written in the <b>',
64: 'CMPRSJS:WTERR:02' => '</b> folder. Error ',
65: 'CMPRSPHP:WTERR:01' => 'The xajax compressed file <b>',
66: 'CMPRSPHP:WTERR:02' => '</b> could not be written to. Error ',
67: 'CMPRSAIO:WTERR:01' => 'The xajax compressed file <b>',
68: 'CMPRSAIO:WTERR:02' => '/xajaxAIO.inc.php</b> could not be written to. Error ',
69: 'DTCTURI:01' => 'xajax Error: xajax failed to automatically identify your Request URI.',
70: 'DTCTURI:02' => 'Please set the Request URI explicitly when you instantiate the xajax object.',
71: 'ARGMGR:ERR:01' => 'Malformed object argument received: ',
72: 'ARGMGR:ERR:02' => ' <==> ',
73: 'ARGMGR:ERR:03' => 'The incoming xajax data could not be converted from UTF-8',
74: 'XJXCTL:IAERR:01' => 'Invalid attribute [',
75: 'XJXCTL:IAERR:02' => '] for element [',
76: 'XJXCTL:IAERR:03' => '].',
77: 'XJXCTL:IRERR:01' => 'Invalid request object passed to xajaxControl::setEvent',
78: 'XJXCTL:IEERR:01' => 'Invalid attribute (event name) [',
79: 'XJXCTL:IEERR:02' => '] for element [',
80: 'XJXCTL:IEERR:03' => '].',
81: 'XJXCTL:MAERR:01' => 'Missing required attribute [',
82: 'XJXCTL:MAERR:02' => '] for element [',
83: 'XJXCTL:MAERR:03' => '].',
84: 'XJXCTL:IETERR:01' => "Invalid end tag designation; should be forbidden or optional.\n",
85: 'XJXCTL:ICERR:01' => "Invalid class specified for html control; should be %inline, %block or %flow.\n",
86: 'XJXCTL:ICLERR:01' => 'Invalid control passed to addChild; should be derived from xajaxControl.',
87: 'XJXCTL:ICLERR:02' => 'Invalid control passed to addChild [',
88: 'XJXCTL:ICLERR:03' => '] for element [',
89: 'XJXCTL:ICLERR:04' => "].\n",
90: 'XJXCTL:ICHERR:01' => 'Invalid parameter passed to xajaxControl::addChildren; should be array of xajaxControl objects',
91: 'XJXCTL:MRAERR:01' => 'Missing required attribute [',
92: 'XJXCTL:MRAERR:02' => '] for element [',
93: 'XJXCTL:MRAERR:03' => '].',
94: 'XJXPLG:GNERR:01' => 'Response plugin should override the getName function.',
95: 'XJXPLG:PERR:01' => 'Response plugin should override the process function.',
96: 'XJXPM:IPLGERR:01' => 'Attempt to register invalid plugin: ',
97: 'XJXPM:IPLGERR:02' => ' should be derived from xajaxRequestPlugin or xajaxResponsePlugin.',
98: 'XJXPM:MRMERR:01' => 'Failed to locate registration method for the following: ',
99: 'XJXRSP:EDERR:01' => 'Passing character encoding to the xajaxResponse constructor is deprecated, instead use $xajax->configure("characterEncoding", ...);',
100: 'XJXRSP:MPERR:01' => 'Invalid or missing plugin name detected in call to xajaxResponse::plugin',
101: 'XJXRSP:CPERR:01' => "The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.",
102: 'XJXRSP:LCERR:01' => "The xajax response object could not load commands as the data provided was not a valid array.",
103: 'XJXRSP:AKERR:01' => 'Invalid tag name encoded in array.',
104: 'XJXRSP:IEAERR:01' => 'Improperly encoded array.',
105: 'XJXRSP:NEAERR:01' => 'Non-encoded array detected.',
106: 'XJXRSP:MBEERR:01' => 'The xajax response output could not be converted to HTML entities because the mb_convert_encoding function is not available',
107: 'XJXRSP:MXRTERR' => 'Error: Cannot mix types in a single response.',
108: 'XJXRSP:MXCTERR' => 'Error: Cannot mix content types in a single response.',
109: 'XJXRSP:MXCEERR' => 'Error: Cannot mix character encodings in a single response.',
110: 'XJXRSP:MXOEERR' => 'Error: Cannot mix output entities (true/false) in a single response.',
111: 'XJXRM:IRERR' => 'An invalid response was returned while processing this request.',
112: 'XJXRM:MXRTERR' => 'Error: You cannot mix response types while processing a single request: '
113: );
114:
115: $this->sLanguage = 'en';
116: }
117:
118: 119: 120: 121: 122: 123:
124: public static function &getInstance()
125: {
126: static $obj;
127: if (!$obj) {
128: $obj = new xajaxLanguageManager();
129: }
130: return $obj;
131: }
132:
133: 134: 135: 136: 137: 138: 139: 140: 141: 142:
143: public function configure($sName, $mValue)
144: {
145: if ('language' == $sName) {
146: if ($mValue !== $this->sLanguage) {
147: $sFolder = dirname(__FILE__);
148: @include $sFolder . '/xajax_lang_' . $mValue . '.inc.php';
149:
150: $this->sLanguage = $mValue;
151: }
152: }
153: }
154:
155: 156: 157: 158: 159: 160: 161: 162: 163: 164:
165: public function register($sLanguage, $aMessages) {
166: $this->aMessages[$sLanguage] = $aMessages;
167: }
168:
169: 170: 171: 172: 173: 174: 175: 176:
177: public function getText($sMessage)
178: {
179: if (isset($this->aMessages[$this->sLanguage]))
180: if (isset($this->aMessages[$this->sLanguage][$sMessage]))
181: return $this->aMessages[$this->sLanguage][$sMessage];
182:
183: return '(Unknown language or message identifier)'
184: . $this->sLanguage
185: . '::'
186: . $sMessage;
187: }
188: }
189: