SEO URL TOOLS is PHP class that consists of number of functions provided as tools for URL handling and manipulation. They provide simple and efficient means for parsing and creating URL's in documents.
function seo_url_tools($p_mode = false, $p_use_root_script = false)
This is object constructor. It initializes object. You may provide URL mode on initialization if you want to ($p_mode). Also, you may set if root document will be used in URL's ($p_use_root_script). If pretty url mode is on and root document is also enforced, then pretty urls will work even if rewrite engine is not turned on (at least it works on Apache 1.3 with PHP 4.3). You may set or change mode later in any time.
function set_seo_urls_mode ($p_mode, $p_use_root_script = '')
Sets URL mode: true - seo url (pretty url), false - standard query url. Set if root script is used in URL's (true - yes, false - no).
function get_full_current_url ($p_result_type = 'string')
Returns full URL of the current document. Output type may be string or array, which you specify as parameter. If type is not specified, it defaults to string.
function get_current_url ($p_result_type = 'string')
Returns current URL without unnecessary items (default values are removed). By other means it works the same as get_full_current_url ()
function get_exact_current_url ()
Returns exact URL of the current document as sent in request from user. Output value is a string.
function get_root_url($p_url)
Returns string URL of the root of the site. This function is meaned to provide easy way to construct url that leads to index of the whole site. It pays attention to URL options so they are preserved if necessary. For instance if language is set, get_root_url() will give you URL that leads to index page but in current language. It takes both string an array as input parameter. If input parameter is not specified, current url is used.
function force_array_url ($p_url)
It takes url in any of two formats (string or array) and returns array structure.
function force_url_string ($p_url)
It takes url in any of two formats (string or array) and returns string structure
function url2array ($p_url_str)
Converts string url to array url structure. This actually parses string to url items. You should have all class properties customized to be able to parse URL according to your URL specification.
function array2url ($p_rurl)
Converts url array structure into string. Use this when you need to display URL in document. You should have all class properties customized to be able to construct URL that suits your URL specifications
function url_add_param ($p_url, $p_param, $p_clean_what = nil)
Adds specified list of parameters to specified url. If $p_url already contains parameter this will change it's value. If new value for existing parameter is empty, parameter will be removed from url. $purl may be string or array structure.
$p_param contains defining parameters. May be string or array structured in the same manner as url array structure. If string parameters are used they will be parsed and array structure filled in. If query mode, string values cannot have definitions of section, path parameters and options in path part of url as that part of the string would be treated as document name. If you need to change section, path parameters or options, use query parameters in url string (worse option) or pass values as array structure.
Section, path and options parts of structure are used to create pretty url parameters if pretty url mode is used if query mode is on, these options would be treated as query parameters. That allows you to use the same structure to set parameters and respective url syntax would be used depending on url mode (pretty url or query url).
If $p_clean_what is specified, url will be cleaned before parameters added. For parameter options check function clean_url_properties().
Result of this function is array structure with altered URL parameters.
function url_current_add_param ($p_params)
Adds specified list of parameters to current url (url of current document). It works similar to url_add_param() with exception that you may specify type of the result through parameter $p_result_type. It is useful when you need to change few parameters to current URL and display it in a document.
function quick_current_url ($p_option='', $p_item='', $p_page='', $p_lang='', $p_client='')
Changes some parameter values in current URL. This function is targeted to situation where you have simple way to radically change URL by setting lots of parameters but to avoid creating complex array structure. For instance, when you create URL of menu option you want to remove most of the parameters from current url and keep or change one or two.
function set_sections ($p_sections = '', $p_default)
This defines possible sections in URL. Url section will be recognized in URL only if section is previously defined through this option. You may specify list of sections as array or comma separated string. You also may specify name of the section that will be used as default if section is not specified in URL. On string url creation, if url section is default section, section would not be displayed in URL.
function section_exists ($p_section)
Check if specified section name exists in defined sections list
function get_section_default ($p_section)
Returns name of the default section
function is_section_default ($p_section)
Checks if specified section name is default section
function set_default_port ($p_value)
Sets default port in url. This means that if port is not part of the url, this port will be assumed. Also, on string url creation, if url port is default port, then port will not be shown in url string. By default, http port is used, port 80
function is_port_default ($p_value)
Checks if specified port is default
function set_option ($p_name, $p_type, $p_default_value='', $p_values='')
Adds option to option list. You must specify option name and type.
$p_name is name that would be used to access this option value
$p_type is type of the option and it may be 'numeric' or 'char'. You may define just one numeric type parameter and unlimited number of char parameters
$p_default value is optional. You may specify default value of the option. That means if option value is not specified in URL, default value will be assumed. Also, when UTL string is created and this URL option has default value, URL option will be omitted from string.
$p_values is not required for numeric type as in numeric type, value may be any number. But, in char type option, $p_values specifies allowed values for this specific option. This is important, as string URL does not contain option name, so parser must guess option name by comparing parsed value to allowed values. If it get match than it associates value to this option name. That introduces limit that if you have several char type options, they must not have the same any allowed value. $p_values may be array list or string with comma separated list of values
function option_exists ($p_option)
Checks if option of specified name is defined
function get_option_default ($p_option)
Returns default value of specified option name
function is_option_default ($p_option, $p_value)
Checks if $p_value is default value of the option named $p_option
function match_option ($p_value)
Returns name of the option, which $p_value belongs to.
function set_path_names ($p_names)
Sets path names. Specify path names as comma delimited string. You must specify path names in order they should show in path. As path values are not named, values read from path will be assigned to path names according to order of appearance. If you do not specify path names path names will be automatically generated as 'p' followed by path order. The first path value will be associated to p0, the second to p1 etc. If you specify path names then then they will replace auto generated names. Of for some reason url contains more path values than custom defined path names, automatic path names will be used for those not custom defined. Automatic path names will contain 'p' followed by order or the value (including named values). i.e. fourth value will be named p3.
function path_name_exists ($p_value)
Checks if name $p_value is defined as path name
function get_path_name ($p_value)
Returns name of the path name by order. $p_value is path name order number starting from zero. If there is no custom defined path name, automatic path name is generated according to parameter order
function set_default_path_value ($p_value)
Sets default path value. This is the value used if path values are not specified in URL.
function is_menu_path_default($m_value)
Checks if the first path value is default value.
function url_root ()
Return root level of site. This works if function is called from script which is in the root of the site, or if script is included by other script which is in the root. Pay attention that this returns absolute root of the site regardless of current parameters. If you need url of site index use get_root_url()
function clean_url_properties ($p_url, $p_clean_what = nil)
Cleans specified items of the url (all or from comma separated list).
Possible clean options:
all - remove all items from the url
params - remove path and query
vars - remove section, path, options, query and fragment
scheme - remove scheme from url
user - remove username from url
pass - remove password from url
host - remove host from url
port - remove port from url
root - remove root from url
doc - remove document from url
section - remove section from url
path - remove path from url
options - remove options from url
query - remove query from url
fragment - remove fragment from url
Returns url in format same as input format (if input is array, output would be array too.
function clean_item ($p_value)
Removes empty items in array
function get_url_param ($p_url, $p_param_type, $p_param_name = '')
Returns value of the URL parameter from specified url
$p_url is url that should be parsed. It may be string or array
$p_param_type is type of parameter (section, path, option...)
$p_param_name is name of parameter which value you want to get
function clean_string_url ($p_value)
Cleans url string from multiplied / in path.
force_correct_current_url()
Checks if URL user typed in browser matches correct url for the document, and if not, enforces correct URL
clean_url_string ($p_url_string)
Clean url string from notwanted characters (or substrings). It repalces characters not wallowed in url with proper replacements. You may customize replacament definitions by using replacements_add() or by setting contents of file _url_transform.php which should be in the same directory where this library resides.
function replacements_add ($p_array)
Sets list of replacements for clean_url_string(). Input is array list of strings that should be replaced and replacements.
function version_info ($p_item = '')
Returns version information. Input parameter may be empty, 'name' or 'number'. Empty parameter returns version info as array, 'name' returns library name and 'number' returns version number.
Built on DevCMS 0.1.4 and SEO URL Tools 1.0.38 - ©2007 Copyright by Predrag Supurović, ©2007 Copyright by DataVoyage