PageRenderTime 77ms CodeModel.GetById 4ms app.highlight 59ms RepoModel.GetById 2ms app.codeStats 0ms

/www/lib/xajax/xajax_core/xajaxAIO.inc.php

http://firmkernel.googlecode.com/
PHP | 1242 lines | 1228 code | 14 blank | 0 comment | 154 complexity | 723f66eecfcb5159b7a37159f9a22a42 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1<?php 
  2class xajaxCall{var $sFunction;var $sReturnValue;var $aParameters;var $sMode;var $sRequestType;var $sResponseProcessor;var $sRequestURI;var $sContentType;function xajaxCall($sFunction=''){$this->sFunction=$sFunction;$this->aParameters=array();$this->sMode='';$this->sRequestType='';$this->sResponseProcessor='';$this->sRequestURI='';$this->sContentType='';}
  3function setFunction($sFunction){$this->sFunction=$sFunction;return $this;}
  4function clearParameters(){$this->aParameters=array();}
  5function addParameter($sParameter,$bUseQuotes=true){$this->aParameters[]=array($sParameter,$bUseQuotes);return $this;}
  6function addFormValuesParameter($sFormID){$this->aParameters[]=array('xajax.getFormValues("'.$sFormID.'")');return $this;}
  7function setMode($sMode){$this->sMode=$sMode;return $this;}
  8function setRequestType($sRequestType){$this->sRequestType=$sRequestType;return $this;}
  9function setResponseProcessor($sResponseProcessor){$this->sResponseProcessor=$sResponseProcessor;return $this;}
 10function setRequestURI($sRequestURI){$this->sRequestURI=$sRequestURI;return $this;}
 11function setContentType($sContentType){$this->sContentType=$sContentType;}
 12function setReturnValue($sReturnValue){$this->sReturnValue=$sReturnValue;}
 13function generate(){$output='xajax.call("';$output .=$this->sFunction;$output .='", {';$separator='';if(0 < count($this->aParameters)){$output .='parameters: [';foreach($this->aParameters as $aParameter){$output .=$separator;$bUseQuotes=$aParameter[1];if($bUseQuotes)
 14$output .='"';$output .=$aParameter[0];if($bUseQuotes)
 15$output .='"';$separator=',';}
 16$output .=']';}
 17if(0 < strlen($this->sMode)){$output .=$separator;$output .='mode:"';$output .=$this->sMode;$output .='"';$separator=',';}
 18if(0 < strlen($this->sRequestType)){$output .=$separator;$output .='requestType:"';$output .=$this->sRequestType;$output .='"';$separator=',';}
 19if(0 < strlen($this->sResponseProcessor)){$output .=$separator;$output .='responseProcessor:';$output .=$this->sResponseProcessor;$separator=',';}
 20if(0 < strlen($this->sRequestURI)){$output .=$separator;$output .='requestURI:"';$output .=$this->sRequestURI;$output .='"';$separator=',';}
 21if(0 < strlen($this->sContentType)){$output .=$separator;$output .='contentType:"';$output .=$this->sContentType;$output .='"';$separator=',';}
 22$output .='}); ';if(0 < strlen($this->sReturnValue)){$output .='return ';$output .=$this->sReturnValue;}else{$output .='return false;';}
 23return $output;}
 24}
 25
 26class xajaxPluginManager{var $aRequestPlugins;var $aResponsePlugins;var $aConfigurable;var $aRegistrars;var $aProcessors;var $aClientScriptGenerators;function xajaxPluginManager(){$this->aRequestPlugins=array();$this->aResponsePlugins=array();$this->aConfigurable=array();$this->aRegistrars=array();$this->aProcessors=array();$this->aClientScriptGenerators=array();}
 27function&getInstance(){static $obj;if(!$obj){$obj=new xajaxPluginManager();}
 28return $obj;}
 29function loadPlugins($aFolders){foreach($aFolders as $sFolder){if(is_dir($sFolder))
 30if($handle=opendir($sFolder)){while(!(false===($sName=readdir($handle)))){$nLength=strlen($sName);if(8 < $nLength){$sFileName=substr($sName,0,$nLength-8);$sExtension=substr($sName,$nLength-8,8);if('.inc.php'==$sExtension){require $sFolder . '/' . $sFileName . $sExtension;}
 31}
 32}
 33closedir($handle);}
 34}
 35}
 36function _insertIntoArray(&$aPlugins,&$objPlugin,$nPriority){while(isset($aPlugins[$nPriority]))
 37$nPriority++;$aPlugins[$nPriority]=&$objPlugin;}
 38function registerPlugin(&$objPlugin,$nPriority=1000){if(is_a($objPlugin,'xajaxRequestPlugin')){$this->_insertIntoArray($this->aRequestPlugins,$objPlugin,$nPriority);if(method_exists($objPlugin,'register'))
 39$this->_insertIntoArray($this->aRegistrars,$objPlugin,$nPriority);if(method_exists($objPlugin,'canProcessRequest'))
 40if(method_exists($objPlugin,'processRequest'))
 41$this->_insertIntoArray($this->aProcessors,$objPlugin,$nPriority);}
 42else if(is_a($objPlugin,'xajaxResponsePlugin')){$this->aResponsePlugins[]=&$objPlugin;}
 43else{}
 44if(method_exists($objPlugin,'configure'))
 45$this->_insertIntoArray($this->aConfigurable,$objPlugin,$nPriority);if(method_exists($objPlugin,'generateClientScript'))
 46$this->_insertIntoArray($this->aClientScriptGenerators,$objPlugin,$nPriority);}
 47function canProcessRequest(){$bHandled=false;$aKeys=array_keys($this->aProcessors);sort($aKeys);foreach($aKeys as $sKey){$mResult=$this->aProcessors[$sKey]->canProcessRequest();if(true===$mResult)
 48$bHandled=true;else if(is_string($mResult))
 49return $mResult;}
 50return $bHandled;}
 51function processRequest(){$bHandled=false;$aKeys=array_keys($this->aProcessors);sort($aKeys);foreach($aKeys as $sKey){$mResult=$this->aProcessors[$sKey]->processRequest();if(true===$mResult)
 52$bHandled=true;else if(is_string($mResult))
 53return $mResult;}
 54return $bHandled;}
 55function configure($sName,$mValue){$aKeys=array_keys($this->aConfigurable);sort($aKeys);foreach($aKeys as $sKey)
 56$this->aConfigurable[$sKey]->configure($sName,$mValue);}
 57function register($aArgs){$aKeys=array_keys($this->aRegistrars);sort($aKeys);foreach($aKeys as $sKey){$objPlugin=&$this->aRegistrars[$sKey];$mResult=&$objPlugin->register($aArgs);if(is_a($mResult,'xajaxRequest'))
 58return $mResult;if(is_array($mResult))
 59return $mResult;if(is_bool($mResult))
 60if(true===$mResult)
 61return true;}
 62}
 63function generateClientScript(){$aKeys=array_keys($this->aClientScriptGenerators);sort($aKeys);foreach($aKeys as $sKey)
 64$this->aClientScriptGenerators[$sKey]->generateClientScript();}
 65function&getPlugin($sName){$aKeys=array_keys($this->aResponsePlugins);sort($aKeys);foreach($aKeys as $sKey)
 66if(is_a($this->aResponsePlugins[$sKey],$sName))
 67return $this->aResponsePlugins[$sKey];$bFailure=false;return $bFailure;}
 68}
 69
 70
 71class xajaxResponseManager{var $objResponse;var $sCharacterEncoding;var $bOutputEntities;var $aDebugMessages;function xajaxResponseManager(){$this->objResponse=NULL;$this->aDebugMessages=array();}
 72function&getInstance(){static $obj;if(!$obj){$obj=new xajaxResponseManager();}
 73return $obj;}
 74function configure($sName,$mValue){if('characterEncoding'==$sName){$this->sCharacterEncoding=$mValue;if(isset($this->objResponse))
 75$this->objResponse->setCharacterEncoding($this->sCharacterEncoding);}
 76else if('outputEntities'==$sName){if(true===$mValue||false===$mValue){$this->bOutputEntities=$mValue;if(isset($this->objResponse))
 77$this->objResponse->setOutputEntities($this->bOutputEntities);}
 78}
 79}
 80function clear(){$this->objResponse=NULL;}
 81function append($mResponse){if(is_a($mResponse,'xajaxResponse')){if(NULL==$this->objResponse){$this->objResponse=$mResponse;}else if(is_a($this->objResponse,'xajaxResponse')){if($this->objResponse!=$mResponse)
 82$this->objResponse->absorb($mResponse);}else{$objLanguageManager=&xajaxLanguageManager::getInstance();$this->debug(
 83$objLanguageManager->getText('XJXRM:MXRTERR')
 84. get_class($this->objResponse)
 85. ')'
 86);}
 87}else if(is_a($mResponse,'xajaxCustomResponse')){if(NULL==$this->objResponse){$this->objResponse=$mResponse;}else if(is_a($this->objResponse,'xajaxCustomResponse')){if($this->objResponse!=$mResponse)
 88$this->objResponse->absorb($mResponse);}else{$objLanguageManager=&xajaxLanguageManager::getInstance();$this->debug(
 89$objLanguageManager->getText('XJXRM:MXRTERR')
 90. get_class($this->objResponse)
 91. ')'
 92);}
 93}else{$objLanguageManager=&xajaxLanguageManager::getInstance();$this->debug($objLanguageManager->getText('XJXRM:IRERR'));}
 94}
 95function debug($sMessage){$this->aDebugMessages[]=$sMessage;}
 96function send(){if(NULL!=$this->objResponse){foreach($this->aDebugMessages as $sMessage)
 97$this->objResponse->debug($sMessage);$this->aDebugMessages=array();$this->objResponse->printOutput();}
 98}
 99function getCharacterEncoding(){return $this->sCharacterEncoding;}
100function getOutputEntities(){return $this->bOutputEntities;}
101}
102
103class xajaxLanguageManager{var $aMessages;var $sLanguage;function xajaxLanguageManager(){$this->aMessages=array();$this->aMessages['en']=array(
104'LOGHDR:01'=> '** xajax Error Log - ',
105'LOGHDR:02'=> " **\n",
106'LOGHDR:03'=> "\n\n\n",
107'LOGERR:01'=> "** Logging Error **\n\nxajax was unable to write to the error log file:\n",
108'LOGMSG:01'=> "** PHP Error Messages: **",
109'CMPRSJS:RDERR:01'=> 'The xajax uncompressed Javascript file could not be found in the <b>',
110'CMPRSJS:RDERR:02'=> '</b> folder.  Error ',
111'CMPRSJS:WTERR:01'=> 'The xajax compressed javascript file could not be written in the <b>',
112'CMPRSJS:WTERR:02'=> '</b> folder.  Error ',
113'CMPRSPHP:WTERR:01'=> 'The xajax compressed file <b>',
114'CMPRSPHP:WTERR:02'=> '</b> could not be written to.  Error ',
115'CMPRSAIO:WTERR:01'=> 'The xajax compressed file <b>',
116'CMPRSAIO:WTERR:02'=> '/xajaxAIO.inc.php</b> could not be written to.  Error ',
117'DTCTURI:01'=> 'xajax Error: xajax failed to automatically identify your Request URI.',
118'DTCTURI:02'=> 'Please set the Request URI explicitly when you instantiate the xajax object.',
119'ARGMGR:ERR:01'=> 'Malformed object argument received: ',
120'ARGMGR:ERR:02'=> ' <==> ',
121'ARGMGR:ERR:03'=> 'The incoming xajax data could not be converted from UTF-8',
122'XJXCTL:IAERR:01'=> 'Invalid attribute [',
123'XJXCTL:IAERR:02'=> '] for element [',
124'XJXCTL:IAERR:03'=> '].',
125'XJXCTL:IRERR:01'=> 'Invalid request object passed to xajaxControl::setEvent',
126'XJXCTL:IEERR:01'=> 'Invalid attribute (event name) [',
127'XJXCTL:IEERR:02'=> '] for element [',
128'XJXCTL:IEERR:03'=> '].',
129'XJXCTL:MAERR:01'=> 'Missing required attribute [',
130'XJXCTL:MAERR:02'=> '] for element [',
131'XJXCTL:MAERR:03'=> '].',
132'XJXCTL:IETERR:01'=> "Invalid end tag designation; should be forbidden or optional.\n",
133'XJXCTL:ICERR:01'=> "Invalid class specified for html control; should be %inline, %block or %flow.\n",
134'XJXCTL:ICLERR:01'=> 'Invalid control passed to addChild; should be derived from xajaxControl.',
135'XJXCTL:ICLERR:02'=> 'Invalid control passed to addChild [',
136'XJXCTL:ICLERR:03'=> '] for element [',
137'XJXCTL:ICLERR:04'=> "].\n",
138'XJXCTL:ICHERR:01'=> 'Invalid parameter passed to xajaxControl::addChildren; should be array of xajaxControl objects',
139'XJXCTL:MRAERR:01'=> 'Missing required attribute [',
140'XJXCTL:MRAERR:02'=> '] for element [',
141'XJXCTL:MRAERR:03'=> '].',
142'XJXPLG:GNERR:01'=> 'Response plugin should override the getName function.',
143'XJXPLG:PERR:01'=> 'Response plugin should override the process function.',
144'XJXPM:IPLGERR:01'=> 'Attempt to register invalid plugin: ',
145'XJXPM:IPLGERR:02'=> ' should be derived from xajaxRequestPlugin or xajaxResponsePlugin.',
146'XJXPM:MRMERR:01'=> 'Failed to locate registration method for the following: ',
147'XJXRSP:EDERR:01'=> 'Passing character encoding to the xajaxResponse constructor is deprecated, instead use $xajax->configure("characterEncoding", ...);',
148'XJXRSP:MPERR:01'=> 'Invalid or missing plugin name detected in call to xajaxResponse::plugin',
149'XJXRSP:CPERR:01'=> "The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.",
150'XJXRSP:LCERR:01'=> "The xajax response object could not load commands as the data provided was not a valid array.",
151'XJXRSP:AKERR:01'=> 'Invalid tag name encoded in array.',
152'XJXRSP:IEAERR:01'=> 'Improperly encoded array.',
153'XJXRSP:NEAERR:01'=> 'Non-encoded array detected.',
154'XJXRSP:MBEERR:01'=> 'The xajax response output could not be converted to HTML entities because the mb_convert_encoding function is not available',
155'XJXRSP:MXRTERR'=> 'Error: Cannot mix types in a single response.',
156'XJXRSP:MXCTERR'=> 'Error: Cannot mix content types in a single response.',
157'XJXRSP:MXCEERR'=> 'Error: Cannot mix character encodings in a single response.',
158'XJXRSP:MXOEERR'=> 'Error: Cannot mix output entities (true/false) in a single response.',
159'XJXRM:IRERR'=> 'An invalid response was returned while processing this request.',
160'XJXRM:MXRTERR'=> 'Error:  You cannot mix response types while processing a single request: '
161);$this->sLanguage='en';}
162function&getInstance(){static $obj;if(!$obj){$obj=new xajaxLanguageManager();}
163return $obj;}
164function configure($sName,$mValue){if('language'==$sName){if($mValue!==$this->sLanguage){$sFolder=dirname(__FILE__);@include $sFolder . '/xajax_lang_' . $mValue . '.inc.php';$this->sLanguage=$mValue;}
165}
166}
167function register($sLanguage,$aMessages){$this->aMessages[$sLanguage]=$aMessages;}
168function getText($sMessage){if(isset($this->aMessages[$this->sLanguage]))
169if(isset($this->aMessages[$this->sLanguage][$sMessage]))
170return $this->aMessages[$this->sLanguage][$sMessage];return '(Unknown language or message identifier)'
171. $this->sLanguage
172. '::'
173. $sMessage;}
174}
175
176if(!defined('XAJAX_METHOD_UNKNOWN'))define('XAJAX_METHOD_UNKNOWN',0);if(!defined('XAJAX_METHOD_GET'))define('XAJAX_METHOD_GET',1);if(!defined('XAJAX_METHOD_POST'))define('XAJAX_METHOD_POST',2);class xajaxArgumentManager{var $aArgs;var $bDecodeUTF8Input;var $sCharacterEncoding;var $nMethod;var $aSequence;function convertStringToBool($sValue){if(0==strcasecmp($sValue,'true'))
177return true;if(0==strcasecmp($sValue,'false'))
178return false;if(is_numeric($sValue)){if(0==$sValue)
179return false;return true;}
180return false;}
181function argumentStripSlashes(&$sArg){if(false==is_string($sArg))
182return;$sArg=stripslashes($sArg);}
183function argumentDecodeXML(&$sArg){if(false==is_string($sArg))
184return;if(0==strlen($sArg))
185return;$nStackDepth=0;$aStack=array();$aArg=array();$nCurrent=0;$nLast=0;$aExpecting=array();$nFound=0;list($aExpecting,$nFound)=$this->aSequence['start'];$nLength=strlen($sArg);$sKey='';$mValue='';while($nCurrent < $nLength){$bFound=false;foreach($aExpecting as $sExpecting=> $nExpectedLength){if($sArg[$nCurrent]==$sExpecting[0]){if($sExpecting==substr($sArg,$nCurrent,$nExpectedLength)){list($aExpecting,$nFound)=$this->aSequence[$sExpecting];switch($nFound){case 3:
186$sKey='';break;case 4:
187$sKey=str_replace(
188array('<'.'![CDATA[',']]>'),
189'',
190substr($sArg,$nLast,$nCurrent-$nLast)
191);break;case 5:
192$mValue='';break;case 6:
193if($nLast < $nCurrent){$mValue=str_replace(
194array('<'.'![CDATA[',']]>'),
195'',
196substr($sArg,$nLast,$nCurrent-$nLast)
197);$cType=substr($mValue,0,1);$sValue=substr($mValue,1);switch($cType){case 'S':$mValue=false===$sValue ? '':$sValue;break;case 'B':$mValue=$this->convertStringToBool($sValue);break;case 'N':$mValue=floatval($sValue);break;case '*':$mValue=null;break;}
198}
199break;case 7:
200$aArg[$sKey]=$mValue;break;case 1:
201++$nStackDepth;array_push($aStack,$aArg);$aArg=array();array_push($aStack,$sKey);$sKey='';break;case 8:
202if(1 < $nStackDepth){$mValue=$aArg;$sKey=array_pop($aStack);$aArg=array_pop($aStack);--$nStackDepth;}else{$sArg=$aArg;return;}
203break;}
204$nCurrent+=$nExpectedLength;$nLast=$nCurrent;$bFound=true;break;}
205}
206}
207if(false==$bFound){if(0==$nCurrent){$sArg=str_replace(
208array('<'.'![CDATA[',']]>'),
209'',
210$sArg
211);$cType=substr($sArg,0,1);$sValue=substr($sArg,1);switch($cType){case 'S':$sArg=false===$sValue ? '':$sValue;break;case 'B':$sArg=$this->convertStringToBool($sValue);break;case 'N':$sArg=floatval($sValue);break;case '*':$sArg=null;break;}
212return;}
213$nCurrent++;}
214}
215$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
216$objLanguageManager->getText('ARGMGR:ERR:01')
217. $sExpecting
218. $objLanguageManager->getText('ARGMGR:ERR:02')
219. $sArg
220,E_USER_ERROR
221);}
222function argumentDecodeUTF8_iconv(&$mArg){if(is_array($mArg)){foreach(array_keys($mArg)as $sKey){$sNewKey=$sKey;$this->argumentDecodeUTF8_iconv($sNewKey);if($sNewKey!=$sKey){$mArg[$sNewKey]=$mArg[$sKey];unset($mArg[$sKey]);$sKey=$sNewKey;}
223$this->argumentDecodeUTF8_iconv($mArg[$sKey]);}
224}
225else if(is_string($mArg))
226$mArg=iconv("UTF-8",$this->sCharacterEncoding.'//TRANSLIT',$mArg);}
227function argumentDecodeUTF8_mb_convert_encoding(&$mArg){if(is_array($mArg)){foreach(array_keys($mArg)as $sKey){$sNewKey=$sKey;$this->argumentDecodeUTF8_mb_convert_encoding($sNewKey);if($sNewKey!=$sKey){$mArg[$sNewKey]=$mArg[$sKey];unset($mArg[$sKey]);$sKey=$sNewKey;}
228$this->argumentDecodeUTF8_mb_convert_encoding($mArg[$sKey]);}
229}
230else if(is_string($mArg))
231$mArg=mb_convert_encoding($mArg,$this->sCharacterEncoding,"UTF-8");}
232function argumentDecodeUTF8_utf8_decode(&$mArg){if(is_array($mArg)){foreach(array_keys($mArg)as $sKey){$sNewKey=$sKey;$this->argumentDecodeUTF8_utf8_decode($sNewKey);if($sNewKey!=$sKey){$mArg[$sNewKey]=$mArg[$sKey];unset($mArg[$sKey]);$sKey=$sNewKey;}
233$this->argumentDecodeUTF8_utf8_decode($mArg[$sKey]);}
234}
235else if(is_string($mArg))
236$mArg=utf8_decode($mArg);}
237function xajaxArgumentManager(){$this->aArgs=array();$this->bDecodeUTF8Input=false;$this->sCharacterEncoding='UTF-8';$this->nMethod=XAJAX_METHOD_UNKNOWN;$this->aSequence=array(
238'<'.'k'.'>'=> array(array(
239'<'.'/k'.'>'=> 4
240),3),
241'<'.'/k'.'>'=> array(array(
242'<'.'v'.'>'=> 3,
243'<'.'/e'.'>'=> 4
244),4),
245'<'.'v'.'>'=> array(array(
246'<'.'xjxobj'.'>'=> 8,
247'<'.'/v'.'>'=> 4
248),5),
249'<'.'/v'.'>'=> array(array(
250'<'.'/e'.'>'=> 4,
251'<'.'k'.'>'=> 3
252),6),
253'<'.'e'.'>'=> array(array(
254'<'.'k'.'>'=> 3,
255'<'.'v'.'>'=> 3,
256'<'.'/e'.'>'=> 4
257),2),
258'<'.'/e'.'>'=> array(array(
259'<'.'e'.'>'=> 3,
260'<'.'/xjxobj'.'>'=> 9
261),7),
262'<'.'xjxobj'.'>'=> array(array(
263'<'.'e'.'>'=> 3,
264'<'.'/xjxobj'.'>'=> 9
265),1),
266'<'.'/xjxobj'.'>'=> array(array(
267'<'.'/v'.'>'=> 4
268),8),
269'start'=> array(array(
270'<'.'xjxobj'.'>'=> 8
271),9)
272);if(isset($_POST['xjxargs'])){$this->nMethod=XAJAX_METHOD_POST;$this->aArgs=$_POST['xjxargs'];}else if(isset($_GET['xjxargs'])){$this->nMethod=XAJAX_METHOD_GET;$this->aArgs=$_GET['xjxargs'];}
273if(1==get_magic_quotes_gpc())
274array_walk($this->aArgs,array(&$this,'argumentStripSlashes'));array_walk($this->aArgs,array(&$this,'argumentDecodeXML'));}
275function&getInstance(){static $obj;if(!$obj){$obj=new xajaxArgumentManager();}
276return $obj;}
277function configure($sName,$mValue){if('decodeUTF8Input'==$sName){if(true===$mValue||false===$mValue)
278$this->bDecodeUTF8Input=$mValue;}else if('characterEncoding'==$sName){$this->sCharacterEncoding=$mValue;}
279}
280function getRequestMethod(){return $this->nMethod;}
281function process(){if($this->bDecodeUTF8Input){$sFunction='';if(function_exists('iconv'))
282$sFunction="iconv";else if(function_exists('mb_convert_encoding'))
283$sFunction="mb_convert_encoding";else if($this->sCharacterEncoding=="ISO-8859-1")
284$sFunction="utf8_decode";else{$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
285$objLanguageManager->getText('ARGMGR:ERR:03')
286,E_USER_NOTICE
287);}
288$mFunction=array(&$this,'argumentDecodeUTF8_' . $sFunction);array_walk($this->aArgs,$mFunction);$this->bDecodeUTF8Input=false;}
289return $this->aArgs;}
290}
291
292
293if(false==defined('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT'))define('XAJAX_HTML_CONTROL_DOCTYPE_FORMAT','XHTML');if(false==defined('XAJAX_HTML_CONTROL_DOCTYPE_VERSION'))define('XAJAX_HTML_CONTROL_DOCTYPE_VERSION','1.0');if(false==defined('XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION'))define('XAJAX_HTML_CONTROL_DOCTYPE_VALIDATION','TRANSITIONAL');class xajaxControl{var $sTag;var $sEndTag;var $aAttributes;var $aEvents;var $sClass;function xajaxControl($sTag,$aConfiguration=array()){$this->sTag=$sTag;$this->clearAttributes();if(isset($aConfiguration['attributes']))
294if(is_array($aConfiguration['attributes']))
295foreach($aConfiguration['attributes'] as $sKey=> $sValue)
296$this->setAttribute($sKey,$sValue);$this->clearEvents();if(isset($aConfiguration['event']))
297call_user_func_array(array(&$this,'setEvent'),$aConfiguration['event']);else if(isset($aConfiguration['events']))
298if(is_array($aConfiguration['events']))
299foreach($aConfiguration['events'] as $aEvent)
300call_user_func_array(array(&$this,'setEvent'),$aEvent);$this->sClass='%block';$this->sEndTag='forbidden';}
301function getClass(){return $this->sClass;}
302function clearAttributes(){$this->aAttributes=array();}
303function setAttribute($sName,$sValue){$this->aAttributes[$sName]=$sValue;}
304function getAttribute($sName){if(false==isset($this->aAttributes[$sName]))
305return null;return $this->aAttributes[$sName];}
306function clearEvents(){$this->aEvents=array();}
307function setEvent($sEvent,&$objRequest,$aParameters=array(),$sBeforeRequest='',$sAfterRequest='; return false;'){$this->aEvents[$sEvent]=array(
308&$objRequest,
309$aParameters,
310$sBeforeRequest,
311$sAfterRequest
312);}
313function getHTML($bFormat=false){ob_start();if($bFormat)
314$this->printHTML();else
315$this->printHTML(false);return ob_get_clean();}
316function printHTML($sIndent=''){$sClass=$this->getClass();if('%inline'!=$sClass)
317if(false===(false===$sIndent))
318echo $sIndent;echo '<';echo $this->sTag;echo ' ';$this->_printAttributes();$this->_printEvents();if('forbidden'==$this->sEndTag){if('HTML'==XAJAX_HTML_CONTROL_DOCTYPE_FORMAT)
319echo '>';else if('XHTML'==XAJAX_HTML_CONTROL_DOCTYPE_FORMAT)
320echo '/>';if('%inline'!=$sClass)
321if(false===(false===$sIndent))
322echo "\n";return;}
323else if('optional'==$this->sEndTag){echo '/>';if('%inline'==$sClass)
324if(false===(false===$sIndent))
325echo "\n";return;}
326}
327function _printAttributes(){foreach($this->aAttributes as $sKey=> $sValue)
328if('disabled'!=$sKey||'false'!=$sValue)
329echo "{$sKey}='{$sValue}' ";}
330function _printEvents(){foreach(array_keys($this->aEvents)as $sKey){$aEvent=&$this->aEvents[$sKey];$objRequest=&$aEvent[0];$aParameters=$aEvent[1];$sBeforeRequest=$aEvent[2];$sAfterRequest=$aEvent[3];foreach($aParameters as $aParameter){$nParameter=$aParameter[0];$sType=$aParameter[1];$sValue=$aParameter[2];$objRequest->setParameter($nParameter,$sType,$sValue);}
331$objRequest->useDoubleQuote();echo "{$sKey}='{$sBeforeRequest}";$objRequest->printScript();echo "{$sAfterRequest}' ";}
332}
333function backtrace(){if(0 <=version_compare(PHP_VERSION,'4.3.0'))
334return '<div><div>Backtrace:</div><pre>'
335. print_r(debug_backtrace(),true)
336. '</pre></div>';return '';}
337}
338class xajaxControlContainer extends xajaxControl{var $aChildren;var $sChildClass;function xajaxControlContainer($sTag,$aConfiguration=array()){xajaxControl::xajaxControl($sTag,$aConfiguration);$this->clearChildren();if(isset($aConfiguration['child']))
339$this->addChild($aConfiguration['child']);else if(isset($aConfiguration['children']))
340$this->addChildren($aConfiguration['children']);$this->sEndTag='required';}
341function getClass(){$sClass=xajaxControl::getClass();if(0 < count($this->aChildren)&&'%flow'==$sClass)
342return $this->getContentClass();else if(0==count($this->aChildren)||'%inline'==$sClass||'%block'==$sClass)
343return $sClass;$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
344$objLanguageManager->getText('XJXCTL:ICERR:01')
345. $this->backtrace()
346,E_USER_ERROR
347);}
348function getContentClass(){$sClass='';foreach(array_keys($this->aChildren)as $sKey){if(''==$sClass)
349$sClass=$this->aChildren[$sKey]->getClass();else if($sClass!=$this->aChildren[$sKey]->getClass())
350return '%flow';}
351if(''==$sClass)
352return '%inline';return $sClass;}
353function clearChildren(){$this->sChildClass='%inline';$this->aChildren=array();}
354function addChild(&$objControl){$this->aChildren[]=&$objControl;}
355function addChildren(&$aChildren){foreach(array_keys($aChildren)as $sKey)
356$this->addChild($aChildren[$sKey]);}
357function printHTML($sIndent=''){$sClass=$this->getClass();if('%inline'!=$sClass)
358if(false===(false===$sIndent))
359echo $sIndent;echo '<';echo $this->sTag;echo ' ';$this->_printAttributes();$this->_printEvents();if(0==count($this->aChildren)){if('optional'==$this->sEndTag){echo '/>';if('%inline'!=$sClass)
360if(false===(false===$sIndent))
361echo "\n";return;}
362}
363echo '>';$sContentClass=$this->getContentClass();if('%inline'!=$sContentClass)
364if(false===(false===$sIndent))
365echo "\n";$this->_printChildren($sIndent);if('%inline'!=$sContentClass)
366if(false===(false===$sIndent))
367echo $sIndent;echo '<' . '/';echo $this->sTag;echo '>';if('%inline'!=$sClass)
368if(false===(false===$sIndent))
369echo "\n";}
370function _printChildren($sIndent=''){if(false==is_a($this,'clsDocument'))
371if(false===(false===$sIndent))
372$sIndent .="\t";foreach(array_keys($this->aChildren)as $sKey){$objChild=&$this->aChildren[$sKey];$objChild->printHTML($sIndent);}
373}
374}
375
376class xajaxPlugin{}
377class xajaxRequestPlugin extends xajaxPlugin{function configure($sName,$mValue){}
378function register($aArgs){return false;}
379function generateClientScript(){}
380function canProcessRequest(){return false;}
381function processRequest(){return false;}
382}
383class xajaxResponsePlugin extends xajaxPlugin{var $objResponse;function setResponse(&$objResponse){$this->objResponse=&$objResponse;}
384function addCommand($aAttributes,$sData){$this->objResponse->addPluginCommand($this,$aAttributes,$sData);}
385function getName(){}
386function process(){}
387}
388
389if(!defined('XAJAX_DEFAULT_CHAR_ENCODING'))define('XAJAX_DEFAULT_CHAR_ENCODING','utf-8');if(!defined('XAJAX_PROCESSING_EVENT'))define('XAJAX_PROCESSING_EVENT','xajax processing event');if(!defined('XAJAX_PROCESSING_EVENT_BEFORE'))define('XAJAX_PROCESSING_EVENT_BEFORE','beforeProcessing');if(!defined('XAJAX_PROCESSING_EVENT_AFTER'))define('XAJAX_PROCESSING_EVENT_AFTER','afterProcessing');if(!defined('XAJAX_PROCESSING_EVENT_INVALID'))define('XAJAX_PROCESSING_EVENT_INVALID','invalidRequest');class xajax{var $aSettings;var $bErrorHandler;var $aProcessingEvents;var $bExitAllowed;var $bCleanBuffer;var $sLogFile;var $sCoreIncludeOutput;var $objPluginManager;var $objArgumentManager;var $objResponseManager;var $objLanguageManager;function xajax($sRequestURI=null,$sLanguage=null){$this->bErrorHandler=false;$this->aProcessingEvents=array();$this->bExitAllowed=true;$this->bCleanBuffer=true;$this->sLogFile='';$this->__wakeup();$this->configureMany(
390array(
391'characterEncoding'=> XAJAX_DEFAULT_CHAR_ENCODING,
392'decodeUTF8Input'=> false,
393'outputEntities'=> false,
394'defaultMode'=> 'asynchronous',
395'defaultMethod'=> 'POST',
396'wrapperPrefix'=> 'xajax_',
397'debug'=> false,
398'verbose'=> false,
399'useUncompressedScripts'=> false,
400'statusMessages'=> false,
401'waitCursor'=> true,
402'scriptDeferral'=> false,
403'exitAllowed'=> true,
404'errorHandler'=> false,
405'cleanBuffer'=> false,
406'allowBlankResponse'=> false,
407'allowAllResponseTypes'=> false,
408'generateStubs'=> true,
409'logFile'=> '',
410'timeout'=> 6000,
411'version'=> $this->getVersion()
412)
413);if(null!==$sRequestURI)
414$this->configure('requestURI',$sRequestURI);else
415$this->configure('requestURI',$this->_detectURI());if(null!==$sLanguage)
416$this->configure('language',$sLanguage);if('utf-8'!=XAJAX_DEFAULT_CHAR_ENCODING)$this->configure("decodeUTF8Input",true);}
417function __sleep(){$aMembers=get_class_vars(get_class($this));if(isset($aMembers['objLanguageManager']))
418unset($aMembers['objLanguageManager']);if(isset($aMembers['objPluginManager']))
419unset($aMembers['objPluginManager']);if(isset($aMembers['objArgumentManager']))
420unset($aMembers['objArgumentManager']);if(isset($aMembers['objResponseManager']))
421unset($aMembers['objResponseManager']);if(isset($aMembers['sCoreIncludeOutput']))
422unset($aMembers['sCoreIncludeOutput']);return array_keys($aMembers);}
423function __wakeup(){ob_start();$sLocalFolder=dirname(__FILE__);$aPluginFolders=array();$aPluginFolders[]=dirname($sLocalFolder). '/xajax_plugins';$this->objPluginManager=&xajaxPluginManager::getInstance();$this->objPluginManager->loadPlugins($aPluginFolders);$this->objLanguageManager=&xajaxLanguageManager::getInstance();$this->objArgumentManager=&xajaxArgumentManager::getInstance();$this->objResponseManager=&xajaxResponseManager::getInstance();$this->sCoreIncludeOutput=ob_get_clean();}
424function&getGlobalResponse(){static $obj;if(!$obj){$obj=new xajaxResponse();}
425return $obj;}
426function getVersion(){return 'xajax 0.5';}
427function register($sType,$mArg){$aArgs=func_get_args();$nArgs=func_num_args();if(2 < $nArgs){if(XAJAX_PROCESSING_EVENT==$aArgs[0]){$sEvent=$aArgs[1];$xuf=&$aArgs[2];if(false==is_a($xuf,'xajaxUserFunction'))
428$xuf=&new xajaxUserFunction($xuf);$this->aProcessingEvents[$sEvent]=&$xuf;return true;}
429}
430if(1 < $nArgs){$aArgs[1]=&$mArg;}
431return $this->objPluginManager->register($aArgs);}
432function configure($sName,$mValue){if('errorHandler'==$sName){if(true===$mValue||false===$mValue)
433$this->bErrorHandler=$mValue;}else if('exitAllowed'==$sName){if(true===$mValue||false===$mValue)
434$this->bExitAllowed=$mValue;}else if('cleanBuffer'==$sName){if(true===$mValue||false===$mValue)
435$this->bCleanBuffer=$mValue;}else if('logFile'==$sName){$this->sLogFile=$mValue;}
436$this->objLanguageManager->configure($sName,$mValue);$this->objArgumentManager->configure($sName,$mValue);$this->objPluginManager->configure($sName,$mValue);$this->objResponseManager->configure($sName,$mValue);$this->aSettings[$sName]=$mValue;}
437function configureMany($aOptions){foreach($aOptions as $sName=> $mValue)
438$this->configure($sName,$mValue);}
439function getConfiguration($sName){if(isset($this->aSettings[$sName]))
440return $this->aSettings[$sName];return NULL;}
441function canProcessRequest(){return $this->objPluginManager->canProcessRequest();}
442function processRequest(){if($this->canProcessRequest()){if($this->bErrorHandler){$GLOBALS['xajaxErrorHandlerText']="";set_error_handler("xajaxErrorHandler");}
443$mResult=true;if(isset($this->aProcessingEvents[XAJAX_PROCESSING_EVENT_BEFORE])){$bEndRequest=false;$this->aProcessingEvents[XAJAX_PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest));$mResult=(false===$bEndRequest);}
444if(true===$mResult)
445$mResult=$this->objPluginManager->processRequest();if(true===$mResult){if($this->bCleanBuffer){$er=error_reporting(0);while(ob_get_level()> 0)ob_end_clean();error_reporting($er);}
446if(isset($this->aProcessingEvents[XAJAX_PROCESSING_EVENT_AFTER])){$bEndRequest=false;$this->aProcessingEvents[XAJAX_PROCESSING_EVENT_AFTER]->call(array(&$bEndRequest));if(true===$bEndRequest){$this->objResponseManager->clear();$this->objResponseManager->append($aResult[1]);}
447}
448}
449else if(is_string($mResult)){if($this->bCleanBuffer){$er=error_reporting(0);while(ob_get_level()> 0)ob_end_clean();error_reporting($er);}
450$this->objResponseManager->clear();$this->objResponseManager->append(new xajaxResponse());if(isset($this->aProcessingEvents[XAJAX_PROCESSING_EVENT_INVALID]))
451$this->aProcessingEvents[XAJAX_PROCESSING_EVENT_INVALID]->call();else
452$this->objResponseManager->debug($mResult);}
453if($this->bErrorHandler){$sErrorMessage=$GLOBALS['xajaxErrorHandlerText'];if(!empty($sErrorMessage)){if(0 < strlen($this->sLogFile)){$fH=@fopen($this->sLogFile,"a");if(NULL!=$fH){fwrite(
454$fH,
455$this->objLanguageManager->getText('LOGHDR:01')
456. strftime("%b %e %Y %I:%M:%S %p")
457. $this->objLanguageManager->getText('LOGHDR:02')
458. $sErrorMessage
459. $this->objLanguageManager->getText('LOGHDR:03')
460);fclose($fH);}else{$this->objResponseManager->debug(
461$this->objLanguageManager->getText('LOGERR:01')
462. $this->sLogFile
463);}
464}
465$this->objResponseManager->debug(
466$this->objLanguageManager->getText('LOGMSG:01')
467. $sErrorMessage
468);}
469}
470$this->objResponseManager->send();if($this->bErrorHandler)restore_error_handler();if($this->bExitAllowed)exit();}
471}
472function printJavascript($sJsURI="",$aJsFiles=array()){if(0 < strlen($sJsURI))
473$this->configure("javascript URI",$sJsURI);if(0 < count($aJsFiles))
474$this->configure("javascript files",$aJsFiles);$this->objPluginManager->generateClientScript();}
475function getJavascript($sJsURI='',$aJsFiles=array()){ob_start();$this->printJavascript($sJsURI,$aJsFiles);return ob_get_clean();}
476function autoCompressJavascript($sJsFullFilename=NULL,$bAlways=false){$sJsFile='xajax_js/xajax_core.js';if($sJsFullFilename){$realJsFile=$sJsFullFilename;}
477else{$realPath=realpath(dirname(dirname(__FILE__)));$realJsFile=$realPath . '/'. $sJsFile;}
478if(!file_exists($realJsFile)||true==$bAlways){$srcFile=str_replace('.js','_uncompressed.js',$realJsFile);if(!file_exists($srcFile)){trigger_error(
479$this->objLanguageManager->getText('CMPRSJS:RDERR:01')
480. dirname($realJsFile)
481. $this->objLanguageManager->getText('CMPRSJS:RDERR:02')
482,E_USER_ERROR
483);}
484require_once(dirname(__FILE__). '/xajaxCompress.inc.php');$javaScript=implode('',file($srcFile));$compressedScript=xajaxCompressFile($javaScript);$fH=@fopen($realJsFile,'w');if(!$fH){trigger_error(
485$this->objLanguageManager->getText('CMPRSJS:WTERR:01')
486. dirname($realJsFile)
487. $this->objLanguageManager->getText('CMPRSJS:WTERR:02')
488,E_USER_ERROR
489);}
490else{fwrite($fH,$compressedScript);fclose($fH);}
491}
492}
493function _compressSelf($sFolder=null){if(null==$sFolder)
494$sFolder=dirname(dirname(__FILE__));require_once(dirname(__FILE__). '/xajaxCompress.inc.php');if($handle=opendir($sFolder)){while(!(false===($sName=readdir($handle)))){if('.'!=$sName&&'..'!=$sName&&is_dir($sFolder . '/' . $sName)){$this->_compressSelf($sFolder . '/' . $sName);}else if(8 < strlen($sName)&&0==strpos($sName,'.compressed')){if('.inc.php'==substr($sName,strlen($sName)-8,8)){$sName=substr($sName,0,strlen($sName)-8);$sPath=$sFolder . '/' . $sName . '.inc.php';if(file_exists($sPath)){$aParsed=array();$aFile=file($sPath);$nSkip=0;foreach(array_keys($aFile)as $sKey)
495if('//SkipDebug'==$aFile[$sKey])
496++$nSkip;else if('//EndSkipDebug'==$aFile[$sKey])
497--$nSkip;else if(0==$nSkip)
498$aParsed[]=$aFile[$sKey];unset($aFile);$compressedScript=xajaxCompressFile(implode('',$aParsed));$sNewPath=$sPath;$fH=@fopen($sNewPath,'w');if(!$fH){trigger_error(
499$this->objLanguageManager->getText('CMPRSPHP:WTERR:01')
500. $sNewPath
501. $this->objLanguageManager->getText('CMPRSPHP:WTERR:02')
502,E_USER_ERROR
503);}
504else{fwrite($fH,$compressedScript);fclose($fH);}
505}
506}
507}
508}
509closedir($handle);}
510}
511function _compile($sFolder=null,$bWriteFile=true){if(null==$sFolder)
512$sFolder=dirname(__FILE__);require_once(dirname(__FILE__). '/xajaxCompress.inc.php');$aOutput=array();if($handle=opendir($sFolder)){while(!(false===($sName=readdir($handle)))){if('.'!=$sName&&'..'!=$sName&&is_dir($sFolder . '/' . $sName)){$aOutput[]=$this->_compile($sFolder . '/' . $sName,false);}else if(8 < strlen($sName)){if('.inc.php'==substr($sName,strlen($sName)-8,8)){$sName=substr($sName,0,strlen($sName)-8);$sPath=$sFolder . '/' . $sName . '.inc.php';if(
513'xajaxAIO'!=$sName&&
514'legacy'!=$sName&&
515'xajaxCompress'!=$sName
516){if(file_exists($sPath)){$aParsed=array();$aFile=file($sPath);$nSkip=0;foreach(array_keys($aFile)as $sKey)
517if('//SkipDebug'==substr($aFile[$sKey],0,11))
518++$nSkip;else if('//EndSkipDebug'==substr($aFile[$sKey],0,14))
519--$nSkip;else if('//SkipAIO'==substr($aFile[$sKey],0,9))
520++$nSkip;else if('//EndSkipAIO'==substr($aFile[$sKey],0,12))
521--$nSkip;else if('<'.'?php'==substr($aFile[$sKey],0,5)){}
522else if('?'.'>'==substr($aFile[$sKey],0,2)){}
523else if(0==$nSkip)
524$aParsed[]=$aFile[$sKey];unset($aFile);$aOutput[]=xajaxCompressFile(implode('',$aParsed));}
525}
526}
527}
528}
529closedir($handle);}
530if($bWriteFile){$fH=@fopen($sFolder . '/xajaxAIO.inc.php','w');if(!$fH){trigger_error(
531$this->objLanguageManager->getText('CMPRSAIO:WTERR:01')
532. $sFolder
533. $this->objLanguageManager->getText('CMPRSAIO:WTERR:02')
534,E_USER_ERROR
535);}
536else{fwrite($fH,'<'.'?php ');fwrite($fH,implode('',$aOutput));fclose($fH);}
537}
538return implode('',$aOutput);}
539function _detectURI(){$aURL=array();if(!empty($_SERVER['REQUEST_URI'])){$_SERVER['REQUEST_URI']=str_replace(
540array('"',"'",'<','>'),
541array('%22','%27','%3C','%3E'),
542$_SERVER['REQUEST_URI']
543);$aURL=parse_url($_SERVER['REQUEST_URI']);}
544if(empty($aURL['scheme'])){if(!empty($_SERVER['HTTP_SCHEME'])){$aURL['scheme']=$_SERVER['HTTP_SCHEME'];}else{$aURL['scheme']=
545(!empty($_SERVER['HTTPS'])&&strtolower($_SERVER['HTTPS'])!='off')
546? 'https'
547:'http';}
548}
549if(empty($aURL['host'])){if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])){if(strpos($_SERVER['HTTP_X_FORWARDED_HOST'],':')> 0){list($aURL['host'],$aURL['port'])=explode(':',$_SERVER['HTTP_X_FORWARDED_HOST']);}else{$aURL['host']=$_SERVER['HTTP_X_FORWARDED_HOST'];}
550}else if(!empty($_SERVER['HTTP_HOST'])){if(strpos($_SERVER['HTTP_HOST'],':')> 0){list($aURL['host'],$aURL['port'])=explode(':',$_SERVER['HTTP_HOST']);}else{$aURL['host']=$_SERVER['HTTP_HOST'];}
551}else if(!empty($_SERVER['SERVER_NAME'])){$aURL['host']=$_SERVER['SERVER_NAME'];}else{echo $this->objLanguageManager->getText('DTCTURI:01');echo $this->objLanguageManager->getText('DTCTURI:02');exit();}
552}
553if(empty($aURL['port'])&&!empty($_SERVER['SERVER_PORT'])){$aURL['port']=$_SERVER['SERVER_PORT'];}
554if(!empty($aURL['path']))
555if(0==strlen(basename($aURL['path'])))
556unset($aURL['path']);if(empty($aURL['path'])){$sPath=array();if(!empty($_SERVER['PATH_INFO'])){$sPath=parse_url($_SERVER['PATH_INFO']);}else{$sPath=parse_url($_SERVER['PHP_SELF']);}
557if(isset($sPath['path']))
558$aURL['path']=str_replace(array('"',"'",'<','>'),array('%22','%27','%3C','%3E'),$sPath['path']);unset($sPath);}
559if(empty($aURL['query'])&&!empty($_SERVER['QUERY_STRING'])){$aURL['query']=$_SERVER['QUERY_STRING'];}
560if(!empty($aURL['query'])){$aURL['query']='?'.$aURL['query'];}
561$sURL=$aURL['scheme'].'://';if(!empty($aURL['user'])){$sURL.=$aURL['user'];if(!empty($aURL['pass'])){$sURL.=':'.$aURL['pass'];}
562$sURL.='@';}
563$sURL.=$aURL['host'];if(!empty($aURL['port'])
564&&(($aURL['scheme']=='http'&&$aURL['port']!=80)
565||($aURL['scheme']=='https'&&$aURL['port']!=443))){$sURL.=':'.$aURL['port'];}
566$sURL.=$aURL['path'].@$aURL['query'];unset($aURL);$aURL=explode("?",$sURL);if(1 < count($aURL)){$aQueries=explode("&",$aURL[1]);foreach($aQueries as $sKey=> $sQuery){if("xjxGenerate"==substr($sQuery,0,11))
567unset($aQueries[$sKey]);}
568$sQueries=implode("&",$aQueries);$aURL[1]=$sQueries;$sURL=implode("?",$aURL);}
569return $sURL;}
570function setCharEncoding($sEncoding){$this->configure('characterEncoding',$sEncoding);}
571function getCharEncoding(){return $this->getConfiguration('characterEncoding');}
572function setFlags($flags){foreach($flags as $name=> $value){$this->configure($name,$value);}
573}
574function setFlag($name,$value){$this->configure($name,$value);}
575function getFlag($name){return $this->getConfiguration($name);}
576function setRequestURI($sRequestURI){$this->configure('requestURI',$sRequestURI);}
577function getRequestURI(){return $this->getConfiguration('requestURI');}
578function setDefaultMode($sDefaultMode){$this->configure('defaultMode',$sDefaultMode);}
579function getDefaultMode(){return $this->getConfiguration('defaultMode');}
580function setDefaultMethod($sMethod){$this->configure('defaultMethod',$sMethod);}
581function getDefaultMethod(){return $this->getConfiguration('defaultMethod');}
582function setWrapperPrefix($sPrefix){$this->configure('wrapperPrefix',$sPrefix);}
583function getWrapperPrefix(){return $this->getConfiguration('wrapperPrefix');}
584function setLogFile($sFilename){$this->configure('logFile',$sFilename);}
585function getLogFile(){return $this->getConfiguration('logFile');}
586function registerFunction($mFunction,$sIncludeFile=null){$xuf=&new xajaxUserFunction($mFunction,$sIncludeFile);return $this->register(XAJAX_FUNCTION,$xuf);}
587function registerCallableObject(&$oObject){$mResult=false;if(0 > version_compare(PHP_VERSION,'5.0'))
588eval('$mResult = $this->register(XAJAX_CALLABLE_OBJECT, &$oObject);');else
589$mResult=$this->register(XAJAX_CALLABLE_OBJECT,$oObject);return $mResult;}
590function registerEvent($sEventName,$mCallback){$this->register(XAJAX_PROCESSING_EVENT,$sEventName,$mCallback);}
591}
592function xajaxErrorHandler($errno,$errstr,$errfile,$errline){$errorReporting=error_reporting();if(($errno&$errorReporting)==0)return;if($errno==E_NOTICE){$errTypeStr='NOTICE';}
593else if($errno==E_WARNING){$errTypeStr='WARNING';}
594else if($errno==E_USER_NOTICE){$errTypeStr='USER NOTICE';}
595else if($errno==E_USER_WARNING){$errTypeStr='USER WARNING';}
596else if($errno==E_USER_ERROR){$errTypeStr='USER FATAL ERROR';}
597else if(defined('E_STRICT')&&$errno==E_STRICT){return;}
598else{$errTypeStr='UNKNOWN: ' . $errno;}
599$sCrLf="\n";ob_start();echo $GLOBALS['xajaxErrorHandlerText'];echo $sCrLf;echo '----';echo $sCrLf;echo '[';echo $errTypeStr;echo '] ';echo $errstr;echo $sCrLf;echo 'Error on line ';echo $errline;echo ' of file ';echo $errfile;$GLOBALS['xajaxErrorHandlerText']=ob_get_clean();}
600
601class xajaxResponse{var $aCommands;var $sCharacterEncoding;var $bOutputEntities;var $returnValue;var $objPluginManager;function xajaxResponse(){if(0 < func_num_args()){$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
602$objLanguageManager->getText('XJXRSP:EDERR:01')
603,E_USER_ERROR
604);}
605$this->aCommands=array();$objResponseManager=&xajaxResponseManager::getInstance();$this->sCharacterEncoding=$objResponseManager->getCharacterEncoding();$this->bOutputEntities=$objResponseManager->getOutputEntities();$this->objPluginManager=&xajaxPluginManager::getInstance();}
606function setCharacterEncoding($sCharacterEncoding){$this->sCharacterEncoding=$sCharacterEncoding;return $this;}
607function setOutputEntities($bOutputEntities){$this->bOutputEntities=(boolean)$bOutputEntities;return $this;}
608function&plugin(){$aArgs=func_get_args();$nArgs=func_num_args();if(false==(0 < $nArgs)){$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
609$objLanguageManager->getText('XJXRSP:MPERR:01')
610,E_USER_ERROR
611);}
612$sName=array_shift($aArgs);$objPlugin=&$this->objPluginManager->getPlugin($sName);if(false===$objPlugin){$bReturn=false;return $bReturn;}
613$objPlugin->setResponse($this);if(0 < count($aArgs)){$sMethod=array_shift($aArgs);$aFunction=array(&$objPlugin,$sMethod);call_user_func_array($aFunction,$aArgs);}
614return $objPlugin;}
615function&__get($sPluginName){$objPlugin=&$this->plugin($sPluginName);return $objPlugin;}
616function confirmCommands($iCmdNumber,$sMessage){return $this->addCommand(
617array(
618'cmd'=>'cc',
619'id'=>$iCmdNumber
620),
621$sMessage
622);}
623function assign($sTarget,$sAttribute,$sData){return $this->addCommand(
624array(
625'cmd'=>'as',
626'id'=>$sTarget,
627'prop'=>$sAttribute
628),
629$sData
630);}
631function append($sTarget,$sAttribute,$sData){return $this->addCommand(
632array(
633'cmd'=>'ap',
634'id'=>$sTarget,
635'prop'=>$sAttribute
636),
637$sData
638);}
639function prepend($sTarget,$sAttribute,$sData){return $this->addCommand(
640array(
641'cmd'=>'pp',
642'id'=>$sTarget,
643'prop'=>$sAttribute
644),
645$sData
646);}
647function replace($sTarget,$sAttribute,$sSearch,$sData){return $this->addCommand(
648array(
649'cmd'=>'rp',
650'id'=>$sTarget,
651'prop'=>$sAttribute
652),
653array(
654's'=> $sSearch,
655'r'=> $sData
656)
657);}
658function clear($sTarget,$sAttribute){return $this->assign(
659$sTarget,
660$sAttribute,
661''
662);}
663function contextAssign($sAttribute,$sData){return $this->addCommand(
664array(
665'cmd'=>'c:as',
666'prop'=>$sAttribute
667),
668$sData
669);}
670function contextAppend($sAttribute,$sData){return $this->addCommand(
671array(
672'cmd'=>'c:ap',
673'prop'=>$sAttribute
674),
675$sData
676);}
677function contextPrepend($sAttribute,$sData){return $this->addCommand(
678array(
679'cmd'=>'c:pp',
680'prop'=>$sAttribute
681),
682$sData
683);}
684function contextClear($sAttribute){return $this->contextAssign(
685$sAttribute,
686''
687);}
688function alert($sMsg){return $this->addCommand(
689array(
690'cmd'=>'al'
691),
692$sMsg
693);}
694function debug($sMessage){return $this->addCommand(
695array(
696'cmd'=>'dbg'
697),
698$sMessage
699);}
700function redirect($sURL,$iDelay=0){$queryStart=strpos($sURL,'?',strrpos($sURL,'/'));if($queryStart!==FALSE){$queryStart++;$queryEnd=strpos($sURL,'#',$queryStart);if($queryEnd===FALSE)
701$queryEnd=strlen($sURL);$queryPart=substr($sURL,$queryStart,$queryEnd-$queryStart);parse_str($queryPart,$queryParts);$newQueryPart="";if($queryParts){$first=true;foreach($queryParts as $key=> $value){if($first)
702$first=false;else
703$newQueryPart .='&';$newQueryPart .=rawurlencode($key).'='.rawurlencode($value);}
704}else if($_SERVER['QUERY_STRING']){$newQueryPart=rawurlencode($_SERVER['QUERY_STRING']);}
705$sURL=str_replace($queryPart,$newQueryPart,$sURL);}
706if($iDelay)
707$this->script(
708'window.setTimeout("window.location = \''
709. $sURL
710. '\';",'
711.($iDelay*1000)
712. ');'
713);else
714$this->script(
715'window.location = "'
716. $sURL
717. '";'
718);return $this;}
719function script($sJS){return $this->addCommand(
720array(
721'cmd'=>'js'
722),
723$sJS
724);}
725function call(){$aArgs=func_get_args();$sFunc=array_shift($aArgs);return $this->addCommand(
726array(
727'cmd'=>'jc',
728'func'=>$sFunc
729),
730$aArgs
731);}
732function remove($sTarget){return $this->addCommand(
733array(
734'cmd'=>'rm',
735'id'=>$sTarget),
736''
737);}
738function create($sParent,$sTag,$sId,$sType=null){if(false===(null===$sType)){$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
739$objLanguageManager->getText('XJXRSP:CPERR:01')
740,E_USER_WARNING
741);}
742return $this->addCommand(
743array(
744'cmd'=>'ce',
745'id'=>$sParent,
746'prop'=>$sId
747),
748$sTag
749);}
750function insert($sBefore,$sTag,$sId){return $this->addCommand(
751array(
752'cmd'=>'ie',
753'id'=>$sBefore,
754'prop'=>$sId
755),
756$sTag
757);}
758function insertAfter($sAfter,$sTag,$sId){return $this->addCommand(
759array(
760'cmd'=>'ia',
761'id'=>$sAfter,
762'prop'=>$sId
763),
764$sTag
765);}
766function createInput($sParent,$sType,$sName,$sId){return $this->addCommand(
767array(
768'cmd'=>'ci',
769'id'=>$sParent,
770'prop'=>$sId,
771'type'=>$sType
772),
773$sName
774);}
775function insertInput($sBefore,$sType,$sName,$sId){return $this->addCommand(
776array(
777'cmd'=>'ii',
778'id'=>$sBefore,
779'prop'=>$sId,
780'type'=>$sType
781),
782$sName
783);}
784function insertInputAfter($sAfter,$sType,$sName,$sId){return $this->addCommand(
785array(
786'cmd'=>'iia',
787'id'=>$sAfter,
788'prop'=>$sId,
789'type'=>$sType
790),
791$sName
792);}
793function setEvent($sTarget,$sEvent,$sScript){return $this->addCommand(
794array(
795'cmd'=>'ev',
796'id'=>$sTarget,
797'prop'=>$sEvent
798),
799$sScript
800);}
801function addEvent($sTarget,$sEvent,$sScript){return $this->setEvent(
802$sTarget,
803$sEvent,
804$sScript
805);}
806function addHandler($sTarget,$sEvent,$sHandler){return $this->addCommand(
807array(
808'cmd'=>'ah',
809'id'=>$sTarget,
810'prop'=>$sEvent
811),
812$sHandler
813);}
814function removeHandler($sTarget,$sEvent,$sHandler){return $this->addCommand(
815array(
816'cmd'=>'rh',
817'id'=>$sTarget,
818'prop'=>$sEvent
819),
820$sHandler);}
821function setFunction($sFunction,$sArgs,$sScript){return $this->addCommand(
822array(
823'cmd'=>'sf',
824'func'=>$sFunction,
825'prop'=>$sArgs
826),
827$sScript
828);}
829function wrapFunction($sFunction,$sArgs,$aScripts,$sReturnValueVariable){return $this->addCommand(
830array(
831'cmd'=>'wpf',
832'func'=>$sFunction,
833'prop'=>$sArgs,
834'type'=>$sReturnValueVariable
835),
836$aScripts
837);}
838function includeScript($sFileName,$sType=null,$sId=null){$command=array('cmd'=> 'in');if(false===(null===$sType))
839$command['type']=$sType;if(false===(null===$sId))
840$command['elm_id']=$sId;return $this->addCommand(
841$command,
842$sFileName
843);}
844function includeScriptOnce($sFileName,$sType=null,$sId=null){$command=array('cmd'=> 'ino');if(false===(null===$sType))
845$command['type']=$sType;if(false===(null===$sId))
846$command['elm_id']=$sId;return $this->addCommand(
847$command,
848$sFileName
849);}
850function removeScript($sFileName,$sUnload=''){$this->addCommand(
851array(
852'cmd'=>'rjs',
853'unld'=>$sUnload
854),
855$sFileName
856);return $this;}
857function includeCSS($sFileName,$sMedia=null){$command=array('cmd'=> 'css');if(false===(null===$sMedia))
858$command['media']=$sMedia;return $this->addCommand(
859$command,
860$sFileName
861);}
862function removeCSS($sFileName,$sMedia=null){$command=array('cmd'=>'rcss');if(false===(null===$sMedia))
863$command['media']=$sMedia;return $this->addCommand(
864$command,
865$sFileName
866);}
867function waitForCSS($iTimeout=600){$sData="";$this->addCommand(
868array(
869'cmd'=>'wcss',
870'prop'=>$iTimeout
871),
872$sData
873);return $this;}
874function waitFor($script,$tenths){return $this->addCommand(
875array(
876'cmd'=>'wf',
877'prop'=>$tenths
878),
879$script
880);}
881function sleep($tenths){$this->addCommand(
882array(
883'cmd'=>'s',
884'prop'=>$tenths
885),
886''
887);return $this;}
888function setReturnValue($value){$this->returnValue=$this->_encodeArray($value);return $this;}
889function getContentType(){return 'text/xml';}
890function getOutput(){ob_start();$this->_printHeader_XML();$this->_printResponse_XML();return ob_get_clean();}
891function printOutput(){$this->_sendHeaders();$this->_printHeader_XML();$this->_printResponse_XML();}
892function _sendHeaders(){$objArgumentManager=&xajaxArgumentManager::getInstance();if(XAJAX_METHOD_GET==$objArgumentManager->getRequestMethod()){header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s"). " GMT");header("Cache-Control: no-cache, must-revalidate");header("Pragma: no-cache");}
893$sCharacterSet='';if($this->sCharacterEncoding&&0 < strlen(trim($this->sCharacterEncoding))){$sCharacterSet='; charset="' . trim($this->sCharacterEncoding). '"';}
894$sContentType=$this->getContentType();header('content-type: ' . $sContentType . ' ' . $sCharacterSet);}
895function getCommandCount(){return count($this->aCommands);}
896function loadCommands($mCommands,$bBefore=false){if(is_a($mCommands,'xajaxResponse')){$this->returnValue=$mCommands->returnValue;if($bBefore){$this->aCommands=array_merge($mCommands->aCommands,$this->aCommands);}
897else{$this->aCommands=array_merge($this->aCommands,$mCommands->aCommands);}
898}
899else if(is_array($mCommands)){if($bBefore){$this->aCommands=array_merge($mCommands,$this->aCommands);}
900else{$this->aCommands=array_merge($this->aCommands,$mCommands);}
901}
902else{if(!empty($mCommands)){$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
903$objLanguageManager->getText('XJXRSP:LCERR:01')
904,E_USER_ERROR
905);}
906}
907}
908function absorb($objResponse){$this->loadCommands($objResponse);}
909function addPluginCommand($objPlugin,$aAttributes,$mData){$aAttributes['plg']=$objPlugin->getName();return $this->addCommand($aAttributes,$mData);}
910function addCommand($aAttributes,$mData){$aAttributes['data']=$this->_encodeArray($mData);$this->aCommands[]=$aAttributes;return $this;}
911function _printHeader_XML(){echo '<';echo '?';echo 'xml version="1.0"';$sEncoding=trim($this->sCharacterEncoding);if($this->sCharacterEncoding&&0 < strlen($sEncoding)){echo ' encoding="';echo $sEncoding;echo '"';}
912echo ' ?';echo '>';}
913function _printResponse_XML(){echo '<';echo 'xjx>';if(null!==$this->returnValue){echo '<';echo 'xjxrv>';$this->_printArray_XML($this->returnValue);echo '<';echo '/xjxrv>';}
914foreach(array_keys($this->aCommands)as $sKey)
915$this->_printCommand_XML($this->aCommands[$sKey]);echo '<';echo '/xjx>';}
916function _printCommand_XML(&$aAttributes){echo '<';echo 'cmd';$mData='';foreach(array_keys($aAttributes)as $sKey){if($sKey){if('data'!=$sKey){echo ' ';echo $sKey;echo '="';echo $aAttributes[$sKey];echo '"';}else
917$mData=&$aAttributes[$sKey];}
918}
919echo '>';$this->_printArray_XML($mData);echo '<';echo '/cmd>';}
920function _printArray_XML(&$mArray){if('object'==gettype($mArray))
921$mArray=get_object_vars($mArray);if(false==is_array($mArray)){$this->_printEscapedString_XML($mArray);return;}
922echo '<';echo 'xjxobj>';foreach(array_keys($mArray)as $sKey){if(is_array($mArray[$sKey])){echo '<';echo 'e>';foreach(array_keys($mArray[$sKey])as $sInnerKey){if(htmlspecialchars($sInnerKey,ENT_COMPAT,'UTF-8')!=$sInnerKey){$objLanguageManager=&xajaxLanguageManager::getInstance();trigger_error(
923$objLanguageManager->getText('XJXRSP:AKERR:01')
924,E_USER_ERROR
925);}
926if('k'==$sInnerKey||'v'==$sInnerKey){echo '<';echo $sInnerKey;echo '>';$this->_printArray_XML($mArray[$sKey][$sInnerKey]);echo '<';echo '/';echo $sIn…

Large files files are truncated, but you can click here to view the full file