/sources/urls.php

Description
Functions
build_keep_form_fields (line 580)

Get hidden fields for a form representing 'keep_x'. If we are having a GET form instead of a POST form, we need to do this. This function also encodes the page name, as we'll always want that.

  • return: The builtup hidden form fields
tempcode build_keep_form_fields ([ID_TEXT $page = ''], [boolean $keep_all = false], [?array $exclude = NULL])
  • ID_TEXT $page: The page for the form to go to (blank: don't attach)
  • boolean $keep_all: Whether to keep all elements of the current URL represented in this form (rather than just the keep_ fields, and page)
  • ?array $exclude: A list of parameters to exclude (NULL: don't exclude any)
build_keep_post_fields (line 592)

Relay all POST variables for this URL, to the URL embedded in the form.

  • return: The builtup hidden form fields
tempcode build_keep_post_fields ([?array $exclude = NULL])
  • ?array $exclude: A list of parameters to exclude (NULL: exclude none)
build_url (line 285)

Build and return a proper URL, from the $vars array.

Note: URL parameters should always be in lower case (one of the coding standards)

  • return: The URL in tempcode format.
tempcode build_url (array $vars, [ID_TEXT $zone_name = ''], [?array $skip = NULL], [boolean $keep_all = false], [boolean $avoid_remap = false], [boolean $skip_keep = false], [string $hash = ''])
  • array $vars: A map of parameter names to parameter values. E.g. array('page'=>'example','type'=>'foo','id'=>2). Values may be strings or integers, or NULL. NULL indicates "skip this". 'page' cannot be NULL.
  • ID_TEXT $zone_name: The zone the URL is pointing to. YOU SHOULD NEVER HARD CODE THIS- USE '_SEARCH', '_SELF' (if you're self-referencing your own page) or the output of get_module_zone.
  • ?array $skip: Variables to explicitly not put in the URL (perhaps because we have $keep_all set, or we are blocking certain keep_ values). The format is of a map where the keys are the names, and the values are 1. (NULL: don't skip any)
  • boolean $keep_all: Whether to keep all non-skipped parameters that were in the current URL, in this URL
  • boolean $avoid_remap: Whether to avoid mod_rewrite (sometimes essential so we can assume the standard URL parameter addition scheme in templates)
  • boolean $skip_keep: Whether to skip actually putting on keep_ parameters (rarely will this skipping be desirable)
  • string $hash: Hash portion of the URL (blank: none). May or may not start '#' - code will put it on if needed
can_try_mod_rewrite (line 267)

Find if mod_rewrite is in use

  • return: Whether mod_rewrite is in use
boolean can_try_mod_rewrite ([boolean $avoid_remap = false])
  • boolean $avoid_remap: Whether to explicitly avoid using mod_rewrite. Whilst it might seem weird to put this in as a function parameter, it removes duplicated logic checks in the code.
convert_url_to_path (line 729)

Convert a URL to a local file path.

  • return: File path (NULL: is not local)
?PATH convert_url_to_path (URLPATH $url)
  • URLPATH $url: The value to convert
find_id_moniker (line 809)

Find the textual moniker for a typical ocPortal URL path. This will be called from inside build_url, based on details learned from a moniker hook (only if a hook exists to hint how to make the requested link SEO friendly).

  • return: The moniker ID (NULL: could not find)
?string find_id_moniker (array $url_parts)
  • array $url_parts: The URL component map (must contain 'page', 'type', and 'id' if this function is to do anything).
fixup_protocolless_urls (line 741)

Sometimes users don't enter full URLs but do intend for them to be absolute. This code tries to see what relative URLs are actually absolute ones, via an algorithm. It then fixes the URL.

  • return: The fixed URL (or original one if no fix was needed)
URLPATH fixup_protocolless_urls (URLPATH $in)
  • URLPATH $in: The URL to fix
get_self_url (line 85)

Get a well formed URL equivalent to the current URL.

  • return: The URL (tempcode or string)
mixed get_self_url ([boolean $evaluate = false], [boolean $root_if_posted = false], [?array $extra_params = NULL], [boolean $posted_too = false], [boolean $avoid_remap = false])
  • boolean $evaluate: Whether to evaluate the URL (so as we don't return tempcode)
  • boolean $root_if_posted: Whether to direct to the default page if there was a POST request leading to where we are now (i.e. to avoid missing post fields when we go to this URL)
  • ?array $extra_params: A map of extra parameters for the URL (NULL: none)
  • boolean $posted_too: Whether to also keep POSTed data, in the GET request (useful if either_param is used to get the data instead of post_param - of course the POST data must be of the not--persistant-state-changing variety)
  • boolean $avoid_remap: Whether to avoid mod_rewrite (sometimes essential so we can assume the standard URL parameter addition scheme in templates)
get_self_url_easy (line 53)

Get a well formed URL equivalent to the current URL. Reads direct from the environment and does no clever mapping at all. This function should rarely be used.

  • return: The URL
URLPATH get_self_url_easy ()
init__urls (line 24)

Standard code module initialisation function.

void init__urls ()
is_page_https (line 237)

Find whether the specified page is to use HTTPS (if not -- it will use HTTP).

All images (etc) on a HTTPS page should use HTTPS to avoid mixed-content browser notices.

  • return: Whether the page is to run across an HTTPS connection
boolean is_page_https (ID_TEXT $zone, ID_TEXT $page)
  • ID_TEXT $zone: The zone the page is in
  • ID_TEXT $page: The page codename
load_moniker_hooks (line 776)

Load up hooks needed to detect how to use monikers.

void load_moniker_hooks ()
looks_like_url (line 564)

Find if a value appears to be some kind of URL (possibly an ocPortalised Comcode one).

  • return: Whether the value appears to be a URL
boolean looks_like_url (string $value, [boolean $lax = false])
  • string $value: The value to check
  • boolean $lax: Whether to be a bit lax in the check
ocp_url_decode_post_process (line 180)

Decode a URL component that was encoded with hackerish_url_encode

  • return: The encoded result
URLPATH ocp_url_decode_post_process (URLPATH $url_part)
  • URLPATH $url_part: The URL to encode
ocp_url_encode (line 146)

Encode a URL component in such a way that it won't get nuked by Apache %2F blocking security and url encoded '&' screwing. The get_param function will map it back. Hackerish but necessary.

  • return: The encoded result
URLPATH ocp_url_encode (URLPATH $url_part, [?boolean $consider_rewrite = NULL])
  • URLPATH $url_part: The URL to encode
  • ?boolean $consider_rewrite: Whether we have to consider mod_rewrite (NULL: don't know, look up)
ocp_url_encode_mini (line 169)

Encode a URL component, as per ocp_url_encode but without slashes being encoded.

  • return: The encoded result
URLPATH ocp_url_encode_mini (URLPATH $url_part, [?boolean $consider_rewrite = NULL])
  • URLPATH $url_part: The URL to encode
  • ?boolean $consider_rewrite: Whether we have to consider mod_rewrite (NULL: don't know, look up)
page_link_decode (line 629)

Take a page link and convert to attributes and zone.

  • return: Triple: zone, attribute-array, hash part of a URL including the hash (or blank)
array page_link_decode (SHORT_TEXT $param)
  • SHORT_TEXT $param: The page link
page_path_to_pagelink (line 767)

Convert a local page file path to a written page-link.

  • return: The page link (blank: could not convert).
string page_path_to_pagelink (string $page)
  • string $page: The path.
qualify_url (line 617)

Take a URL and base-URL, and fully qualify the URL according to it.

  • return: Fully qualified URL
URLPATH qualify_url (URLPATH $url, URLPATH $url_base)
  • URLPATH $url: The URL to fully qualified
  • URLPATH $url_base: The base-URL
remove_url_mistakes (line 198)

Map spaces to %20 and put http:// in front of URLs starting www.

  • return: The fixed result
URLPATH remove_url_mistakes (URLPATH $url)
  • URLPATH $url: The URL to fix
skippable_keep (line 214)

Find whether we can skip the normal preservation of a keep value, for whatever reason.

  • return: Whether we can skip it
boolean skippable_keep (string $key, string $val)
  • string $key: Parameter name
  • string $val: Parameter value
url_is_local (line 552)

Find if the specified URL is local or not (actually, if it is relative). This is often used by code that wishes to use file system functions on URLs (ocPortal will store such relative local URLs for uploads, etc)

  • return: Whether the URL is local
boolean url_is_local (URLPATH $url)
  • URLPATH $url: The URL to check
url_monikers_enabled (line 334)

Find whether URL monikers are enabled.

  • return: Whether URL monikers are enabled.
boolean url_monikers_enabled ()
url_to_filename (line 604)

Takes a URL, and converts it into a file system storable filename. This is used to cache URL contents to the servers filesystem.

  • return: A usable filename based on the URL
string url_to_filename (URLPATH $url_full)
  • URLPATH $url_full: The URL to convert to an encoded filename
url_to_pagelink (line 755)

Convert a local URL to a page-link.

  • return: The page link (blank: could not convert).
string url_to_pagelink (URLPATH $url, [boolean $abs_only = false], [boolean $perfect_only = true])
  • URLPATH $url: The URL to convert. Note it may not be a short URL, and it must be based on the local base URL (else failure WILL occur).
  • boolean $abs_only: Whether to only convert absolute URLs. Turn this on if you're not sure what you're passing is a URL not and you want to be extra safe.
  • boolean $perfect_only: Whether to only allow perfect conversions.
_build_url (line 354)

Build and return a proper URL, from the $vars array.

Note: URL parameters should always be in lower case (one of the coding standards)

  • return: The URL in string format.
string _build_url (array $vars, [ID_TEXT $zone_name = ''], [?array $skip = NULL], [boolean $keep_all = false], [boolean $avoid_remap = false], [boolean $skip_keep = false], [string $hash = ''])
  • array $vars: A map of parameter names to parameter values. Values may be strings or integers, or NULL. NULL indicates "skip this". 'page' cannot be NULL.
  • ID_TEXT $zone_name: The zone the URL is pointing to. YOU SHOULD NEVER HARD CODE THIS- USE '_SEARCH', '_SELF' (if you're self-referencing your own page) or the output of get_module_zone.
  • ?array $skip: Variables to explicitly not put in the URL (perhaps because we have $keep_all set, or we are blocking certain keep_ values). The format is of a map where the keys are the names, and the values are 1. (NULL: don't skip any)
  • boolean $keep_all: Whether to keep all non-skipped parameters that were in the current URL, in this URL
  • boolean $avoid_remap: Whether to avoid mod_rewrite (sometimes essential so we can assume the standard URL parameter addition scheme in templates)
  • boolean $skip_keep: Whether to skip actually putting on keep_ parameters (rarely will this skipping be desirable)
  • string $hash: Hash portion of the URL (blank: none).
_url_rewrite_params (line 446)

Attempt to use mod_rewrite to improve this URL.

  • return: The improved URL (NULL: couldn't do anything)
?URLPATH _url_rewrite_params (ID_TEXT $zone_name, array $vars, [boolean $force_index_php = false])
  • ID_TEXT $zone_name: The name of the zone for this
  • array $vars: A map of variables to include in our URL
  • boolean $force_index_php: Force inclusion of the index.php name into a short URL, so something may tack on extra parameters to the result here

Documentation generated on Sun, 02 Jan 2011 23:27:37 +0000 by phpDocumentor 1.4.3