Class to create websafe names

Provides some common features such as common debugging, globals/configuration access for childs.

author Stefan Seifarth / stese
author Murat Purc
package Contenido Backend plugins
subpackage ModRewrite

 Methods

Build a recursiv path for mod_rewrite rule like server directories (dir1/dir2/dir3)

buildRecursivPath(int $iCatId, int $iLangId, int $iLastId) : string

Parameters

$iCatId

int

Latest category id

$iLangId

int

Language id

$iLastId

int

Last category id

Returns

stringlinkpath with correct uri

Return full contenido url from single anchor

contenidoHtmlAnchor(array $aMatches, $bXHTML) : string

Parameters

$aMatches

array

[0] = complete anchor, [1] = pre arguments, [2] = anchor name, [3] = post arguments

$bXHTML

Returns

stringNew anchor

Get article id and language id from article language id

getArtIdByArtlangId(int $iArtlangId) : array

Parameters

$iArtlangId

int

Current article id

Returns

arrayArray with idart and idlang of current article

Get article id by article websafe name

getArtIdByWebsafeName(string $sArtName, int $iCatId, $iLangId) : int | null

Parameters

$sArtName

string

Websafe name

$iCatId

int

Category id

$iLangId

Returns

intnullRecent article id or null

Get article urlname and language id

getArtIds(int $iArtlangId) : array

Parameters

$iArtlangId

int

idartlang

Returns

arrayUrlname, idlang of empty array

Get article websafe name from idartlang.

getArtLangWebsafeName(int $iArtLangId) : string

Parameters

$iArtLangId

int

idartlang

Returns

stringArticle websafe name

Get article name from article id and language id

getArtTitle(int $iArtId, int $iLangId) : string

NOTE : seems to be not used???

Parameters

$iArtId

int

Article id

$iLangId

int

Language id

Returns

stringArticle name

Get article websafe name from article id and language id.

getArtWebsafeName(int $iArtId, int $iLangId) : string

Parameters

$iArtId

int

Article id

$iLangId

int

Language id

Returns

stringArticle websafe name

Funcion to return cat id by path.

getCatIdByUrlPath(string $path) : int

Caches the paths at first call to provode faster processing at further calls.

Parameters

$path

string

Category path

Returns

intCategory id

Get language ids from category id

getCatLanguages(int $iCatId) : array

Parameters

$iCatId

int

Category id

Returns

arrayUsed language ids

Get category name from category id and language id.

getCatName(int $iCatId, int $iLangId) : string

Parameters

$iCatId

int

Category id

$iLangId

int

Language id

Returns

stringCategory name

Splits passed argument into scheme://host and path/query.

getClientFullUrlParts(string $url) : array

Example: input = http://host/front_content.php?idcat=123 return = array('htmlpath' => 'http://host', 'url' => 'front_content.php?idcat=123')

Parameters

$url

string

URL to split

Returns

arrayAssoziative array including the two parts: - array('htmlpath' => $path, 'url' => $url)

Get client id from client name

getClientId(string $sClientName) : integer

Parameters

$sClientName

string

Client name

Returns

integerClient id

Get name of client by id.

getClientName(int $clientId) : string

Parameters

$clientId

int

Client id

Returns

stringClient name

Returns configuration of mod rewrite, content of gobal $cfg['mod_rewrite']

getConfig(string $key, $default) : mixed
Inherited

inherited_from \ModRewriteBase::getConfig()

Parameters

$key

string

Name of configuration key

$default

Returns

mixedDesired value mr configuration, either the full configuration or one of the desired subpart

Returns .htaccess related assoziative info array

getHtaccessInfo() : array

Returns

array

Used to postprocess resolved path

getIdFromPathresolverResult(array $results) : mixed

Error site handling if category not found

if percentage == 100 and there is no 100 percentage result value, error site will be shown - can be adjust by user settings for smooth similar effects - 80 to 95 will be best but have to check by user

deprecated Is no more used

Parameters

$results

array

Pathresolver results array

Returns

mixedCategoryid or false

Get language id from language name thanks to Nicolas Dickinson for multi Client/Language BugFix

getLanguageId(string $sLanguageName, int $iClientId) : integer

Parameters

$sLanguageName

string

Language name

$iClientId

int

Client id

Returns

integerLanguage id

Returns name of language by id.

