kernel/classes/ezurlwildcard.php

Show: inherited
Table of Contents

File containing the eZURLWildcard class.

Copyright
Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.  
License
eZ Business Use License Agreement Version 2.0  
Package
kernel  
Version
4.6.0  

\eZURLWildcard

Package: kernel

File containing the eZURLWildcard class.

Parent(s)
\eZPersistentObject
Copyright
Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.  
License
eZ Business Use License Agreement Version 2.0  
Version
4.6.0  

Constants

Constantint  WILDCARDS_PER_CACHE_FILE = 100

Max number of wildcard entries per cache file

int
Constantint  TYPE_NONE = 0

Wildcards types

int
Constant  TYPE_FORWARD = 1
Constant  TYPE_DIRECT = 2
Constantstring  CACHE_SIGNATURE = 'urlalias-wildcard'

ExpiryHandler key

string

Properties

Propertypublic  $PersistentDataDirty= ''
Details
Type
n/a
Inherited_from
\eZPersistentObject::$$PersistentDataDirty  
Propertyprotected\array(eZClusterFileHandlerInterface)  $cacheFiles= 'array()'
static

Cluster file handler instances of cache files

Default valuearray()Details
Type
\array(eZClusterFileHandlerInterface)
Propertyprotectedarray  $wildcardsIndex= 'null'
static

Wildcards index local cache

Default valuenullDetails
Type
array

Methods

methodpublicasArray( ) : array

Converts the url wildcard object to an associative array with the attribute names as array keys and the values as array values

Returns
Type Description
array
methodpublicattribute(  $attr,  $noFunction = false ) : void
inherited

Inherited from: \eZPersistentObject::attribute()
Parameters
Name Type Description
$attr
$noFunction
methodpublicattributes( ) : void
inherited

Inherited from: \eZPersistentObject::attributes()
methodprotectedcacheInfo( ) : array
static

Returns an array with information on the wildcard cache The array containst the following keys - dir - The directory for the cache - file - The base filename for the caches - path - The entire path (including filename) for the cache - keys - Array with key values which is used to uniquely identify the cache

Returns
Type Description
array
methodprotectedcacheInfoDirectories(  $wildcardCacheDir,  $wildcardCacheFile,  $wildcardCachePath,  $wildcardKeys ) : void
static

Sets the various cache information to the parameters.

Parameters
Name Type Description
$wildcardCacheDir
$wildcardCacheFile
$wildcardCachePath
$wildcardKeys
Details
Private
 
methodpubliccleanup( string $baseURL ) : void
static

Removes a wildcard based on a source_url.

