[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/lib/ -> weblib.php (summary)

Library of functions for web output Library of all general-purpose Moodle PHP functions and constants that produce HTML output

Author: Martin Dougiamas
License: http://www.gnu.org/copyleft/gpl.html GNU Public License
Version: $Id$
File Size: 7070 lines (245 kb)
Included or required:0 times
Referenced: 3 times
Includes or requires: 0 files

Defines 2 classes

moodle_url:: (145 methods):
  moodle_url()
  params()
  remove_params()
  param()
  get_query_string()
  hidden_params_out()
  out()
  out_action()
  data_submitted()
  stripslashes_safe()
  stripslashes_recursive()
  addslashes_recursive()
  break_up_long_words()
  str_ireplace()
  stripos()
  element_to_popup_window()
  link_to_popup_window()
  button_to_popup_window()
  close_window_button()
  close_window()
  close_this_window()
  choose_from_menu()
  choose_from_menu_yesno()
  choose_from_menu_nested()
  choose_from_radio()
  print_checkbox()
  print_textfield()
  popup_form()
  formerr()
  validate_email()
  get_file_argument()
  get_slash_arguments()
  parse_slash_arguments()
  format_text_menu()
  format_text()
  text_format_name()
  reset_text_filters_cache()
  format_string()
  format_text_email()
  filter_text()
  filter_string()
  trusttext_present()
  trusttext_strip()
  trusttext_mark()
  trusttext_after_edit()
  trusttext_prepare_edit()
  clean_text()
  purify_html()
  cleanAttributes()
  cleanAttributes2()
  replace_smilies()
  text_to_html()
  markdown_to_html()
  html_to_text()
  convert_urls_into_links()
  highlight()
  highlightfast()
  get_html_lang()
  skip_main_destination()
  print_header()
  require_js()
  get_require_js_code()
  force_strict_header()
  print_header_simple()
  print_footer()
  current_theme()
  current_category_theme()
  style_sheet_setup()
  theme_setup()
  user_login_string()
  check_theme_arrows()
  link_arrow_right()
  link_arrow_left()
  get_accesshide()
  get_separator()
  print_navigation()
  build_navigation()
  print_headline()
  print_heading()
  print_heading_with_help()
  print_heading_block()
  print_continue()
  print_box()
  print_box_start()
  print_box_end()
  print_container()
  print_container_start()
  print_container_end()
  open_containers()
  print_container_end_all()
  _print_custom_corners_start()
  _print_custom_corners_end()
  print_single_button()
  print_spacer()
  print_file_picture()
  print_user_picture()
  print_user()
  print_group_picture()
  print_png()
  print_table()
  print_recent_activity_note()
  print_textarea()
  use_html_editor()
  print_editor_config()
  update_course_icon()
  switchroles_form()
  update_mymoodle_icon()
  update_tag_button()
  update_module_button()
  update_category_button()
  update_categories_button()
  update_categories_search_button()
  navmenu()
  navmenulist()
  print_date_selector()
  print_time_selector()
  print_timer_selector()
  print_grade_menu()
  print_scale_menu()
  print_scale_menu_helpbutton()
  print_error()
  mdie()
  editorhelpbutton()
  helpbutton()
  emoticonhelpbutton()
  editorshortcutshelpbutton()
  notice()
  notice_yesno()
  error_get_last()
  redirect()
  redirect()
  notify()
  obfuscate_email()
  obfuscate_text()
  obfuscate_mailto()
  print_paging_bar()
  rebuildnolinktag()
  print_side_block()
  print_side_block_start()
  print_side_block_end()
  print_speller_code()
  print_speller_button()
  page_id_and_class()
  print_maintenance_message()
  adjust_allowed_tags()

tabobject:: (14 methods):
  tabobject()
  print_tabs()
  convert_tree_to_html()
  convert_tabrows_to_tree()
  page_doc_link()
  doc_link()
  debugging()
  disable_debugging()
  frametarget()
  print_location_comment()
  print_arrow()
  right_to_left()
  fix_align_rtl()
  is_in_popup()

Defines 14 functions

  s()
  p()
  addslashes_js()
  strip_querystring()
  get_referer()
  me()
  qualified_me()

Class: moodle_url  - X-Ref

Class for creating and manipulating urls.

See short write up here http://docs.moodle.org/en/Development:lib/weblib.php_moodle_url
moodle_url($url = null, $params = array()   X-Ref
Pass no arguments to create a url that refers to this page. Use empty string to create empty url.

param: string $url url default null means use this page url with no query string
param: array $params these params override anything in the query string where params have the same name.

params($params)   X-Ref
Add an array of params to the params for this page. The added params override existing ones if they
have the same name.

param: array $params

remove_params()   X-Ref
Remove all params if no arguments passed. Or else remove param $arg1, $arg2, etc.

param: string $arg1
param: string $arg2
param: string $arg3

param($paramname, $param)   X-Ref
Add a param to the params for this page. The added param overrides existing one if they
have the same name.

param: string $paramname name
param: string $param value

get_query_string($overrideparams = array()   X-Ref
No description

hidden_params_out($exclude = array()   X-Ref
Outputs params as hidden form elements.

param: array $exclude params to ignore
param: integer $indent indentation
param: array $overrideparams params to add to the output params, these
return: string html for form elements.

out($noquerystring = false, $overrideparams = array()   X-Ref
Output url

param: boolean $noquerystring whether to output page params as a query string in the url.
param: array $overrideparams params to add to the output url, these override existing ones with the same name.
return: string url

out_action($overrideparams = array()   X-Ref
Output action url with sesskey

param: boolean $noquerystring whether to output page params as a query string in the url.
return: string url

data_submitted($url='')   X-Ref
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.

param: string $url not used anymore
return: mixed false or object

stripslashes_safe($mixed)   X-Ref
Moodle replacement for php stripslashes() function,
works also for objects and arrays.

The standard php stripslashes() removes ALL backslashes
even from strings - so  C:\temp becomes C:temp - this isn't good.
This function should work as a fairly safe replacement
to be called on quoted AND unquoted strings (to be sure)

param: mixed something to remove unsafe slashes from
return: mixed

stripslashes_recursive($var)   X-Ref
Recursive implementation of stripslashes()

This function will allow you to strip the slashes from a variable.
If the variable is an array or object, slashes will be stripped
from the items (or properties) it contains, even if they are arrays
or objects themselves.

param: mixed the variable to remove slashes from
return: mixed

addslashes_recursive($var)   X-Ref
Recursive implementation of addslashes()

This function will allow you to add the slashes from a variable.
If the variable is an array or object, slashes will be added
to the items (or properties) it contains, even if they are arrays
or objects themselves.

param: mixed the variable to add slashes from
return: mixed

break_up_long_words($string, $maxsize=20, $cutchar=' ')   X-Ref
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.

param: string $string the string to be modified
param: int $maxsize maximum length of the string to be returned
param: string $cutchar the string used to represent word breaks
return: string

str_ireplace($find, $replace, $string)   X-Ref
This does a search and replace, ignoring case
This function is only used for versions of PHP older than version 5
which do not have a native version of this function.
Taken from the PHP manual, by bradhuizenga @ softhome.net

param: string $find the string to search for
param: string $replace the string to replace $find with
param: string $string the string to search through

stripos($haystack, $needle, $offset=0)   X-Ref
Locate the position of a string in another string

This function is only used for versions of PHP older than version 5
which do not have a native version of this function.
Taken from the PHP manual, by dmarsh @ spscc.ctc.edu

param: string $haystack The string to be searched
param: string $needle The string to search for
param: int $offset The position in $haystack where the search should begin.

element_to_popup_window($type=null, $url=null, $name=null, $linkname=null,$height=400, $width=500, $title=null,$options=null, $return=false, $id=null, $class=null)   X-Ref
This function will print a button/link/etc. form element
that will work on both Javascript and non-javascript browsers.
Relies on the Javascript function openpopup in javascript.php

All parameters default to null, only $type and $url are mandatory.

$url must be relative to home page  eg /mod/survey/stuff.php
param: string $url Web link relative to home page
param: string $name Name to be assigned to the popup window (this is used by
param: string $linkname Text to be displayed as web link
param: int $height Height to assign to popup window
param: int $width Height to assign to popup window
param: string $title Text to be displayed as popup page title
param: string $options List of additional options for popup window
param: string $return If true, return as a string, otherwise print
param: string $id id added to the element
param: string $class class added to the element
return: string

link_to_popup_window($url, $name=null, $linkname=null,$height=400, $width=500, $title=null,$options=null, $return=false)   X-Ref
Creates and displays (or returns) a link to a popup window, using element_to_popup_window function.

return: string html code to display a link to a popup window.

button_to_popup_window($url, $name=null, $linkname=null,$height=400, $width=500, $title=null, $options=null, $return=false,$id=null, $class=null)   X-Ref
Creates and displays (or returns) a buttons to a popup window, using element_to_popup_window function.

return: string html code to display a button to a popup window.

close_window_button($name='closewindow', $return=false)   X-Ref
Prints a simple button to close a window

param: string $name name of the window to close
param: boolean $return whether this function should return a string or output it
return: string if $return is true, nothing otherwise

close_window($delay=0)   X-Ref
No description

close_this_window()   X-Ref
No description

choose_from_menu($options, $name, $selected='', $nothing='choose', $script='',$nothingvalue='0', $return=false, $disabled=false, $tabindex=0, $id='')   X-Ref
Given an array of values, output the HTML for a select element with those options.
Normally, you only need to use the first few parameters.

param: array $options The options to offer. An array of the form
param: string $name the name of this form control, as in <select name="..." ...
param: string $selected the option to select initially, default none.
param: string $nothing The label for the 'nothing is selected' option. Defaults to get_string('choose').
param: string $script in not '', then this is added to the <select> element as an onchange handler.
param: string $nothingvalue The value corresponding to the $nothing option. Defaults to 0.
param: boolean $return if false (the default) the the output is printed directly, If true, the
param: boolean $disabled if true, the select is generated in a disabled state. Default, false.
param: int $tabindex if give, sets the tabindex attribute on the <select> element. Default none.
param: string $id value to use for the id attribute of the <select> element. If none is given,

choose_from_menu_yesno($name, $selected, $script = '',$return = false, $disabled = false, $tabindex = 0)   X-Ref
Choose value 0 or 1 from a menu with options 'No' and 'Yes'.
Other options like choose_from_menu.

param: string $name
param: string $selected
param: string $string (defaults to '')
param: boolean $return whether this function should return a string or output it (defaults to false)
param: boolean $disabled (defaults to false)
param: int $tabindex

choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$script = '',$nothingvalue=0,$return=false,$disabled=false,$tabindex=0)   X-Ref
Just like choose_from_menu, but takes a nested array (2 levels) and makes a dropdown menu
including option headings with the first level.


choose_from_radio($options, $name, $checked='', $return=false)   X-Ref
Given an array of values, creates a group of radio buttons to be part of a form

param: array  $options  An array of value-label pairs for the radio group (values as keys)
param: string $name     Name of the radiogroup (unique in the form)
param: string $checked  The value that is already checked

print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='',$return=false)   X-Ref
No description

print_textfield($name, $value, $alt = '',$size=50,$maxlength=0, $return=false)   X-Ref
No description

popup_form($common, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false,$targetwindow='self', $selectlabel='', $optionsextra=NULL)   X-Ref
Implements a complete little popup form

param: string $common  The URL up to the point of the variable that changes
param: array $options  Alist of value-label pairs for the popup list
param: string $formid Id must be unique on the page (originaly $formname)
param: string $selected The option that is already selected
param: string $nothing The label for the "no choice" option
param: string $help The name of a help page if help is required
param: string $helptext The name of the label for the help button
param: boolean $return Indicates whether the function should return the text
param: string $targetwindow The name of the target page to open the linked page in.
param: string $selectlabel Text to place in a [label] element - preferred for accessibility.
param: array $optionsextra TODO, an array?
return: string If $return is true then the entire form is returned as a string.

formerr($error)   X-Ref
Prints some red text

param: string $error The text to be displayed in red

validate_email($address)   X-Ref
Validates an email to make sure it makes sense.

param: string $address The email address to validate.
return: boolean

get_file_argument($scriptname)   X-Ref
Extracts file argument either from file parameter or PATH_INFO

param: string $scriptname name of the calling script
return: string file path (only safe characters)

get_slash_arguments($file='file.php')   X-Ref
Searches the current environment variables for some slash arguments

param: string $file ?

parse_slash_arguments($string, $i=0)   X-Ref
Extracts arguments from "/foo/bar/something"
eg http://mysite.com/script.php/foo/bar/something

param: string $string ?
param: int $i ?
return: array|string

format_text_menu()   X-Ref
Just returns an array of text formats suitable for a popup menu

return: array

format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL)   X-Ref
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 format_string().

param: string $text The text to be formatted. This is raw text originally from user input.
param: int $format Identifier of the text format to be used
param: array $options ?
param: int $courseid ?
return: string

text_format_name( $key )   X-Ref
No description

reset_text_filters_cache()   X-Ref
Resets all data related to filters, called during upgrade or when filter settings change.

return: void

format_string($string, $striplinks=true, $courseid=NULL )   X-Ref
No description

format_text_email($text, $format)   X-Ref
Given text in a variety of format codings, this function returns
the text as plain text suitable for plain email.

param: string $text The text to be formatted. This is raw text originally from user input.
param: int $format Identifier of the text format to be used
return: string

filter_text($text, $courseid=NULL)   X-Ref
Given some text in HTML format, this function will pass it
through any filters that have been defined in $CFG->textfilterx
The variable defines a filepath to a file containing the
filter function.  The file must contain a variable called
$textfilter_function which contains the name of the function
with $courseid and $text parameters

param: string $text The text to be passed through format filters
param: int $courseid ?
return: string

filter_string($string, $courseid=NULL)   X-Ref
Given a string (short text) in HTML format, this function will pass it
through any filters that have been defined in $CFG->stringfilters
The variable defines a filepath to a file containing the
filter function.  The file must contain a variable called
$textfilter_function which contains the name of the function
with $courseid and $text parameters

param: string $string The text to be passed through format filters
param: int $courseid The id of a course
return: string

trusttext_present($text)   X-Ref
Is the text marked as trusted?

param: string $text text to be searched for TRUSTTEXT marker
return: boolean

trusttext_strip($text)   X-Ref
This funtion MUST be called before the cleaning or any other
function that modifies the data! We do not know the origin of trusttext
in database, if it gets there in tweaked form we must not convert it
to supported form!!!

Please be carefull not to use stripslashes on data from database
or twice stripslashes when processing data recieved from user.

param: string $text text that may contain TRUSTTEXT marker
return: text without any TRUSTTEXT marker

trusttext_mark($text)   X-Ref
Mark text as trusted, such text may contain any HTML tags because the
normal text cleaning will be bypassed.
Please make sure that the text comes from trusted user before storing
it into database!


trusttext_after_edit(&$text, $context)   X-Ref
No description

trusttext_prepare_edit(&$text, &$format, $usehtmleditor, $context)   X-Ref
No description

clean_text($text, $format=FORMAT_MOODLE)   X-Ref
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.

param: string $text The text to be cleaned
param: int $format Identifier of the text format to be used
return: string The cleaned up text

purify_html($text)   X-Ref
KSES replacement cleaning function - uses HTML Purifier.


cleanAttributes($str)   X-Ref
This function takes a string and examines it for HTML tags.
If tags are detected it passes the string to a helper function {@link cleanAttributes2()}
which checks for attributes and filters them for malicious content
17/08/2004              ::          Eamon DOT Costello AT dcu DOT ie

param: string $str The string to be examined for html tags
return: string

cleanAttributes2($htmlArray)   X-Ref
This function takes a string with an html tag and strips out any unallowed
protocols e.g. javascript:
It calls ancillary functions in kses which are prefixed by kses
17/08/2004              ::          Eamon DOT Costello AT dcu DOT ie

param: array $htmlArray An array from {@link cleanAttributes()}, containing in its 1st
return: string

replace_smilies(&$text)   X-Ref
Replaces all known smileys in the text with image equivalents

param: string $text Passed by reference. The string to search for smily strings.
return: string

text_to_html($text, $smiley=true, $para=true, $newlines=true)   X-Ref
Given plain text, makes it into HTML as nicely as possible.
May contain HTML tags already

param: string $text The string to convert.
param: boolean $smiley Convert any smiley characters to smiley images?
param: boolean $para If true then the returned string will be wrapped in paragraph tags
param: boolean $newlines If true then lines newline breaks will be converted to HTML newline breaks.
return: string

markdown_to_html($text)   X-Ref
Given Markdown formatted text, make it into XHTML using external function

param: string $text The markdown formatted text to be converted.
return: string Converted text

html_to_text($html)   X-Ref
Given HTML text, make it into plain text using external function

param: string $html The text to be converted.
return: string

convert_urls_into_links(&$text)   X-Ref
Given some text this function converts any URLs it finds into HTML links

param: string $text Passed in by reference. The string to be searched for urls.

highlight($needle, $haystack, $case=0,$left_string='<span class="highlight">', $right_string='</span>')   X-Ref
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.
Function found here: http://forums.devshed.com/t67822/scdaa2d1c3d4bacb4671d075ad41f0854.html

param: string $needle The string to search for
param: string $haystack The string to search for $needle in
param: int $case whether to do case-sensitive or insensitive matching.
return: string

highlightfast($needle, $haystack)   X-Ref
This function will highlight instances of $needle in $haystack
It's faster that the above function and doesn't care about
HTML or anything.

param: string $needle The string to search for
param: string $haystack The string to search for $needle in
return: string

get_html_lang($dir = false)   X-Ref
Return a string containing 'lang', xml:lang and optionally 'dir' HTML attributes.
Internationalisation, for print_header and backup/restorelib.

param: $dir Default false.
return: string Attributes.

skip_main_destination()   X-Ref
Return the markup for the destination of the 'Skip to main content' links.
Accessibility improvement for keyboard-only users.
Used in course formats, /index.php and /course/index.php

return: string HTML element.

print_header($title='', $heading='', $navigation='', $focus='',$meta='', $cache=true, $button='&nbsp;', $menu='',$usexml=false, $bodytags='', $return=false)   X-Ref
Print a standard header

param: string  $title Appears at the top of the window
param: string  $heading Appears at the top of the page
param: array   $navigation Array of $navlinks arrays (keys: name, link, type) for use as breadcrumbs links
param: string  $focus Indicates form element to get cursor focus on load eg  inputform.password
param: string  $meta Meta tags to be added to the header
param: boolean $cache Should this page be cacheable?
param: string  $button HTML code for a button (usually for module editing)
param: string  $menu HTML code for a popup menu
param: boolean $usexml use XML for this page
param: string  $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
param: bool    $return If true, return the visible elements of the header instead of echoing them.

require_js($lib,$extracthtml=0)   X-Ref
Used to include JavaScript libraries.

When the $lib parameter is given, the function will ensure that the
named library is loaded onto the page - either in the HTML <head>,
just after the header, or at an arbitrary later point in the page,
depending on where this function is called.

Libraries will not be included more than once, so this works like
require_once in PHP.

There are two special-case calls to this function which are both used only
by weblib print_header:
$extracthtml = 1: this is used before printing the header.
It returns the script tag code that should go inside the <head>.
$extracthtml = 2: this is used after printing the header and handles any
require_js calls that occurred within the header itself.

param: mixed $lib - string or array of strings
param: int $extracthtml Do not set this parameter usually (leave 0), only
return: mixed No return value, except when using $extracthtml it returns the html code.

get_require_js_code($loadlibs)   X-Ref
Should not be called directly - use require_js. This function obtains the code
(script tags) needed to include JavaScript libraries.

param: array $loadlibs Array of library files to include
return: string HTML code to include them

force_strict_header($output)   X-Ref
Debugging aid: serve page as 'application/xhtml+xml' where possible,
and substitute the XHTML strict document type.
Note, requires the 'xmlns' fix in function print_header above.
See:  http://tracker.moodle.org/browse/MDL-7883
TODO:


print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',$cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='', $return=false)   X-Ref
This version of print_header is simpler because the course name does not have to be
provided explicitly in the strings. It can be used on the site page as in courses
Eventually all print_header could be replaced by print_header_simple

param: string $title Appears at the top of the window
param: string $heading Appears at the top of the page
param: string $navigation Premade navigation string (for use as breadcrumbs links)
param: string $focus Indicates form element to get cursor focus on load eg  inputform.password
param: string $meta Meta tags to be added to the header
param: boolean $cache Should this page be cacheable?
param: string $button HTML code for a button (usually for module editing)
param: string $menu HTML code for a popup menu
param: boolean $usexml use XML for this page
param: string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
param: bool   $return If true, return the visible elements of the header instead of echoing them.

print_footer($course=NULL, $usercourse=NULL, $return=false)   X-Ref
Can provide a course object to make the footer contain a link to
to the course home page, otherwise the link will go to the site home

param: mixed $course course object, used for course link button or
param: object $usercourse course used in user link
param: boolean $return output as string
return: mixed string or void

current_theme()   X-Ref
Returns the name of the current theme

return: string

current_category_theme($categoryid=0)   X-Ref
Retrieves the category theme if one exists, otherwise checks the parent categories.
Recursive function.

param: integer   $categoryid   id of the category to check
return: string    theme name

style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $forceconfig='', $lang='')   X-Ref
This function is called by stylesheets to set up the header
approriately as well as the current path

param: int $lastmodified ?
param: int $lifetime ?
param: string $thename ?

theme_setup($theme = '', $params=NULL)   X-Ref
No description

user_login_string($course=NULL, $user=NULL)   X-Ref
Returns text to be displayed to the user which reflects their login status

param: course $course {@link $COURSE} object containing course information
param: user $user {@link $USER} object containing user information
return: string

check_theme_arrows()   X-Ref
Tests whether $THEME->rarrow, $THEME->larrow have been set (theme/-/config.php).
If not it applies sensible defaults.

Accessibility: right and left arrow Unicode characters for breadcrumb, calendar,
search forum block, etc. Important: these are 'silent' in a screen-reader
(unlike &gt; &raquo;), and must be accompanied by text.

link_arrow_right($text, $url='', $accesshide=false, $addclass='')   X-Ref
Return the right arrow with text ('next'), and optionally embedded in a link.
See function above, check_theme_arrows.

param: string $text HTML/plain text label (set to blank only for breadcrumb separator cases).
param: string $url An optional link to use in a surrounding HTML anchor.
param: bool $accesshide True if text should be hidden (for screen readers only).
param: string $addclass Additional class names for the link, or the arrow character.
return: string HTML string.

link_arrow_left($text, $url='', $accesshide=false, $addclass='')   X-Ref
Return the left arrow with text ('previous'), and optionally embedded in a link.
See function above, check_theme_arrows.

param: string $text HTML/plain text label (set to blank only for breadcrumb separator cases).
param: string $url An optional link to use in a surrounding HTML anchor.
param: bool $accesshide True if text should be hidden (for screen readers only).
param: string $addclass Additional class names for the link, or the arrow character.
return: string HTML string.

get_accesshide($text, $elem='span', $class='', $attrs='')   X-Ref
Return a HTML element with the class "accesshide", for accessibility.
Please use cautiously - where possible, text should be visible!

param: string $text Plain text.
param: string $elem Lowercase element name, default "span".
param: string $class Additional classes for the element.
param: string $attrs Additional attributes string in the form, "name='value' name2='value2'"
return: string HTML string.

get_separator()   X-Ref
Return the breadcrumb trail navigation separator.

return: string HTML string.

print_navigation($navigation, $separator=0, $return=false)   X-Ref
Prints breadcrumb trail of links, called in theme/-/header.html

param: mixed $navigation The breadcrumb navigation string to be printed
param: string $separator The breadcrumb trail separator. The default 0 leads to the use
param: boolean $return False to echo the breadcrumb string (default), true to return it.

build_navigation($extranavlinks, $cm = null)   X-Ref
This function will build the navigation string to be used by print_header
and others.

It automatically generates the site and course level (if appropriate) links.

If you pass in a $cm object, the method will also generate the activity (e.g. 'Forums')
and activityinstances (e.g. 'General Developer Forum') navigation levels.

If you want to add any further navigation links after the ones this function generates,
the pass an array of extra link arrays like this:
array(
array('name' => $linktext1, 'link' => $url1, 'type' => $linktype1),
array('name' => $linktext2, 'link' => $url2, 'type' => $linktype2)
)
The normal case is to just add one further link, for example 'Editing forum' after
'General Developer Forum', with no link.
To do that, you need to pass
array(array('name' => $linktext, 'link' => '', 'type' => 'title'))
However, becuase this is a very common case, you can use a shortcut syntax, and just
pass the string 'Editing forum', instead of an array as $extranavlinks.

At the moment, the link types only have limited significance. Type 'activity' is
recognised in order to implement the $CFG->hideactivitytypenavlink feature. Types
that are known to appear are 'home', 'course', 'activity', 'activityinstance' and 'title'.
This really needs to be documented better. In the mean time, try to be consistent, it will
enable people to customise the navigation more in future.

When passing a $cm object, the fields used are $cm->modname, $cm->name and $cm->course.
If you get the $cm object using the function get_coursemodule_from_instance or
get_coursemodule_from_id (as recommended) then this will be done for you automatically.
If you don't have $cm->modname or $cm->name, this fuction will attempt to find them using
the $cm->module and $cm->instance fields, but this takes extra database queries, so a
warning is printed in developer debug mode.

param: mixed $extranavlinks - Normally an array of arrays, keys: name, link, type. If you
param: mixed $cm - optionally the $cm object, if you want this function to generate the
return: $navigation as an object so it can be differentiated from old style

print_headline($text, $size=2, $return=false)   X-Ref
Prints a string in a specified size  (retained for backward compatibility)

param: string $text The text to be displayed
param: int $size The size to set the font for text display.

print_heading($text, $align='', $size=2, $class='main', $return=false)   X-Ref
Prints text in a format for use in headings.

param: string $text The text to be displayed
param: string $align The alignment of the printed paragraph of text
param: int $size The size to set the font for text display.

print_heading_with_help($text, $helppage, $module='moodle', $icon='', $return=false)   X-Ref
Centered heading with attached help button (same title text)
and optional icon attached

param: string $text The text to be displayed
param: string $helppage The help page to link to
param: string $module The module whose help should be linked to
param: string $icon Image to display if needed

print_heading_block($heading, $class='', $return=false)   X-Ref
No description

print_continue($link, $return=false)   X-Ref
Print a link to continue on to another page.

param: string $link The url to create a link to.

print_box($message, $classes='generalbox', $ids='', $return=false)   X-Ref
Print a message in a standard themed box.
Replaces print_simple_box (see deprecatedlib.php)

param: string $message, the content of the box
param: string $classes, space-separated class names.
param: string $idbase
param: boolean $return, return as string or just print it
return: mixed string or void

print_box_start($classes='generalbox', $ids='', $return=false)   X-Ref
Starts a box using divs
Replaces print_simple_box_start (see deprecatedlib.php)

param: string $classes, space-separated class names.
param: string $idbase
param: boolean $return, return as string or just print it
return: mixed string or void

print_box_end($return=false)   X-Ref
Simple function to end a box (see above)
Replaces print_simple_box_end (see deprecatedlib.php)

param: boolean $return, return as string or just print it

print_container($message, $clearfix=false, $classes='', $idbase='', $return=false)   X-Ref
Print a message in a standard themed container.

param: string $message, the content of the container
param: boolean $clearfix clear both sides
param: string $classes, space-separated class names.
param: string $idbase
param: boolean $return, return as string or just print it
return: string or void

print_container_start($clearfix=false, $classes='', $idbase='', $return=false)   X-Ref
Starts a container using divs

param: boolean $clearfix clear both sides
param: string $classes, space-separated class names.
param: string $idbase
param: boolean $return, return as string or just print it
return: mixed string or void

print_container_end($return=false)   X-Ref
Simple function to end a container (see above)

param: boolean $return, return as string or just print it
return: mixed string or void

open_containers()   X-Ref
Returns number of currently open containers

return: int number of open containers

print_container_end_all($return=false, $keep=0)   X-Ref
Force closing of open containers

param: boolean $return, return as string or just print it
param: int $keep number of containers to be kept open - usually theme or page containers
return: mixed string or void

_print_custom_corners_start($clearfix=false, $classes='', $idbase='')   X-Ref
Internal function - do not use directly!
Starting part of the surrounding divs for custom corners

param: boolean $clearfix, add CLASS "clearfix" to the inner div against collapsing
param: string $classes
param: mixed $idbase, optionally, define one idbase to be added to all the elements in the corners
return: string

_print_custom_corners_end($idbase)   X-Ref
Internal function - do not use directly!
Ending part of the surrounding divs for custom corners

param: string $idbase
return: string

print_single_button($link, $options, $label='OK', $method='get', $target='_self', $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='')   X-Ref
Print a self contained form with a single submit button.

param: string $link used as the action attribute on the form, so the URL that will be hit if the button is clicked.
param: array $options these become hidden form fields, so these options get passed to the script at $link.
param: string $label the caption that appears on the button.
param: string $method HTTP method used on the request of the button is clicked. 'get' or 'post'.
param: string $target no longer used.
param: boolean $return if false, output the form directly, otherwise return the HTML as a string.
param: string $tooltip a tooltip to add to the button as a title attribute.
param: boolean $disabled if true, the button will be disabled.
param: string $jsconfirmmessage if not empty then display a confirm dialogue with this string as the question.
return: string / nothing depending on the $return paramter.

print_spacer($height=1, $width=1, $br=true, $return=false)   X-Ref
Print a spacer image with the option of including a line break.

param: int $height ?
param: int $width ?
param: boolean $br ?

print_file_picture($path, $courseid=0, $height='', $width='', $link='', $return=false)   X-Ref
Given the path to a picture file in a course, or a URL,
this function includes the picture in the page.

param: string $path ?
param: int $courseid ?
param: int $height ?
param: int $width ?
param: string $link ?

print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true)   X-Ref
Print the specified user's avatar.

If you pass a $user object that has id, picture, imagealt, firstname, lastname
you save a DB query.

param: int $user takes a userid, or a userobj
param: int $courseid ?
param: boolean $picture Print the user picture?
param: int $size Size in pixels.  Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatability
param: boolean $return If false print picture to current page, otherwise return the output as string
param: boolean $link Enclose printed image in a link to view specified course?
param: string $target link target attribute
param: boolean $alttext use username or userspecified text in image alt attribute

print_user($user, $course, $messageselect=false, $return=false)   X-Ref
Prints a summary of a user in a nice little box.

param: user $user A {@link $USER} object representing a user
param: course $course A {@link $COURSE} object representing a course

print_group_picture($group, $courseid, $large=false, $return=false, $link=true)   X-Ref
Print a specified group's avatar.

param: group $group A single {@link group} object OR array of groups.
param: int $courseid The course ID.
param: boolean $large Default small picture, or large.
param: boolean $return If false print picture, otherwise return the output as string
param: boolean $link Enclose image in a link to view specified course?
return: string

print_png($url, $sizex, $sizey, $return, $parameters='alt=""')   X-Ref
Print a png image.

param: string $url ?
param: int $sizex ?
param: int $sizey ?
param: boolean $return ?
param: string $parameters ?

print_table($table, $return=false)   X-Ref
Print a nicely formatted table.

param: array $table is an object with several properties.
param: bool $return whether to return an output string or echo now
return: boolean or $string

print_recent_activity_note($time, $user, $text, $link, $return=false, $viewfullnames=null)   X-Ref
No description

print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='')   X-Ref
Prints a basic textarea field.

param: boolean $usehtmleditor ?
param: int $rows ?
param: int $cols ?
param: null $width <b>Legacy field no longer used!</b>  Set to zero to get control over mincols
param: null $height <b>Legacy field no longer used!</b>  Set to zero to get control over minrows
param: string $name ?
param: string $value ?
param: int $courseid ?

use_html_editor($name='', $editorhidebuttons='', $id='')   X-Ref
Sets up the HTML editor on textareas in the current page.
If a field name is provided, then it will only be
applied to that field - otherwise it will be used
on every textarea in the page.

In most cases no arguments need to be supplied

param: string $name Form element to replace with HTMl editor by name

print_editor_config($editorhidebuttons='', $return=false)   X-Ref
No description

update_course_icon($courseid)   X-Ref
Returns a turn edit on/off button for course in a self contained form.
Used to be an icon, but it's now a simple form button

Note that the caller is responsible for capchecks.

param: int $courseid The course  to update by id as found in 'course' table
return: string

switchroles_form($courseid)   X-Ref
Returns a little popup menu for switching roles

param: int $courseid The course  to update by id as found in 'course' table
return: string

update_mymoodle_icon()   X-Ref
Returns a turn edit on/off button for course in a self contained form.
Used to be an icon, but it's now a simple form button

param: int $courseid The course  to update by id as found in 'course' table
return: string

update_tag_button($tagid)   X-Ref
Returns a turn edit on/off button for tag in a self contained form.

return: string

update_module_button($moduleid, $courseid, $string)   X-Ref
Prints the editing button on a module "view" page

param: type description

update_category_button($categoryid)   X-Ref
Prints the editing button on a category page

param: int $categoryid ?
return: string

update_categories_button()   X-Ref
Prints the editing button on categories listing

return: string

update_categories_search_button($search,$page,$perpage)   X-Ref
Prints the editing button on search results listing
For bulk move courses to another category


navmenu($course, $cm=NULL, $targetwindow='self')   X-Ref
Given a course and a (current) coursemodule
This function returns a small popup menu with all the
course activity modules in it, as a navigation menu
The data is taken from the serialised array stored in
the course record

param: course $course A {@link $COURSE} object.
param: course $cm A {@link $COURSE} object.
param: string $targetwindow ?
return: string

navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $width=50, $cmid=0)   X-Ref
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

