class vB5_Route

Traits

Constants

DEFAULT_CLASS

PREFIX_MAXSIZE

REGEX_MAXSIZE

Properties

protected $routeId
protected $routeGuid
protected $redirect301 Current route Id for current for request
protected string $prefix Prefix for the route. Always encoded in UTF-8.
protected $rawprefix
protected string $regex Regular expression to be matched by URL. Always encoded in UTF-8.
protected $ishomeroute
protected string $controller (Optional) Stores controller to be called
protected string $action (Optional) Stores action to be invoked in controller
protected string $template (Optional) Stores template id to be loaded
protected array $arguments Contains parameters stored in db and extracted from URL
protected array $matches Contains the matches passed to the class
protected array $queryParameters Contains query string parameters
protected string $anchor Contains anchor id
protected string $pageKey Contains the page key for preloading cache
protected mixed $userAction Stores user action associated to the route.
protected vB5_Route $canonicalRoute
protected array $breadcrumbs Contains the breadcrumbs for header
$headlinks Contains the links for header
static protected $routeidentcache

Methods

__sleep()

No description

__wakeup()

No description

__construct($routeInfo, $matches, $queryString = '', $anchor = '')

No description

initRoute($routeInfo, $matches, $queryString = '', $anchor = '')

No description

getRouteId()

No description

getRouteGuid()

No description

getRedirect301()

No description

getPrefix()

No description

getRawPrefix()

No description

getIsHomeRoute()

No description

getController()

No description

getAction()

No description

getTemplate()

No description

getArguments()

No description

getQueryParameters()

No description

getAnchor()

No description

setPageKey()

No description

getPageKey()

No description

setUserAction()

No description

mixed
getUserAction()

Returns the user action associated with the route

setBreadcrumbs()

Sets the breadcrumbs for the route

addParentNodeBreadcrumbs(int $nodeId, bool $onlyAddTopParent = false)

Adds breadcrumb entries for all the parents of the passed node id.

checkRoutePermissions()

Checks to see if a user can access the page represented by this route. Will throw a vB_Exception_NodePermission if the user is not allowed to view the page. Does nothing otherwise. This is intended to get the permission checks out of the route constructors so that we don't get random exceptions while trying to create urls.

array
getBreadcrumbs()

Returns breadcrumbs to be displayed in page header

mixed
getUrl()

Get the url of this route. To be overriden by child classes.

getFullUrl($options = "")

No description

getCanonicalRoute()

Returns the route referenced by the associated item

getCanonicalPrefix()

No description

getCanonicalUrl()

Returns the canonical url which may be based on a different route

getCanonicalQueryParameters()

Returns false if query parameters do not determine canonicality otherwise return query parameters

static 
prepareTitle($title)

No description

static 
prepareUrlIdent($ident)

No description

static bool
validInput(array $data)

Checks if route info is valid and performs any required sanitation

static boolean
isPrefixUsed(string $prefix)

Checks if the prefix is already in use.

static int
saveRoute($data, $condition = array())

Stores route in db and returns its id

static 
createRoute($class, $data)

No description

static int
updateRoute($routeId, $data, $cloneRoute = false)

Update the route.

static 
updateRedirects($db, $oldrouteid, $newrouteid)

No description

static 
deleteRouteInternal($db, $routeid)

No description

static 
deleteRoute($routeid)

Deletes the route

static 
updateSecondaryHomepageRoutes($oldRouteInfo, $new_data)

No description

static 
removeHomepageRoute(array $routeInfo)

Do any extra processing required if this route is changed from a homepage route to a regular route.

static array
getPrefixSet(string $url)

Generates an array with all prefixes for $url

static null|vB5_Route
selectBestRoute($pathInfo, $queryString = '', $anchor = '', $matchedRoutes = array())

Returns the route that best fits the pathInfo in $matchedRoutes

static 
compareRoutes($route1, $route2)

No description

static 
getRouteByIdent($routeident)

No description

static array|bool
getChannelConversationRouteInfo(int $channelId)

Returns the route info for the generic conversation route for the given channel

static 
preloadRoutes($routeIds)

No description

static 
loadNameRoutes()

Loads list of named routes, which changes rarely

static 
getClassName($routeId, $routeInfo = array())

No description

static 
getRoute($routeId, $data = array(), $extra = array(), $anchor = '')

No description

static string
buildUrl(string $options, array $data = array(), array $extra = array(), string $anchor = '')

Returns the URL associated to the route info. It does not use canonical route.

static string[]
buildUrls(array $URLInfoList)

get the urls in one batch

static string[]
bulkFetchUrls(string $className, array $URLInfoList)

Build URLs using a single instance for the class. It does not check permissions. Used by buildUrls()

static array
exportArguments(string $arguments)

Returns arguments to be exported

static string
importArguments(string $arguments)

Returns an array with imported values for the route

static int
importContentId(string $arguments)

Returns the content id from the imported values of the route after being parsed

getHash($route, array $data, array $extra)

No description

static 
getHashKey($options = array(), $data = array(), $extra = array())

No description

