Moodle  2.2.1
http://www.collinsharper.com
moodle_url Class Reference

Public Member Functions

 __construct ($url, array $params=null)
 params (array $params=null)
 remove_params ($params=null)
 remove_all_params ($params=null)
 param ($paramname, $newvalue= '')
 get_query_string ($escaped=true, array $overrideparams=null)
 __toString ()
 out ($escaped=true, array $overrideparams=null)
 out_omit_querystring ($includeanchor=false)
 compare (moodle_url $url, $matchtype=URL_MATCH_EXACT)
 set_anchor ($anchor)
 set_slashargument ($path, $parameter= 'file', $supported=NULL)

Static Public Member Functions

static make_file_url ($urlbase, $path, $forcedownload=false)
static make_pluginfile_url ($contextid, $component, $area, $itemid, $pathname, $filename, $forcedownload=false)
static make_draftfile_url ($draftid, $pathname, $filename, $forcedownload=false)
static make_legacyfile_url ($courseid, $filepath, $forcedownload=false)

Protected Member Functions

 merge_overrideparams (array $overrideparams=null)

Protected Attributes

 $scheme = ''
 $host = ''
 $port = ''
 $user = ''
 $pass = ''
 $path = ''
 $slashargument = ''
 $anchor = null
 $params = array()

Detailed Description

Definition at line 235 of file weblib.php.


Constructor & Destructor Documentation

__construct ( url,
array params = null 
)

Create new instance of moodle_url.

Parameters:
moodle_url | string$url- moodle_url means make a copy of another moodle_url and change parameters, string means full url or shortened form (ex.: '/course/view.php'). It is strongly encouraged to not include query string because it may result in double encoded values. Use the $params instead. For admin URLs, just use /admin/script.php, this class takes care of the $CFG->admin issue.
array$paramsthese params override current params or add new

Definition at line 293 of file weblib.php.

Here is the call graph for this function:


Member Function Documentation

Shortcut for printing of encoded URL.

Returns:
string

Definition at line 490 of file weblib.php.

Here is the call graph for this function:

compare ( moodle_url url,
matchtype = URL_MATCH_EXACT 
)

Compares this moodle_url with another See documentation of constants for an explanation of the comparison flags.

Parameters:
moodle_url$urlThe moodle_url object to compare
int$matchtypeThe type of comparison (URL_MATCH_BASE, URL_MATCH_PARAMS, URL_MATCH_EXACT)
Returns:
boolean

Definition at line 549 of file weblib.php.

Here is the call graph for this function:

get_query_string ( escaped = true,
array overrideparams = null 
)

Get the params as as a query string. This method should not be used outside of this method.

Parameters:
boolean$escapedUse & as params separator instead of plain &
array$overrideparamsparams to add to the output params, these override existing ones with the same name.
Returns:
string query string that can be added to a url.

Definition at line 469 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static make_draftfile_url ( draftid,
pathname,
filename,
forcedownload = false 
) [static]

Factory method for creation of url pointing to draft file of current user.

Parameters:
int$draftiddraft item id
string$pathname
string$filename
bool$forcedownload
Returns:
moodle_url

Definition at line 698 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static make_file_url ( urlbase,
path,
forcedownload = false 
) [static]

General moodle file url.

Parameters:
string$urlbasethe script serving the file
string$path
bool$forcedownload
Returns:
moodle_url

Definition at line 652 of file weblib.php.

Here is the caller graph for this function:

static make_legacyfile_url ( courseid,
filepath,
forcedownload = false 
) [static]

Factory method for creating of links to legacy course files.

Parameters:
int$courseid
string$filepath
bool$forcedownload
Returns:
moodle_url

Definition at line 714 of file weblib.php.

Here is the call graph for this function:

static make_pluginfile_url ( contextid,
component,
area,
itemid,
pathname,
filename,
forcedownload = false 
) [static]

Factory method for creation of url pointing to plugin file. Please note this method can be used only from the plugins to create urls of own files, it must not be used outside of plugins!

Parameters:
int$contextid
string$component
string$area
int$itemid
string$pathname
string$filename
bool$forcedownload
Returns:
moodle_url

Definition at line 679 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

merge_overrideparams ( array overrideparams = null) [protected]

Merges parameters and validates them

Parameters:
array$overrideparams
Returns:
array merged parameters

Definition at line 442 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

out ( escaped = true,
array overrideparams = null 
)

Output url

If you use the returned URL in HTML code, you want the escaped ampersands. If you use the returned URL in HTTP headers, you want $escaped=false.

Parameters:
boolean$escapedUse & as params separator instead of plain &
array$overrideparamsparams to add to the output url, these override existing ones with the same name.
Returns:
string Resulting URL

Definition at line 504 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

out_omit_querystring ( includeanchor = false)

Returns url without parameters, everything before '?'.

Parameters:
bool$includeanchorif self::anchor is defined, should it be returned?
Returns:
string

Definition at line 528 of file weblib.php.

Here is the caller graph for this function:

param ( paramname,
newvalue = '' 
)

Add a param to the params for this url.

The added param overrides existing one if they have the same name.

Parameters:
string$paramnamename
string$newvalueParam value. If new value specified current value is overriden or parameter is added
Returns:
mixed string parameter value, null if parameter does not exist

Definition at line 425 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

params ( array params = null)

Add an array of params to the params for this url.

The added params override existing ones if they have the same name.

Parameters:
array$paramsDefaults to null. If null then returns all params.
Returns:
array Array of Params for url.

Definition at line 365 of file weblib.php.

Here is the caller graph for this function:

remove_all_params ( params = null)

Remove all url parameters

Parameters:
$params
Returns:
void

Definition at line 411 of file weblib.php.

Here is the call graph for this function:

remove_params ( params = null)

Remove all params if no arguments passed. Remove selected params if arguments are passed.

Can be called as either remove_params('param1', 'param2') or remove_params(array('param1', 'param2')).

Parameters:
mixed$paramseither an array of param names, or a string param name,
string$params,...any number of additional param names.
Returns:
array url parameters

Definition at line 396 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

set_anchor ( anchor)

Sets the anchor for the URI (the bit after the hash)

Parameters:
string$anchornull means remove previous

Definition at line 601 of file weblib.php.

Here is the caller graph for this function:

set_slashargument ( path,
parameter = 'file',
supported = NULL 
)

Sets the url slashargument value

Parameters:
string$pathusually file path
string$parametername of page parameter if slasharguments not supported
bool$supportedusually null, then it depends on $CFG->slasharguments, use true or false for other servers
Returns:
void

Definition at line 624 of file weblib.php.

Here is the call graph for this function:


Field Documentation

$anchor = null [protected]

Definition at line 275 of file weblib.php.

$host = '' [protected]

Definition at line 245 of file weblib.php.

$params = array() [protected]

Definition at line 280 of file weblib.php.

$pass = '' [protected]

Definition at line 260 of file weblib.php.

$path = '' [protected]

Definition at line 265 of file weblib.php.

$port = '' [protected]

Definition at line 250 of file weblib.php.

$scheme = '' [protected]

Definition at line 240 of file weblib.php.

$slashargument = '' [protected]

Definition at line 270 of file weblib.php.

$user = '' [protected]

Definition at line 255 of file weblib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations