Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

Base class for all HTML classes

Author: Adam Daniel <adaniel1@eesus.jnj.com>
Version: 1.2.2
File Size: 449 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

HTML_Common:: (2 methods):
  __construct()
  HTML_Common()

name:: (23 methods):
  raiseError()
  apiVersion()
  _getLineEnd()
  _getTab()
  _getTabs()
  _getAttrString()
  _parseAttributes()
  _getAttrKey()
  _updateAttrArray()
  _removeAttr()
  getAttribute()
  setAttributes()
  getAttributes()
  updateAttributes()
  removeAttribute()
  setLineEnd()
  setTabOffset()
  getTabOffset()
  setTab()
  setComment()
  getComment()
  toHtml()
  display()


Class: HTML_Common  - X-Ref

Base class for all HTML classes

__construct($attributes = null, $tabOffset = 0)   X-Ref
Class constructor

param: mixed   $attributes     Associative array of table tag attributes
param: int     $tabOffset      Indent offset in tabs

HTML_Common($attributes = null, $tabOffset = 0)   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

raiseError($message = null,$code = null,$mode = null,$options = null,$userinfo = null,$error_class = null,$skipmsg = false)   X-Ref
No description

apiVersion()   X-Ref
Returns the current API version

returns: double

_getLineEnd()   X-Ref
Returns the lineEnd

return: string

_getTab()   X-Ref
Returns a string containing the unit for indenting HTML

return: string

_getTabs()   X-Ref
Returns a string containing the offset for the whole HTML code

return: string

_getAttrString($attributes)   X-Ref
Returns an HTML formatted attribute string

param: array   $attributes
return: string

_parseAttributes($attributes)   X-Ref
Returns a valid atrributes array from either a string or array

param: mixed   $attributes     Either a typical HTML attribute string or an associative array

_getAttrKey($attr, $attributes)   X-Ref
Returns the array key for the given non-name-value pair attribute

param: string    $attr         Attribute
param: array     $attributes   Array of attribute
return: bool

_updateAttrArray(&$attr1, $attr2)   X-Ref
Updates the attributes in $attr1 with the values in $attr2 without changing the other existing attributes

param: array   $attr1      Original attributes array
param: array   $attr2      New attributes array

_removeAttr($attr, &$attributes)   X-Ref
Removes the given attribute from the given array

param: string    $attr           Attribute name
param: array     $attributes     Attribute array
return: void

getAttribute($attr)   X-Ref
Returns the value of the given attribute

param: string    $attr   Attribute name
return: void

setAttributes($attributes)   X-Ref
Sets the HTML attributes

param: mixed   $attributes     Either a typical HTML attribute string or an associative array

getAttributes($asString = false)   X-Ref
Returns the assoc array (default) or string of attributes

param: bool    Whether to return the attributes as string
return: mixed   attributes

updateAttributes($attributes)   X-Ref
Updates the passed attributes without changing the other existing attributes

param: mixed   $attributes     Either a typical HTML attribute string or an associative array

removeAttribute($attr)   X-Ref
Removes an attribute

param: string    $attr   Attribute name
return: void

setLineEnd($style)   X-Ref
Sets the line end style to Windows, Mac, Unix or a custom string.

param: string  $style  "win", "mac", "unix" or custom string.
return: void

setTabOffset($offset)   X-Ref
Sets the tab offset

param: int     $offset

getTabOffset()   X-Ref
Returns the tabOffset

return: int

setTab($string)   X-Ref
Sets the string used to indent HTML

param: string    $string     String used to indent ("\11", "\t", '  ', etc.).
return: void

setComment($comment)   X-Ref
Sets the HTML comment to be displayed at the beginning of the HTML string

param: string
return: void

getComment()   X-Ref
Returns the HTML comment

return: string

toHtml()   X-Ref
Abstract method.  Must be extended to return the objects HTML

return: string

display()   X-Ref
Displays the HTML to the screen