Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/weblib.php File Reference

Go to the source code of this file.

Data Structures

class  moodle_url
class  tabobject
class  progress_bar
class  progress_trace
class  null_progress_trace
class  text_progress_trace
class  html_progress_trace
class  html_list_progress_trace

Namespaces

namespace  core
namespace  moodlecore

Enumerations

enum  FORMAT_MOODLE
 Constants. More...
enum  FORMAT_HTML
enum  FORMAT_PLAIN
enum  FORMAT_WIKI
enum  FORMAT_MARKDOWN
enum  URL_MATCH_BASE
enum  URL_MATCH_PARAMS
enum  URL_MATCH_EXACT

Functions

 s ($var, $obsolete=false)
 Functions.
 p ($var, $obsolete=false)
 addslashes_js ($var)
 strip_querystring ($url)
 get_referer ($stripquery=true)
 me ()
 qualified_me ()
 data_submitted ()
 break_up_long_words ($string, $maxsize=20, $cutchar=' ')
 close_window ($delay=0, $reloadopener=false)
 page_doc_link ($text='')
 validate_email ($address)
 get_file_argument ()
 format_text_menu ()
 format_text ($text, $format=FORMAT_MOODLE, $options=NULL, $courseid_do_not_use=NULL)
 reset_text_filters_cache ()
 format_string ($string, $striplinks=true, $options=NULL)
 replace_ampersands_not_followed_by_entity ($string)
 strip_links ($string)
 wikify_links ($string)
 format_text_email ($text, $format)
 format_module_intro ($module, $activity, $cmid, $filter=true)
 trusttext_strip ($text)
 trusttext_pre_edit ($object, $field, $context)
 trusttext_trusted ($context)
 trusttext_active ()
 clean_text ($text, $format=FORMAT_HTML, $options=array())
 purify_html ($text, $options=array())
 text_to_html ($text, $smiley_ignored=null, $para=true, $newlines=true)
 markdown_to_html ($text)
 html_to_text ($html, $width=75, $dolinks=true)
 highlight ($needle, $haystack, $matchcase=false, $prefix= '< span class="highlight">', $suffix= '</span >')
 highlightfast ($needle, $haystack)
 get_html_lang ($dir=false)
 send_headers ($contenttype, $cacheable=true)
 STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////.
 link_arrow_right ($text, $url='', $accesshide=false, $addclass='')
 link_arrow_left ($text, $url='', $accesshide=false, $addclass='')
 get_accesshide ($text, $elem='span', $class='', $attrs='')
 get_separator ()
 print_collapsible_region ($contents, $classes, $id, $caption, $userpref= '', $default=false, $return=false)
 print_collapsible_region_start ($classes, $id, $caption, $userpref= '', $default=false, $return=false)
 print_collapsible_region_end ($return=false)
 print_group_picture ($group, $courseid, $large=false, $return=false, $link=true)
 print_recent_activity_note ($time, $user, $text, $link, $return=false, $viewfullnames=null)
 navmenulist ($course, $sections, $modinfo, $strsection, $strjumpto, $width=50, $cmid=0)
 print_grade_menu ($courseid, $name, $current, $includenograde=true, $return=false)
 mdie ($msg='', $errorcode=1)
 notice ($message, $link='', $course=NULL)
 redirect ($url, $message='', $delay=-1)
 obfuscate_email ($email)
 obfuscate_text ($plaintext)
 obfuscate_mailto ($email, $label='', $dimmed=false)
 rebuildnolinktag ($text)
 print_maintenance_message ()
 print_tabs ($tabrows, $selected=NULL, $inactive=NULL, $activated=NULL, $return=false)
 convert_tree_to_html ($tree, $row=0)
 convert_tabrows_to_tree ($tabrows, $selected, $inactive, $activated)
 debugging ($message= '', $level=DEBUG_NORMAL, $backtrace=null)
 print_location_comment ($file, $line, $return=false)
 right_to_left ()
 fix_align_rtl ($align)
 is_in_popup ()
 print_password_policy ()

