/program/lib/htmllib.php - useful functions for generating HTML-code
This file provides various utility routines that aid in creating HTML-code.
construct a href from a path, params and a fragment
construct an HTML A tag with optional parameters and attributes
this constructs an A tag of the form
<a href="$href?p1=v1&p2=v2 att1="val1" att2="val2">
If no parameters are specified, nothing is added to the href. If no attributes are specified the tag only has the href attribute If $params is an array, the elements of this array are added to the href after a rawurlencode(). The complete $href is then escaped via htmlspecialchars(). If $attributes is an array, all elements are added as escaped key-value-pairs. If string, then just append. If $anchor is not empty, the string is appended to the constructed opening tag and subsequently a closing tag is appended.
Note that urlencoding and specialchars are applied to the URL property and that the other properties are only are htmlspecialchars()'ed. The optional $anchor is not changed in any way.
Examples:
html_a('index.php'): <a href="index.php"> html_a('index.php',array('foo'=>'bar')): <a href="index.php?foo=bar"> html_a('index.php',array('x'=>'y'),array('title'=>'foo')): <a href="index.php?x=y" title="foo"> html_a('index.php','',array('class'=>'dimmed'),'baz'): <a href="index.php" class="dimmed">baz</a> html_a('','',array('name'=>'chapter1'),'chapter 1'): <a name="chapter1">chapter 1</a>
convert an array of name-value pairs to a string
this converts an array of name-value-pairs to a string containing attribute="content" items, where both 'attribute' and 'content' are properly escaped (with htmlspecialchars()). Properties that don't have content, such as 'disabled' or 'selected' or 'checked' can be specified using the special value NULL, e.g. array('disabled' => NULL). If the parameter $attributes happens to be a string, it is returned with a space prepended. If it is neither a string nor an array (e.g. NULL), an empty string is returned. Note that the attribute="content" elements are delimited with spaces, and that a leading space is prepended (but not trailing space is added).
construct the opening of a HTML form
companion of html_form: close the tag
construct an HTML IMG tag with optional attributes
this constructs an IMG tag of the form
If no attributes are specified the tag only has the src attribute If $attributes is an array, all elements are added as raw encoded key-value-pairs. If it is a string, then just append.
Examples:
html_img('icon.gif'): <img src="icon.gif"> html_img('icon.gif',array('width'=>16, 'height'=>16)): <img src="icon.gif" width="16" height="16">
STUB
STUB
STUB
STUB
construct the opening of a HTML table
construct table closing tag
construct a generic HTML-tag with attributes, optionally close it too
Documentation generated on Wed, 11 May 2011 23:45:13 +0200 by phpDocumentor 1.4.0