getLanguageName(int $languageId) : string

Parameters

$languageId

int

Language id

Returns

stringLanuage name

Initialization, is to call at least once, also possible to call multible times, if different client configuration is to load.

initialize(int $clientId) 

Loads configuration of passed client and sets some properties.

Parameters

$clientId

int

Client id

Returns enabled state of mod rewrite plugin

isEnabled() : bool
Inherited

inherited_from \ModRewriteBase::isEnabled()

Returns

bool

Check articles on websafe name.

isInCatArticles(string $sName, int $iArtId, int $iLangId, int $iCatId) : bool

Check all articles in the current category on existing same websafe name.

Parameters

$sName

string

Websafe name to check

$iArtId

int

Current article id

$iLangId

int

Current language id

$iCatId

int

Category id

Returns

boolTrue if websafename already exists, false if not

Check categories on websafe name

isInCategories(string $sName, int $iCatId, int $iLangId) : bool

Check all categories in the main parent category on existing same websafe name

Parameters

$sName

string

Websafe name to check

$iCatId

int

Current category id

$iLangId

int

Current language id

Returns

boolTrue if websafename already exists, false if not

Recreate all or only empty aliases (categories and articles).

recreateAliases(bool $bOnlyEmpty) 

Shortcut to recreateCategoriesAliases() and recreateArticlesAliases()

Parameters

$bOnlyEmpty

bool

Flag to reset only empty items

Recreates all or only empty urlname entries in art_lang table.

recreateArticlesAliases(bool $bOnlyEmpty) 

Parameters

$bOnlyEmpty

bool

Flag to reset only empty items

Recreates all or only empty aliases in categories table.

recreateCategoriesAliases(bool $bOnlyEmpty) 

Parameters

$bOnlyEmpty

bool

Flag to reset only empty items

Method to reset all aliases (categories and articles).

resetAliases() 

Shortcut to recreateCategoriesAliases() and recreateArticlesAliases()

Method to reset all aliases in articles.

resetArticlesAliases() 

Clears all urlname entries in art_lang table, and sets the value for all existing entries.

deprecated see ModRewrite::recreateArticlesAliases();

Method to reset all aliases in categories.

resetCategoriesAliases() 

Clears all urlname entries in cat_lang table, and sets the value for all existing entries.

deprecated see ModRewrite::recreateCategoriesAliases();

Return full contenido url from single anchor

rewriteHtmlAnchor(array $aMatches) : string

Parameters

$aMatches

array

[0] = complete anchor, [1] = pre arguments, [2] = anchor name, [3] = post arguments

Returns

stringNew anchor

Set websafe name in article list.

setArtWebsafeName(string $sName, int $iArtId, int $iLangId, int $iCatId) : bool

Insert new websafe name in article list

Parameters

$sName

string

Original name (will be converted)

$iArtId

int

Current article id

$iLangId

int

Current language id

$iCatId

int

Category id

Returns

boolTrue if insert was successfully

Set urlpath of category

setCatUrlPath(int $iCatId, int $iLangId) : bool

Parameters

$iCatId

int

Category id

$iLangId

int

Language id

Returns

boolTrue if insert was successfully

Set websafe name in category list.

setCatWebsafeName(string $sName, int $iCatId, int $iLangId) : bool

Insert new websafe name in category list.

Parameters

$sName

string

Original name (will be converted) or alias

$iCatId

int

Category id

$iLangId

int

Language id

Returns

boolTrue if insert was successfully

Sets the configuration of mod rewrite, content of gobal $cfg['mod_rewrite']

setConfig(string $key, mixed $value) 
Inherited

inherited_from \ModRewriteBase::setConfig()

Parameters

$key

string

Name of configuration key

$value

mixed

The value to set

Sets the enabled state of mod rewrite plugin

setEnabled($bEnabled) 
Inherited

pparam bool $bEnabled
inherited_from \ModRewriteBase::setEnabled()

Parameters

$bEnabled

Function to preclean a url.

urlPreClean(string $url) : string

Removes absolute path declaration '/front_content.php' or relative path definition to actual dir './front_content.php', ampersand entities '&' and returns a url like 'front_content.php?idart=12&idlang=1'

Parameters

$url

string

Url to clean

Returns

stringCleaned Url

 Properties

 

Database instance

$_db : \DB_Contenido