Enumeration Type Documentation

Plain HTML (with some tags stripped)

Definition at line 48 of file weblib.php.

Markdown-formatted text http://daringfireball.net/projects/markdown/

Definition at line 65 of file weblib.php.

Constants.

Define text formatting types ... eventually we can add Wiki, BBcode etc Does all sorts of transformations and filtering

Definition at line 43 of file weblib.php.

Plain text (even tags are printed in full)

Definition at line 53 of file weblib.php.

Wiki-formatted text Deprecated: left here just to note that '3' is not used (at the moment) and to catch any latent wiki-like text (which generates an error)

Definition at line 60 of file weblib.php.

A moodle_url comparison using this flag will return true if the base URLs match, params are ignored

Definition at line 70 of file weblib.php.

A moodle_url comparison using this flag will return true if the two URLs are identical, except for the order of the params

Definition at line 78 of file weblib.php.

A moodle_url comparison using this flag will return true if the base URLs match and the params of url1 are part of url2

Definition at line 74 of file weblib.php.


Function Documentation

addslashes_js ( var)

Does proper javascript quoting.

Do not use addslashes anymore, because it does not work when magic_quotes_sybase is enabled.

Parameters:
mixed$varString, Array, or Object to add slashes to
Returns:
mixed quoted result

Definition at line 128 of file weblib.php.

Here is the caller graph for this function:

break_up_long_words ( string,
maxsize = 20,
cutchar = ' ' 
)

Given some normal text this function will break up any long words to a given size by inserting the given character

It's multibyte savvy and doesn't change anything inside html tags.

Parameters:
string$stringthe string to be modified
int$maxsizemaximum length of the string to be returned
string$cutcharthe string used to represent word breaks
Returns:
string

Loading the textlib singleton instance. We are going to need it.

First of all, save all the tags inside the text to skip them

Process the string adding the cut when necessary

Finally load the tags back again

Definition at line 755 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

clean_text ( text,
format = FORMAT_HTML,
options = array() 
)

Given raw text (eg typed in by a user), this function cleans it up and removes any nasty tags that could mess up Moodle pages through XSS attacks.

The result must be used as a HTML text fragment, this function can not cleanup random parts of html tags such as url or src attributes.

NOTE: the format parameter was deprecated because we can safely clean only HTML.

Parameters:
string$textThe text to be cleaned
int | string$formatdeprecated parameter, should always contain FORMAT_HTML or FORMAT_MOODLE
array$optionsArray of options; currently only option supported is 'allowid' (if true, does not remove id attributes when cleaning)
Returns:
string The cleaned up text

Definition at line 1427 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

close_window ( delay = 0,
reloadopener = false 
)

Try and close the current window using JavaScript, either immediately, or after a delay.

Echo's out the resulting XHTML & javascript

object object

Parameters:
integer$delaya delay in seconds before closing the window. Default 0.
boolean$reloadopenerif true, we will see if this window was a pop-up, and try to reload the parent window before this one closes.

Definition at line 802 of file weblib.php.

convert_tabrows_to_tree ( tabrows,
selected,
inactive,
activated 
)

Convert nested tabrows to a nested array

Parameters:
array$tabrowsA [nested] array of tab row objects
string$selectedThe tabrow to select (by id)
array$inactiveAn array of tabrow id's to make inactive
array$activatedAn array of tabrow id's to make active
Returns:
array The nested array

Work backwards through the rows (bottom to top) collecting the tree as we go.

Definition at line 2643 of file weblib.php.

Here is the caller graph for this function:

convert_tree_to_html ( tree,
row = 0 
)

Converts a nested array tree into HTML ul:li [recursive]

Parameters:
array$treeA tree array to convert
int$rowUsed in identifying the iteration level and in ul classes
Returns:
string HTML structure

