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 class
  4:  *
  5:  * @package     Plugin
  6:  * @subpackage  ModRewrite
  7:  * @version     SVN Revision $Rev:$
  8:  * @id          $Id: class.modrewritetest.php 6077 2013-12-07 23:40:41Z 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:  * Mod rewrite test class.
 20:  *
 21:  * @author      Murat Purc <murat@purc.de>
 22:  * @package     Plugin
 23:  * @subpackage  ModRewrite
 24:  */
 25: class ModRewriteTest {
 26: 
 27:     /**
 28:      * Global $cfg array
 29:      * @var  array
 30:      */
 31:     protected $_aCfg;
 32: 
 33:     /**
 34:      * Global $cfg['tab'] array
 35:      * @var  array
 36:      */
 37:     protected $_aCfgTab;
 38: 
 39:     /**
 40:      * Max items to process
 41:      * @var  int
 42:      */
 43:     protected $_iMaxItems;
 44: 
 45:     /**
 46:      * Actual resolved url
 47:      * @var  string
 48:      */
 49:     protected $_sResolvedUrl;
 50: 
 51:     /**
 52:      * Routing found flag
 53:      * @var  bool
 54:      */
 55:     protected $_bRoutingFound = false;
 56: 
 57:     /**
 58:      * Constuctor
 59:      * @param  int  $maxItems  Max items (urls to articles/categories) to process
 60:      */
 61:     public function __construct($maxItems) {
 62:         global $cfg;
 63:         $this->_aCfg = & $cfg;
 64:         $this->_aCfgTab = & $cfg['tab'];
 65:         $this->_iMaxItems = $maxItems;
 66:     }
 67: 
 68:     /**
 69:      * Returns resolved URL
 70:      *
 71:      * @return  bool  Resolved URL
 72:      */
 73:     public function getResolvedUrl() {
 74:         return $this->_sResolvedUrl;
 75:     }
 76: 
 77:     /**
 78:      * Returns flagz about found routing
 79:      *
 80:      * @return  bool
 81:      */
 82:     public function getRoutingFoundState() {
 83:         return $this->_bRoutingFound;
 84:     }
 85: 
 86:     /**
 87:      * Fetchs full structure of the installation (categories and articles) and returns it back.
 88:      *
 89:      * @param   int    $idclient  Client id
 90:      * @param   int    $idlang    Language id
 91:      * @return  array  Full structure as follows
 92:      * <code>
 93:      *   $arr[idcat] = Category dataset
 94:      *   $arr[idcat]['articles'][idart] = Article dataset
 95:      * </code>
 96:      */
 97:     public function fetchFullStructure($idclient = NULL, $idlang = NULL) {
 98:         global $client, $lang;
 99: 
100:         $db = cRegistry::getDb();
101:         $db2 = cRegistry::getDb();
102: 
103:         if (!$idclient || (int) $idclient == 0) {
104:             $idclient = $client;
105:         }
106:         if (!$idlang || (int) $idlang == 0) {
107:             $idlang = $lang;
108:         }
109: 
110:         $aTab = $this->_aCfgTab;
111: 
112:         $aStruct = array();
113: 
114:         $sql = "SELECT
115:                     *
116:                 FROM
117:                     " . $aTab['cat_tree'] . " AS a,
118:                     " . $aTab['cat_lang'] . " AS b,
119:                     " . $aTab['cat'] . " AS c
120:                 WHERE
121:                     a.idcat = b.idcat AND
122:                     c.idcat = a.idcat AND
123:                     c.idclient = '" . $idclient . "' AND
124:                     b.idlang = '" . $idlang . "'
125:                 ORDER BY
126:                     a.idtree";
127: 
128:         $db->query($sql);
129: 
130:         $counter = 0;
131: 
132:         while ($db->nextRecord()) {
133: 
134:             if (++$counter == $this->_iMaxItems) {
135:                 break; // break this loop
136:             }
137: 
138:             $idcat = $db->f('idcat');
139:             $aStruct[$idcat] = $db->getRecord();
140:             $aStruct[$idcat]['articles'] = array();
141: 
142:             $sql2 = "SELECT
143:                          *
144:                      FROM
145:                          " . $aTab['cat_art'] . "  AS a,
146:                          " . $aTab['art'] . "      AS b,
147:                          " . $aTab['art_lang'] . " AS c
148:                      WHERE
149:                          a.idcat = '" . $idcat . "' AND
150:                          b.idart = a.idart AND
151:                          c.idart = a.idart AND
152:                          c.idlang = '" . $idlang . "' AND
153:                          b.idclient = '" . $idclient . "'
154:                      ORDER BY
155:                          c.title ASC";
156: 
157:             $db2->query($sql2);
158: 
159:             while ($db2->nextRecord()) {
160:                 $idart = $db2->f('idart');
161:                 $aStruct[$idcat]['articles'][$idart] = $db2->getRecord();
162:                 if (++$counter == $this->_iMaxItems) {
163:                     break 2; // break this and also superior loop
164:                 }
165:             }
166:         }
167: 
168:         return $aStruct;
169:     }
170: 
171:     /**
172:      * Creates an URL using passed data.
173:      *
174:      * The result is used to generate seo urls...
175:      *
176:      * @param  array  $arr  Assoziative array with some data as follows:
177:      * <code>
178:      * $arr['idcat']
179:      * $arr['idart']
180:      * $arr['idcatart']
181:      * $arr['idartlang']
182:      * </code>
183:      * @param  string  $type  Either 'c' or 'a' (category or article). If set to
184:      *                        'c' only the parameter idcat will be added to the URL
185:      */
186:     public function composeURL($arr, $type) {
187:         $type = ($type == 'a') ? 'a' : 'c';
188: 
189:         $param = array();
190: 
191:         if ($type == 'c') {
192:             $param[] = 'idcat=' . $arr['idcat'];
193:         } else {
194:             if (mr_getRequest('idart')) {
195:                 $param[] = 'idart=' . $arr['idart'];
196:             }
197:             if (mr_getRequest('idcat')) {
198:                 $param[] = 'idcat=' . $arr['idcat'];
199:             }
200:             if (mr_getRequest('idcatart')) {
201:                 $param[] = 'idcatart=' . $arr['idcatart'];
202:             }
203:             if (mr_getRequest('idartlang')) {
204:                 $param[] = 'idartlang=' . $arr['idartlang'];
205:             }
206:         }
207:         $param[] = 'foo=bar';
208:         return 'front_content.php?' . implode('&amp;', $param);
209:     }
210: 
211:     /**
212:      * Resolves variables of an page (idcat, idart, idclient, idlang, etc.) by
213:      * processing passed url using ModRewriteController
214:      *
215:      * @param   string  $url  Url to resolve
216:      * @return  array   Assoziative array with resolved data
217:      */
218:     public function resolveUrl($url) {
219:         // some globals to reset
220:         $aGlobs = array(
221:             'mr_preprocessedPageError', 'idart', 'idcat'
222:         );
223:         foreach ($aGlobs as $p => $k) {
224:             if (isset($GLOBALS[$k])) {
225:                 unset($GLOBALS[$k]);
226:             }
227:         }
228: 
229:         $aReturn = array();
230: 
231:         // create an mod rewrite controller instance and execute processing
232:         $oMRController = new ModRewriteController($url);
233:         $oMRController->execute();
234: 
235:         if ($oMRController->errorOccured()) {
236: 
237:             // an error occured (idcat and or idart couldn't catched by controller)
238:             $aReturn['mr_preprocessedPageError'] = 1;
239:             $aReturn['error'] = $oMRController->getError();
240: 
241:             $this->_sResolvedUrl = '';
242:             $this->_bRoutingFound = false;
243:         } else {
244: 
245:             // set some global variables
246: 
247:             $this->_sResolvedUrl = $oMRController->getResolvedUrl();
248:             $this->_bRoutingFound = $oMRController->getRoutingFoundState();
249: 
250:             if ($oMRController->getClient()) {
251:                 $aReturn['client'] = $oMRController->getClient();
252:             }
253: 
254:             if ($oMRController->getChangeClient()) {
255:                 $aReturn['changeclient'] = $oMRController->getChangeClient();
256:             }
257: 
258:             if ($oMRController->getLang()) {
259:                 $aReturn['lang'] = $oMRController->getLang();
260:             }
261: 
262:             if ($oMRController->getChangeLang()) {
263:                 $aReturn['changelang'] = $oMRController->getChangeLang();
264:             }
265: 
266:             if ($oMRController->getIdArt()) {
267:                 $aReturn['idart'] = $oMRController->getIdArt();
268:             }
269: 
270:             if ($oMRController->getIdCat()) {
271:                 $aReturn['idcat'] = $oMRController->getIdCat();
272:             }
273: 
274:             if ($oMRController->getPath()) {
275:                 $aReturn['path'] = $oMRController->getPath();
276:             }
277:         }
278: 
279:         return $aReturn;
280:     }
281: 
282:     /**
283:      * Creates a readable string from passed resolved data array.
284:      *
285:      * @param   array   $data Assoziative array with resolved data
286:      * @return  string  Readable resolved data
287:      */
288:     public function getReadableResolvedData(array $data) {
289:         // compose resolved string
290:         $ret = '';
291:         foreach ($data as $k => $v) {
292:             $ret .= $k . '=' . $v . '; ';
293:         }
294:         $ret = substr($ret, 0, strlen($ret) - 2);
295:         return $ret;
296:     }
297: 
298: }
299: 
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0