param: course $course A {@link $COURSE} object.
return: string

print_date_selector($day, $month, $year, $currenttime=0, $return=false)   X-Ref
Prints form items with the names $day, $month and $year

param: string $day   fieldname
param: string $month  fieldname
param: string $year  fieldname
param: int $currenttime A default timestamp in GMT
param: boolean $return

print_time_selector($hour, $minute, $currenttime=0, $step=5, $return=false)   X-Ref
Prints form items with the names $hour and $minute

param: string $hour  fieldname
param: string ? $minute  fieldname
param: $currenttime A default timestamp in GMT
param: int $step minute spacing
param: boolean $return

print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit', $return=false)   X-Ref
Prints time limit value selector

param: int $timelimit default
param: string $unit
param: string $name
param: boolean $return

print_grade_menu($courseid, $name, $current, $includenograde=true, $return=false)   X-Ref
Prints a grade menu (as part of an existing form) with help
Showing all possible numerical grades and scales

param: int $courseid ?
param: string $name ?
param: string $current ?
param: boolean $includenograde ?

print_scale_menu($courseid, $name, $current, $return=false)   X-Ref
Prints a scale menu (as part of an existing form) including help button
Just like {@link print_grade_menu()} but without the numeric grades

param: int $courseid ?
param: string $name ?
param: string $current ?