Definition at line 2578 of file weblib.php.

Here is the caller graph for this function:

Determine if there is data waiting to be processed from a form

Used on most forms in Moodle to check for data Returns the data as an object, if it's found. This object can be used in foreach loops without casting because it's cast to (array) automatically

Checks that submitted POST data exists and returns it as object.

$_POST

Returns:
mixed false or object

Definition at line 735 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

debugging ( message = '',
level = DEBUG_NORMAL,
backtrace = null 
)

Standard Debugging Function

Returns true if the current site debugging settings are equal or above specified level. If passed a parameter it will emit a debugging notice similar to trigger_error(). The routing of notices is controlled by $CFG->debugdisplay eg use like this:

1) debugging('a normal debug notice'); 2) debugging('something really picky', DEBUG_ALL); 3) debugging('annoying debug message only for developers', DEBUG_DEVELOPER); 4) if (debugging()) { perform extra debugging operations (do not use print or echo) }

In code blocks controlled by debugging() (such as example 4) any output should be routed via debugging() itself, or the lower-level trigger_error() or error_log(). Using echo or print will break XHTML JS and HTTP headers.

It is also possible to define NO_DEBUG_DISPLAY which redirects the message to error_log.

DEBUG_NORMAL

Parameters:
string$messagea message to print
int$levelthe level at which this debugging statement should show
array$backtraceuse different backtrace
Returns:
bool

Definition at line 2698 of file weblib.php.

Here is the call graph for this function:

fix_align_rtl ( align)

Returns swapped left<=>right if in RTL environment. part of RTL support

Parameters:
string$alignalign to check
Returns:
string

Definition at line 2786 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

format_module_intro ( module,
activity,
cmid,
filter = true 
)

Formats activity intro text

object CONTEXT_MODULE

Parameters:
string$modulename of module
object$activityinstance of activity
int$cmidcourse module id
bool$filterfilter resulting html text
Returns:
text

Definition at line 1342 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

format_string ( string,
striplinks = true,
options = NULL 
)

Given a simple string, this function returns the string processed by enabled string filters if $CFG->filterall is enabled

This function should be used to print short strings (non html) that need filter processing e.g. activity titles, post subjects, glossary concepts.

bool $strcache

Parameters:
string$stringThe string to be filtered. Should be plain text, expect possibly for multilang tags.
boolean$striplinksTo strip any link in the result text. Moodle 1.8 default changed from false to true! MDL-8713
array$optionsoptions array/object or courseid
Returns:
string

Definition at line 1190 of file weblib.php.

Here is the call graph for this function:

format_text ( text,
format = FORMAT_MOODLE,
options = NULL,
courseid_do_not_use = NULL 
)

Given text in a variety of format codings, this function returns the text as safe HTML.

This function should mainly be used for long strings like posts, answers, glossary items etc. For short strings

See also:
format_string().
 Options:
      trusted     :   If true the string won't be cleaned. Default false required noclean=true.
      noclean     :   If true the string won't be cleaned. Default false required trusted=true.
      nocache     :   If true the strign will not be cached and will be formatted every call. Default false.
      filter      :   If true the string will be run through applicable filters as well. Default true.
      para        :   If true then the returned string will be wrapped in div tags. Default true.
      newlines    :   If true then lines newline breaks will be converted to HTML newline breaks. Default true.
      context     :   The context that will be used for filtering.
      overflowdiv :   If set to true the formatted text will be encased in a div
                      with the class no-overflow before being returned. Default false.
      allowid     :   If true then id attributes will not be removed, even when
                      using htmlpurifier. Default false.
 
Todo:
Finish documenting this function

array $croncache

Parameters:
string$textThe text to be formatted. This is raw text originally from user input.
int$formatIdentifier of the text format to be used [FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_MARKDOWN]
object/array$options text formatting options
int$courseid_do_not_usedeprecated course id, use context option instead
Returns:
string

