Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cUriBuilderMR
  • ModRewrite
  • ModRewrite_ContentController
  • ModRewrite_ContentExpertController
  • ModRewrite_ContentTestController
  • ModRewrite_ControllerAbstract
  • ModRewriteBase
  • ModRewriteController
  • ModRewriteDebugger
  • ModRewriteTest
  • ModRewriteUrlStack
  • ModRewriteUrlUtil

Functions

  • mr_arrayValue
  • mr_buildGeneratedCode
  • mr_buildNewUrl
  • mr_conCopyArtLang
  • mr_conMoveArticles
  • mr_conSaveArticle
  • mr_conSyncArticle
  • mr_debugOutput
  • mr_getConfiguration
  • mr_getRequest
  • mr_header
  • mr_i18n
  • mr_loadConfiguration
  • mr_queryAndNextRecord
  • mr_removeMultipleChars
  • mr_requestCleanup
  • mr_runFrontendController
  • mr_setClientLanguageId
  • mr_setConfiguration
  • mr_strCopyCategory
  • mr_strMovedownCategory
  • mr_strMoveSubtree
  • mr_strMoveUpCategory
  • mr_strNewCategory
  • mr_strNewTree
  • mr_strRenameCategory
  • mr_strSyncCategory
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * AMR test controller
  4:  *
  5:  * @package     Plugin
  6:  * @subpackage  ModRewrite
  7:  * @id          $Id$:
  8:  * @author      Murat Purc <murat@purc.de>
  9:  * @copyright   four for business AG <www.4fb.de>
 10:  * @license     http://www.contenido.org/license/LIZENZ.txt
 11:  * @link        http://www.4fb.de
 12:  * @link        http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: 
 18: /**
 19:  * Content controller to run tests.
 20:  *
 21:  * @author      Murat Purc <murat@purc.de>
 22:  * @package     Plugin
 23:  * @subpackage  ModRewrite
 24:  */
 25: class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
 26: 
 27:     /**
 28:      * Number of max items to process
 29:      * @var  int
 30:      */
 31:     protected $_iMaxItems = 0;
 32: 
 33:     /**
 34:      * Initializer method, sets some view variables
 35:      */
 36:     public function init() {
 37:         $this->_oView->content = '';
 38:         $this->_oView->form_idart_chk = ($this->_getParam('idart')) ? ' checked="checked"' : '';
 39:         $this->_oView->form_idcat_chk = ($this->_getParam('idcat')) ? ' checked="checked"' : '';
 40:         $this->_oView->form_idcatart_chk = ($this->_getParam('idcatart')) ? ' checked="checked"' : '';
 41:         $this->_oView->form_idartlang_chk = ($this->_getParam('idartlang')) ? ' checked="checked"' : '';
 42:         $this->_oView->form_maxitems = (int) $this->_getParam('maxitems', 200);
 43:         $this->_iMaxItems = $this->_oView->form_maxitems;
 44:     }
 45: 
 46:     /**
 47:      * Index action
 48:      */
 49:     public function indexAction() {
 50:         $this->_oView->content = '';
 51:     }
 52: 
 53:     /**
 54:      * Test action
 55:      */
 56:     public function testAction() {
 57:         $this->_oView->content = '';
 58: 
 59:         // Array for testcases
 60:         $aTests = array();
 61: 
 62:         // Instance of mr test
 63:         $oMRTest = new ModRewriteTest($this->_iMaxItems);
 64: 
 65:         $startTime = getmicrotime();
 66: 
 67:         // Fetch complete CONTENIDO page structure
 68:         $aStruct = $oMRTest->fetchFullStructure();
 69:         ModRewriteDebugger::add($aStruct, 'mr_test.php $aStruct');
 70: 
 71:         // Loop through the structure and compose testcases
 72:         foreach ($aStruct as $idcat => $aCat) {
 73:             // category
 74:             $aTests[] = array(
 75:                 'url' => $oMRTest->composeURL($aCat, 'c'),
 76:                 'level' => $aCat['level'],
 77:                 'name' => $aCat['name']
 78:             );
 79: 
 80:             foreach ($aCat['articles'] as $idart => $aArt) {
 81:                 // articles
 82:                 $aTests[] = array(
 83:                     'url' => $oMRTest->composeURL($aArt, 'a'),
 84:                     'level' => $aCat['level'],
 85:                     'name' => $aCat['name'] . ' :: ' . $aArt['title']
 86:                 );
 87:             }
 88:         }
 89: 
 90:         // compose content
 91:         $this->_oView->content = '<pre>';
 92: 
 93:         $oMRUrlStack = ModRewriteUrlStack::getInstance();
 94: 
 95:         // first loop to add urls to mr url stack
 96:         foreach ($aTests as $p => $v) {
 97:             $oMRUrlStack->add($v['url']);
 98:         }
 99: 
100:         $successCounter = 0;
101:         $failCounter = 0;
102: 
103:         // second loop to do the rest
104:         foreach ($aTests as $p => $v) {
105:             $url = mr_buildNewUrl($v['url']);
106:             $arr = $oMRTest->resolveUrl($url);
107:             $error = '';
108:             $resUrl = $oMRTest->getResolvedUrl();
109:             $color = 'green';
110: 
111:             if ($url !== $resUrl) {
112:                 if ($oMRTest->getRoutingFoundState()) {
113:                     $successCounter++;
114:                     $resUrl = 'route to -&gt; ' . $resUrl;
115:                 } else {
116:                     $color = 'red';
117:                     $failCounter++;
118:                 }
119:             } else {
120:                 $successCounter++;
121:             }
122: 
123:             // @todo: translate
124:             if (isset($arr['error'])) {
125:                 switch ($arr['error']) {
126:                     case ModRewriteController::ERROR_CLIENT:
127:                         $error = 'client';
128:                         break;
129:                     case ModRewriteController::ERROR_LANGUAGE:
130:                         $error = 'language';
131:                         break;
132:                     case ModRewriteController::ERROR_CATEGORY:
133:                         $error = 'category';
134:                         break;
135:                     case ModRewriteController::ERROR_ARTICLE:
136:                         $error = 'article';
137:                         break;
138:                     case ModRewriteController::ERROR_POST_VALIDATION:
139:                         $error = 'validation';
140:                         break;
141:                 }
142:             }
143: 
144:             $pref = str_repeat('    ', $v['level']);
145: 
146:             // render resolve information for current item
147:             $itemTpl = $this->_oView->lng_result_item_tpl;
148:             $itemTpl = str_replace('{pref}', $pref, $itemTpl);
149:             $itemTpl = str_replace('{name}', $v['name'], $itemTpl);
150:             $itemTpl = str_replace('{url_in}', $v['url'], $itemTpl);
151:             $itemTpl = str_replace('{url_out}', $url, $itemTpl);
152:             $itemTpl = str_replace('{color}', $color, $itemTpl);
153:             $itemTpl = str_replace('{url_res}', $resUrl, $itemTpl);
154:             $itemTpl = str_replace('{err}', $error, $itemTpl);
155:             $itemTpl = str_replace('{data}', $oMRTest->getReadableResolvedData($arr), $itemTpl);
156: 
157:             $this->_oView->content .= "\n" . $itemTpl . "\n";
158:         }
159:         $this->_oView->content .= '</pre>';
160: 
161:         $totalTime = sprintf('%.4f', (getmicrotime() - $startTime));
162: 
163:         // render information about current test
164:         $msg = $this->_oView->lng_result_message_tpl;
165:         $msg = str_replace('{time}', $totalTime, $msg);
166:         $msg = str_replace('{num_urls}', ($successCounter + $failCounter), $msg);
167:         $msg = str_replace('{num_success}', $successCounter, $msg);
168:         $msg = str_replace('{num_fail}', $failCounter, $msg);
169: 
170:         $this->_oView->content = $msg . $this->_oView->content;
171:     }
172: 
173: }
174: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0