Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Static Protected Member Functions | Static Protected Attributes | List of all members
eZURLWildcard Class Reference

Handles URL alias wildcards in eZ Publish. More...

Inheritance diagram for eZURLWildcard:

## Public Member Functions
| asArray ()
| store ( $fieldFilters=null)
Public Member Functions inherited from eZPersistentObject
| __construct ( $row=null)
| eZPersistentObject ( $row=null)
| fill ( $row)
| remove ( $conditions=null, $extraConditions=null)
| sync ( $fieldFilters=null)
| attributes ()
| hasAttribute ( $attr)
| attribute ( $attr, $noFunction=false)
| setAttribute ( $attr, $val)
| hasDirtyData ()
| setHasDirtyData ( $hasDirtyData)

## Static Public Member Functions
static | definition ()
static | cleanup ( $baseURL)
static | removeAll ()
static | removeByIDs ( $idList)
static | fetch ( $id, $asObject=true)
static | fetchBySourceURL ( $url, $asObject=true)
static | fetchList ( $offset=false, $limit=false, $asObject=true)
static | fetchListCount ()
static | translate (&$uri)
static | expireCache ()
static | fetchCacheFile ( $filepath)
static | wildcardExists ( $uriString)
Static Public Member Functions inherited from eZPersistentObject
static | replaceFieldsWithShortNames (eZDBInterface $db, array $fieldDefs, &$fields)
static | count ( $def, $conds=null, $field=null)
static | fetchObject ( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
static | removeObject ( $def, $conditions=null, $extraConditions=null)
static | storeObject ( $obj, $fieldFilters=null)
static | conditionText ( $conditions)
static | conditionTextByRow ( $conditions, $row)
static | fetchObjectList ( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
static | handleRows ( $rows, $class_name, $asObject)
static | swapRow ( $table, $keys, $order_id, $rows, $id1, $id2)
static | newObjectOrder ( $def, $orderField, $conditions)
static | reorderObject ( $def, $orderField, $conditions, $down=true)
static | escapeArray ( $array)
static | updateObjectList ( $parameters)
static | getShortAttributeName ( $db, $def, $attrName)

## Public Attributes
const | WILDCARDS_PER_CACHE_FILE = 100
const | TYPE_NONE = 0
const | TYPE_FORWARD = 1
const | TYPE_DIRECT = 2
const | CACHE_SIGNATURE = 'urlalias-wildcard'
Public Attributes inherited from eZPersistentObject
| $PersistentDataDirty
| $ID
| $ContentObjectID
| $SectionID
| $OwnerID
| $ClassID
| $Published
| $Modified
| $CurrentVersion
| $Status
| $RemoteID
| $LanguageMask
| $InitialLanguageID
| $NodeID
| $ParentNodeID
| $MainNodeID
| $ContentObjectVersion
| $ContentObjectIsPublished
| $Depth
| $SortField
| $SortOrder
| $Priority
| $ModifiedSubNode
| $PathString
| $PathIdentificationString
| $IsHidden
| $IsInvisible
| $UserID
| $Name
| $Locale
| $Identifier
| $NavigationPartIdentifier
| $SerializedDescriptionList
| $URLAliasName
| $AlwaysAvailable
| $CanTranslate
| $DataInt1
| $DataInt2
| $DataInt3
| $DataInt4
| $DataFloat1
| $DataFloat2
| $DataFloat3
| $DataFloat4
| $DataText1
| $DataText2
| $DataText3
| $DataText4
| $DataText5
| $SerializedDataText
| $Category
| $PolicyID
| $Values
| $Created
| $CurrencyCode
| $ProductCollectionID
| $ItemCount
| $Price
| $IsVATIncluded
| $VATValue
| $DiscountValue
| $Email
| $IsTemporary
| $IsArchived
| $IsActive
| $OrderID
| $ModifierID
| $Code
| $Symbol
| $AutoRateValue
| $CustomRateValue
| $RateFactor
| $Main
| $MementoKey
| $MainKey
| $WorkflowEventPos
| $LanguageID
| $ContentObjectStateGroupID
| $contentobject_attribute_id
| $contentobject_id
| $rating
| $rating_count
| $rating_average

## Static Protected Member Functions
static | cacheInfo ()
static | cacheInfoDirectories (&$wildcardCacheDir, &$wildcardCacheFile, &$wildcardCachePath, &$wildcardKeys)
static | expiryTimestamp ()
static | wildcardsIndex ()
static | createWildcardsIndex ()
static | matchRegexpCode ( $wildcard)
static | matchReplaceCode ( $wildcard)
static | translateWithCache ( $wildcardNum, &$uri, &$wildcardInfo, $matchRegexp)
static | loadCacheFile ( $cacheID='index')
Static Protected Member Functions inherited from eZPersistentObject
static | replaceFieldsWithLongNames (eZDBInterface $db, array $fieldDefs, &$fields)

## Static Protected Attributes
static | $cacheFiles = array()
static | $wildcardsIndex = null

## Detailed Description

Handles URL alias wildcards in eZ Publish.

Definition at line 18 of file ezurlwildcard.php.

## Member Function Documentation

## ◆ asArray()

eZURLWildcard::asArray | ( |  | ) |

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

Returns
  array

Definition at line 83 of file ezurlwildcard.php.

References eZPersistentObject\attribute().

## ◆ cacheInfo()

static eZURLWildcard::cacheInfo | ( |  | ) |
| static protected

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
    array

Definition at line 350 of file ezurlwildcard.php.

References eZSys\cacheDirectory().

Referenced by cacheInfoDirectories(), and loadCacheFile().

## ◆ cacheInfoDirectories()

static eZURLWildcard::cacheInfoDirectories | ( | & | $wildcardCacheDir,
|  | & | $wildcardCacheFile,
|  | & | $wildcardCachePath,
|  | & | $wildcardKeys
| ) |  |
| static protected

Sets the various cache information to the parameters.

Definition at line 378 of file ezurlwildcard.php.

References cacheInfo().

Referenced by createWildcardsIndex().

## ◆ cleanup()

static eZURLWildcard::cleanup | ( |  | $baseURL | ) |
| 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

  string | $baseURL | URL prefix matched against destination_url

Returns
  void

Definition at line 106 of file ezurlwildcard.php.

References expireCache(), and eZDB\instance().

## ◆ createWildcardsIndex()

static eZURLWildcard::createWildcardsIndex | ( |  | ) |
| static protected

Create the wildcard cache

The wildcard caches are splitted between several files: 'wildcard_<md5>index.php': contains regexps for wildcards 'wildcard<md5>0.php', 'wildcard<md5>1.php', ... 'wildcard<md5>_N.php': contains cached wildcards. Each file has info about eZURLWildcard::WILDCARDS_PER_CACHE_FILE wildcards.

Returns
  array

Definition at line 457 of file ezurlwildcard.php.

References $wildcardsIndex, cacheInfoDirectories(), eZPersistentObject\count(), fetchList(), loadCacheFile(), matchRegexpCode(), matchReplaceCode(), eZDir\mkdir(), and WILDCARDS_PER_CACHE_FILE.

Referenced by wildcardsIndex().

## ◆ definition()

static eZURLWildcard::definition | ( |  | ) |
| static

Returns the definition for the object, the default implementation is to return an empty array. It's upto each inheriting class to return a proper definition array.

The definition array is an associative array consists of these keys:

- fields: an associative array of fields which defines which database field (the key) is to fetched and how they map to object member variables (the value).
- keys: an array of fields which is used for uniquely identifying the object in the table.
- function_attributes: an associative array of attributes which maps to member functions, used for fetching data with functions.
- set_functions: an associative array of attributes which maps to member functions, used for setting data with functions.
- increment_key: the field which is incremented on table inserts.
- class_name: the classname which is used for instantiating new objecs when fetching from the database.
- sort: an associative array which defines the default sorting of lists, the key is the table field while the value is the sorting method which is either 'asc' or 'desc'.
- name: the name of the database table

Example: `public static function definition() { return array( "fields" => array( "id" => "ID", "version" => "Version", "name" => "Name" ), "keys" => array( "id", "version" ), "function_attributes" => array( "current" => "currentVersion", "class_name" => "className" ), "increment_key" => "id", "class_name" => "eZContentClass", "sort" => array( "id" => "asc" ), "name" => "ezcontentclass" ); }`

Returns
  array

Reimplemented from eZPersistentObject.

Definition at line 52 of file ezurlwildcard.php.

## ◆ expireCache()

static eZURLWildcard::expireCache | ( |  | ) |
| static

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

Returns
  void

Definition at line 392 of file ezurlwildcard.php.

Referenced by cleanup(), and removeAll().

## ◆ expiryTimestamp()

static eZURLWildcard::expiryTimestamp | ( |  | ) |
| static protected

Returns the expiry timestamp for wildcard cache from eZExpiryHandler

Returns
  int|bool the timestamp if set, false otherwise

Definition at line 405 of file ezurlwildcard.php.

## ◆ fetch()

static eZURLWildcard::fetch | ( |  | $id,
|  |  | $asObject = `true`
| ) |  |
| static

Fetch a wildcard by numerical ID

Parameters

  int | $id |
  bool | $asObject |

Returns
  eZURLWildcard null if no match was found

Definition at line 154 of file ezurlwildcard.php.

References eZPersistentObject\fetchObject().

## ◆ fetchBySourceURL()

static eZURLWildcard::fetchBySourceURL | ( |  | $url,
|  |  | $asObject = `true`
| ) |  |
| static

Fetches a wildcard by source url

Parameters

  string | $url | Source URL
  bool | $asObject |

Returns
  eZURLWildcard Null if no match was found

Definition at line 168 of file ezurlwildcard.php.

References eZPersistentObject\fetchObject().

## ◆ fetchCacheFile()

static eZURLWildcard::fetchCacheFile | ( |  | $filepath | ) |
| static

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

Parameters

  string | $filepath |

Returns
  array

Definition at line 642 of file ezurlwildcard.php.

## ◆ fetchList()

static eZURLWildcard::fetchList | ( |  | $offset = `false`,
|  |  | $limit = `false`,
|  |  | $asObject = `true`
| ) |  |
| static

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

Parameters

  int | $offset | Offset to limit the list from
  int | $limit | Limit to the number of fetched items
  bool | $asObject |

Returns
  array[eZURLWildcard]

Definition at line 183 of file ezurlwildcard.php.

References eZPersistentObject\fetchObjectList().

Referenced by createWildcardsIndex().

## ◆ fetchListCount()

static eZURLWildcard::fetchListCount | ( |  | ) |
| static

Returns the number of wildcards in the database without any filtering

Returns
  int Number of wildcards in the database

Definition at line 197 of file ezurlwildcard.php.

References eZPersistentObject\fetchObjectList().

## ◆ loadCacheFile()

static eZURLWildcard::loadCacheFile | ( |  | $cacheID = `'index'` | ) |
| static protected

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

  $cacheID | Cache file number. Will load the index if not provided.

Returns
  eZClusterFileHandlerInterface

Definition at line 620 of file ezurlwildcard.php.

References cacheInfo(), and eZClusterFileHandler\instance().

Referenced by createWildcardsIndex(), translateWithCache(), and wildcardsIndex().

## ◆ matchRegexpCode()

static eZURLWildcard::matchRegexpCode | ( |  | $wildcard | ) |
| static protected

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

Parameters

  array | $wildcard | wildcard data with a source_url key

Returns
  string preg_match compatible string

Definition at line 513 of file ezurlwildcard.php.

Referenced by createWildcardsIndex().

## ◆ matchReplaceCode()

static eZURLWildcard::matchReplaceCode | ( |  | $wildcard | ) |
| static protected

Converts the destination-url of a wildcard to a preg_replace compatible expression. Example: foobar/{1} will be converted to ...

Todo:
  fix the example

Parameters

  array | $wildcard | Wildcard array with a destination_url key

Returns
  string match/replace PHP Code

Todo:
  Try to replace the eval'd code with a preg_replace expression

Definition at line 539 of file ezurlwildcard.php.

Referenced by createWildcardsIndex().

## ◆ removeAll()

static eZURLWildcard::removeAll | ( |  | ) |
| static

Removes all the wildcards

Returns
  void

Definition at line 120 of file ezurlwildcard.php.

References expireCache(), and eZPersistentObject\removeObject().

## ◆ removeByIDs()

static eZURLWildcard::removeByIDs | ( |  | $idList | ) |
| static

Removes wildcards based on an ID list

Parameters

  array | $idList | array of numerical ID

Returns
  void

Definition at line 131 of file ezurlwildcard.php.

References eZPersistentObject\count(), and eZPersistentObject\removeObject().

## ◆ store()

eZURLWildcard::store | ( |  | $fieldFilters = `null` | ) |

Stores the eZURLWildcard persistent object

Reimplemented from eZPersistentObject.

Definition at line 94 of file ezurlwildcard.php.

References eZPersistentObject\store().

## ◆ translate()

static eZURLWildcard::translate | ( | & | $uri | ) |
| static

Transforms the URI if there exists an alias for it.

Parameters

  eZURI | string | $uri |

Returns
  mixed The translated URI if the resource has moved, or true|false if translation was (un)successful

Definition at line 217 of file ezurlwildcard.php.

References eZURLAliasML\cleanURL(), eZURLAliasML\translate(), translateWithCache(), TYPE_DIRECT, TYPE_FORWARD, eZDebugSetting\writeDebug(), and eZDebug\writeError().

## ◆ translateWithCache()

static eZURLWildcard::translateWithCache | ( |  | $wildcardNum,
|  | & | $uri,
|  | & | $wildcardInfo,
|  |  | $matchRegexp
| ) |  |
| static protected

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

  int | $wildcardNum |
  eZURI | string | $uri |
  mixed | $wildcardInfo |
  mixed | $matches |

Returns
  bool

Todo:
  make private, this method isn't used anywhere else

Definition at line 585 of file ezurlwildcard.php.

References loadCacheFile(), eZDebugSetting\writeDebug(), and eZDebug\writeError().

Referenced by translate().

## ◆ wildcardExists()

static eZURLWildcard::wildcardExists | ( |  | $uriString | ) |
| static

Checks if $uriString exists as a wildcard

Parameters

  string | $uriString |

Returns
  boolean

Examples
  /web/vh/ezpublish.se7enx.com/doc/api.exponential.earth/src/exponential/kernel/classes/ezurlaliasml.php.

Definition at line 653 of file ezurlwildcard.php.

References wildcardsIndex().

Referenced by eZURLAliasML\translate().

## ◆ wildcardsIndex()

static eZURLWildcard::wildcardsIndex | ( |  | ) |
| static protected

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

Returns
  array The wildcards index, as an array of regexps

Definition at line 425 of file ezurlwildcard.php.

References $wildcardsIndex, createWildcardsIndex(), and loadCacheFile().

Referenced by wildcardExists().

## Member Data Documentation

## ◆ $cacheFiles

eZURLWildcard::$cacheFiles = array()
| static protected

Definition at line 44 of file ezurlwildcard.php.

## ◆ $wildcardsIndex

eZURLWildcard::$wildcardsIndex = null
| static protected

Definition at line 50 of file ezurlwildcard.php.

Referenced by createWildcardsIndex(), and wildcardsIndex().

## ◆ CACHE_SIGNATURE

const eZURLWildcard::CACHE_SIGNATURE = 'urlalias-wildcard'

Definition at line 38 of file ezurlwildcard.php.

## ◆ TYPE_DIRECT

const eZURLWildcard::TYPE_DIRECT = 2

Definition at line 32 of file ezurlwildcard.php.

Referenced by translate().

## ◆ TYPE_FORWARD

const eZURLWildcard::TYPE_FORWARD = 1

Definition at line 31 of file ezurlwildcard.php.

Referenced by translate().

## ◆ TYPE_NONE

const eZURLWildcard::TYPE_NONE = 0

Definition at line 30 of file ezurlwildcard.php.

## ◆ WILDCARDS_PER_CACHE_FILE

const eZURLWildcard::WILDCARDS_PER_CACHE_FILE = 100

Definition at line 24 of file ezurlwildcard.php.

Referenced by createWildcardsIndex().

The documentation for this class was generated from the following file:

- ezurlwildcard.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.