Definition at line 962 of file weblib.php.

Here is the call graph for this function:

format_text_email ( text,
format 
)

Given text in a variety of format codings, this function returns the text as plain text suitable for plain email.

FORMAT_MOODLE FORMAT_HTML FORMAT_PLAIN FORMAT_WIKI FORMAT_MARKDOWN

Parameters:
string$textThe text to be formatted. This is raw text originally from user input.
int$formatIdentifier of the text format to be used [FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN]
Returns:
string

Definition at line 1304 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Just returns an array of text formats suitable for a popup menu

FORMAT_MOODLE FORMAT_HTML FORMAT_PLAIN FORMAT_MARKDOWN

Returns:
array

Definition at line 923 of file weblib.php.

Here is the caller graph for this function:

get_accesshide ( text,
elem = 'span',
class = '',
attrs = '' 
)

Return a HTML element with the class "accesshide", for accessibility. Please use cautiously - where possible, text should be visible!

Parameters:
string$textPlain text.
string$elemLowercase element name, default "span".
string$classAdditional classes for the element.
string$attrsAdditional attributes string in the form, "name='value' name2='value2'"
Returns:
string HTML string.

Definition at line 1830 of file weblib.php.

Here is the caller graph for this function:

Extracts file argument either from file parameter or PATH_INFO Note: $scriptname parameter is not needed anymore

string $_SERVER PARAM_PATH

Returns:
string file path (only safe characters)

Definition at line 877 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_html_lang ( dir = false)

Return a string containing 'lang', xml:lang and optionally 'dir' HTML attributes. Internationalisation, for print_header and backup/restorelib.

Parameters:
bool$dirDefault false
Returns:
string Attributes

Definition at line 1703 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_referer ( stripquery = true)

Returns the URL of the HTTP_REFERER, less the querystring portion if required

$_SERVER

Parameters:
boolean$stripqueryif true, also removes the query part of the url.
Returns:
string The resulting referer or empty string

Definition at line 169 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Return the breadcrumb trail navigation separator.

Returns:
string HTML string.

Definition at line 1839 of file weblib.php.

Here is the caller graph for this function:

highlight ( needle,
haystack,
matchcase = false,
prefix = '<span class="highlight">',
suffix = '</span>' 
)

This function will highlight search words in a given string

It cares about HTML and will not ruin links. It's best to use this function after performing any conversions to HTML.

Parameters:
string$needleThe search string. Syntax like "word1 +word2 -word3" is dealt with correctly.
string$haystackThe string (HTML) within which to highlight the search terms.
boolean$matchcasewhether to do case-sensitive. Default case-insensitive.
string$prefixthe string to put before each search term found.
string$suffixthe string to put after each search term found.
Returns:
string The highlighted HTML.

Quick bail-out in trivial cases.

Break up the search term into words, discard any -words and build a regexp.

Another chance to bail-out if $search was only -words

Find all the HTML tags in the input, and store them in a placeholders array.

In $hastack, replace each HTML tag with the corresponding placeholder.

In the resulting string, Do the highlighting.

Turn the placeholders back into HTML tags.

Definition at line 1612 of file weblib.php.

Here is the caller graph for this function:

highlightfast ( needle,
haystack 
)

This function will highlight instances of $needle in $haystack

It's faster that the above function highlight() and doesn't care about HTML or anything.

Parameters:
string$needleThe string to search for
string$haystackThe string to search for $needle in
Returns:
string The highlighted HTML

Definition at line 1671 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

html_to_text ( html,
width = 75,
dolinks = true 
)

Given HTML text, make it into plain text using external function

Parameters:
string$htmlThe text to be converted.
integer$widthWidth to wrap the text at. (optional, default 75 which is a good value for email. 0 means do not limit line length.)
boolean$dolinksBy default, any links in the HTML are collected, and printed as a list at the end of the HTML. If you don't want that, set this argument to false.
Returns:
string plain text equivalent of the HTML.

