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 ry to resolv 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. $GLOBALS['mpDebug']->setConfig($options);
  170.  
  171. $GLOBALS['mpDebug']->addDebug($cfg['mod_rewrite']'mr_test.php $cfg[mod_rewrite]');
  172.  
  173.  
  174. ####################################################################################################
  175. ##### Form processing / Controller
  176.  
  177.  
  178. $mrTestNoOptionSelected false;
  179. if (!_getRequest('idart'&& !_getRequest('idcat'&& !_getRequest('idcatart'&& !_getRequest('idartlang')) {
  180.     $mrTestNoOptionSelected true;
  181. }
  182.  
  183. $aData['form']['idart_chk']     (_getRequest('idart')) ' checked="checked"' '';
  184. $aData['form']['idcat_chk']     (_getRequest('idcat')) ' checked="checked"' '';
  185. $aData['form']['idcatart_chk']  (_getRequest('idcatart')) ' checked="checked"' '';
  186. $aData['form']['idartlang_chk'(_getRequest('idartlang')) ' checked="checked"' '';
  187. $aData['form']['maxitems']      _getRequest('maxitems'200);
  188.  
  189.  
  190. $oMrTestAction new ModRewriteTestActions();
  191.  
  192. if ($mrTestNoOptionSelected{
  193.     $oMrTestAction->executeIndex();
  194. else {
  195.     $oMrTestAction->executeTest();
  196. }
  197.  
  198.  
  199. if (isset($GLOBALS['mpDebug'])) {
  200.     $aData['content'.= $GLOBALS['mpDebug']->getResults(false);
  201. }
  202.  
  203.  
  204. ####################################################################################################
  205. ##### Contenido front_content.php footer
  206.  
  207. if (file_exists("config.after.php")) {@include("config.after.php");}
  208. if (isset ($savedlang)){$lang $savedlang;}
  209. page_close();
  210.  
  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.         $GLOBALS['mpDebug']->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.         foreach ($aTests as $p => $v{
  365.             $url    mr_build_new_url($v['url']);
  366.             $arr    $oMRTest->resolveUrl($url);
  367.             $resUrl $oMRTest->getResolvedUrl();
  368.             $color  'green';
  369.             if ($url !== $resUrl{
  370.                 if ($oMRTest->getRoutingFoundState()) {
  371.                     $resUrl 'route to -&gt; ' $resUrl;
  372.                 else {
  373.                     $color  'red';
  374.                 }
  375.             }
  376.             $pref   str_repeat('    '$v['level']);
  377.             $this->data['content'.= "\n"
  378.                 . $pref '<strong>' $v['name''</strong>' "\n"
  379.                 . $pref 'builder in:    ' $v['url'"\n"
  380.                 . $pref 'builder out:   <a href="' $url '" target="_blank">' $url '</a>'  "\n"
  381.                 . $pref '<span style="color:' $color '">resolved url:  ' $resUrl "</span>\n"
  382.                 . $pref 'resolved data: ' $oMRTest->getReadableResolvedData($arr"\n";
  383.         }
  384.         $this->data['content'.= '</pre>';
  385.  
  386.         $totalTime sprintf('%.4f'(getmicrotime($startTime));
  387.         $msg '<strong>Execution of test took: ' $totalTime ' seconds.</strong><br /><br />';
  388.  
  389.         $this->data['content'$msg $this->data['content'];
  390.  
  391.     }
  392.  
  393. }
  394.  
  395.  
  396. /**
  397.  * Advanced Mod Rewrite test class.
  398.  *
  399.  * @author      Murat Purc <murat@purc.de>
  400.  * @copyright   © Murat Purc 2008
  401.  * @package     Contenido
  402.  * @subpackage  ModRewriteTest
  403.  */
  404. class ModRewriteTest {
  405.  
  406.     /**
  407.      * @var  array  Global $cfg array
  408.      */
  409.     private $cfg;
  410.  
  411.     /**
  412.      * @var  array  Global $cfg['tab'] array
  413.      */
  414.     private $cfgTab;
  415.  
  416.  
  417.     /**
  418.      * @var  int  Max items to process
  419.      */
  420.     private $maxItems;
  421.  
  422.     /**
  423.      * @var  string  Actual resolved url
  424.      */
  425.     private $sResolvedUrl;
  426.  
  427.  
  428.     /**
  429.      * @var  bool  Routing found flag
  430.      */
  431.     private $bRoutingFound = false;
  432.  
  433.  
  434.     /**
  435.      * Constuctor
  436.      */
  437.     function __construct({
  438.         $this->cfg    = $GLOBALS['cfg'];
  439.         $this->cfgTab = $GLOBALS['cfg']['tab'];
  440.         $this->maxItems = $GLOBALS['aData']['form']['maxitems'];
  441.     }
  442.  
  443.  
  444.     /**
  445.      * Returns resolved URL
  446.      *
  447.      * @return  bool  Resolved URL
  448.      */
  449.     function getResolvedUrl(){
  450.         return $this->sResolvedUrl;
  451.     }
  452.  
  453.  
  454.     /**
  455.      * Returns flagz about found routing
  456.      *
  457.      * @return  bool 
  458.      */
  459.     function getRoutingFoundState(){
  460.         return $this->bRoutingFound;
  461.     }
  462.  
  463.  
  464.     /**
  465.      * Fetchs full structure of the installation (categories and articles) and returns it back.
  466.      *
  467.      * @param   int    $idclient  Client id
  468.      * @param   int    $idlang    Language id
  469.      * @return  array  Full structure as follows
  470.      *  <code>
  471.      *    $arr[idcat] = Category dataset
  472.      *    $arr[idcat]['articles'][idart] = Article dataset
  473.      *  </code>
  474.      */
  475.     function fetchFullStructure($idclient=null$idlang=null{
  476.  
  477.         $db  new DB_Contenido();
  478.         $db2 new DB_Contenido();
  479.  
  480.         if (!$idclient || (int) $idclient == 0{
  481.             $idclient $GLOBALS['client'];
  482.         }
  483.         if (!$idlang || (int) $idlang == 0{
  484.             $idlang $GLOBALS['lang'];
  485.         }
  486.  
  487.         $aTab $this->cfgTab;
  488.  
  489.         $aStruct array();
  490.  
  491.         $sql "SELECT
  492.                     *
  493.                 FROM
  494.                     " $aTab['cat_tree'" AS a,
  495.                     " $aTab['cat_lang'" AS b,
  496.                     " $aTab['cat'" AS c
  497.                 WHERE
  498.                     a.idcat = b.idcat AND
  499.                     c.idcat = a.idcat AND
  500.                     c.idclient = '".$idclient."' AND
  501.                     b.idlang = '".$idlang."'
  502.                 ORDER BY
  503.                     a.idtree";
  504.  
  505.         $db->query($sql);
  506.  
  507.         $loop    false;
  508.         $counter 0;
  509.  
  510.         while ($db->next_record()) {
  511.  
  512.             if (++$counter == $this->maxItems{
  513.                 break// break this loop
  514.             }
  515.  
  516.             $idcat $db->f('idcat');
  517.             $aStruct[$idcat$db->Record;
  518.             $aStruct[$idcat]['articles'array();
  519.  
  520.             if ($this->cfg['is_start_compatible'== true{
  521.                 $compStatement ' a.is_start DESC, ';
  522.             else {
  523.                 $compStatement '';
  524.             }
  525.  
  526.             $sql2 "SELECT
  527.                          *
  528.                      FROM
  529.                          ".$aTab['cat_art']."  AS a,
  530.                          ".$aTab['art']."      AS b,
  531.                          ".$aTab['art_lang']." AS c
  532.                      WHERE
  533.                          a.idcat = '".$idcat."' AND
  534.                          b.idart = a.idart AND
  535.                          c.idart = a.idart AND
  536.                          c.idlang = '".$idlang."' AND
  537.                          b.idclient = '".$idclient."'
  538.                      ORDER BY
  539.                          " $compStatement "
  540.                          c.title ASC";
  541.  
  542.             $db2->query($sql2);
  543.  
  544.             while ($db2->next_record()) {
  545.                 $idart $db2->f('idart');
  546.                 $aStruct[$idcat]['articles'][$idart$db2->Record;
  547.                 if (++$counter == $this->maxItems{
  548.                     break 2// break this and also superior loop
  549.                 }
  550.             }
  551.         }
  552.  
  553.         return $aStruct;
  554.     }
  555.  
  556.  
  557.     /**
  558.      * Creates an URL using passed data.
  559.      *
  560.      * The result is used to generate seo urls...
  561.      *
  562.      * @param  array  $arr  Assoziative array with some data as follows:
  563.      *  <code>
  564.      *  $arr['idcat']
  565.      *  $arr['idart']
  566.      *  $arr['idcatart']
  567.      *  $arr['idartlang']
  568.      *  </code>
  569.      * @param  string  $type  Either 'c' or 'a' (category or article). If set to
  570.      *                         'c' only the parameter idcat will be added to the URL
  571.      */
  572.     function composeURL($arr$type{
  573.         $type ($type == 'a''a' 'c';
  574.  
  575.         $param array();
  576.  
  577.         if ($type == 'c'{
  578.             $param['idcat=' $arr['idcat'];
  579.         else {
  580.             if (_getRequest('idart')) {
  581.                 $param['idart=' $arr['idart'];
  582.             }
  583.             if (_getRequest('idcat')) {
  584.                 $param['idcat=' $arr['idcat'];
  585.             }
  586.             if (_getRequest('idcatart')) {
  587.                 $param['idcatart=' $arr['idcatart'];
  588.             }
  589.             if (_getRequest('idartlang')) {
  590.                 $param['idartlang=' $arr['idartlang'];
  591.             }
  592.         }
  593.         $param['foo=bar';
  594.         return 'front_content.php?' implode('&amp;'$param);
  595.  
  596.     }
  597.  
  598.  
  599.     /**
  600.      * Resolves variables of an page (idcat, idart, idclient, idlang, etc.) by
  601.      * processing passed url using ModRewriteController
  602.      *
  603.      * @param   string  $url  Url to resolve
  604.      * @return  array   Assoziative array with resolved data
  605.      */
  606.     public function resolveUrl($url){
  607.  
  608.         // some globals to reset
  609.         $aGlobs array(
  610.             'mr_preprocessedPageError''idart''idcat'
  611.         );
  612.         foreach ($aGlobs as $p => $k{
  613.             if (isset($GLOBALS[$k])) unset($GLOBALS[$k])}
  614.         }
  615.  
  616.         $aReturn array();
  617.  
  618.         // create an mod rewrite controller instance and execute processing
  619.         $oMRController new ModRewriteController($url);
  620.         $oMRController->execute();
  621.  
  622.         if ($oMRController->errorOccured()) {
  623.  
  624.             // an error occured (idcat and or idart couldn't catched by controller)
  625.             $aReturn['mr_preprocessedPageError'1;
  626.  
  627.             $this->sResolvedUrl  = '';
  628.             $this->bRoutingFound = false;
  629.  
  630.         else {
  631.  
  632.             // set some global variables
  633.  
  634.             $this->sResolvedUrl  = $oMRController->getResolvedUrl();
  635.             $this->bRoutingFound = $oMRController->getRoutingFoundState();
  636.  
  637.             if ($oMRController->getClient()) {
  638.                 $aReturn['client'$oMRController->getClient();
  639.             }
  640.  
  641.             if ($oMRController->getChangeClient()) {
  642.                 $aReturn['changeclient'$oMRController->getChangeClient();
  643.             }
  644.  
  645.             if ($oMRController->getLang()) {
  646.                 $aReturn['lang'$oMRController->getLang();
  647.             }
  648.  
  649.             if ($oMRController->getChangeLang()) {
  650.                 $aReturn['changelang'$oMRController->getChangeLang();
  651.             }
  652.  
  653.             if ($oMRController->getIdArt()) {
  654.                 $aReturn['idart'$oMRController->getIdArt();
  655.             }
  656.  
  657.             if ($oMRController->getIdCat()) {
  658.                 $aReturn['idcat'$oMRController->getIdCat();
  659.             }
  660.  
  661.             if ($oMRController->getPath()) {
  662.                 $aReturn['path'$oMRController->getPath();
  663.             }
  664.  
  665.         }
  666.  
  667.         return $aReturn;
  668.     }
  669.  
  670.  
  671.     /**
  672.      * Creates a readable string from passed resolved data array.
  673.      *
  674.      * @param   array   Assoziative array with resolved data
  675.      * @return  string  Readable resolved data
  676.      */
  677.     public function getReadableResolvedData(array $data{
  678.         // compose resolved string
  679.         $ret '';
  680.         foreach ($data as $k => $v{
  681.             $ret .= $k '=' $v '; ';
  682.         }
  683.         $ret substr($ret0strlen($ret)-2);
  684.         return $ret;
  685.     }
  686.  
  687. }
  688.  
  689.  
  690. /**
  691.  * Minimalistic'n simple way to get request variables.
  692.  *
  693.  * Checks occurance in $_GET, then in $_POST. Uses trim() and strip_tags() to preclean data.
  694.  *
  695.  * @param   string  $key      Name of var to get
  696.  * @param   mixed   $default  Default value to return
  697.  * @return  mixed   The value
  698.  */
  699. function _getRequest($key$default=null{
  700.     static $cache;
  701.     if (!isset($cache)) {
  702.         $cache array();
  703.     }
  704.     if (isset($cache[$key])) {
  705.         return $cache[$key];
  706.     }
  707.     if (isset($_GET[$key])) {
  708.         $val $_GET[$key];
  709.     elseif (isset($_POST[$key])) {
  710.         $val $_POST[$key];
  711.     else {
  712.         $val $default;
  713.     }
  714.     $cache[$keystrip_tags(trim($val));
  715.     return $cache[$key];
  716. }

Documentation generated on Mon, 08 Sep 2008 03:09:17 +0200 by phpDocumentor 1.4.0