print_scale_menu_helpbutton($courseid, $scale, $return=false)   X-Ref
Prints a help button about a scale

param: id $courseid ?
param: object $scale ?

print_error($errorcode, $module='error', $link='', $a=NULL, $extralocations=NULL)   X-Ref
Print an error page displaying an error message.  New method - use this for new code.

param: string $errorcode The name of the string from error.php (or other specified file) to print
param: string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
param: object $a Extra words and phrases that might be required in the error string
param: array $extralocations An array of strings with other locations to look for string files
return: does not return, terminates script

mdie($msg='', $errorcode=1)   X-Ref
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");

param: string  $msg       Error message
param: integer $errorcode Error code to emit

editorhelpbutton()   X-Ref
Returns a string of html with an image of a help icon linked to a help page on a number of help topics.
Should be used only with htmleditor or textarea.

param: mixed $helptopics variable amount of params accepted. Each param may be a string or an array of arguments for
return: string

helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false,$imagetext='')   X-Ref
Print a help button.

param: string $page  The keyword that defines a help page
param: string $title The title of links, rollover tips, alt tags etc
param: string $module Which module is the page defined in
param: mixed $image Use a help image for the link?  (true/false/"both")
param: boolean $linktext If true, display the title next to the help icon.
param: string $text If defined then this text is used in the page, and
param: boolean $return If true then the output is returned as a string, if false it is printed to the current page.
param: string $imagetext The full text for the helpbutton icon. If empty use default help.gif
return: string

