Source for file mr_test.php

Documentation is available at mr_test.php

  1. <?php
  2. /**
  3.  * Testscript for Advanced Mod Rewrite Plugin.
  4.  *
  5.  * The goal of this testscript is to provide an easy way for a variance comparison
  6.  * of created SEO URLs against their resolved parts.
  7.  *
  8.  * This testscript fetches the full category and article structure of actual
  9.  * Contenido installation, creates the SEO URLs for each existing category/article
  10.  * and resolves the generated URLs.
  11.  *
  12.  * Usage:
  13.  * ------
  14.  * 1. Install the Advanced Mod Rewrite Plugin
  15.  * 2. Set your desired plugin settings by using the Advanced Mod Rewrite area
  16.  *    in the Backend
  17.  * 3. Copy this file to your client directory, it is normally named '/cms/'
  18.  * 4. Exclude this file from rewriting, add following line in your .htaccess
  19.  *    RewriteRule ^cms/mr_test.php.*$ - [L]
  20.  * 5. Browse to http://host/cms/mr_test.php
  21.  * 6. Disable the script after finished testing, see line 31
  22.  *
  23.  * @author      Murat Purc <murat@purc.de>
  24.  * @copyright   © Murat Purc 2008
  25.  * @package     Contenido
  26.  * @subpackage  ModRewrite
  27.  */
  28.  
  29.  
  30. // Uncomment following line, if you're finished with the tests
  31. #die('Testscript disabled');
  32.  
  33.  
  34. ####################################################################################################
  35. ##### Contenido front_content.php header (compressed)
  36.  
  37. if (!defined("CON_FRAMEWORK")) define("CON_FRAMEWORK"true)}
  38. $contenido_path '';
  39. include_once ("config.php");
  40. include_once ($contenido_path 'classes/class.security.php');
  41. Contenido_Security::checkRequests();
  42. if (isset($_REQUEST['belang'])) {
  43.     $aValid array('de_DE''en_US''fr_FR''it_IT''nl_NL');
  44.     if (!in_array(strval($_REQUEST['belang'])$aValid)) {
  45.         die('Please use a valid language!');
  46.     }
  47. }
  48. include_once ($contenido_path."includes/startup.php");
  49. if ($cfg['http_params_check']['enabled'=== true{
  50.     cInclude('classes''class.httpinputvalidator.php');
  51.     $oHttpInputValidator new HttpInputValidator($cfg["path"]["contenido"$cfg["path"]["includes"'/config.http_check.php');
  52. }
  53. cInclude("includes""functions.con.php");
  54. cInclude("includes""functions.con2.php");
  55. cInclude("includes""functions.api.php");
  56. cInclude("includes""functions.pathresolver.php");
  57. if ($contenido{
  58.     page_open(array ('sess' => 'Contenido_Session''auth' => 'Contenido_Challenge_Crypt_Auth''perm' => 'Contenido_Perm'));
  59.     i18nInit($cfg["path"]["contenido"].$cfg["path"]["locale"]$belang);
  60. else {
  61.     page_open(array ('sess' => 'Contenido_Frontend_Session''auth' => 'Contenido_Frontend_Challenge_Crypt_Auth''perm' => 'Contenido_Perm'));
  62. }
  63. require_once $cfg['path']['contenido'$cfg['path']['includes''functions.includePluginConf.php';
  64. # Don't call hook, otherwhise the plugin will try to resolve the url and redirects to errorpage
  65. #CEC_Hook::execute('Contenido.Frontend.AfterLoadPlugins');
  66. $db new DB_Contenido;
  67. $sess->register("cfgClient");
  68. $sess->register("errsite_idcat");
  69. $sess->register("errsite_idart");
  70. $sess->register("encoding");
  71. if ($cfgClient["set"!= "set"{
  72.     rereadClients();
  73. }
  74. $sql "SELECT idlang, encoding FROM ".$cfg["tab"]["lang"];
  75. $db->query($sql);
  76. while ($db->next_record()) {
  77.     $encoding[$db->f("idlang")$db->f("encoding");
  78. }
  79. if (is_numeric($tmpchangelang&& $tmpchangelang 0{
  80.     $savedlang $lang;
  81.     $lang $tmpchangelang;
  82. }
  83. if (isset($changeclient&& !is_numeric($changeclient)) {
  84.     unset ($changeclient);
  85. }
  86. if (isset($client&& !is_numeric($client)) {
  87.     unset ($client);
  88. }
  89. if (isset($changelang&& !is_numeric($changelang)) {
  90.     unset ($changelang);
  91. }
  92. if (isset($lang&& !is_numeric($lang)) {
  93.     unset ($lang);
  94. }
  95. if (isset($changeclient)){
  96.     $client $changeclient;
  97.     unset($lang);
  98.     unset($load_lang);
  99. }
  100. if (isset($changelang)) $lang $changelang;
  101. if (!isset($client)) {
  102.     $client $load_client;
  103. }
  104. if (!isset($lang)) {
  105.     if(isset($load_lang)){
  106.         $lang $load_lang;
  107.     else {
  108.         $sql "SELECT
  109.                     B.idlang
  110.                 FROM
  111.                     ".$cfg["tab"]["clients_lang"]." AS A,
  112.                     ".$cfg["tab"]["lang"]." AS B
  113.                 WHERE
  114.                     A.idclient='".Contenido_Security::toInteger($client)."' AND
  115.                     A.idlang = B.idlang
  116.                 LIMIT
  117.                     0,1";
  118.         $db->query($sql);
  119.         $db->next_record();
  120.         $lang $db->f("idlang");
  121.     }
  122. }
  123. if (!$sess->is_registered("lang") ) $sess->register("lang");
  124. if (!$sess->is_registered("client") ) $sess->register("client");
  125. if (isset ($username)) {
  126.     $auth->login_if(true);
  127. }
  128. header("Content-Type: text/html; charset={$encoding[$lang]}");
  129. if (isset ($logout)) {
  130.     $auth->logout(true);
  131.     $auth->unauth(true);
  132.     $auth->auth["uname""nobody";
  133. }
  134. if (file_exists("config.local.php")) {
  135.     include ("config.local.php");
  136. }
  137. $errurl  "front_content.php?client=$client&idcat=".$errsite_idcat[$client]."&idart=".$errsite_idart[$client]."&lang=$lang&error=1";
  138. $errsite 'Location: ' CEC_Hook::execute('Contenido.Frontend.CreateURL'$errurl);
  139. if (isset($mr_preprocessedPageError)) {
  140.     unset($mr_preprocessedPageError);
  141.     header($errsite);
  142. }
  143. if (isset($path&& strlen($path1{
  144.     if ($cfg["urlpathresolve"== true{
  145.         $iLangCheck 0;
  146.         $idcat prResolvePathViaURLNames($path$iLangCheck);
  147.     else {
  148.         $iLangCheck 0;
  149.         $idcat prResolvePathViaCategoryNames($path$iLangCheck);
  150.         if($lang != iLangCheck){
  151.             $lang $iLangCheck;
  152.         }
  153.     }
  154. }
  155.  
  156.  
  157. ####################################################################################################
  158. ##### Plugin related area
  159.  
  160.  
  161. // set debug configuration, if you want to see the debug toolbar
  162. $options array(
  163.     'enable'                    => true,
  164.     'ressource_urls'            => array('/contenido/logs/errorlog.txt'),
  165.     'dump_super_globals'        => array('$_GET''$_POST''$_COOKIE''$_SESSION'),
  166.     'ignore_empty_superglobals' => true,
  167.     'magic_word'                => 'foobar'
  168. );
  169. $oDebug->setConfig($options);
  170.  
  171.  
  172. ####################################################################################################
  173. ##### Form processing / Controller
  174.  
  175.  
  176. $mrTestNoOptionSelected false;
  177. if (!_getRequest('idart'&& !_getRequest('idcat'&& !_getRequest('idcatart'&& !_getRequest('idartlang')) {
  178.     $mrTestNoOptionSelected true;
  179. }
  180.  
  181. $aData['form']['idart_chk']     (_getRequest('idart')) ' checked="checked"' '';
  182. $aData['form']['idcat_chk']     (_getRequest('idcat')) ' checked="checked"' '';
  183. $aData['form']['idcatart_chk']  (_getRequest('idcatart')) ' checked="checked"' '';
  184. $aData['form']['idartlang_chk'(_getRequest('idartlang')) ' checked="checked"' '';
  185. $aData['form']['maxitems']      _getRequest('maxitems'200);
  186.  
  187.  
  188. $oMrTestAction new ModRewriteTestActions();
  189.  
  190. if ($mrTestNoOptionSelected{
  191.     $oMrTestAction->executeIndex();
  192. else {
  193.     $oMrTestAction->executeTest();
  194. }
  195.  
  196.  
  197. if (isset($oDebug)) {
  198.     if (is_array($GLOBALS['DB_Contenido_QueryCache']&& count($GLOBALS['DB_Contenido_QueryCache']0{
  199.         $oDebug->addDebug($GLOBALS['DB_Contenido_QueryCache']'sql statements');
  200.     }
  201.     $aData['content'.= $oDebug->getResults(false);
  202. }
  203.  
  204.  
  205. ####################################################################################################
  206. ##### Contenido front_content.php footer
  207.  
  208. if (file_exists("config.after.php")) {@include("config.after.php");}
  209. if (isset ($savedlang)){$lang $savedlang;}
  210. page_close();
  211.  
  212.  
  213. ####################################################################################################
  214. #### Template / View
  215.  
  216. echo <<<HTML
  217. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  218.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  219. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="de">
  220. <head>
  221.     <title>Test - Contenido Plugin Advanced Mod Rewrite</title>
  222.     <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
  223.     <style type="text/css">
  224.     body {margin:0; padding:0; background:#fff; color:#000; font-family:arial,helvetica,sans-serif; font-size:12px;}
  225.     #wrap {margin:15px 10px;}
  226.     h1 {font-size:16px;}
  227.     form {width:70%; border:1px solid #999; background:#eaeaea; padding:0.5em; margin-bottom:15px;}
  228.     fieldset {margin-bottom:10px;}
  229.     fieldset p {margin:0;}
  230.     form .chk {width:24%; float:left;}
  231.     .left {float:left;}
  232.     .right {float:right;}
  233.     .clear {clear:both; font-size:0pt !important; height:0pt !important; line-height:0pt !important;}
  234.     </style>
  235. </head>
  236. <body>
  237. <div id="wrap">
  238.  
  239. <h1>Advanced Mod Rewrite test</h1>
  240.  
  241. <form name="mr_test" id="mr_test" action="{$_SERVER['PHP_SELF']}">
  242.     <fieldset>
  243.         <legend>Parameter to add</legend>
  244.         <p></p>
  245.         <div class="chk">
  246.             <input type="checkbox" id="idart" name="idart" value="1"{$aData['form']['idart_chk']} /><label for="idart">idart</label>
  247.         </div>
  248.         <div class="chk">
  249.             <input type="checkbox" id="idcat" name="idcat" value="1"{$aData['form']['idcat_chk']} /><label for="idcat">idcat</label>
  250.         </div>
  251.         <div class="chk">
  252.             <input type="checkbox" id="idcatart" name="idcatart" value="1"{$aData['form']['idcatart_chk']} /><label for="idcatart">idcatart</label>
  253.         </div>
  254.         <div class="chk">
  255.             <input type="checkbox" id="idartlang" name="idartlang" value="1"{$aData['form']['idartlang_chk']} /><label for="idartlang">idartlang</label>
  256.         </div>
  257.         <br class="clear" />
  258.     </fieldset>
  259.     <div style="margin:0.3em 0;">
  260.         <div class="left">
  261.             <label for="maxitems">Max items to process: </label><input type="text" id="maxitems" maxlength="4" name="maxitems" value="{$aData['form']['maxitems']}" />
  262.         </div>
  263.         <div class="right" style="padding-right:5px;">
  264.             <input type="submit" name="test" value="run test" />
  265.         </div>
  266.         <br class="clear" />
  267.     </div>
  268. </form>
  269.  
  270. {$aData['content']}
  271.  
  272. </div>
  273. </body>
  274. </html>
  275. HTML;
  276.  
  277.  
  278. ####################################################################################################
  279. ##### Classes / Functions
  280.  
  281.  
  282. /**
  283.  * Simple action controller.
  284.  *
  285.  * @author      Murat Purc <murat@purc.de>
  286.  * @copyright   © Murat Purc 2008
  287.  * @package     Contenido
  288.  * @subpackage  ModRewriteTest
  289.  */
  290.  
  291.     private $data;
  292.  
  293.     function __construct({
  294.         $this->data = $GLOBALS['aData'];
  295.     }
  296.  
  297.     /**
  298.      * Execute index action
  299.      */
  300.     function executeIndex({
  301.         $this->data['content''<pre>
  302.  
  303. Select several options from above and run the test.
  304.  
  305. <b>The result will be a outputlist like:</b>
  306.  
  307. Navigationame
  308. builder in:    The URL beeing passed to the URL builder
  309. builder out:   Result of rebuild URL, should be consistent with your settings
  310. resolved url:  Resolved URL (the URL beeing returned by URL builder) by ModRewriteController
  311. resolved data: Some resolved variables like $client, $lang, etc.
  312.  
  313. <b>Example:</b>
  314.  
  315. Navigationame
  316. builder in:    front_content.php?idcat=1&foo=bar
  317. builder out:   /deutsch-hauptnavigation.index.html?foo=bar
  318. resolved url:  /deutsch/hauptnavigation/index.html?foo=bar
  319. resolved data: client=1; lang=1; changelang=1; idcat=1
  320. </pre>';
  321.  
  322.     }
  323.  
  324.     /**
  325.      * Execute test action
  326.      */
  327.     function executeTest({
  328.         $this->data['content''';
  329.  
  330.         // Array for testcases
  331.         $aTests  array();
  332.  
  333.         // Instance of mr test
  334.         $oMRTest new ModRewriteTest();
  335.  
  336.         $startTime getmicrotime();
  337.  
  338.         // Fetch complete Contenido page structure
  339.         $aStruct $oMRTest->fetchFullStructure();
  340.         Contenido_mpDebug::getInstance()->addDebug($aStruct'mr_test.php $aStruct');
  341.  
  342.         // Loop through the structure and compose testcases
  343.         foreach ($aStruct as $idcat => $aCat{
  344.             // category
  345.             $aTests[array(
  346.                 'url'   => $oMRTest->composeURL($aCat'c'),
  347.                 'level' => $aCat['level'],
  348.                 'name'  => $aCat['name']
  349.             );
  350.  
  351.             foreach ($aCat['articles'as $idart => $aArt{
  352.                 // articles
  353.                 $aTests[array(
  354.                     'url'  => $oMRTest->composeURL($aArt'a'),
  355.                     'level' => $aCat['level'],
  356.                     'name' => $aCat['name'' :: ' $aArt['title']
  357.                 );
  358.             }
  359.         }
  360.  
  361.         // compose content
  362.         $this->data['content''<pre>';
  363.  
  364.         $oMRUrlStack ModRewriteUrlStack::getInstance();
  365.  
  366.         // first loop to add urls to mr url stack
  367.         foreach ($aTests as $p => $v{
  368.             $oMRUrlStack->add($v['url']);
  369.         }
  370.  
  371.         // second loop to do the rest
  372.         foreach ($aTests as $p => $v{
  373.             $url    mr_buildNewUrl($v['url']);
  374.             $arr    $oMRTest->resolveUrl($url);
  375.             $resUrl $oMRTest->getResolvedUrl();
  376.             $color  'green';
  377.  
  378.             if ($url !== $resUrl{
  379.                 if ($oMRTest->getRoutingFoundState()) {
  380.                     $resUrl 'route to -&gt; ' $resUrl;
  381.                 else {
  382.                     $color  'red';
  383.                 }
  384.             }
  385.             $pref   str_repeat('    '$v['level']);
  386.  
  387.             $this->data['content'.= "\n"
  388.                 . $pref '<strong>' $v['name''</strong>' "\n"
  389.                 . $pref 'builder in:    ' $v['url'"\n"
  390.                 . $pref 'builder out:   <a href="' $url '" target="_blank">' $url '</a>'  "\n"
  391.                 . $pref '<span style="color:' $color '">resolved url:  ' $resUrl "</span>\n"
  392.                 . $pref 'resolved data: ' $oMRTest->getReadableResolvedData($arr"\n";
  393.         }
  394.         $this->data['content'.= '</pre>';
  395.  
  396.         $totalTime sprintf('%.4f'(getmicrotime($startTime));
  397.         $msg '<strong>Execution of test took: ' $totalTime ' seconds.</strong><br /><br />';
  398.  
  399.         $this->data['content'$msg $this->data['content'];
  400.  
  401.     }
  402.  
  403. }
  404.  
  405.  
  406. /**
  407.  * Advanced Mod Rewrite test class.
  408.  *
  409.  * @author      Murat Purc <murat@purc.de>
  410.  * @copyright   © Murat Purc 2008
  411.  * @package     Contenido
  412.  * @subpackage  ModRewriteTest
  413.  */
  414. class ModRewriteTest {
  415.  
  416.     /**
  417.      * @var  array  Global $cfg array
  418.      */
  419.     private $cfg;
  420.  
  421.     /**
  422.      * @var  array  Global $cfg['tab'] array
  423.      */
  424.     private $cfgTab;
  425.  
  426.  
  427.     /**
  428.      * @var  int  Max items to process
  429.      */
  430.     private $maxItems;
  431.  
  432.     /**
  433.      * @var  string  Actual resolved url
  434.      */
  435.     private $sResolvedUrl;
  436.  
  437.  
  438.     /**
  439.      * @var  bool  Routing found flag
  440.      */
  441.     private $bRoutingFound = false;
  442.  
  443.  
  444.     /**
  445.      * Constuctor
  446.      */
  447.     function __construct({
  448.         $this->cfg    = $GLOBALS['cfg'];
  449.         $this->cfgTab = $GLOBALS['cfg']['tab'];
  450.         $this->maxItems = $GLOBALS['aData']['form']['maxitems'];
  451.     }
  452.  
  453.  
  454.     /**
  455.      * Returns resolved URL
  456.      *
  457.      * @return  bool  Resolved URL
  458.      */
  459.     function getResolvedUrl(){
  460.         return $this->sResolvedUrl;
  461.     }
  462.  
  463.  
  464.     /**
  465.      * Returns flagz about found routing
  466.      *
  467.      * @return  bool 
  468.      */
  469.     function getRoutingFoundState(){
  470.         return $this->bRoutingFound;
  471.     }
  472.  
  473.  
  474.     /**
  475.      * Fetchs full structure of the installation (categories and articles) and returns it back.
  476.      *
  477.      * @param   int    $idclient  Client id
  478.      * @param   int    $idlang    Language id
  479.      * @return  array  Full structure as follows
  480.      *  <code>
  481.      *    $arr[idcat] = Category dataset
  482.      *    $arr[idcat]['articles'][idart] = Article dataset
  483.      *  </code>
  484.      */
  485.     function fetchFullStructure($idclient=null$idlang=null{
  486.  
  487.         $db  new DB_Contenido();
  488.         $db2 new DB_Contenido();
  489.  
  490.         if (!$idclient || (int) $idclient == 0{
  491.             $idclient $GLOBALS['client'];
  492.         }
  493.         if (!$idlang || (int) $idlang == 0{
  494.             $idlang $GLOBALS['lang'];
  495.         }
  496.  
  497.         $aTab $this->cfgTab;
  498.  
  499.         $aStruct array();
  500.  
  501.         $sql "SELECT
  502.                     *
  503.                 FROM
  504.                     " $aTab['cat_tree'" AS a,
  505.                     " $aTab['cat_lang'" AS b,
  506.                     " $aTab['cat'" AS c
  507.                 WHERE
  508.                     a.idcat = b.idcat AND
  509.                     c.idcat = a.idcat AND
  510.                     c.idclient = '".$idclient."' AND
  511.                     b.idlang = '".$idlang."'
  512.                 ORDER BY
  513.                     a.idtree";
  514.  
  515.         $db->query($sql);
  516.  
  517.         $loop    false;
  518.         $counter 0;
  519.  
  520.         while ($db->next_record()) {
  521.  
  522.             if (++$counter == $this->maxItems{
  523.                 break// break this loop
  524.             }
  525.  
  526.             $idcat $db->f('idcat');
  527.             $aStruct[$idcat$db->Record;
  528.             $aStruct[$idcat]['articles'array();
  529.  
  530.             if ($this->cfg['is_start_compatible'== true{
  531.                 $compStatement ' a.is_start DESC, ';
  532.             else {
  533.                 $compStatement '';
  534.             }
  535.  
  536.             $sql2 "SELECT
  537.                          *
  538.                      FROM
  539.                          ".$aTab['cat_art']."  AS a,
  540.                          ".$aTab['art']."      AS b,
  541.                          ".$aTab['art_lang']." AS c
  542.                      WHERE
  543.                          a.idcat = '".$idcat."' AND
  544.                          b.idart = a.idart AND
  545.                          c.idart = a.idart AND
  546.                          c.idlang = '".$idlang."' AND
  547.                          b.idclient = '".$idclient."'
  548.                      ORDER BY
  549.                          " $compStatement "
  550.                          c.title ASC";
  551.  
  552.             $db2->query($sql2);
  553.  
  554.             while ($db2->next_record()) {
  555.                 $idart $db2->f('idart');
  556.                 $aStruct[$idcat]['articles'][$idart$db2->Record;
  557.                 if (++$counter == $this->maxItems{
  558.                     break 2// break this and also superior loop
  559.                 }
  560.             }
  561.         }
  562.  
  563.         return $aStruct;
  564.     }
  565.  
  566.  
  567.     /**
  568.      * Creates an URL using passed data.
  569.      *
  570.      * The result is used to generate seo urls...
  571.      *
  572.      * @param  array  $arr  Assoziative array with some data as follows:
  573.      *  <code>
  574.      *  $arr['idcat']
  575.      *  $arr['idart']
  576.      *  $arr['idcatart']
  577.      *  $arr['idartlang']
  578.      *  </code>
  579.      * @param  string  $type  Either 'c' or 'a' (category or article). If set to
  580.      *                         'c' only the parameter idcat will be added to the URL
  581.      */
  582.     function composeURL($arr$type{
  583.         $type ($type == 'a''a' 'c';
  584.  
  585.         $param array();
  586.  
  587.         if ($type == 'c'{
  588.             $param['idcat=' $arr['idcat'];
  589.         else {
  590.             if (_getRequest('idart')) {
  591.                 $param['idart=' $arr['idart'];
  592.             }
  593.             if (_getRequest('idcat')) {
  594.                 $param['idcat=' $arr['idcat'];
  595.             }
  596.             if (_getRequest('idcatart')) {
  597.                 $param['idcatart=' $arr['idcatart'];
  598.             }
  599.             if (_getRequest('idartlang')) {
  600.                 $param['idartlang=' $arr['idartlang'];
  601.             }
  602.         }
  603.         $param['foo=bar';
  604.         return 'front_content.php?' implode('&amp;'$param);
  605.  
  606.     }
  607.  
  608.  
  609.     /**
  610.      * Resolves variables of an page (idcat, idart, idclient, idlang, etc.) by
  611.      * processing passed url using ModRewriteController
  612.      *
  613.      * @param   string  $url  Url to resolve
  614.      * @return  array   Assoziative array with resolved data
  615.      */
  616.     public function resolveUrl($url){
  617.  
  618.         // some globals to reset
  619.         $aGlobs array(
  620.             'mr_preprocessedPageError''idart''idcat'
  621.         );
  622.         foreach ($aGlobs as $p => $k{
  623.             if (isset($GLOBALS[$k])) unset($GLOBALS[$k])}
  624.         }
  625.  
  626.         $aReturn array();
  627.  
  628.         // create an mod rewrite controller instance and execute processing
  629.         $oMRController new ModRewriteController($url);
  630.         $oMRController->execute();
  631.  
  632.         if ($oMRController->errorOccured()) {
  633.  
  634.             // an error occured (idcat and or idart couldn't catched by controller)
  635.             $aReturn['mr_preprocessedPageError'1;
  636.  
  637.             $this->sResolvedUrl  = '';
  638. ##++##            $this->sResolvedUrl  = '';
  639.             $this->bRoutingFound = false;
  640.  
  641.         else {
  642.  
  643.             // set some global variables
  644.  
  645.             $this->sResolvedUrl  = $oMRController->getResolvedUrl();
  646.             $this->bRoutingFound = $oMRController->getRoutingFoundState();
  647.  
  648.             if ($oMRController->getClient()) {
  649.                 $aReturn['client'$oMRController->getClient();
  650.             }
  651.  
  652.             if ($oMRController->getChangeClient()) {
  653.                 $aReturn['changeclient'$oMRController->getChangeClient();
  654.             }
  655.  
  656.             if ($oMRController->getLang()) {
  657.                 $aReturn['lang'$oMRController->getLang();
  658.             }
  659.  
  660.             if ($oMRController->getChangeLang()) {
  661.                 $aReturn['changelang'$oMRController->getChangeLang();
  662.             }
  663.  
  664.             if ($oMRController->getIdArt()) {
  665.                 $aReturn['idart'$oMRController->getIdArt();
  666.             }
  667.  
  668.             if ($oMRController->getIdCat()) {
  669.                 $aReturn['idcat'$oMRController->getIdCat();
  670.             }
  671.  
  672.             if ($oMRController->getPath()) {
  673.                 $aReturn['path'$oMRController->getPath();
  674.             }
  675.  
  676.         }
  677.  
  678.         return $aReturn;
  679.     }
  680.  
  681.  
  682.     /**
  683.      * Creates a readable string from passed resolved data array.
  684.      *
  685.      * @param   array   Assoziative array with resolved data
  686.      * @return  string  Readable resolved data
  687.      */
  688.     public function getReadableResolvedData(array $data{
  689.         // compose resolved string
  690.         $ret '';
  691.         foreach ($data as $k => $v{
  692.             $ret .= $k '=' $v '; ';
  693.         }
  694.         $ret substr($ret0strlen($ret)-2);
  695.         return $ret;
  696.     }
  697.  
  698. }
  699.  
  700.  
  701. /**
  702.  * Minimalistic'n simple way to get request variables.
  703.  *
  704.  * Checks occurance in $_GET, then in $_POST. Uses trim() and strip_tags() to preclean data.
  705.  *
  706.  * @param   string  $key      Name of var to get
  707.  * @param   mixed   $default  Default value to return
  708.  * @return  mixed   The value
  709.  */
  710. function _getRequest($key$default=null{
  711.     static $cache;
  712.     if (!isset($cache)) {
  713.         $cache array();
  714.     }
  715.     if (isset($cache[$key])) {
  716.         return $cache[$key];
  717.     }
  718.     if (isset($_GET[$key])) {
  719.         $val $_GET[$key];
  720.     elseif (isset($_POST[$key])) {
  721.         $val $_POST[$key];
  722.     else {
  723.         $val $default;
  724.     }
  725.     $cache[$keystrip_tags(trim($val));
  726.     return $cache[$key];
  727. }

Documentation generated on Sun, 21 Dec 2008 21:43:13 +0100 by phpDocumentor 1.4.1