Mod rewrite url stack class. Provides features to collect urls and to get the pretty path and names of categories/articles at one go.

Main goal of this class is to collect urls and to get the urlpath and urlname of the related categories/articles at one go. This will reduce the queries against the database. Therefore the full advantage will be taken by rewriting the urls at codeoutput in front_content.php, where you will be able to collect all urls at once...

Usage:

// get the instance
$oMRUrlStack = ModRewriteUrlStack::getInstance();

// add several urls to fill the stack
$oMRUrlStack->add('front_content.php?idcat=123');
$oMRUrlStack->add('front_content.php?idart=321');
$oMRUrlStack->add('front_content.php?idcatart=213');
$oMRUrlStack->add('front_content.php?idcatlang=213');
$oMRUrlStack->add('front_content.php?idartlang=312');

// now the first call will get the pretty path and names from database at one go
$aPrettyParts = $oMRUrlStack->getPrettyUrlParts('front_content.php?idcat=123');
echo $aPrettyParts['urlpath']; // something like 'Main-category-name/Category-name/Another-category-name/'
echo $aPrettyParts['urlname']; // something like 'Name-of-an-article'

author Murat Purc
package Contenido Backend plugins
subpackage ModRewrite

 Methods

Adds an url to the stack

add(string $url) 

Parameters

$url

string

Url, like front_content.php?idcat=123...

Returns a instance of ModRewriteUrlStack (singleton implementation)

getInstance() : \ModRewriteUrlStack

Returns the pretty urlparts (only category path an article name) of the desired url.

getPrettyUrlParts(string $url) : array

Parameters

$url

string

Url, like front_content.php?idcat=123...

Returns

arrayAssoziative array like $arr['urlpath'] $arr['urlname']

Constructor, sets some properties.

__construct() 

Main function to get the urlparts of urls.

_chunkSetPrettyUrlParts() 

Composes the query by looping thru stored but non processed urls, executes the query and adds the (urlpath and urlname) result to the stack.

Extracts passed url using parse_urla and adds also the 'params' array to it

_extractUrl(string $url) : array

Parameters

$url

string

Url, like front_content.php?idcat=123...

Returns

arrayComponents containing result of parse_url with additional 'params' array

Extracts article or category related parameter from passed params array and generates an identifier.

_makeStackId(array $aParams) : string

Parameters

$aParams

array

Parameter array

Returns

stringComposed stack id

 Properties

 

Contenido related parameter array

$_aConParams : array

 

Url stack array

$_aStack : array

 

Database tables array

$_aTab : array

 

Array for urls

$_aUrls : array

 

Language id

$_idLang : int

 

Self instance

$_instance : \ModRewriteUrlStack

 

Database object

$_oDb : \DB_Contenido