emoticonhelpbutton($form, $field, $return = false)   X-Ref
Print a help button.

Prints a special help button that is a link to the "live" emoticon popup
param: string $form ?
param: string $field ?

editorshortcutshelpbutton()   X-Ref
Print a help button.

Prints a special help button for html editors (htmlarea in this case)

notice($message, $link='', $course=NULL)   X-Ref
Print a message and exit.

param: string $message ?
param: string $link ?

notice_yesno($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno=NULL, $methodyes='post', $methodno='post')   X-Ref
Print a message along with "Yes" and "No" links for the user to continue.

param: string $message The text to display
param: string $linkyes The link to take the user to if they choose "Yes"
param: string $linkno The link to take the user to if they choose "No"

error_get_last()   X-Ref
No description

redirect($url, $message='', $delay=-1)   X-Ref
Redirects the user to another page, after printing a notice

param: string $url The url to take the user to
param: string $message The text message to display to the user about the redirect, if any
param: string $delay How long before refreshing to the new page at $url?

redirect()   X-Ref
No description

notify($message, $style='notifyproblem', $align='center', $return=false)   X-Ref
Print a bold message in an optional color.

param: string $message The message to print out
param: string $style Optional style to display message text in
param: string $align Alignment option
param: bool $return whether to return an output string or echo now