Definition at line 1587 of file weblib.php.

Here is the caller graph for this function:

Returns true if the page is displayed in a popup window. Gets the information from the URL parameter inpopup.

Todo:
Use a central function to create the popup calls all over Moodle and In the moment only works with resources and probably questions.
Returns:
boolean

Definition at line 2805 of file weblib.php.

Here is the call graph for this function:

link_arrow_left ( text,
url = '',
accesshide = false,
addclass = '' 
)

Return the left arrow with text ('previous'), and optionally embedded in a link.

object

Parameters:
string$textHTML/plain text label (set to blank only for breadcrumb separator cases).
string$urlAn optional link to use in a surrounding HTML anchor.
bool$accesshideTrue if text should be hidden (for screen readers only).
string$addclassAdditional class names for the link, or the arrow character.
Returns:
string HTML string.

Definition at line 1796 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

link_arrow_right ( text,
url = '',
accesshide = false,
addclass = '' 
)

Return the right arrow with text ('next'), and optionally embedded in a link.

object

Parameters:
string$textHTML/plain text label (set to blank only for breadcrumb separator cases).
string$urlAn optional link to use in a surrounding HTML anchor.
bool$accesshideTrue if text should be hidden (for screen readers only).
string$addclassAdditional class names for the link, or the arrow character.
Returns:
string HTML string.

Definition at line 1762 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

markdown_to_html ( text)

Given Markdown formatted text, make it into XHTML using external function

object

Parameters:
string$textThe markdown formatted text to be converted.
Returns:
string Converted text

Definition at line 1564 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

mdie ( msg = '',
errorcode = 1 
)

Print an error to STDOUT and exit with a non-zero code. For commandline scripts. Default errorcode is 1.

Very useful for perl-like error-handling:

do_somethting() or mdie("Something went wrong");

Parameters:
string$msgError message
integer$errorcodeError code to emit

Definition at line 2197 of file weblib.php.

me ( )

Returns the name of the current script, WITH the querystring portion.

This function is necessary because PHP_SELF and REQUEST_URI and SCRIPT_NAME return different things depending on a lot of things like your OS, Web server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.) NOTE: This function returns false if the global variables needed are not set.

string

Returns:
mixed String, or false if the global variables needed are not set

Definition at line 193 of file weblib.php.

Here is the caller graph for this function:

navmenulist ( course,
sections,
modinfo,
strsection,
strjumpto,
width = 50,
cmid = 0 
)

Returns a popup menu with course activity modules

Given a course This function returns a small popup menu with all the course activity modules in it, as a navigation menu outputs a simple list structure in XHTML The data is taken from the serialised array stored in the course record

Todo:
Finish documenting this function

object CONTEXT_COURSE

Parameters:
course$courseA $COURSE object.
string$sections
string$modinfo
string$strsection
string$strjumpto
int$width
string$cmid
Returns:
string The HTML block

Don't show excess hidden sections

Definition at line 2061 of file weblib.php.

Here is the call graph for this function:

notice ( message,
link = '',
course = NULL 
)

Print a message and exit.

Parameters:
string$messageThe message to print in the notice
string$linkThe link to use for the continue button
object$courseA course object
Returns:
void This function simply exits

Definition at line 2210 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

obfuscate_email ( email)

Given an email address, this function will return an obfuscated version of it

Parameters:
string$emailThe email address to obfuscate
Returns:
string The obfuscated email address

Definition at line 2383 of file weblib.php.

Here is the caller graph for this function:

obfuscate_mailto ( email,
label = '',
dimmed = false 
)

This function uses the obfuscate_email() and obfuscate_text() to generate a fully obfuscated email link, ready to use.

Parameters:
string$emailThe email address to display
string$labelThe text to displayed as hyperlink to $email
boolean$dimmedIf true then use css class 'dimmed' for hyperlink
Returns:
string The obfuscated mailto link

