Getting and setting values
getInstance()
This is the singleton accessor. It should always be called as &getInstance(). The first time it's called, it initializes the DTD, character set (from the core language object), and loads any head tags stored in the mainframe object.Parameters:noneReturns:pointer to the static singleton object.
get()
Retrieves an object property. Returns null if the property is not set.Parameters:$var - the name of the property to retrieveReturns:The property named $var if set; null if not set
set()
Sets an object property. Ignored if the property name begins with an underscore. For example, $_tags is a pseudo-private property and can not be set using set().Parameters:$var - the name of the property to set$value - the value to set the property toReturns:none
useXmlPrologue()
Use this function to turn the xml prologue on or off. Also returns the value of the $useXmlPrologue property. When $useXmlPrologue is false, function renderXmlPrologue() will not render the prologue.Parameters:$flag - turns the xml prologue on and offReturns:A boolean value for $useXmlPrologue
tag()
Used to construct an html tag. Uses vsprintf(). Pass multiple variables in an array. Multiple variables are passed to string %s variables from left to right. For a list of available tags, see Class mosHtmlHelper/default properties.Parameters:$key - an array key from the $_tags array.$vars - an array of variables to pass to vsprintf(). Can be a string if passing a single variable.Returns:An html tag with $vars inserted from left to right.Examples:
Rendering tags
Rendering:Echoing a string to output wrapped in prepend and postpend strings. The default behavior is no prepend with a charriage return '\n' as the postpend.There are two basic methods of rendering a tag. The first is to use the default function render(). Using render() with a switch/case name contstructs a tag and automatically inserts information from the Mambo core. The second rendering method is to use one of the custom tag rendering functions. The custom render functions allow you to pass variables to a function to create a custom tag.
Examples:mosHtmlHelper::render('doctype');
mosHtmlHelper::renderCss('a/path/to/my/print_css.css', 'screen');
render()
Renders a string wrapped by prepend and postpend strings. Can also be used to call helper functions. For a list of available helper methods in this function, see the switch() function in Class mosHtmlHelper/code#render().Parameters:$string - the string to render. Can also call a rendering helper method.$postpend - a string to append to the string. Default is '\n'$prepend - a string to prepend to the string. Default is nullReturns:none
Rendering with helper methods
Use one of the rendering helper methods if you need to render a tag and insert your own tag parameters.
renderDoctype()
Renders a valid DTD. The default document type is read from $mosConfig_doctype. If $mosConfig_doctype is not set, the default is XHTML 1.0 Transitional.Parameters:$type - the DTD document type as an array key from $_docTypes. The default is the value of $mosConfig_doctype. For a list of available keys, see xxx.Returns:none
renderXmlPrologue()
Renders a valid xml prologue ONLY if $useXmlPrologue is true OR $doctype matches one of the array values in $_docTypesMobile. The default character set is taken from the Mambo language object. If not set in the language object, the default is utf-8.Parameters:$charset - passed to encoding="%s". Defaults to the Mambo language character set.Returns:none
renderTitle()
Renders a standard <title> tag.Parameters:$title - Passed to<title>%s</title>. Defaults to the Mambo page title.Returns:none
renderMeta()
Renders a standard <meta> tag.Parameters:$name - passed toname="%s"$content - passed tocontent="%s"Returns:none
renderMetaLink()
Renders a standard <link> tag.Parameters:$href - passed tohref="%s" $title - passed totitle="%s"Returns:none
renderMetaLinkRel()
Renders a rel type <link> tag.Parameters:$rel - passed torel="%s"$href - passed tohref="%s" Returns:none
renderCharset()
Renders a typical character set <meta> tag.Parameters:$charset - passed tocontent="text/html; charset=%s". Defaults to the Mambo character set.Returns:none
renderCss()
Renders a typical css <link> tag. If both $filepath and $media are empty, renders a standard css link tag using a default of /templates/some_template/css/template_css.css and if a 'print.css' file exists in the /css/ folder, it is also rendered with 'media="print"'Parameters:$filepath - passed to href="%s" $media - appended to the end of the tag as " media=%s" if non-emptyReturns:none
renderJavascript()
Renders a Javascript <script> block. Can be used to either load a js script file or to create a <script> block containing javascript code. Default behavior is to render the javascript block in $mosMainframe->_head['mambojavascript'].Parameters:$link - appended to <script> tag as ' src=%s'$code - a block of javascrip code excluding <script> tags. Causes $link to be ignored. $code is wrapped in standard javascript tags with charriage returns before and after the code.Returns:none
Utility Functions
showHead()
Can be used as a replacement for mosShowHead(). Allows for inclusion or exclusion of selected head tags.Parameters:$keys - a single key or array of keys from $mainframe->_head[]. Keys listed here will be rendered in the order listed.$exclude - exclude a single key or array of keys from $mainframe->_head[].Returns:none
showMeta()
loadHeadTags()
Loads head tags into the helper object from $mainframe->_head. Not normally needed outside the class.Parameters:noneReturns:none
docTypeIsMobile()
Checks a document type key and returns true if it matches one of the array values in $_docTypesMobile.Parameters:$key - the key to check. If $key is empty, the $doctype property is checked.Returns:boolean - true if mobile document type otherwise false.