obfuscate_email($email)   X-Ref
Given an email address, this function will return an obfuscated version of it

param: string $email The email address to obfuscate
return: string

obfuscate_text($plaintext)   X-Ref
This function takes some text and replaces about half of the characters
with HTML entity equivalents.   Return string is obviously longer.

param: string $plaintext The text to be obfuscated
return: string

obfuscate_mailto($email, $label='', $dimmed=false)   X-Ref
This function uses the {@link obfuscate_email()} and {@link obfuscate_text()}
to generate a fully obfuscated email link, ready to use.

param: string $email The email address to display
param: string $label The text to dispalyed as hyperlink to $email
param: boolean $dimmed If true then use css class 'dimmed' for hyperlink
return: string

print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page',$nocurr=false, $return=false)   X-Ref
Prints a single paging bar to provide access to other pages  (usually in a search)

param: int $totalcount Thetotal number of entries available to be paged through
param: int $page The page you are currently viewing
param: int $perpage The number of entries that should be shown per page
param: mixed $baseurl If this  is a string then it is the url which will be appended with $pagevar, an equals sign and the page number.
param: string $pagevar This is the variable name that you use for the page number in your code (ie. 'tablepage', 'blogpage', etc)
param: bool $nocurr do not display the current page as a link
param: bool $return whether to return an output string or echo now
return: bool or string

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

