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

Documentation generated on Sun, 08 Feb 2009 22:01:11 +0100 by phpDocumentor 1.4.1