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