Definition at line 2438 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

obfuscate_text ( plaintext)

This function takes some text and replaces about half of the characters with HTML entity equivalents. Return string is obviously longer.

Parameters:
string$plaintextThe text to be obfuscated
Returns:
string The obfuscated text

Definition at line 2406 of file weblib.php.

Here is the caller graph for this function:

p ( var,
obsolete = false 
)

Add quotes to HTML characters

Prints $var with HTML characters (like "<", ">", etc.) properly quoted. This function simply calls s()

See also:
s()
Todo:
Remove obsolete param $obsolete if not used anywhere
Parameters:
string$varthe string potentially containing HTML characters
boolean$obsoleteno longer used.
Returns:
string

Definition at line 116 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

page_doc_link ( text = '')

Returns a string containing a link to the user documentation for the current page. Also contains an icon by default. Shown to teachers and admin only.

object object

Parameters:
string$textThe text to be displayed for the link
string$iconpathThe path to the icon to be displayed
Returns:
string The link to user documentation for this current page

Definition at line 834 of file weblib.php.

Here is the call graph for this function:

print_collapsible_region ( contents,
classes,
id,
caption,
userpref = '',
default = false,
return = false 
)

Print (or return) a collapsible region, that has a caption that can be clicked to expand or collapse the region.

If JavaScript is off, then the region will always be expanded.

Parameters:
string$contentsthe contents of the box.
string$classesclass names added to the div that is output.
string$idid added to the div that is output. Must not be blank.
string$captiontext displayed at the top. Clicking on this will cause the region to expand or contract.
string$userprefthe name of the user preference that stores the user's preferred default state. (May be blank if you do not wish the state to be persisted.
boolean$defaultInitial collapsed state to use if the user_preference it not set.
boolean$returnif true, return the HTML as a string, rather than printing it.
Returns:
string|void If $return is false, returns nothing, otherwise returns a string of HTML.

Definition at line 1860 of file weblib.php.

Here is the call graph for this function:

print_collapsible_region_end ( return = false)

Close a region started with print_collapsible_region_start.

Parameters:
boolean$returnif true, return the HTML as a string, rather than printing it.
Returns:
string|void if $return is false, returns nothing, otherwise returns a string of HTML.

Definition at line 1923 of file weblib.php.

Here is the caller graph for this function:

print_collapsible_region_start ( classes,
id,
caption,
userpref = '',
default = false,
return = false 
)

Print (or return) the start of a collapsible region, that has a caption that can be clicked to expand or collapse the region. If JavaScript is off, then the region will always be expanded.

Parameters:
string$classesclass names added to the div that is output.
string$idid added to the div that is output. Must not be blank.
string$captiontext displayed at the top. Clicking on this will cause the region to expand or contract.
string$userprefthe name of the user preference that stores the user's preferred default state. (May be blank if you do not wish the state to be persisted.
boolean$defaultInitial collapsed state to use if the user_preference it not set.
boolean$returnif true, return the HTML as a string, rather than printing it.
Returns:
string|void if $return is false, returns nothing, otherwise returns a string of HTML.

Definition at line 1886 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

print_grade_menu ( courseid,
name,
current,
includenograde = true,
return = false 
)

Prints a grade menu (as part of an existing form) with help Showing all possible numerical grades and scales

Todo:

Finish documenting this function

Deprecate: this is only used in a few contrib modules

object

Parameters:
int$courseidThe course ID
string$name
string$current
boolean$includenogradeInclude those with no grades
boolean$returnIf set to true returns rather than echo's
Returns:
string|bool Depending on value of $return

Definition at line 2154 of file weblib.php.

Here is the call graph for this function:

print_group_picture ( group,
courseid,
large = false,
return = false,
link = true 
)

Print a specified group's avatar.

object CONTEXT_COURSE

