Overview

Packages

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