param: string $text Text to search for nolink tag in
return: string

print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array()   X-Ref
Prints a nice side block with an optional header.  The content can either
be a block of HTML or a list of text with optional icons.

param: string $heading Block $title embedded in HTML tags, for example <h2>.
param: string $content ?
param: array $list ?
param: array $icons ?
param: string $footer ?
param: array $attributes ?
param: string $title Plain text title, as embedded in the $heading.

print_side_block_start($heading='', $attributes = array()   X-Ref
Starts a nice side block with an optional header.

param: string $heading ?
param: array $attributes ?

print_side_block_end($attributes = array()   X-Ref
Print table ending tags for a side block box.


print_speller_code($usehtmleditor=false, $return=false)   X-Ref
Prints out code needed for spellchecking.
Original idea by Ludo (Marc Alier).

Opening CDATA and <script> are output by weblib::use_html_editor()
param: boolean $usehtmleditor Normally set by $CFG->htmleditor, can be overriden here
param: boolean $return If false, echos the code instead of returning it

print_speller_button()   X-Ref
Print button for spellchecking when editor is disabled


page_id_and_class(&$getid, &$getclass)   X-Ref
No description

print_maintenance_message()   X-Ref
Prints a maintenance message from /maintenance.html


adjust_allowed_tags()   X-Ref
Adjust the list of allowed tags based on $CFG->allowobjectembed and user roles (admin)


Class: tabobject  - X-Ref

tabobject($id, $link='', $text='', $title='', $linkedwhenselected=false)   X-Ref
No description

print_tabs($tabrows, $selected=NULL, $inactive=NULL, $activated=NULL, $return=false)   X-Ref
Returns a string containing a nested list, suitable for formatting into tabs with CSS.

param: array $tabrows An array of rows where each row is an array of tab objects
param: string $selected  The id of the selected tab (whatever row it's on)
param: array  $inactive  An array of ids of inactive tabs that are not selectable.
param: array  $activated An array of ids of other tabs that are currently activated

convert_tree_to_html($tree, $row=0)   X-Ref
No description

convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated)   X-Ref
No description

page_doc_link($text='', $iconpath='')   X-Ref
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.

param: string $text      The text to be displayed for the link
param: string $iconpath  The path to the icon to be displayed

doc_link($path='', $text='', $iconpath='')   X-Ref
Returns a string containing a link to the user documentation.
Also contains an icon by default. Shown to teachers and admin only.

param: string $path      The page link after doc root and language, no
param: string $text      The text to be displayed for the link
param: string $iconpath  The path to the icon to be displayed

debugging($message='', $level=DEBUG_NORMAL)   X-Ref
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 develpers', 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.


param: string $message a message to print
param: int $level the level at which this debugging statement should show
return: bool

disable_debugging()   X-Ref
Disable debug messages from debugging(), while keeping PHP error reporting level as is.


frametarget()   X-Ref
Returns string to add a frame attribute, if required


print_location_comment($file, $line, $return = false)   X-Ref
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).

param: string $file
param: integer $line
param: boolean $return Whether to return or print the comment
return: mixed Void unless true given as third parameter

print_arrow($direction='up', $strsort=null, $return=false)   X-Ref
Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
provide this function with the language strings for sortasc and sortdesc.
If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.

param: string $direction 'up' or 'down'
param: string $strsort The language string used for the alt attribute of this image
param: bool $return Whether to print directly or return the html string
return: string HTML for the image

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


fix_align_rtl($align)   X-Ref
Returns swapped left<=>right if in RTL environment.
part of RTL support

param: string $align align to check
return: string

is_in_popup()   X-Ref
Returns true if the page is displayed in a popup window.
Gets the information from the URL parameter inpopup.

return: boolean

Functions
Functions that are not part of a class:

s($var, $strip=false)   X-Ref
Add quotes to HTML characters

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

param: string $var the string potentially containing HTML characters
param: boolean $strip to decide if we want to strip slashes or no. Default to false.
return: string

p($var, $strip=false)   X-Ref
Add quotes to HTML characters

Prints $var with HTML characters (like "<", ">", etc.) properly quoted.
This function is very similar to {@link s()}

param: string $var the string potentially containing HTML characters
param: boolean $strip to decide if we want to strip slashes or no. Default to false.
return: string

addslashes_js($var)   X-Ref
Does proper javascript quoting.
Do not use addslashes anymore, because it does not work when magic_quotes_sybase is enabled.

param: mixed value
return: mixed quoted result

strip_querystring($url)   X-Ref
Remove query string from url

Takes in a URL and returns it without the querystring portion

param: string $url the url which may have a query string attached
return: string

get_referer($stripquery=true)   X-Ref
Returns the URL of the HTTP_REFERER, less the querystring portion if required

param: boolean $stripquery if true, also removes the query part of the url.
return: string

me()   X-Ref
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.)
<b>NOTE:</b> This function returns false if the global variables needed are not set.

return: string

qualified_me()   X-Ref
Like {@link me()} but returns a full URL

return: string



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7