Source for file class.modrewriteurlutil.php
Documentation is available at class.modrewriteurlutil.php
* Includes Mod Rewrite url utility class.
* @author Murat Purc <murat@purc.de>
* @copyright © Murat Purc 2008
* Mod Rewrite url utility class. Handles convertion of Urls from contenido core
* based url composition pattern to AMR (Advanced Mod Rewrite) url composition
* pattern and vice versa.
* @author Murat Purc <murat@purc.de>
* Self instance (singleton implementation)
private static $_instance;
* Contenido category word separator
* AMR category word separator
* Contenido category separator
* Contenido article separator
* Contenido article word separator
* AMR article word separator
* AMR extension used for articlenames (e. g. .html)
* Contructor, sets some AMR configuration related properties
$this->_mrCatSep =
$aCfg['category_seperator'];
$this->_mrArtSep =
$aCfg['article_seperator'];
$this->_mrExt =
$aCfg['file_extension'];
* Returns self instance (singleton pattern)
* @return ModRewriteUrlUtil
if (self::$_instance ==
null) {
self::$_instance =
new ModRewriteUrlUtil();
* Converts passed AMR url path to Contenido url path.
* @param string $urlPath AMR url path
* @return string Contenido url path
#echo "<pre><strong>toContenidoUrlPath($urlPath) return $newUrlPath</strong></pre>";
* Converts passed Contenido url path to AMR url path.
* @param string $urlPath Contenido url path
* @return string AMR url path
#echo "<pre><strong>toModRewriteUrlPath($urlPath)</strong></pre>";
* Converts passed url path to a another url path (Contenido to AMR and vice versa).
* @param string $urlPath Source url path
* @param string $fromCatSep Source category seperator
* @param string $toCatSep Destination category seperator
* @param string $fromCatWordSep Source category word seperator
* @param string $toCatWordSep Destination category word seperator
* @param string $fromArtSep Source article seperator
* @param string $toArtSep Destination article seperator
* @return string Destination url path
private function _toUrlPath($urlPath, $fromCatSep, $toCatSep, $fromCatWordSep, $toCatWordSep,
$fromArtSep, $toArtSep) {
if ((string)
$urlPath ==
'') {
if (substr($urlPath, -
1) ==
$fromArtSep) {
$urlPath =
substr($urlPath, 0, -
1) .
'{TAS}';
// pre replace category word seperator and category seperator
$urlPath =
str_replace($fromCatWordSep, '{CWS}', $urlPath);
// replace category word seperator
$urlPath =
str_replace('{CWS}', $toCatWordSep, $urlPath);
* Converts passed AMR url name to Contenido url name.
* @param string $urlName AMR url name
* @return string Contenido url name
* Converts passed Contenido url name to AMR url name.
* @param string $urlName Contenido url name
* @return string AMR url name
* Converts passed url name to a another url name (Contenido to AMR and vice versa).
* @param string $urlName Source url name
* @param string $fromArtWordSep Source article word seperator
* @param string $toArtWordSep Destination article word seperator
* @return string Destination url name
private function _toUrlName($urlName, $fromArtWordSep, $toArtWordSep) {
if ((string)
$urlName ==
'') {
#echo "<pre>\$fromArtWordSep: $fromArtWordSep\n\$toArtWordSep: $toArtWordSep</pre>";
// replace article word seperator
$urlName =
str_replace($fromArtWordSep, $toArtWordSep, $urlName);
#echo "<pre>\$urlName: $urlName</pre>";
* Converts passed AMR url to Contenido url.
* @param string $url AMR url
* @return string Contenido url
// replace category word and article word seperator
* Converts passed AMR url to Contenido url.
* @param string $url AMR url
* @return string Contenido url
// replace category word and article word seperator
* Converts passed url to a another url (Contenido to AMR and vice versa).
* @param string $urlPath Source url path
* @param string $fromCatSep Source category seperator
* @param string $toCatSep Destination category seperator
* @param string $fromCatWordSep Source category word seperator
* @param string $toCatWordSep Destination category word seperator
* @param string $fromArtSep Source article seperator
* @param string $toArtSep Destination article seperator
* @param string $fromArtWordSep Source article word seperator
* @param string $toArtWordSep Destination article word seperator
* @return string Destination url
private function _toUrl($url, $fromCatSep, $toCatSep, $fromCatWordSep, $toCatWordSep,
$fromArtSep, $toArtSep, $fromArtWordSep, $toArtWordSep) {
if ((string)
$url ==
'') {
// replace category seperator
// replace article seperator
// no articlename, replace category word seperator
$url =
str_replace($fromCatWordSep, $toCatWordSep, $url);
#echo "<pre>\$url: $url</pre>";
// replace category word and article word seperator
#echo "<pre>\$path: $path; \$file: $file</pre>";
Documentation generated on Tue, 25 Nov 2008 22:07:30 +0100 by phpDocumentor 1.4.1