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
    • 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:      * @return  array  Full structure as follows
 91:      * <code>
 92:      *   $arr[idcat] = Category dataset
 93:      *   $arr[idcat]['articles'][idart] = Article dataset
 94:      * </code>
 95:      */
 96:     public function fetchFullStructure($idclient = NULL, $idlang = NULL) {
 97:         global $client, $lang;
 98: 
 99:         $db = cRegistry::getDb();
100:         $db2 = cRegistry::getDb();
101: 
102:         if (!$idclient || (int) $idclient == 0) {
103:             $idclient = $client;
104:         }
105:         if (!$idlang || (int) $idlang == 0) {
106:             $idlang = $lang;
107:         }
108: 
109:         $aTab = $this->_aCfgTab;
110: 
111:         $aStruct = array();
112: 
113:         $sql = "SELECT
114:                     *
115:                 FROM
116:                     " . $aTab['cat_tree'] . " AS a,
117:                     " . $aTab['cat_lang'] . " AS b,
118:                     " . $aTab['cat'] . " AS c
119:                 WHERE
120:                     a.idcat = b.idcat AND
121:                     c.idcat = a.idcat AND
122:                     c.idclient = '" . $idclient . "' AND
123:                     b.idlang = '" . $idlang . "'
124:                 ORDER BY
125:                     a.idtree";
126: 
127:         $db->query($sql);
128: 
129:         $counter = 0;
130: 
131:         while ($db->nextRecord()) {
132: 
133:             if (++$counter == $this->_iMaxItems) {
134:                 break; // break this loop
135:             }
136: 
137:             $idcat = $db->f('idcat');
138:             $aStruct[$idcat] = $db->getRecord();
139:             $aStruct[$idcat]['articles'] = array();
140: 
141:             $sql2 = "SELECT
142:                          *
143:                      FROM
144:                          " . $aTab['cat_art'] . "  AS a,
145:                          " . $aTab['art'] . "      AS b,
146:                          " . $aTab['art_lang'] . " AS c
147:                      WHERE
148:                          a.idcat = '" . $idcat . "' AND
149:                          b.idart = a.idart AND
150:                          c.idart = a.idart AND
151:                          c.idlang = '" . $idlang . "' AND
152:                          b.idclient = '" . $idclient . "'
153:                      ORDER BY
154:                          c.title ASC";
155: 
156:             $db2->query($sql2);
157: 
158:             while ($db2->nextRecord()) {
159:                 $idart = $db2->f('idart');
160:                 $aStruct[$idcat]['articles'][$idart] = $db2->getRecord();
161:                 if (++$counter == $this->_iMaxItems) {
162:                     break 2; // break this and also superior loop
163:                 }
164:             }
165:         }
166: 
167:         return $aStruct;
168:     }
169: 
170:     /**
171:      * Creates an URL using passed data.
172:      *
173:      * The result is used to generate seo urls...
174:      *
175:      * @param  array  $arr  Assoziative array with some data as follows:
176:      * <code>
177:      * $arr['idcat']
178:      * $arr['idart']
179:      * $arr['idcatart']
180:      * $arr['idartlang']
181:      * </code>
182:      * @param  string  $type  Either 'c' or 'a' (category or article). If set to
183:      *                        'c' only the parameter idcat will be added to the URL
184:      */
185:     public function composeURL($arr, $type) {
186:         $type = ($type == 'a') ? 'a' : 'c';
187: 
188:         $param = array();
189: 
190:         if ($type == 'c') {
191:             $param[] = 'idcat=' . $arr['idcat'];
192:         } else {
193:             if (mr_getRequest('idart')) {
194:                 $param[] = 'idart=' . $arr['idart'];
195:             }
196:             if (mr_getRequest('idcat')) {
197:                 $param[] = 'idcat=' . $arr['idcat'];
198:             }
199:             if (mr_getRequest('idcatart')) {
200:                 $param[] = 'idcatart=' . $arr['idcatart'];
201:             }
202:             if (mr_getRequest('idartlang')) {
203:                 $param[] = 'idartlang=' . $arr['idartlang'];
204:             }
205:         }
206:         $param[] = 'foo=bar';
207:         return 'front_content.php?' . implode('&amp;', $param);
208:     }
209: 
210:     /**
211:      * Resolves variables of an page (idcat, idart, idclient, idlang, etc.) by
212:      * processing passed url using ModRewriteController
213:      *
214:      * @param   string  $url  Url to resolve
215:      * @return  array   Assoziative array with resolved data
216:      */
217:     public function resolveUrl($url) {
218:         // some globals to reset
219:         $aGlobs = array(
220:             'mr_preprocessedPageError', 'idart', 'idcat'
221:         );
222:         foreach ($aGlobs as $p => $k) {
223:             if (isset($GLOBALS[$k])) {
224:                 unset($GLOBALS[$k]);
225:             }
226:         }
227: 
228:         $aReturn = array();
229: 
230:         // create an mod rewrite controller instance and execute processing
231:         $oMRController = new ModRewriteController($url);
232:         $oMRController->execute();
233: 
234:         if ($oMRController->errorOccured()) {
235: 
236:             // an error occured (idcat and or idart couldn't catched by controller)
237:             $aReturn['mr_preprocessedPageError'] = 1;
238:             $aReturn['error'] = $oMRController->getError();
239: 
240:             $this->_sResolvedUrl = '';
241:             $this->_bRoutingFound = false;
242:         } else {
243: 
244:             // set some global variables
245: 
246:             $this->_sResolvedUrl = $oMRController->getResolvedUrl();
247:             $this->_bRoutingFound = $oMRController->getRoutingFoundState();
248: 
249:             if ($oMRController->getClient()) {
250:                 $aReturn['client'] = $oMRController->getClient();
251:             }
252: 
253:             if ($oMRController->getChangeClient()) {
254:                 $aReturn['changeclient'] = $oMRController->getChangeClient();
255:             }
256: 
257:             if ($oMRController->getLang()) {
258:                 $aReturn['lang'] = $oMRController->getLang();
259:             }
260: 
261:             if ($oMRController->getChangeLang()) {
262:                 $aReturn['changelang'] = $oMRController->getChangeLang();
263:             }
264: 
265:             if ($oMRController->getIdArt()) {
266:                 $aReturn['idart'] = $oMRController->getIdArt();
267:             }
268: 
269:             if ($oMRController->getIdCat()) {
270:                 $aReturn['idcat'] = $oMRController->getIdCat();
271:             }
272: 
273:             if ($oMRController->getPath()) {
274:                 $aReturn['path'] = $oMRController->getPath();
275:             }
276:         }
277: 
278:         return $aReturn;
279:     }
280: 
281:     /**
282:      * Creates a readable string from passed resolved data array.
283:      *
284:      * @param   array   $data Assoziative array with resolved data
285:      * @return  string  Readable resolved data
286:      */
287:     public function getReadableResolvedData(array $data) {
288:         // compose resolved string
289:         $ret = '';
290:         foreach ($data as $k => $v) {
291:             $ret .= $k . '=' . $v . '; ';
292:         }
293:         $ret = cString::getPartOfString($ret, 0, cString::getStringLength($ret) - 2);
294:         return $ret;
295:     }
296: 
297: }
298: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0