PageRenderTime 72ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/xajax_core/xajaxResponse.inc.php

https://bitbucket.org/jdboss/aide
PHP | 1908 lines | 846 code | 144 blank | 918 comment | 87 complexity | 308a74ef521c4006feb04f9968872266 MD5 | raw file
  1. <?php
  2. /*
  3. File: xajaxResponse.inc.php
  4. Contains the response class.
  5. Title: xajax response class
  6. Please see <copyright.inc.php> for a detailed description, copyright
  7. and license information.
  8. */
  9. /*
  10. @package xajax
  11. @version $Id: xajaxResponse.inc.php 361 2007-05-24 12:48:14Z calltoconstruct $
  12. @copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
  13. @copyright Copyright (c) 2008-2009 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
  14. @license http://www.xajaxproject.org/bsd_license.txt BSD License
  15. */
  16. /*
  17. Class: xajaxResponse
  18. Collect commands to be sent back to the browser in response to a xajax
  19. request. Commands are encoded and packaged in a format that is acceptable
  20. to the response handler from the javascript library running on the client
  21. side.
  22. Common commands include:
  23. - <xajaxResponse->assign>: Assign a value to an elements property.
  24. - <xajaxResponse->append>: Append a value on to an elements property.
  25. - <xajaxResponse->script>: Execute a portion of javascript code.
  26. - <xajaxResponse->call>: Execute an existing javascript function.
  27. - <xajaxResponse->alert>: Display an alert dialog to the user.
  28. Elements are identified by the value of the HTML id attribute. If you do
  29. not see your updates occuring on the browser side, ensure that you are
  30. using the correct id in your response.
  31. */
  32. class xajaxResponse
  33. {
  34. /**#@+
  35. * @access protected
  36. */
  37. /*
  38. Array: aCommands
  39. Stores the commands that will be sent to the browser in the response.
  40. */
  41. var $aCommands;
  42. /*
  43. String: sCharacterEncoding
  44. The name of the encoding method you wish to use when dealing with
  45. special characters. See <xajax->setEncoding> for more information.
  46. */
  47. var $sCharacterEncoding;
  48. /*
  49. Boolean: bOutputEntities
  50. Convert special characters to the HTML equivellent. See also
  51. <xajax->bOutputEntities> and <xajax->setFlag>.
  52. */
  53. var $bOutputEntities;
  54. /*
  55. Mixed: returnValue
  56. A string, array or integer value to be returned to the caller when
  57. using 'synchronous' mode requests. See <xajax->setMode> for details.
  58. */
  59. var $returnValue;
  60. /*
  61. Object: objPluginManager
  62. A reference to the global plugin manager.
  63. */
  64. var $objPluginManager;
  65. /**#@-*/
  66. /*
  67. Constructor: xajaxResponse
  68. Create and initialize a xajaxResponse object.
  69. */
  70. function xajaxResponse()
  71. {
  72. //SkipDebug
  73. if (0 < func_num_args()) {
  74. $objLanguageManager =& xajaxLanguageManager::getInstance();
  75. trigger_error(
  76. $objLanguageManager->getText('XJXRSP:EDERR:01')
  77. , E_USER_ERROR
  78. );
  79. }
  80. //EndSkipDebug
  81. $this->aCommands = array();
  82. $objResponseManager =& xajaxResponseManager::getInstance();
  83. $this->sCharacterEncoding = $objResponseManager->getCharacterEncoding();
  84. $this->bOutputEntities = $objResponseManager->getOutputEntities();
  85. $this->objPluginManager =& xajaxPluginManager::getInstance();
  86. }
  87. /*
  88. Function: setCharacterEncoding
  89. Overrides the default character encoding (or the one specified in the
  90. constructor) to the specified character encoding.
  91. Parameters:
  92. sCharacterEncoding - (string): The encoding method to use for this response.
  93. See also, <xajaxResponse->xajaxResponse>()
  94. Returns:
  95. object - The xajaxResponse object.
  96. */
  97. function setCharacterEncoding($sCharacterEncoding)
  98. {
  99. $this->sCharacterEncoding = $sCharacterEncoding;
  100. return $this;
  101. }
  102. /*
  103. Function: setOutputEntities
  104. Convert special characters to their HTML equivellent automatically
  105. (only works if the mb_string extension is available).
  106. Parameters:
  107. bOption - (boolean): Convert special characters
  108. Returns:
  109. object - The xajaxResponse object.
  110. */
  111. function setOutputEntities($bOutputEntities)
  112. {
  113. $this->bOutputEntities = (boolean)$bOutputEntities;
  114. return $this;
  115. }
  116. /*
  117. Function: plugin
  118. Provides access to registered response plugins. If you are using PHP
  119. 4 or 5, pass the plugin name as the first argument, the plugin method
  120. name as the second argument and subsequent arguments (if any) to be
  121. passed along to the plugin.
  122. Optionally, if you use PHP 5, you can pass just the plugin name as the
  123. first argument and the plugin object will be returned. You can then
  124. access the methods of the plugin directly.
  125. Parameters:
  126. sName - (string): Name of the plugin.
  127. sFunction - (string, optional): The name of the method to call.
  128. arg1...argn - (mixed, optional): Additional arguments to pass on to
  129. the plugin function.
  130. Returns:
  131. object - The plugin specified by sName.
  132. */
  133. function &plugin()
  134. {
  135. $aArgs = func_get_args();
  136. $nArgs = func_num_args();
  137. //SkipDebug
  138. if (false == (0 < $nArgs)) {
  139. $objLanguageManager =& xajaxLanguageManager::getInstance();
  140. trigger_error(
  141. $objLanguageManager->getText('XJXRSP:MPERR:01')
  142. , E_USER_ERROR
  143. );
  144. }
  145. //EndSkipDebug
  146. $sName = array_shift($aArgs);
  147. $objPlugin =& $this->objPluginManager->getPlugin($sName);
  148. if (false === $objPlugin)
  149. {
  150. $bReturn = false;
  151. return $bReturn;
  152. }
  153. $objPlugin->setResponse($this);
  154. if (0 < count($aArgs))
  155. {
  156. $sMethod = array_shift($aArgs);
  157. $aFunction = array(&$objPlugin, $sMethod);
  158. call_user_func_array($aFunction, $aArgs);
  159. }
  160. return $objPlugin;
  161. }
  162. /*
  163. Function: __get
  164. Magic function for PHP 5. Used to permit plugins to be called as if they
  165. where native members of the xajaxResponse instance.
  166. Parameters:
  167. sPluginName - (string): The name of the plugin.
  168. Returns:
  169. object - The plugin specified by sPluginName.
  170. */
  171. function &__get($sPluginName)
  172. {
  173. $objPlugin =& $this->plugin($sPluginName);
  174. return $objPlugin;
  175. }
  176. /*
  177. Function: confirmCommands
  178. Response command that prompts user with [ok] [cancel] style
  179. message box. If the user clicks cancel, the specified
  180. number of response commands following this one, will be
  181. skipped.
  182. Parameters:
  183. iCmdNumber - (integer): The number of commands to skip upon cancel.
  184. sMessage - (string): The message to display to the user.
  185. Returns:
  186. object : The xajaxResponse object.
  187. */
  188. function confirmCommands($iCmdNumber, $sMessage)
  189. {
  190. return $this->addCommand(
  191. array(
  192. 'cmd'=>'cc',
  193. 'id'=>$iCmdNumber
  194. ),
  195. $sMessage
  196. );
  197. }
  198. /*
  199. Function: assign
  200. Response command indicating that the specified value should be
  201. assigned to the given element's attribute.
  202. Parameters:
  203. sTarget - (string): The id of the html element on the browser.
  204. sAttribute - (string): The property to be assigned.
  205. sData - (string): The value to be assigned to the property.
  206. Returns:
  207. object : The <xajaxResponse> object.
  208. */
  209. function assign($sTarget,$sAttribute,$sData)
  210. {
  211. return $this->addCommand(
  212. array(
  213. 'cmd'=>'as',
  214. 'id'=>$sTarget,
  215. 'prop'=>$sAttribute
  216. ),
  217. $sData
  218. );
  219. }
  220. /*
  221. Function: append
  222. Response command that indicates the specified data should be appended
  223. to the given element's property.
  224. Parameters:
  225. sTarget - (string): The id of the element to be updated.
  226. sAttribute - (string): The name of the property to be appended to.
  227. sData - (string): The data to be appended to the property.
  228. Returns:
  229. object : The <xajaxResponse> object.
  230. */
  231. function append($sTarget,$sAttribute,$sData)
  232. {
  233. return $this->addCommand(
  234. array(
  235. 'cmd'=>'ap',
  236. 'id'=>$sTarget,
  237. 'prop'=>$sAttribute
  238. ),
  239. $sData
  240. );
  241. }
  242. /*
  243. Function: prepend
  244. Response command to prepend the specified value onto the given
  245. element's property.
  246. Parameters:
  247. sTarget - (string): The id of the element to be updated.
  248. sAttribute - (string): The property to be updated.
  249. sData - (string): The value to be prepended.
  250. Returns:
  251. object : The <xajaxResponse> object.
  252. */
  253. function prepend($sTarget,$sAttribute,$sData)
  254. {
  255. return $this->addCommand(
  256. array(
  257. 'cmd'=>'pp',
  258. 'id'=>$sTarget,
  259. 'prop'=>$sAttribute
  260. ),
  261. $sData
  262. );
  263. }
  264. /*
  265. Function: replace
  266. Replace a specified value with another value within the given
  267. element's property.
  268. Parameters:
  269. sTarget - (string): The id of the element to update.
  270. sAttribute - (string): The property to be updated.
  271. sSearch - (string): The needle to search for.
  272. sData - (string): The data to use in place of the needle.
  273. */
  274. function replace($sTarget,$sAttribute,$sSearch,$sData)
  275. {
  276. return $this->addCommand(
  277. array(
  278. 'cmd'=>'rp',
  279. 'id'=>$sTarget,
  280. 'prop'=>$sAttribute
  281. ),
  282. array(
  283. 's' => $sSearch,
  284. 'r' => $sData
  285. )
  286. );
  287. }
  288. /*
  289. Function: clear
  290. Response command used to clear the specified property of the
  291. given element.
  292. Parameters:
  293. sTarget - (string): The id of the element to be updated.
  294. sAttribute - (string): The property to be clared.
  295. Returns:
  296. object - The <xajaxResponse> object.
  297. */
  298. function clear($sTarget,$sAttribute)
  299. {
  300. return $this->assign(
  301. $sTarget,
  302. $sAttribute,
  303. ''
  304. );
  305. }
  306. /*
  307. Function: contextAssign
  308. Response command used to assign a value to a member of a
  309. javascript object (or element) that is specified by the context
  310. member of the request. The object is referenced using the 'this' keyword
  311. in the sAttribute parameter.
  312. Parameters:
  313. sAttribute - (string): The property to be updated.
  314. sData - (string): The value to assign.
  315. Returns:
  316. object : The <xajaxResponse> object.
  317. */
  318. function contextAssign($sAttribute, $sData)
  319. {
  320. return $this->addCommand(
  321. array(
  322. 'cmd'=>'c:as',
  323. 'prop'=>$sAttribute
  324. ),
  325. $sData
  326. );
  327. }
  328. /*
  329. Function: contextAppend
  330. Response command used to append a value onto the specified member
  331. of the javascript context object (or element) specified by the context
  332. member of the request. The object is referenced using the 'this' keyword
  333. in the sAttribute parameter.
  334. Parameters:
  335. sAttribute - (string): The member to be appended to.
  336. sData - (string): The value to append.
  337. Returns:
  338. object : The <xajaxResponse> object.
  339. */
  340. function contextAppend($sAttribute, $sData)
  341. {
  342. return $this->addCommand(
  343. array(
  344. 'cmd'=>'c:ap',
  345. 'prop'=>$sAttribute
  346. ),
  347. $sData
  348. );
  349. }
  350. /*
  351. Function: contextPrepend
  352. Response command used to prepend the speicified data to the given
  353. member of the current javascript object specified by context in the
  354. current request. The object is access via the 'this' keyword in the
  355. sAttribute parameter.
  356. Parameters:
  357. sAttribute - (string): The member to be updated.
  358. sData - (string): The value to be prepended.
  359. Returns:
  360. object : The <xajaxResponse> object.
  361. */
  362. function contextPrepend($sAttribute, $sData)
  363. {
  364. return $this->addCommand(
  365. array(
  366. 'cmd'=>'c:pp',
  367. 'prop'=>$sAttribute
  368. ),
  369. $sData
  370. );
  371. }
  372. /*
  373. Function: contextClear
  374. Response command used to clear the value of the property specified
  375. in the sAttribute parameter. The member is access via the 'this'
  376. keyword and can be used to update a javascript object specified
  377. by context in the request parameters.
  378. Parameters:
  379. sAttribute - (string): The member to be cleared.
  380. Returns:
  381. object : The <xajaxResponse> object.
  382. */
  383. function contextClear($sAttribute)
  384. {
  385. return $this->contextAssign(
  386. $sAttribute,
  387. ''
  388. );
  389. }
  390. /*
  391. Function: alert
  392. Response command that is used to display an alert message to the user.
  393. Parameters:
  394. sMsg - (string): The message to be displayed.
  395. Returns:
  396. object : The <xajaxResponse> object.
  397. */
  398. function alert($sMsg)
  399. {
  400. return $this->addCommand(
  401. array(
  402. 'cmd'=>'al'
  403. ),
  404. $sMsg
  405. );
  406. }
  407. function debug($sMessage)
  408. {
  409. return $this->addCommand(
  410. array(
  411. 'cmd'=>'dbg'
  412. ),
  413. $sMessage
  414. );
  415. }
  416. /*
  417. Function: redirect
  418. Response command that causes the browser to navigate to the specified
  419. URL.
  420. Parameters:
  421. sURL - (string): The relative or fully qualified URL.
  422. iDelay - (integer, optional): Number of seconds to delay before
  423. the redirect occurs.
  424. Returns:
  425. object : The <xajaxResponse> object.
  426. */
  427. function redirect($sURL, $iDelay=0)
  428. {
  429. //we need to parse the query part so that the values are rawurlencode()'ed
  430. //can't just use parse_url() cos we could be dealing with a relative URL which
  431. // parse_url() can't deal with.
  432. $queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
  433. if ($queryStart !== FALSE)
  434. {
  435. $queryStart++;
  436. $queryEnd = strpos($sURL, '#', $queryStart);
  437. if ($queryEnd === FALSE)
  438. $queryEnd = strlen($sURL);
  439. $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
  440. parse_str($queryPart, $queryParts);
  441. $newQueryPart = "";
  442. if ($queryParts)
  443. {
  444. $first = true;
  445. foreach($queryParts as $key => $value)
  446. {
  447. if ($first)
  448. $first = false;
  449. else
  450. $newQueryPart .= '&';
  451. $newQueryPart .= rawurlencode($key).'='.rawurlencode($value);
  452. }
  453. } else if ($_SERVER['QUERY_STRING']) {
  454. //couldn't break up the query, but there's one there
  455. //possibly "http://url/page.html?query1234" type of query?
  456. //just encode it and hope it works
  457. $newQueryPart = rawurlencode($_SERVER['QUERY_STRING']);
  458. }
  459. $sURL = str_replace($queryPart, $newQueryPart, $sURL);
  460. }
  461. if ($iDelay)
  462. $this->script(
  463. 'window.setTimeout("window.location = \''
  464. . $sURL
  465. . '\';",'
  466. . ($iDelay*1000)
  467. . ');'
  468. );
  469. else
  470. $this->script(
  471. 'window.location = "'
  472. . $sURL
  473. . '";'
  474. );
  475. return $this;
  476. }
  477. /*
  478. Function: script
  479. Response command that is used to execute a portion of javascript on
  480. the browser. The script runs in it's own context, so variables declared
  481. locally, using the 'var' keyword, will no longer be available after the
  482. call. To construct a variable that will be accessable globally, even
  483. after the script has executed, leave off the 'var' keyword.
  484. Parameters:
  485. sJS - (string): The script to execute.
  486. Returns:
  487. object : The <xajaxResponse> object.
  488. */
  489. function script($sJS)
  490. {
  491. return $this->addCommand(
  492. array(
  493. 'cmd'=>'js'
  494. ),
  495. $sJS
  496. );
  497. }
  498. /*
  499. Function: call
  500. Response command that indicates that the specified javascript
  501. function should be called with the given (optional) parameters.
  502. Parameters:
  503. arg1 - (string): The name of the function to call.
  504. arg2 .. argn : arguments to be passed to the function.
  505. Returns:
  506. object : The <xajaxResponse> object.
  507. */
  508. function call() {
  509. $aArgs = func_get_args();
  510. $sFunc = array_shift($aArgs);
  511. return $this->addCommand(
  512. array(
  513. 'cmd'=>'jc',
  514. 'func'=>$sFunc
  515. ),
  516. $aArgs
  517. );
  518. }
  519. /*
  520. Function: remove
  521. Response command used to remove an element from the document.
  522. Parameters:
  523. sTarget - (string): The id of the element to be removed.
  524. Returns:
  525. object : The <xajaxResponse> object.
  526. */
  527. function remove($sTarget)
  528. {
  529. return $this->addCommand(
  530. array(
  531. 'cmd'=>'rm',
  532. 'id'=>$sTarget),
  533. ''
  534. );
  535. }
  536. /*
  537. Function: create
  538. Response command used to create a new element on the browser.
  539. Parameters:
  540. sParent - (string): The id of the parent element.
  541. sTag - (string): The tag name to be used for the new element.
  542. sId - (string): The id to assign to the new element.
  543. sType - (string, optional): The type of tag, deprecated, use
  544. <xajaxResponse->createInput> instead.
  545. Returns:
  546. object : The <xajaxResponse> object.
  547. */
  548. function create($sParent, $sTag, $sId, $sType=null)
  549. {
  550. //SkipDebug
  551. if (false === (null === $sType)) {
  552. $objLanguageManager =& xajaxLanguageManager::getInstance();
  553. trigger_error(
  554. $objLanguageManager->getText('XJXRSP:CPERR:01')
  555. , E_USER_WARNING
  556. );
  557. }
  558. //EndSkipDebug
  559. return $this->addCommand(
  560. array(
  561. 'cmd'=>'ce',
  562. 'id'=>$sParent,
  563. 'prop'=>$sId
  564. ),
  565. $sTag
  566. );
  567. }
  568. /*
  569. Function: insert
  570. Response command used to insert a new element just prior to the specified
  571. element.
  572. Parameters:
  573. sBefore - (string): The element used as a reference point for the
  574. insertion.
  575. sTag - (string): The tag to be used for the new element.
  576. sId - (string): The id to be used for the new element.
  577. Returns:
  578. object : The <xajaxResponse> object.
  579. */
  580. function insert($sBefore, $sTag, $sId)
  581. {
  582. return $this->addCommand(
  583. array(
  584. 'cmd'=>'ie',
  585. 'id'=>$sBefore,
  586. 'prop'=>$sId
  587. ),
  588. $sTag
  589. );
  590. }
  591. /*
  592. Function: insertAfter
  593. Response command used to insert a new element after the specified
  594. one.
  595. Parameters:
  596. sAfter - (string): The id of the element that will be used as a reference
  597. for the insertion.
  598. sTag - (string): The tag name to be used for the new element.
  599. sId - (string): The id to be used for the new element.
  600. Returns:
  601. object : The <xajaxResponse> object.
  602. */
  603. function insertAfter($sAfter, $sTag, $sId)
  604. {
  605. return $this->addCommand(
  606. array(
  607. 'cmd'=>'ia',
  608. 'id'=>$sAfter,
  609. 'prop'=>$sId
  610. ),
  611. $sTag
  612. );
  613. }
  614. /*
  615. Function: createInput
  616. Response command used to create an input element on the browser.
  617. Parameters:
  618. sParent - (string): The id of the parent element.
  619. sType - (string): The type of the new input element.
  620. sName - (string): The name of the new input element.
  621. sId - (string): The id of the new element.
  622. Returns:
  623. object : The <xajaxResponse> object.
  624. */
  625. function createInput($sParent, $sType, $sName, $sId)
  626. {
  627. return $this->addCommand(
  628. array(
  629. 'cmd'=>'ci',
  630. 'id'=>$sParent,
  631. 'prop'=>$sId,
  632. 'type'=>$sType
  633. ),
  634. $sName
  635. );
  636. }
  637. /*
  638. Function: insertInput
  639. Response command used to insert a new input element preceeding the
  640. specified element.
  641. Parameters:
  642. sBefore - (string): The id of the element to be used as the reference
  643. point for the insertion.
  644. sType - (string): The type of the new input element.
  645. sName - (string): The name of the new input element.
  646. sId - (string): The id of the new input element.
  647. Returns:
  648. object : The <xajaxResponse> object.
  649. */
  650. function insertInput($sBefore, $sType, $sName, $sId)
  651. {
  652. return $this->addCommand(
  653. array(
  654. 'cmd'=>'ii',
  655. 'id'=>$sBefore,
  656. 'prop'=>$sId,
  657. 'type'=>$sType
  658. ),
  659. $sName
  660. );
  661. }
  662. /*
  663. Function: insertInputAfter
  664. Response command used to insert a new input element after the
  665. specified element.
  666. Parameters:
  667. sAfter - (string): The id of the element that is to be used
  668. as the insertion point for the new element.
  669. sType - (string): The type of the new input element.
  670. sName - (string): The name of the new input element.
  671. sId - (string): The id of the new input element.
  672. Returns:
  673. object : The <xajaxResponse> object.
  674. */
  675. function insertInputAfter($sAfter, $sType, $sName, $sId)
  676. {
  677. return $this->addCommand(
  678. array(
  679. 'cmd'=>'iia',
  680. 'id'=>$sAfter,
  681. 'prop'=>$sId,
  682. 'type'=>$sType
  683. ),
  684. $sName
  685. );
  686. }
  687. /*
  688. Function: setEvent
  689. Response command used to set an event handler on the browser.
  690. Parameters:
  691. sTarget - (string): The id of the element that contains the event.
  692. sEvent - (string): The name of the event.
  693. sScript - (string): The javascript to execute when the event is fired.
  694. Returns:
  695. object : The <xajaxResponse> object.
  696. */
  697. function setEvent($sTarget,$sEvent,$sScript)
  698. {
  699. return $this->addCommand(
  700. array(
  701. 'cmd'=>'ev',
  702. 'id'=>$sTarget,
  703. 'prop'=>$sEvent
  704. ),
  705. $sScript
  706. );
  707. }
  708. /*
  709. Function: addEvent
  710. Response command used to set an event handler on the browser.
  711. Parameters:
  712. sTarget - (string): The id of the element that contains the event.
  713. sEvent - (string): The name of the event.
  714. sScript - (string): The javascript to execute when the event is fired.
  715. Returns:
  716. object : The <xajaxResponse> object.
  717. Note:
  718. This function is depreciated and will be removed in a future version.
  719. Use <setEvent> instead.
  720. */
  721. function addEvent($sTarget,$sEvent,$sScript)
  722. {
  723. return $this->setEvent(
  724. $sTarget,
  725. $sEvent,
  726. $sScript
  727. );
  728. }
  729. /*
  730. Function: addHandler
  731. Response command used to install an event handler on the specified element.
  732. Parameters:
  733. sTarget - (string): The id of the element.
  734. sEvent - (string): The name of the event to add the handler to.
  735. sHandler - (string): The javascript function to call when the event is fired.
  736. You can add more than one event handler to an element's event using this method.
  737. Returns:
  738. object - The <xajaxResponse> object.
  739. */
  740. function addHandler($sTarget,$sEvent,$sHandler)
  741. {
  742. return $this->addCommand(
  743. array(
  744. 'cmd'=>'ah',
  745. 'id'=>$sTarget,
  746. 'prop'=>$sEvent
  747. ),
  748. $sHandler
  749. );
  750. }
  751. /*
  752. Function: removeHandler
  753. Response command used to remove an event handler from an element.
  754. Parameters:
  755. sTarget - (string): The id of the element.
  756. sEvent - (string): The name of the event.
  757. sHandler - (string): The javascript function that is called when the
  758. event is fired.
  759. Returns:
  760. object : The <xajaxResponse> object.
  761. */
  762. function removeHandler($sTarget,$sEvent,$sHandler)
  763. {
  764. return $this->addCommand(
  765. array(
  766. 'cmd'=>'rh',
  767. 'id'=>$sTarget,
  768. 'prop'=>$sEvent
  769. ),
  770. $sHandler);
  771. }
  772. /*
  773. Function: setFunction
  774. Response command used to construct a javascript function on the browser.
  775. Parameters:
  776. sFunction - (string): The name of the function to construct.
  777. sArgs - (string): Comma separated list of parameter names.
  778. sScript - (string): The javascript code that will become the body of the
  779. function.
  780. Returns:
  781. object : The <xajaxResponse> object.
  782. */
  783. function setFunction($sFunction, $sArgs, $sScript)
  784. {
  785. return $this->addCommand(
  786. array(
  787. 'cmd'=>'sf',
  788. 'func'=>$sFunction,
  789. 'prop'=>$sArgs
  790. ),
  791. $sScript
  792. );
  793. }
  794. /*
  795. Function: wrapFunction
  796. Response command used to construct a wrapper function around
  797. and existing javascript function on the browser.
  798. Parameters:
  799. sFunction - (string): The name of the existing function to wrap.
  800. sArgs - (string): The comma separated list of parameters for the function.
  801. aScripts - (array): An array of javascript code snippets that will
  802. be used to build the body of the function. The first piece of code
  803. specified in the array will occur before the call to the original
  804. function, the second will occur after the original function is called.
  805. sReturnValueVariable - (string): The name of the variable that will
  806. retain the return value from the call to the original function.
  807. Returns:
  808. object : The <xajaxResponse> object.
  809. */
  810. function wrapFunction($sFunction, $sArgs, $aScripts, $sReturnValueVariable)
  811. {
  812. return $this->addCommand(
  813. array(
  814. 'cmd'=>'wpf',
  815. 'func'=>$sFunction,
  816. 'prop'=>$sArgs,
  817. 'type'=>$sReturnValueVariable
  818. ),
  819. $aScripts
  820. );
  821. }
  822. /*
  823. Function: includeScript
  824. Response command used to load a javascript file on the browser.
  825. Parameters:
  826. sFileName - (string): The relative or fully qualified URI of the
  827. javascript file.
  828. sType - (string): Determines the script type . Defaults to 'text/javascript'.
  829. Returns:
  830. object : The <xajaxResponse> object.
  831. */
  832. function includeScript($sFileName, $sType = null, $sId = null)
  833. {
  834. $command = array('cmd' => 'in');
  835. if (false === (null === $sType))
  836. $command['type'] = $sType;
  837. if (false === (null === $sId))
  838. $command['elm_id'] = $sId;
  839. return $this->addCommand(
  840. $command,
  841. $sFileName
  842. );
  843. }
  844. /*
  845. Function: includeScriptOnce
  846. Response command used to include a javascript file on the browser
  847. if it has not already been loaded.
  848. Parameters:
  849. sFileName - (string): The relative for fully qualified URI of the
  850. javascript file.
  851. sType - (string): Determines the script type . Defaults to 'text/javascript'.
  852. Returns:
  853. object : The <xajaxResponse> object.
  854. */
  855. function includeScriptOnce($sFileName, $sType = null, $sId = null)
  856. {
  857. $command = array('cmd' => 'ino');
  858. if (false === (null === $sType))
  859. $command['type'] = $sType;
  860. if (false === (null === $sId))
  861. $command['elm_id'] = $sId;
  862. return $this->addCommand(
  863. $command,
  864. $sFileName
  865. );
  866. }
  867. /*
  868. Function: removeScript
  869. Response command used to remove a SCRIPT reference to a javascript
  870. file on the browser. Optionally, you can call a javascript function
  871. just prior to the file being unloaded (for cleanup).
  872. Parameters:
  873. sFileName - (string): The relative or fully qualified URI of the
  874. javascript file.
  875. sUnload - (string): Name of a javascript function to call prior
  876. to unlaoding the file.
  877. Returns:
  878. object : The <xajaxResponse> object.
  879. */
  880. function removeScript($sFileName, $sUnload = '') {
  881. $this->addCommand(
  882. array(
  883. 'cmd'=>'rjs',
  884. 'unld'=>$sUnload
  885. ),
  886. $sFileName
  887. );
  888. return $this;
  889. }
  890. /*
  891. Function: includeCSS
  892. Response command used to include a LINK reference to
  893. the specified CSS file on the browser. This will cause the
  894. browser to load and apply the style sheet.
  895. Parameters:
  896. sFileName - (string): The relative or fully qualified URI of
  897. the css file.
  898. sMedia - (string): Determines the media type of the CSS file. Defaults to 'screen'.
  899. Returns:
  900. object : The <xajaxResponse> object.
  901. */
  902. function includeCSS($sFileName, $sMedia = null)
  903. {
  904. $command = array('cmd' => 'css');
  905. if (false === (null === $sMedia))
  906. $command['media'] = $sMedia;
  907. return $this->addCommand(
  908. $command,
  909. $sFileName
  910. );
  911. }
  912. /*
  913. Function: removeCSS
  914. Response command used to remove a LINK reference to
  915. a CSS file on the browser. This causes the browser to
  916. unload the style sheet, effectively removing the style
  917. changes it caused.
  918. Parameters:
  919. sFileName - (string): The relative or fully qualified URI
  920. of the css file.
  921. Returns:
  922. object : The <xajaxResponse> object.
  923. */
  924. function removeCSS($sFileName, $sMedia = null)
  925. {
  926. $command = array('cmd'=>'rcss');
  927. if (false === (null === $sMedia))
  928. $command['media'] = $sMedia;
  929. return $this->addCommand(
  930. $command,
  931. $sFileName
  932. );
  933. }
  934. /*
  935. Function: waitForCSS
  936. Response command instructing xajax to pause while the CSS
  937. files are loaded. The browser is not typically a multi-threading
  938. application, with regards to javascript code. Therefore, the
  939. CSS files included or removed with <xajaxResponse->includeCSS> and
  940. <xajaxResponse->removeCSS> respectively, will not be loaded or
  941. removed until the browser regains control from the script. This
  942. command returns control back to the browser and pauses the execution
  943. of the response until the CSS files, included previously, are
  944. loaded.
  945. Parameters:
  946. iTimeout - (integer): The number of 1/10ths of a second to pause
  947. before timing out and continuing with the execution of the
  948. response commands.
  949. Returns:
  950. object : The <xajaxResponse> object.
  951. */
  952. function waitForCSS($iTimeout = 600) {
  953. $sData = "";
  954. $this->addCommand(
  955. array(
  956. 'cmd'=>'wcss',
  957. 'prop'=>$iTimeout
  958. ),
  959. $sData
  960. );
  961. return $this;
  962. }
  963. /*
  964. Function: waitFor
  965. Response command instructing xajax to delay execution of the response
  966. commands until a specified condition is met. Note, this returns control
  967. to the browser, so that other script operations can execute. xajax
  968. will continue to monitor the specified condition and, when it evaulates
  969. to true, will continue processing response commands.
  970. Parameters:
  971. script - (string): A piece of javascript code that evaulates to true
  972. or false.
  973. tenths - (integer): The number of 1/10ths of a second to wait before
  974. timing out and continuing with the execution of the response
  975. commands.
  976. Returns:
  977. object : The <xajaxResponse> object.
  978. */
  979. function waitFor($script, $tenths) {
  980. return $this->addCommand(
  981. array(
  982. 'cmd'=>'wf',
  983. 'prop'=>$tenths
  984. ),
  985. $script
  986. );
  987. }
  988. /*
  989. Function: sleep
  990. Response command which instructs xajax to pause execution
  991. of the response commands, returning control to the browser
  992. so it can perform other commands asynchronously. After
  993. the specified delay, xajax will continue execution of the
  994. response commands.
  995. Parameters:
  996. tenths - (integer): The number of 1/10ths of a second to
  997. sleep.
  998. Returns:
  999. object : The <xajaxResponse> object.
  1000. */
  1001. function sleep($tenths) {
  1002. $this->addCommand(
  1003. array(
  1004. 'cmd'=>'s',
  1005. 'prop'=>$tenths
  1006. ),
  1007. ''
  1008. );
  1009. return $this;
  1010. }
  1011. /*
  1012. Function: setReturnValue
  1013. Stores a value that will be passed back as part of the response.
  1014. When making synchronous requests, the calling javascript can
  1015. obtain this value immediately as the return value of the
  1016. <xajax.call> function.
  1017. Parameters:
  1018. value - (mixed): Any value.
  1019. Returns:
  1020. object : The <xajaxResponse> object.
  1021. */
  1022. function setReturnValue($value) {
  1023. $this->returnValue = $this->_encodeArray($value);
  1024. return $this;
  1025. }
  1026. /*
  1027. Function: getContentType
  1028. Returns the current content type that will be used for the
  1029. response packet. (typically: "text/xml")
  1030. Returns:
  1031. string : The content type.
  1032. */
  1033. function getContentType()
  1034. {
  1035. return 'text/xml';
  1036. }
  1037. /*
  1038. Function: getOutput
  1039. */
  1040. function getOutput()
  1041. {
  1042. ob_start();
  1043. $this->_printHeader_XML();
  1044. $this->_printResponse_XML();
  1045. return ob_get_clean();
  1046. }
  1047. /*
  1048. Function: printOutput
  1049. Prints the output, generated from the commands added to the response,
  1050. that will be sent to the browser.
  1051. Returns:
  1052. string : The textual representation of the response commands.
  1053. */
  1054. function printOutput()
  1055. {
  1056. $this->_sendHeaders();
  1057. $this->_printHeader_XML();
  1058. $this->_printResponse_XML();
  1059. }
  1060. /*
  1061. Function: _sendHeaders
  1062. Used internally to generate the response headers.
  1063. */
  1064. function _sendHeaders()
  1065. {
  1066. $objArgumentManager =& xajaxArgumentManager::getInstance();
  1067. if (XAJAX_METHOD_GET == $objArgumentManager->getRequestMethod())
  1068. {
  1069. header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  1070. header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  1071. header ("Cache-Control: no-cache, must-revalidate");
  1072. header ("Pragma: no-cache");
  1073. }
  1074. $sCharacterSet = '';
  1075. if ($this->sCharacterEncoding && 0 < strlen(trim($this->sCharacterEncoding))) {
  1076. $sCharacterSet = '; charset="' . trim($this->sCharacterEncoding) . '"';
  1077. }
  1078. $sContentType = $this->getContentType();
  1079. header('content-type: ' . $sContentType . ' ' . $sCharacterSet);
  1080. }
  1081. /*
  1082. Function: getCommandCount
  1083. Returns:
  1084. integer : The number of commands in the response.
  1085. */
  1086. function getCommandCount()
  1087. {
  1088. return count($this->aCommands);
  1089. }
  1090. /*
  1091. Function: loadCommands
  1092. Merges the response commands from the specified <xajaxResponse>
  1093. object with the response commands in this <xajaxResponse> object.
  1094. Parameters:
  1095. mCommands - (object): <xajaxResponse> object.
  1096. bBefore - (boolean): Add the new commands to the beginning
  1097. of the list.
  1098. */
  1099. function loadCommands($mCommands, $bBefore=false)
  1100. {
  1101. if (is_a($mCommands, 'xajaxResponse')) {
  1102. $this->returnValue = $mCommands->returnValue;
  1103. if ($bBefore) {
  1104. $this->aCommands = array_merge($mCommands->aCommands, $this->aCommands);
  1105. }
  1106. else {
  1107. $this->aCommands = array_merge($this->aCommands, $mCommands->aCommands);
  1108. }
  1109. }
  1110. else if (is_array($mCommands)) {
  1111. if ($bBefore) {
  1112. $this->aCommands = array_merge($mCommands, $this->aCommands);
  1113. }
  1114. else {
  1115. $this->aCommands = array_merge($this->aCommands, $mCommands);
  1116. }
  1117. }
  1118. else {
  1119. //SkipDebug
  1120. if (!empty($mCommands)) {
  1121. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1122. trigger_error(
  1123. $objLanguageManager->getText('XJXRSP:LCERR:01')
  1124. , E_USER_ERROR
  1125. );
  1126. }
  1127. //EndSkipDebug
  1128. }
  1129. }
  1130. function absorb($objResponse)
  1131. {
  1132. $this->loadCommands($objResponse);
  1133. }
  1134. /*
  1135. Function: addPluginCommand
  1136. Adds a response command that is generated by a plugin.
  1137. Parameters:
  1138. objPlugin - (object): A reference to a plugin object.
  1139. aAttributes - (array): Array containing the attributes for this
  1140. response command.
  1141. mData - (mixed): The data to be sent with this command.
  1142. Returns:
  1143. object : The <xajaxResponse> object.
  1144. */
  1145. function addPluginCommand($objPlugin, $aAttributes, $mData)
  1146. {
  1147. $aAttributes['plg'] = $objPlugin->getName();
  1148. return $this->addCommand($aAttributes, $mData);
  1149. }
  1150. /*
  1151. Function: addCommand
  1152. Add a response command to the array of commands that will
  1153. be sent to the browser.
  1154. Parameters:
  1155. aAttributes - (array): Associative array of attributes that
  1156. will describe the command.
  1157. mData - (mixed): The data to be associated with this command.
  1158. Returns:
  1159. object : The <xajaxResponse> command.
  1160. */
  1161. function addCommand($aAttributes, $mData)
  1162. {
  1163. $aAttributes['data'] = $this->_encodeArray($mData);
  1164. $this->aCommands[] = $aAttributes;
  1165. return $this;
  1166. }
  1167. /*
  1168. Function: _printHeader_XML
  1169. Used internally to print XML start tag.
  1170. */
  1171. function _printHeader_XML()
  1172. {
  1173. echo '<';
  1174. echo '?';
  1175. echo 'xml version="1.0"';
  1176. $sEncoding = trim($this->sCharacterEncoding);
  1177. if ($this->sCharacterEncoding && 0 < strlen($sEncoding)) {
  1178. echo ' encoding="';
  1179. echo $sEncoding;
  1180. echo '"';
  1181. }
  1182. echo ' ?';
  1183. echo '>';
  1184. }
  1185. /*
  1186. Function: _printResponse_XML
  1187. Used internally to generate the command output.
  1188. */
  1189. function _printResponse_XML()
  1190. {
  1191. echo '<';
  1192. echo 'xjx>';
  1193. if (null !== $this->returnValue)
  1194. {
  1195. echo '<';
  1196. echo 'xjxrv>';
  1197. $this->_printArray_XML($this->returnValue);
  1198. echo '<';
  1199. echo '/xjxrv>';
  1200. }
  1201. foreach(array_keys($this->aCommands) as $sKey)
  1202. $this->_printCommand_XML($this->aCommands[$sKey]);
  1203. echo '<';
  1204. echo '/xjx>';
  1205. }
  1206. /*
  1207. Function: _printCommand_XML
  1208. Prints an XML representation of the command.
  1209. Parameters:
  1210. aAttributes - (array): Associative array of attributes for this
  1211. command.
  1212. */
  1213. function _printCommand_XML(&$aAttributes)
  1214. {
  1215. echo '<';
  1216. echo 'cmd';
  1217. $mData = '';
  1218. foreach (array_keys($aAttributes) as $sKey) {
  1219. if ($sKey) {
  1220. if ('data' != $sKey) {
  1221. echo ' ';
  1222. echo $sKey;
  1223. echo '="';
  1224. echo $aAttributes[$sKey];
  1225. echo '"';
  1226. } else
  1227. $mData =& $aAttributes[$sKey];
  1228. }
  1229. }
  1230. echo '>';
  1231. $this->_printArray_XML($mData);
  1232. echo '<';
  1233. echo '/cmd>';
  1234. }
  1235. /*
  1236. Function: _printArray_XML
  1237. Prints an XML representation of a php array suitable
  1238. for inclusion in the response to the browser. Arrays
  1239. sent via this method will be converted into a javascript
  1240. array on the browser.
  1241. Parameters:
  1242. mArray - (array): Array to be converted.
  1243. */
  1244. function _printArray_XML(&$mArray) {
  1245. if ('object' == gettype($mArray))
  1246. $mArray = get_object_vars($mArray);
  1247. if (false == is_array($mArray)) {
  1248. $this->_printEscapedString_XML($mArray);
  1249. return;
  1250. }
  1251. echo '<';
  1252. echo 'xjxobj>';
  1253. foreach (array_keys($mArray) as $sKey) {
  1254. if (is_array($mArray[$sKey])) {
  1255. echo '<';
  1256. echo 'e>';
  1257. foreach (array_keys($mArray[$sKey]) as $sInnerKey) {
  1258. //SkipDebug
  1259. if (htmlspecialchars($sInnerKey, ENT_COMPAT, 'UTF-8') != $sInnerKey) {
  1260. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1261. trigger_error(
  1262. $objLanguageManager->getText('XJXRSP:AKERR:01')
  1263. , E_USER_ERROR
  1264. );
  1265. }
  1266. //EndSkipDebug
  1267. if ('k' == $sInnerKey || 'v' == $sInnerKey) {
  1268. echo '<';
  1269. echo $sInnerKey;
  1270. echo '>';
  1271. $this->_printArray_XML($mArray[$sKey][$sInnerKey]);
  1272. echo '<';
  1273. echo '/';
  1274. echo $sInnerKey;
  1275. echo '>';
  1276. } else {
  1277. //SkipDebug
  1278. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1279. trigger_error(
  1280. $objLanguageManager->getText('XJXRSP:IEAERR:01')
  1281. , E_USER_ERROR
  1282. );
  1283. //EndSkipDebug
  1284. }
  1285. }
  1286. echo '<';
  1287. echo '/e>';
  1288. } else {
  1289. //SkipDebug
  1290. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1291. trigger_error(
  1292. $objLanguageManager->getText('XJXRSP:NEAERR:01')
  1293. , E_USER_ERROR
  1294. );
  1295. //EndSkipDebug
  1296. }
  1297. }
  1298. echo '<';
  1299. echo '/xjxobj>';
  1300. }
  1301. /*
  1302. Function: _printEscapedString_XML
  1303. Escape the specified data if necessary, so special characters in the
  1304. command data does not interfere with the structure of the response.
  1305. This could be overridden to allow for transport encodings other than
  1306. XML.
  1307. Parameters:
  1308. sData - (string): The data to be escaped.
  1309. Returns:
  1310. string : The escaped data.
  1311. */
  1312. function _printEscapedString_XML(&$sData)
  1313. {
  1314. if (is_null($sData) || false == isset($sData)) {
  1315. echo '*';
  1316. return;
  1317. }
  1318. if ($this->bOutputEntities) {
  1319. //SkipDebug
  1320. if (false === function_exists('mb_convert_encoding')) {
  1321. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1322. trigger_error(
  1323. $objLanguageManager->getText('XJXRSP:MBEERR:01')
  1324. , E_USER_NOTICE
  1325. );
  1326. }
  1327. //EndSkipDebug
  1328. echo call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sCharacterEncoding));
  1329. return;
  1330. }
  1331. $nCDATA = 0;
  1332. $bNoOpenCDATA = (false === strpos($sData, '<'.'![CDATA['));
  1333. if ($bNoOpenCDATA) {
  1334. $bNoCloseCDATA = (false === strpos($sData, ']]>'));
  1335. if ($bNoCloseCDATA) {
  1336. $bSpecialChars = (htmlspecialchars($sData, ENT_COMPAT, 'UTF-8') != $sData);
  1337. if ($bSpecialChars)
  1338. $nCDATA = 1;
  1339. } else
  1340. $nCDATA = 2;
  1341. } else
  1342. $nCDATA = 2;
  1343. if (0 < $nCDATA) {
  1344. echo '<';
  1345. echo '![CDATA[';
  1346. // PHP defines numeric values as integer or float (double and real are aliases of float)
  1347. if (is_string($sData)) {
  1348. echo 'S';
  1349. } else if (is_int($sData) || is_float($sData)) {
  1350. echo 'N';
  1351. } else if (is_bool($sData)) {
  1352. echo 'B';
  1353. }
  1354. if (1 < $nCDATA) {
  1355. $aSegments = explode('<'.'![CDATA[', $sData);
  1356. $aOutput = array();
  1357. $nOutput = 0;
  1358. foreach (array_keys($aSegments) as $keySegment) {
  1359. $aFragments = explode(']]>', $aSegments[$keySegment]);
  1360. $aStack = array();
  1361. $nStack = 0;
  1362. foreach (array_keys($aFragments) as $keyFragment) {
  1363. if (0 < $nStack)
  1364. array_push($aStack, ']]]]><', '![CDATA[>', $aFragments[$keyFragment]);
  1365. else
  1366. $aStack[] = $aFragments[$keyFragment];
  1367. ++$nStack;
  1368. }
  1369. if (0 < $nOutput)
  1370. array_push($aOutput, '<', '![]]><', '![CDATA[CDATA[', implode('', $aStack));
  1371. else
  1372. $aOutput[] = implode('', $aStack);
  1373. ++$nOutput;
  1374. }
  1375. echo implode('', $aOutput);
  1376. } else
  1377. echo $sData;
  1378. echo ']]>';
  1379. } else {
  1380. if (is_string($sData)) {
  1381. echo 'S';
  1382. } else if (is_int($sData) || is_float($sData)) {
  1383. echo 'N';
  1384. } else if (is_bool($sData)) {
  1385. echo 'B';
  1386. }
  1387. echo $sData;
  1388. }
  1389. }
  1390. /*
  1391. Function: _encodeArray
  1392. Recursively serializes a data structure in an array so that it can
  1393. be sent to the browser. This can be thought of as the opposite of
  1394. <xajaxRequestProcessorPlugin->_parseObjXml>.
  1395. Parameters:
  1396. mData - (mixed): The data to be evaluated.
  1397. Returns:
  1398. mixed : The object constructed from the data.
  1399. */
  1400. function _encodeArray(&$mData) {
  1401. if ('object' === gettype($mData))
  1402. $mData = get_object_vars($mData);
  1403. if (false === is_array($mData))
  1404. return $mData;
  1405. $aData = array();
  1406. foreach (array_keys($mData) as $sKey)
  1407. $aData[] = array(
  1408. // key does not need to be encoded
  1409. 'k'=>$sKey,
  1410. 'v'=>$this->_encodeArray($mData[$sKey])
  1411. );
  1412. return $aData;
  1413. }
  1414. }// end class xajaxResponse
  1415. class xajaxCustomResponse
  1416. {
  1417. var $sOutput;
  1418. var $sContentType;
  1419. var $sCharacterEncoding;
  1420. var $bOutputEntities;
  1421. function xajaxCustomResponse($sContentType)
  1422. {
  1423. $this->sOutput = '';
  1424. $this->sContentType = $sContentType;
  1425. $objResponseManager =& xajaxResponseManager::getInstance();
  1426. $this->sCharacterEncoding = $objResponseManager->getCharacterEncoding();
  1427. $this->bOutputEntities = $objResponseManager->getOutputEntities();
  1428. }
  1429. function setCharacterEncoding($sCharacterEncoding)
  1430. {
  1431. $this->sCharacterEncoding = $sCharacterEncoding;
  1432. }
  1433. function setOutputEntities($bOutputEntities)
  1434. {
  1435. $this->bOutputEntities = $bOutputEntities;
  1436. }
  1437. function clear()
  1438. {
  1439. $this->sOutput = '';
  1440. }
  1441. function append($sOutput)
  1442. {
  1443. $this->sOutput .= $sOutput;
  1444. }
  1445. function absorb($objResponse)
  1446. {
  1447. //SkipDebug
  1448. if (false == is_a($objResponse, 'xajaxCustomResponse')) {
  1449. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1450. trigger_error(
  1451. $objLanguageManager->getText('XJXRSP:MXRTERR')
  1452. , E_USER_ERROR
  1453. );
  1454. }
  1455. if ($objResponse->getContentType() != $this->getContentType()) {
  1456. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1457. trigger_error(
  1458. $objLanguageManager->getText('XJXRSP:MXCTERR')
  1459. , E_USER_ERROR
  1460. );
  1461. }
  1462. if ($objResponse->getCharacterEncoding() != $this->getCharacterEncoding()) {
  1463. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1464. trigger_error(
  1465. $objLanguageManager->getText('XJXRSP:MXCEERR')
  1466. , E_USER_ERROR
  1467. );
  1468. }
  1469. if ($objResponse->getOutputEntities() != $this->getOutputEntities()) {
  1470. $objLanguageManager =& xajaxLanguageManager::getInstance();
  1471. trigger_error(
  1472. $objLanguageManager->getText('XJXRSP:MXOEERR')
  1473. , E_USER_ERROR
  1474. );
  1475. }
  1476. //EndSkipDebug
  1477. $this->sOutput .= $objResponse->getOutput();
  1478. }
  1479. function getContentType()
  1480. {
  1481. return $this->sContentType;
  1482. }
  1483. function getCharacterEncoding()
  1484. {
  1485. return $this->sCharacterEncoding;
  1486. }
  1487. function getOutputEntities()
  1488. {
  1489. return $this->bOutputEntities;
  1490. }
  1491. function getOutput()
  1492. {
  1493. return $this->sOutput;
  1494. }
  1495. function printOutput()
  1496. {
  1497. $sContentType = $this->sContentType;
  1498. $sCharacterSet = $this->sCharacterEncoding;
  1499. header("content-type: {$sContentType}; charset={$sCharacterSet}");
  1500. echo $this->sOutput;
  1501. }
  1502. }