Parameters:
array | stdClass$groupA single group object OR array of groups.
int$courseidThe course ID.
boolean$largeDefault small picture, or large.
boolean$returnIf false print picture, otherwise return the output as string
boolean$linkEnclose image in a link to view specified course?
Returns:
string|void Depending on the setting of $return

Definition at line 1945 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

print_location_comment ( file,
line,
return = false 
)

Outputs a HTML comment to the browser. This is used for those hard-to-debug pages that use bits from many different files in very confusing ways (e.g. blocks).

print_location_comment(__FILE__, __LINE__);

Parameters:
string$file
integer$line
boolean$returnWhether to return or print the comment
Returns:
string|void Void unless true given as third parameter

Definition at line 2761 of file weblib.php.

Prints a maintenance message from $CFG->maintenance_message or default if empty

Returns:
void

Definition at line 2473 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns a localized sentence in the current language summarizing the current password policy

Todo:
this should be handled by a function/method in the language pack library once we have a support for it $CFG
Returns:
string

Definition at line 3115 of file weblib.php.

Here is the caller graph for this function:

print_recent_activity_note ( time,
user,
text,
link,
return = false,
viewfullnames = null 
)

Display a recent activity note

CONTEXT_SYSTEM string $strftimerecent

Parameters:
objectA time object
objectA user object
string$textText for display for the note
string$linkThe link to wrap around the text
bool$returnIf set to true the HTML is returned rather than echo'd
string$viewfullnames

Definition at line 2012 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

print_tabs ( tabrows,
selected = NULL,
inactive = NULL,
activated = NULL,
return = false 
)

Returns a string containing a nested list, suitable for formatting into tabs with CSS.

object

