Source for file Common.php
Documentation is available at Common.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Adam Daniel <adaniel1@eesus.jnj.com> |
// +----------------------------------------------------------------------+
// $Id: Common.php 6184 2005-09-07 10:08:17Z bmol $
* Base class for all HTML classes
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* Associative array of table attributes
* Tab offset of the table
* Contains the line end string
* HTML comment on the object
* @param mixed $attributes Associative array of table tag attributes
* or HTML attributes name="value" pairs
* @param int $tabOffset Indent offset in tabs
function HTML_Common($attributes = null, $tabOffset = 0)
* Returns the current API version
* Returns a string containing the unit for indenting HTML
* Returns a string containing the offset for the whole HTML code
* Returns an HTML formatted attribute string
* @param array $attributes
foreach ($attributes as $key => $value) {
} // end func _getAttrString
* Returns a valid atrributes array from either a string or array
* @param mixed $attributes Either a typical HTML attribute string or an associative array
foreach ($attributes as $key => $value) {
$preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" .
"([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/";
for ($counter= 0; $counter< count($regs[1]); $counter++ ) {
$name = $regs[1][$counter];
$check = $regs[0][$counter];
$value = $regs[7][$counter];
if (substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") {
$value = substr($value, 1, - 1);
} // end func _parseAttributes
* Returns the array key for the given non-name-value pair attribute
* @param string $attr Attribute
* @param array $attributes Array of attribute
* 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
foreach ($attr2 as $key => $value) {
} // end func _updateAtrrArray
* Removes the given attribute from the given array
* @param string $attr Attribute name
* @param array $attributes Attribute array
if (isset ($attributes[$attr])) {
unset ($attributes[$attr]);
* Returns the value of the given attribute
* @param string $attr Attribute name
} //end func getAttribute
* Sets the HTML attributes
* @param mixed $attributes Either a typical HTML attribute string or an associative array
} // end func setAttributes
* Returns the assoc array (default) or string of attributes
* @param bool Whether to return the attributes as string
* @return mixed attributes
} //end func getAttributes
* Updates the passed attributes without changing the other existing attributes
* @param mixed $attributes Either a typical HTML attribute string or an associative array
} // end func updateAttributes
* @param string $attr Attribute name
} //end func removeAttribute
* Sets the line end style to Windows, Mac, Unix or a custom string.
* @param string $style "win", "mac", "unix" or custom string.
} // end func setTabOffset
} //end func getTabOffset
* Sets the string used to indent HTML
* @param string $string String used to indent ("\11", "\t", ' ', etc.).
* Sets the HTML comment to be displayed at the beginning of the HTML string
} // end func setHtmlComment
* Returns the HTML comment
* Abstract method. Must be extended to return the objects HTML
* Displays the HTML to the screen
} // end class HTML_Common
|