Class ModRewriteUrlStack

Description

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:

  1.  // get the instance
  2.  $oMRUrlStack ModRewriteUrlStack::getInstance();
  3.  
  4.  // add several urls to fill the stack
  5.  $oMRUrlStack->add('front_content.php?idcat=123');
  6.  $oMRUrlStack->add('front_content.php?idart=321');
  7.  $oMRUrlStack->add('front_content.php?idcatart=213');
  8.  $oMRUrlStack->add('front_content.php?idcatlang=213');
  9.  $oMRUrlStack->add('front_content.php?idartlang=312');
  10.  
  11.  // now the first call will get the pretty path and names from database at one go
  12.  $aPrettyParts $oMRUrlStack->getPrettyUrlParts('front_content.php?idcat=123');
  13.  echo $aPrettyParts['urlpath']// something like 'Main-category-name/Category-name/Another-category-name/'
  14.  echo $aPrettyParts['urlname']// something like 'Name-of-an-article'

  • author: Murat Purc <murat@purc.de>
  • copyright: © Murat Purc 2008
  • date: 09.10.2008

Located in /contenido/plugins/mod_rewrite/classes/class.modrewriteurlstack.php (line 50)


	
			
Variable Summary
 array $_aConParams
 array $_aStack
 array $_aTab
 array $_aUrls
 int $_idLang
 DB_Contenido $_oDb
Method Summary
 ModRewriteUrlStack __construct ()
 void add (string $url)
 array getPrettyUrlParts (string $url)
 array _extractUrl (string $url)
 string _makeStackId ( $aParams)
Variables
static ModRewriteUrlStack $_instance (line 57)

Self instance

  • access: private
array $_aConParams = array(
'idcat' => 1, 'idart' => 1, 'lang' => 1, 'idcatlang' => 1, 'idcatart' => 1, 'idartlang' => 1
)
(line 85)

Contenido related parameter array

  • access: private
array $_aStack = array() (line 78)

Url stack array

  • access: private
array $_aTab (line 94)

Database tables array

  • access: private
array $_aUrls = array() (line 71)

Array for urls

  • access: private
int $_idLang (line 101)

Language id

  • access: private
DB_Contenido $_oDb (line 64)

Database object

  • access: private
Methods
static getInstance (line 119)

Returns a instance of ModRewriteUrlStack (singleton implementation)

  • access: public
ModRewriteUrlStack getInstance ()
Constructor __construct (line 107)

Constructor, sets some properties.

  • access: private
ModRewriteUrlStack __construct ()
add (line 132)

Adds an url to the stack

  • access: public
void add (string $url)
  • string $url: Url, like front_content.php?idcat=123...
getPrettyUrlParts (line 171)

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

  • return: Assoziative array like
    1.  $arr['urlpath']
    2.  $arr['urlname']
  • access: public
array getPrettyUrlParts (string $url)
  • string $url: Url, like front_content.php?idcat=123...
_chunkSetPrettyUrlParts (line 240)

Main function to get the urlparts of urls.

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

  • access: private
void _chunkSetPrettyUrlParts ()
_extractUrl (line 195)

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

  • return: Components containing result of parse_url with additional 'params' array
  • access: private
array _extractUrl (string $url)
  • string $url: Url, like front_content.php?idcat=123...
_makeStackId (line 215)

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

  • return: Composed stack id
  • access: private
string _makeStackId ( $aParams)
  • array $aParams: Parameter array

Documentation generated on Sun, 08 Feb 2009 22:00:39 +0100 by phpDocumentor 1.4.1