Parameters:
array$tabrowsAn array of rows where each row is an array of tab objects
string$selectedThe id of the selected tab (whatever row it's on)
array$inactiveAn array of ids of inactive tabs that are not selectable.
array$activatedAn array of ids of other tabs that are currently activated
bool$returnIf true output is returned rather then echo'd

$inactive must be an array

$activated must be an array

Convert the tab rows into a tree that's easier to process

Print out the current tree of tabs (this function is recursive)

We're done!

Definition at line 2539 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

purify_html ( text,
options = array() 
)

KSES replacement cleaning function - uses HTML Purifier.

Parameters:
string$textThe (X)HTML string to purify
array$optionsArray of options; currently only option supported is 'allowid' (if set, does not remove id attributes when cleaning)
Returns:
string

Definition at line 1459 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the name of the current script, WITH the full URL.

This function is necessary because PHP_SELF and REQUEST_URI and SCRIPT_NAME return different things depending on a lot of things like your OS, Web server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc. NOTE: This function returns false if the global variables needed are not set.

Like me() but returns a full URL

See also:
me()

string

Returns:
mixed String, or false if the global variables needed are not set

Definition at line 212 of file weblib.php.

Here is the caller graph for this function:

rebuildnolinktag ( text)

This function is used to rebuild the <nolink> tag because some formats (PLAIN and WIKI) will transform it to html entities

Parameters:
string$textText to search for nolink tag in
Returns:
string

Definition at line 2462 of file weblib.php.

Here is the caller graph for this function:

redirect ( url,
message = '',
delay = -1 
)

Redirects the user to another page, after printing a notice

This function calls the OUTPUT redirect method, echo's the output and then dies to ensure nothing else happens.

Good practice: You should call this method before starting page output by using any of the OUTPUT methods.

Parameters:
moodle_url | string$urlA moodle_url to redirect to. Strings are not to be trusted!
string$messageThe message to display to the user
int$delayThe delay before redirecting
Returns:
void - does not return!

Definition at line 2249 of file weblib.php.

Here is the call graph for this function:

Given a string, performs a negative lookahead looking for any ampersand character that is not followed by a proper HTML entity. If any is found, it is replaced by &. The string is then returned.

Parameters:
string$string
Returns:
string

Definition at line 1266 of file weblib.php.

Here is the caller graph for this function:

Resets all data related to filters, called during upgrade or when filter settings change.

object object

Returns:
void

Definition at line 1166 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
boolean true if the current language is right-to-left (Hebrew, Arabic etc)

Definition at line 2774 of file weblib.php.

Here is the caller graph for this function:

s ( var,
obsolete = false 
)

Functions.

Add quotes to HTML characters

Returns $var with HTML characters (like "<", ">", etc.) properly quoted. This function is very similar to p()

Todo:
Remove obsolete param $obsolete if not used anywhere
Parameters:
string$varthe string potentially containing HTML characters
boolean$obsoleteno longer used.
Returns:
string

Definition at line 94 of file weblib.php.

send_headers ( contenttype,
cacheable = true 
)

STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////.

Send the HTTP headers that Moodle requires.

Parameters:
$cacheableCan this page be cached on back?

Definition at line 1725 of file weblib.php.

Here is the caller graph for this function:

strip_links ( string)

Given a string, replaces all .* by .* and returns the string.

Parameters:
string$string
Returns:
string

Definition at line 1276 of file weblib.php.

Here is the caller graph for this function:

strip_querystring ( url)

Remove query string from url

Takes in a URL and returns it without the querystring portion

Parameters:
string$urlthe url which may have a query string attached
Returns:
string The remaining URL

Definition at line 153 of file weblib.php.

Here is the caller graph for this function:

text_to_html ( text,
smiley_ignored = null,
para = true,
newlines = true 
)

Given plain text, makes it into HTML as nicely as possible. May contain HTML tags already

Do not abuse this function. It is intended as lower level formatting feature used by {

See also:
format_text()} to convert FORMAT_MOODLE to HTML. You are supposed to call format_text() in most of cases.
Parameters:
string$textThe string to convert.
boolean$smiley_ignoredWas used to determine if smiley characters should convert to smiley images, ignored now
boolean$paraIf true then the returned string will be wrapped in div tags
boolean$newlinesIf true then lines newline breaks will be converted to HTML newline breaks.
Returns:
string

Remove any whitespace that may be between HTML tags

Remove any returns that precede or follow HTML tags

Make returns into HTML newlines.

Wrap the whole thing in a div if required

Definition at line 1535 of file weblib.php.

Here is the caller graph for this function:

Is trusttext feature active?

Returns:
bool

Definition at line 1406 of file weblib.php.

Here is the caller graph for this function:

trusttext_pre_edit ( object,
field,
context 
)

Must be called before editing of all texts with trust flag. Removes all XSS nasties from texts stored in database if needed.

Parameters:
object$objectdata object with xxx, xxxformat and xxxtrust fields
string$fieldname of text field
object$contextactive context
Returns:
object updated $object

Definition at line 1378 of file weblib.php.

Here is the call graph for this function:

trusttext_strip ( text)

Legacy function, used for cleaning of old forum and glossary text only.

object

Parameters:
string$texttext that may contain legacy TRUSTTEXT marker
Returns:
text without legacy TRUSTTEXT marker

Definition at line 1358 of file weblib.php.

trusttext_trusted ( context)

Is current user trusted to enter no dangerous XSS in this context?

Please note the user must be in fact trusted everywhere on this server!!

Parameters:
object$context
Returns:
bool true if user trusted

Definition at line 1397 of file weblib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

validate_email ( address)

Validates an email to make sure it makes sense.

Parameters:
string$addressThe email address to validate.
Returns:
boolean

Definition at line 858 of file weblib.php.

Here is the caller graph for this function:

wikify_links ( string)

This expression turns links into something nice in a text format. (Russell Jungwirth)

Parameters:
string$string
Returns:
string

Definition at line 1286 of file weblib.php.

Here is the caller graph for this function:

 All Data Structures Namespaces Files Functions Variables Enumerations