abstract class vB_Friendly_Url

Base class for friendly URLs.

Constants

CLEAN_URL_REGEX

Regex to clean fragments.

UNI_IGNORE

Unicode URL options

UNI_CONVERT

UNI_STRIP

CANON_OFF

Canonical URL options

CANON_STANDARD

CANON_STRICT

Properties

protected string $id The current resource id.
protected string $title The current title of the resource.
static protected string $request_url The URL parsed from the request.
static protected string $request_uri The URI parsed from the request.
static protected bool $parsed_request Whether we have parsed the request uri.
protected string $uri The resolved uri for the friendly url.
protected string $idvar The request variable for the resource id.
protected array $pageinfo Page info.
protected string $idkey Link info index of the resource id.
protected string $titlekey Link info index of the title.
protected array $ignorelist Array of pageinfo vars to ignore when building the uri.
protected string $script The name of the script that the URL links to.
protected $script_base_option_name
protected string $rewrite_segment The rewrite segment to identify this friendly url type.
protected vB_Registry $registry Reference to the $vbulletin registry.
protected int $urloptions URL options bitfield.
protected bool $parse_post Whether to use the friendly uri in POST requests.
protected bool $always_route Whether to always set the route, even if friendly urls are off.

Methods

__construct(vB_Registry $registry, array $linkinfo = null, array $pageinfo = null, string $idkey = false, string $titlekey = false, int $urloptions = 0)

Constructor.

static vB_Friendly_Url
fetchLibrary(vB_Registry $registry, string $link, array $linkinfo = null, array $pageinfo = null, string $idkey = null, string $titlekey = null)

Factory method.

bool
is_eligible()

Checks if the friendly url is relevant for this request.

set_linkinfo(array $linkinfo)

Sets the linkinfo properties.

set_pageinfo(array $pageinfo)

Sets the pageinfo properties.

static string
clean_fragment(string $fragment, bool $canonical = false)

Cleans output to be parsed into the uri.

static string
clean_entities(string $fragment)

Replaces url entities with -

string
get_query()

Renders the pageinfo query string.

bool
skip_query_var(string $key, bool $skip_pageinfo = true)

Checks whether to ignore a pageinfo element when building the uri.

string
get_uri(bool $canonical = false)

Returns only the uri.

consume_request_uri()

Sets the uri from the current request.

consume_request_pageinfo($clean = false)

Adds pageinfo from the current request's query string.

parse_request_uri()

Parses the uri from the current request.

string
get_url(int $method_override = false, bool $canonical = false)

Render the friendly url.

redirect_canonical_url(string $request_uri)

Redirects to our url if the given uri is not canonical.

set_request(string $uri)

Set the request based on the given uri.

fix_query_string($uri)

Removes bad $_GET variables that may be set by apache when using mod_rewrite.

getScript()

No description

getRewriteSegment()

No description

static string
getMethodName(int $method)

Fetches a friendly name for a FRIENDLY_URL method.

static 
getMethodUsed()

No description

Details

at line 202
protected __construct(vB_Registry $registry, array $linkinfo = null, array $pageinfo = null, string $idkey = false, string $titlekey = false, int $urloptions = 0)

Constructor.

Note: The factory method must be used to create a vB_Friendly_Url.

Parameters

vB_Registry $registry
  • Reference to the vBulletin registry
array $linkinfo
  • Info about the link, the id, title etc
array $pageinfo
  • Additional info about the required request; pagenumber and query string
string $idkey
  • Override the key in $linkinfo for the resource id
string $titlekey
  • Override the key in $linkinfo for the resource title
int $urloptions
  • Bitfield of environment options SEO_NOSESSION, SEO_JS, etc

See also

vB_Friendly_Url::fetchLibrary

at line 257
static vB_Friendly_Url fetchLibrary(vB_Registry $registry, string $link, array $linkinfo = null, array $pageinfo = null, string $idkey = null, string $titlekey = null)

Factory method.

Parameters

vB_Registry $registry
  • Reference to the vBulletin registry
string $link
  • The type of link to create and additional link options
array $linkinfo
  • Info about the link, the id, title etc
array $pageinfo
  • Additional info about the required request; pagenumber and query string
string $idkey
  • Override the key in $linkinfo for the resource id
string $titlekey
  • Override the key in $linkinfo for the resource title

Return Value

vB_Friendly_Url
  • The apprpriate friendly url class

at line 305
protected bool is_eligible()

Checks if the friendly url is relevant for this request.

Return Value

bool

at line 316
protected set_linkinfo(array $linkinfo)

Sets the linkinfo properties.

Parameters

array $linkinfo mixed $linkinfo

at line 337
protected set_pageinfo(array $pageinfo)

Sets the pageinfo properties.

Parameters

array $pageinfo mixed $pageinfo

at line 354
static string clean_fragment(string $fragment, bool $canonical = false)

Cleans output to be parsed into the uri.

Setting $canonical is useful for creating redirect url's that cannot be encoded for redirects.

Parameters

string $fragment
bool $canonical
  • Whether to encode for output

Return Value

string

at line 407
static string clean_entities(string $fragment)

Replaces url entities with -

Parameters

string $fragment

Return Value

string

at line 423
protected string get_query()

Renders the pageinfo query string.

Vars that are included in the main uri should be defined in $ignorelist so they can be skipped.

Return Value

string

at line 460
protected bool skip_query_var(string $key, bool $skip_pageinfo = true)

Checks whether to ignore a pageinfo element when building the uri.

Parameters

string $key
  • The key of the var to check
bool $skip_pageinfo
  • Whether to skip current pageinfo

Return Value

bool
  • Whether to skip the argument

at line 479
string get_uri(bool $canonical = false)

Returns only the uri.

Setting $canonical gets the uri without encoding it for output.

Parameters

bool $canonical
  • If true, don't encode for output

Return Value

string

See also

vB_Friendly_Url::redirect_canonical_url

at line 498
protected consume_request_uri()

Sets the uri from the current request.

at line 511
protected consume_request_pageinfo($clean = false)

Adds pageinfo from the current request's query string.

Parameters

$clean

at line 552
parse_request_uri()

Parses the uri from the current request.

This method also sets FRIENDLY_URL as the detected method and applies the results to $_REQUEST and $_GET.

at line 698
string get_url(int $method_override = false, bool $canonical = false)

Render the friendly url.

Parameters

int $method_override
  • Force a Friendly URL method
bool $canonical
  • Whether to skip encoding for output

Return Value

string

at line 790
redirect_canonical_url(string $request_uri)

Redirects to our url if the given uri is not canonical.

Parameters

string $request_uri
  • The current uri to check

at line 883
protected set_request(string $uri)

Set the request based on the given uri.

Parameters

string $uri

See also

vB_Friendly_Url::decode_friendly_url() The fragment given here is already decoded and should be used as is.

at line 908
fix_query_string($uri)

Removes bad $_GET variables that may be set by apache when using mod_rewrite.

Parameters

$uri

See also

https://issues.apache.org/bugzilla/show_bug.cgi?id=34602 When using mod_rewrite, the fragment is urldecoded before the QS is appended to the rewritten url. If the fragment contains & then $_GET will be corrupted. This method checks the correct uri and resolves the correct values for $_GET.

at line 944
getScript()

at line 949
getRewriteSegment()

at line 961
static string getMethodName(int $method)

Fetches a friendly name for a FRIENDLY_URL method.

Note: This is only for debugging so the names are unphrased.

Parameters

int $method
  • The method to fetch a name for

Return Value

string
  • The friendly name

at line 982
static getMethodUsed()