The URL should be provided without the /* prefix: foobar will remove the wildcard with source_url = foobar/*

Parameters
Name Type Description
$baseURL string

URL prefix matched against destination_url

methodpublicconditionText(  $conditions ) : void
staticinherited

Inherited from: \eZPersistentObject::conditionText()
Parameters
Name Type Description
$conditions
methodpublicconditionTextByRow(  $conditions,  $row ) : void
staticinherited

Inherited from: \eZPersistentObject::conditionTextByRow()
Parameters
Name Type Description
$conditions
$row
methodpubliccount(  $def,  $conds = null,  $field = null ) : void
staticinherited

Inherited from: \eZPersistentObject::count()
Parameters
Name Type Description
$def
$conds
$field
methodprotectedcreateWildcardsIndex( ) : void
static

Create the wildcard cache

The wildcard caches are splitted between several files: 'wildcard__index.php': contains regexps for wildcards 'wildcard__0.php', 'wildcard__1.php', ... 'wildcard__N.php': contains cached wildcards. Each file has info about eZURLWildcard::WILDCARDS_PER_CACHE_FILE wildcards.

methodpublicdefinition( ) : void
static

methodpubliceZPersistentObject(  $row ) : void
inherited

Inherited from: \eZPersistentObject::eZPersistentObject()
Parameters
Name Type Description
$row
methodpubliceZURLWildcard( array $row ) : void

Initializes a new URL alias persistent object

Parameters
Name Type Description
$row array
methodpublicescapeArray(  $array ) : void
staticinherited

Inherited from: \eZPersistentObject::escapeArray()
Parameters
Name Type Description
$array
methodpublicexpireCache( ) : void
static

Expires the wildcard cache. This causes the wildcard cache to be regenerated on the next page load.

methodprotectedexpiryTimestamp( ) : int | bool
static

Returns the expiry timestamp for wildcard cache from eZExpiryHandler

Returns
Type Description
int | bool the timestamp if set, false otherwise
methodpublicfetch( int $id, bool $asObject = true ) : \eZURLWildcard
static

Fetch a wildcard by numerical ID

Parameters
Name Type Description
$id int
$asObject bool
Returns
Type Description
\eZURLWildcard null if no match was found
methodpublicfetchBySourceURL( string $url, bool $asObject = true ) : \eZURLWildcard
static

Fetches a wildcard by source url

Parameters
Name Type Description
$url string

Source URL

$asObject bool
Returns
Type Description
\eZURLWildcard Null if no match was found
methodpublicfetchCacheFile( string $filepath ) : array
static

Includes a wildcard cache file and returns its return value This method is used as a callback by eZClusterFileHandler::processFile

Parameters
Name Type Description
$filepath string
Returns
Type Description
array
methodpublicfetchList( int $offset = false, int $limit = false, bool $asObject = true ) : \array[eZURLWildcard]
static

Fetches the list of URL wildcards. By defaults, fetches all the wildcards

Parameters
Name Type Description
$offset int

Offset to limit the list from

$limit int

Limit to the number of fetched items

$asObject bool
Returns
Type Description
\array[eZURLWildcard]
methodpublicfetchListCount( ) : int
static

Returns the number of wildcards in the database without any filtering

Returns
Type Description
int Number of wildcards in the database
methodpublicfetchObject(  $def,  $field_filters,  $conds,  $asObject = true,  $grouping = null,  $custom_fields = null ) : void
staticinherited

Inherited from: \eZPersistentObject::fetchObject()
Parameters
Name Type Description
$def
$field_filters
$conds
$asObject
$grouping
$custom_fields
methodpublicfetchObjectList(  $def,  $field_filters = null,  $conds = null,  $sorts = null,  $limit = null,  $asObject = true,  $grouping = false,  $custom_fields = null,  $custom_tables = null,  $custom_conds = null ) : void
staticinherited

Inherited from: \eZPersistentObject::fetchObjectList()
Parameters
Name Type Description
$def
$field_filters
$conds
$sorts
$limit
$asObject
$grouping
$custom_fields
$custom_tables
$custom_conds
methodpublicfill(  $row ) : void
inherited

Inherited from: \eZPersistentObject::fill()
Parameters
Name Type Description
$row
methodpublicgetShortAttributeName(  $db,  $def,  $attrName ) : void
staticinherited

Inherited from: \eZPersistentObject::getShortAttributeName()
Parameters
Name Type Description
$db
$def
$attrName
methodpublichandleRows(  $rows,  $class_name,  $asObject ) : void
staticinherited

Inherited from: \eZPersistentObject::handleRows()
Parameters
Name Type Description
$rows
$class_name
$asObject
methodpublichasAttribute(  $attr ) : void
inherited

Inherited from: \eZPersistentObject::hasAttribute()
Parameters
Name Type Description
$attr
methodpublichasDirtyData( ) : void
inherited

Inherited from: \eZPersistentObject::hasDirtyData()
methodpublicisCacheExpired( int $timestamp ) : bool
static

Checks if the wildcard cache is expired

Parameters
Name Type Description
$timestamp int

Timestamp expiry should be checked against

Returns
Type Description
bool true if cache is expired
Details
Deprecated
since 4.2.0  
methodprotectedloadCacheFile( \$cacheID $cacheID = 'index' ) : \eZClusterFileHandlerInterface
static

Loads and returns the cluster handler instance for the requested cache file.

The instance will be returned even if the file doesn't exist

Parameters
Name Type Description
$cacheID \$cacheID

Cache file number. Will load the index if not provided.

Returns
Type Description
\eZClusterFileHandlerInterface
methodprotectedmatchRegexpCode( array $wildcard ) : string
static

Transforms the source-url of a wildcard to a preg_match compatible expression Example: foo/* will be converted to #^foo/(.*)$#

Parameters
Name Type Description
$wildcard array

wildcard data with a source_url key

Returns
Type Description
string preg_match compatible string
methodprotectedmatchReplaceCode( array $wildcard ) : string
static

Converts the destination-url of a wildcard to a preg_replace compatible expression.

Example: foobar/{1} will be converted to ...

Parameters
Name Type Description
$wildcard array

Wildcard array with a destination_url key

Returns
Type Description
string match/replace PHP Code
Details
Todo
fix the example  
Todo
Try to replace the eval'd code with a preg_replace expression  
methodpublicnewObjectOrder(  $def,  $orderField,  $conditions ) : void
staticinherited

Inherited from: \eZPersistentObject::newObjectOrder()
Parameters
Name Type Description
$def
$orderField
$conditions
methodpublicremove(  $conditions = null,  $extraConditions = null ) : void
inherited

Inherited from: \eZPersistentObject::remove()
Parameters
Name Type Description
$conditions
$extraConditions
methodpublicremoveAll( ) : void
static

Removes all the wildcards

methodpublicremoveByIDs( array $idList ) : void
static

Removes wildcards based on an ID list

Parameters
Name Type Description
$idList array

array of numerical ID

methodpublicremoveObject(  $def,  $conditions = null,  $extraConditions = null ) : void
staticinherited

Inherited from: \eZPersistentObject::removeObject()
Parameters
Name Type Description
$def
$conditions
$extraConditions
methodpublicreorderObject(  $def,  $orderField,  $conditions,  $down = true ) : void
staticinherited

Inherited from: \eZPersistentObject::reorderObject()
Parameters
Name Type Description
$def
$orderField
$conditions
$down
methodpublicreplaceFieldsWithShortNames(  $db,  $fieldDefs,  $fields ) : void
staticinherited

Inherited from: \eZPersistentObject::replaceFieldsWithShortNames()
Parameters
Name Type Description
$db
$fieldDefs
$fields
methodpublicsetAttribute(  $attr,  $val ) : void
inherited

Inherited from: \eZPersistentObject::setAttribute()
Parameters
Name Type Description
$attr
$val
methodpublicsetHasDirtyData(  $hasDirtyData ) : void
inherited

Inherited from: \eZPersistentObject::setHasDirtyData()
Parameters
Name Type Description
$hasDirtyData
methodpublicstore(  $fieldFilters = null ) : void

Stores the eZURLWildcard persistent object

Parameters
Name Type Description
$fieldFilters
methodpublicstoreObject(  $obj,  $fieldFilters = null ) : void
staticinherited

Inherited from: \eZPersistentObject::storeObject()
Parameters
Name Type Description
$obj
$fieldFilters
methodpublicswapRow(  $table,  $keys,  $order_id,  $rows,  $id1,  $id2 ) : void
staticinherited

Inherited from: \eZPersistentObject::swapRow()
Parameters
Name Type Description
$table
$keys
$order_id
$rows
$id1
$id2
methodpublicsync(  $fieldFilters = null ) : void
inherited

Inherited from: \eZPersistentObject::sync()
Parameters
Name Type Description
$fieldFilters
methodpublictranslate( \eZURI | string $uri ) : mixed
static

Transforms the URI if there exists an alias for it.

Parameters
Name Type Description
$uri \eZURI | string
Returns
Type Description
mixed The translated URI if the resource has moved, or true|false if translation was (un)successful
methodprotectedtranslateWithCache( int $wildcardNum, \eZURI | string $uri, mixed $wildcardInfo,  $matchRegexp ) : bool
static

The callback loads appropriate cache file for wildcard $wildcardNum, extracts wildcard info and 'replace' url from cache.

The wildcard number (not a wildcard id) is used here in order to load the appropriate cache file.

If it's needed to fetch wildcard from db, use eZURLWildcard::fetchList with offset = $wildcardNum and $limit = 1.

Parameters
Name Type Description
$wildcardNum int
$uri \eZURI | string
$wildcardInfo mixed
$matchRegexp
Returns
Type Description
bool
Details
Todo
make private, this method isn't used anywhere else  
methodpublicupdateObjectList(  $parameters ) : void
staticinherited

Inherited from: \eZPersistentObject::updateObjectList()
Parameters
Name Type Description
$parameters
methodprotectedwildcardsIndex( ) : array
static

Assign function names to input variables. Generates the wildcard cache if expired.

Returns
Type Description
array The wildcards index, as an array of regexps
Documentation was generated by DocBlox 0.18.1.