getRouteSegments()

No description

getHeadLinks()

No description

setHeadLinks()

No description

static array
fetchCommonRoutes()

Returns a list of common routes. We check these to see if we can avoid the far most expensive selectBestRoute call

static 
resetRouteIdentCache()

Resets the route ident cache. This is only intended to be used externally for unit tests, where mulitple tests run during the same request, causing invalid routes (from a previous test to be in $routeidentcache. This doesn't happen on a normal page request, because $routeidentcache is in memory only for the duration of the request. VBV-12736

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 115
protected __construct($routeInfo, $matches, $queryString = '', $anchor = '')

Parameters

$routeInfo
$matches
$queryString
$anchor

at line 120
protected initRoute($routeInfo, $matches, $queryString = '', $anchor = '')

Parameters

$routeInfo
$matches
$queryString
$anchor

at line 218
getRouteId()

at line 223
getRouteGuid()

at line 228
getRedirect301()

at line 233
getPrefix()

at line 238
getRawPrefix()

at line 243
getIsHomeRoute()

at line 248
getController()

at line 253
getAction()

at line 258
getTemplate()

at line 263
getArguments()

at line 268
getQueryParameters()

at line 273
getAnchor()

at line 278
protected setPageKey()

at line 297
getPageKey()

at line 302
protected setUserAction()

at line 323
mixed getUserAction()

Returns the user action associated with the route

Return Value

mixed

at line 331
protected setBreadcrumbs()

Sets the breadcrumbs for the route

at line 348
protected addParentNodeBreadcrumbs(int $nodeId, bool $onlyAddTopParent = false)

Adds breadcrumb entries for all the parents of the passed node id.

This is inclusive of the passed node id, but excludes "home". Modifies $this->breadcrumbs

Parameters

int $nodeId Node ID
bool $onlyAddTopParent If true, only add the top-most parent after home, and ignore the rest.

at line 401
protected checkRoutePermissions()

Checks to see if a user can access the page represented by this route. Will throw a vB_Exception_NodePermission if the user is not allowed to view the page. Does nothing otherwise. This is intended to get the permission checks out of the route constructors so that we don't get random exceptions while trying to create urls.

at line 410
array getBreadcrumbs()

Returns breadcrumbs to be displayed in page header

Return Value

array

at line 423
mixed getUrl()

Get the url of this route. To be overriden by child classes.

This should always return the path encoded in UTF-8. If vB_String::getCharset() is not utf-8, the url should be percent encoded using vB_String::encodeUtf8Url().

Return Value

mixed false|string

at line 440
getFullUrl($options = "")

Parameters

$options

at line 499
vB5_Route getCanonicalRoute()

Returns the route referenced by the associated item

Return Value

vB5_Route

at line 505
getCanonicalPrefix()

at line 520
getCanonicalUrl()

Returns the canonical url which may be based on a different route

at line 550
getCanonicalQueryParameters()

Returns false if query parameters do not determine canonicality otherwise return query parameters

at line 555
static protected prepareTitle($title)

Parameters

$title

at line 561
static protected prepareUrlIdent($ident)

Parameters

$ident

at line 577
static protected bool validInput(array $data)

Checks if route info is valid and performs any required sanitation

Parameters

array $data

Return Value

bool Returns TRUE iff data is valid

at line 640
static boolean isPrefixUsed(string $prefix)

Checks if the prefix is already in use.

Note that redirect routes are not considered "in use" since they are will be overwritten as needed by new/edited pages.

Parameters

string $prefix
  • Prefix to be validated

Return Value

boolean

at line 659
static protected int saveRoute($data, $condition = array())

Stores route in db and returns its id

Parameters

$data
$condition

Return Value

int

at line 683
static createRoute($class, $data)

Parameters

$class
$data

at line 727
static int updateRoute($routeId, $data, $cloneRoute = false)

Update the route.

If the url has changed this may result in a new route being created and the old route being turned into a 301 redirect.

Parameters

$routeId
$data
$cloneRoute

Return Value

int -- the ID of the route created/updated.

at line 916
static protected updateRedirects($db, $oldrouteid, $newrouteid)

Parameters

$db
$oldrouteid
$newrouteid

at line 943
static protected deleteRouteInternal($db, $routeid)

Parameters

$db
$routeid

at line 969
static deleteRoute($routeid)

Deletes the route

This will also delete any redirects to the route being deleted (which don't have much purpose without the route)

It will also clear the cache for the routes deleted.

Parameters

$routeid

at line 995
static protected updateSecondaryHomepageRoutes($oldRouteInfo, $new_data)

Parameters

$oldRouteInfo
$new_data

at line 1009
static protected removeHomepageRoute(array $routeInfo)

Do any extra processing required if this route is changed from a homepage route to a regular route.

The flag will be changed automatically by the core function. This is for any class specific logic.

Parameters

array $routeInfo -- the route being changed.

at line 1020
static array getPrefixSet(string $url)

Generates an array with all prefixes for $url

Parameters

string $url

Return Value

array

at line 1050
static null|vB5_Route selectBestRoute($pathInfo, $queryString = '', $anchor = '', $matchedRoutes = array())

Returns the route that best fits the pathInfo in $matchedRoutes

Parameters

$pathInfo
$queryString
$anchor
$matchedRoutes

Return Value

null|vB5_Route +

at line 1163
static protected compareRoutes($route1, $route2)

Parameters

$route1
$route2

at line 1168
static getRouteByIdent($routeident)

Parameters

$routeident

at line 1211
static array|bool getChannelConversationRouteInfo(int $channelId)

Returns the route info for the generic conversation route for the given channel

Parameters

int $channelId Channel node ID

Return Value

array|bool The route info or false on error.

at line 1260
static preloadRoutes($routeIds)

Parameters

$routeIds

at line 1287
static protected loadNameRoutes()

Loads list of named routes, which changes rarely

at line 1314
static protected getClassName($routeId, $routeInfo = array())

Parameters

$routeId
$routeInfo

at line 1328
static getRoute($routeId, $data = array(), $extra = array(), $anchor = '')

Parameters

$routeId
$data
$extra
$anchor

at line 1375
static string buildUrl(string $options, array $data = array(), array $extra = array(), string $anchor = '')

Returns the URL associated to the route info. It does not use canonical route.

Parameters

string $options A string of routeid & options delimited by | beginning with routeid which can be an (int) routeid or a (string) route class identifier (ex. 'node', 'visitormessage'). Must begin with routeid, but the order of the subsequent options do not matter Accepted option string (TODO:complete this list): nosession: DEPRECATED - DO NOT USE fullurl, bburl: Prepends the frontendurl to the relative url Ex. '51|fullurl' 'node' 'visitormessage|bburl'
array $data An array of "matches" that the route constructor and initRoute() can use to generate the route. Usually the "matches" data is translated to the route arguments by initRoute(), or query parameters or anchors. Typically you will want to pass in all the required arguments for the route fetching/generation (ex. 'nodeid' for a conversation route or 'userid' for a profile route, 'contentpagenum' and 'pagenum' for an article route) and additional data that's only provided internally to for URL generation (ex. 'innerPost' for a conversation to add an anchor) See the specific route's constructor & initRoute() functions for more details about what parameters are used. Ex. array('nodeid' => 42, 'innerPost' => '99')
array $extra An array of query data. Will be translated into a query string. Ex. array('foo' => 'bar', 'life' => '42') will append ?foo=bar&life=42 to the url
string $anchor A string specifying the anchor tag without the hash symbol '#' Ex. 'post42' will append become #post42 to the url

Return Value

string The URL. Will return '#' if URL generation fails (typically occurs when a route identifier is provided in $options but is an invalid identifier, e.g. (int) routeid does not exist in routenew table or (string) routeid isn't a valid route class name)

Exceptions

Exception("error_no_routeid") if routeid was unable to be retrived from $options

at line 1424
static string[] buildUrls(array $URLInfoList)

get the urls in one batch

Parameters

array $URLInfoList Array of data required for URL generation. Each key should uniquely identify each requested URL, and these keys will be used by the output array. Each element is an array with the following data: - route - data - extra - options - options.anchor

Return Value

string[] URLs built based on the input. Keys are a subset of the keys of the input array $URLInfoList.

at line 1534
static protected string[] bulkFetchUrls(string $className, array $URLInfoList)

Build URLs using a single instance for the class. It does not check permissions. Used by buildUrls()

Parameters

string $className Route class of this bulk of URLs
array $URLInfoList Array of data required for URL generation. Each key should uniquely identify each requested URL, and these keys will be used by the output array. Each element is an array with the following data: - route - routeInfo - data - extra - anchor - innerHash @TODO: Expand above with more detail.

Return Value

string[] String array of URLs. The keys will be the same as those provided in input $URLInfoList. URL may be an empty string if route/url construction failed with an exception.

at line 1574
static array exportArguments(string $arguments)

Returns arguments to be exported

Parameters

string $arguments

Return Value

array

at line 1584
static string importArguments(string $arguments)

Returns an array with imported values for the route

Parameters

string $arguments

Return Value

string

at line 1594
static int importContentId(string $arguments)

Returns the content id from the imported values of the route after being parsed

Parameters

string $arguments

Return Value

int

at line 1599
getHash($route, array $data, array $extra)

Parameters

$route
array $data
array $extra

at line 1614
static protected getHashKey($options = array(), $data = array(), $extra = array())

Parameters

$options
$data
$extra

at line 1640
getRouteSegments()

at line 1674
static array fetchCommonRoutes()

Returns a list of common routes. We check these to see if we can avoid the far most expensive selectBestRoute call

Return Value

array of string => string map of url to route class.

at line 1711
static resetRouteIdentCache()

Resets the route ident cache. This is only intended to be used externally for unit tests, where mulitple tests run during the same request, causing invalid routes (from a previous test to be in $routeidentcache. This doesn't happen on a normal page request, because $routeidentcache is in memory only for the duration of the request. VBV-12736

We use it internally to clear the cache when it changes