class vB_Friendly_Url_GenerationOnly extends vB_Friendly_Url

Base class for Url classes that are intended to generate urls only

This is a bit of a hack, but the avantages outweigh the disadvantages The idea is to centralize some url generation that has gotten more complex with the ability to move some portions of the app into subdirectories.

We need some way of capturing the generation logic in a central location and rather than create another one, it seemed like a good fit to make it part of the friendly urls generation. 1) To avoid having yet another similar system, 2) This will automatically allow access to the feature in templates, 3) If we decide we need to make fully SEO friendly urls out of these links we are partway there already. 4) Prevents somebody from accidentally leaving out portions of the logic on a link -- for example forgetting the forum_url path logic on a forum link or the forumhome script option on the forumhome link.

It may be confusing having these be special -- they do not generate anything but basic urls and the pages (and the rewrite scripts) are not set up to handle them if they did generate those urls (though in the cases where there aren't any page parameters only the rewrite url is appreciably different). If somebody attempts to allow generation of the other url types without upgrading the entry pages to friendly url status stuff will break.

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

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

in vB_Friendly_Url 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

in vB_Friendly_Url 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

in vB_Friendly_Url at line 305
protected bool is_eligible()

Checks if the friendly url is relevant for this request.

Return Value

bool

in vB_Friendly_Url at line 316
protected set_linkinfo(array $linkinfo)

Sets the linkinfo properties.

Parameters

array $linkinfo mixed $linkinfo

in vB_Friendly_Url at line 337
protected set_pageinfo(array $pageinfo)

Sets the pageinfo properties.

Parameters

array $pageinfo mixed $pageinfo

in vB_Friendly_Url 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

in vB_Friendly_Url at line 407
static string clean_entities(string $fragment)

Replaces url entities with -

Parameters

string $fragment

Return Value

string

in vB_Friendly_Url 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

in vB_Friendly_Url 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

in vB_Friendly_Url 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 1432
consume_request_uri()

Sets the uri from the current request.

in vB_Friendly_Url at line 511
protected consume_request_pageinfo($clean = false)

Adds pageinfo from the current request's query string.

Parameters

$clean

in vB_Friendly_Url 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 1398
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 1403
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

in vB_Friendly_Url 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.

in vB_Friendly_Url 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.

in vB_Friendly_Url at line 944
getScript()

in vB_Friendly_Url at line 949
getRewriteSegment()

in vB_Friendly_Url 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

in vB_Friendly_Url at line 982
static getMethodUsed()