adaniel Thu Mar 22 18:13:19 2001 EDT
Modified files:
/php4/pear/HTML Common.php
Log:
updated some comments, added display method, and added the toHtml abstract method
Index: php4/pear/HTML/Common.php
diff -u php4/pear/HTML/Common.php:1.4 php4/pear/HTML/Common.php:1.5
--- php4/pear/HTML/Common.php:1.4 Thu Mar 22 17:11:59 2001
+++ php4/pear/HTML/Common.php Thu Mar 22 18:13:18 2001
@@ -16,37 +16,38 @@
// | Authors: Adam Daniel <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.4 2001/03/23 01:11:59 adaniel Exp $
+// $Id: Common.php,v 1.5 2001/03/23 02:13:18 adaniel Exp $
/**
-* Base class for all HTML classes
-*
-* @author Adam Daniel <[EMAIL PROTECTED]>
-* @version 1.3
-* @since PHP 4.0.3pl1
-*/
+ * Base class for all HTML classes
+ *
+ * @author Adam Daniel <[EMAIL PROTECTED]>
+ * @version 1.3
+ * @since PHP 4.0.3pl1
+ * @abstract
+ */
class HTML_Common {
/**
- * Associative array of table attributes
- * @var array
- * @access private
- */
+ * Associative array of table attributes
+ * @var array
+ * @access private
+ */
var $_attributes = array();
/**
- * Tab offset of the table
- * @var int
- * @access private
- */
+ * Tab offset of the table
+ * @var int
+ * @access private
+ */
var $_tabOffset = 0;
/**
- * Class constructor
- * @param mixed $attributes Associative array of table tag attributes
- * or HTML attributes name="value" pairs
- * @access public
- */
+ * Class constructor
+ * @param mixed $attributes Associative array of table tag attributes
+ * or HTML attributes name="value" pairs
+ * @access public
+ */
function HTML_Common($attributes=null, $tabOffset=0)
{
$this->setTabOffset($tabOffset);
@@ -54,30 +55,30 @@
} // end constructor
/**
- * Returns the current API version
- * @access public
- * @returns double
- */
+ * Returns the current API version
+ * @access public
+ * @returns double
+ */
function apiVersion()
{
return 1.3;
} // end func apiVersion
/**
- * Returns a string of \t for the tabOffset property
- * @access private
- */
+ * Returns a string of \t for the tabOffset property
+ * @access private
+ */
function _getTabs()
{
return $this->_tabOffset > 0 ? str_repeat("\t", $this->_tabOffset) : "";
} // end func _getTabs
/**
- * Returns an HTML formatted attribute string
- * @param array $attributes
- * @return string
- * @access private
- */
+ * Returns an HTML formatted attribute string
+ * @param array $attributes
+ * @return string
+ * @access private
+ */
function _getAttrString($attributes)
{
$strAttr = "";
@@ -94,10 +95,10 @@
} // 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
- * @access private
- */
+ * Returns a valid atrributes array from either a string or array
+ * @param mixed $attributes Either a typical HTML attribute string or an
+associative array
+ * @access private
+ */
function _parseAttributes($attributes)
{
if (is_array($attributes)) {
@@ -127,12 +128,12 @@
} // end func _parseAttributes
/**
- * 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
- * @access private
- * @return array
- */
+ * 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
+ * @access private
+ * @return array
+ */
function _updateAttrArray(&$attr1, $attr2)
{
while (list($key, $value) = each($attr2)) {
@@ -162,20 +163,20 @@
} // end func _updateAtrrArray
/**
- * Sets the HTML attributes
- * @param mixed $attributes Either a typical HTML attribute string or an
associative array
- * @access public
- */
+ * Sets the HTML attributes
+ * @param mixed $attributes Either a typical HTML attribute string or an
+associative array
+ * @access public
+ */
function setAttributes($attributes)
{
$this->_attributes = $this->_parseAttributes($attributes);
} // end func _setAttributes
/**
- * Updates the passed attributes without changing the other existing attributes
- * @param mixed $attributes Either a typical HTML attribute string or an
associative array
- * @access public
- */
+ * Updates the passed attributes without changing the other existing attributes
+ * @param mixed $attributes Either a typical HTML attribute string or an
+associative array
+ * @access public
+ */
function updateAttributes($attributes)
{
$attributes = $this->_parseAttributes($attributes);
@@ -183,14 +184,36 @@
} // end func updateAttributes
/**
- * Sets the tab offset
- * @param int $offset
- * @access public
- */
+ * Sets the tab offset
+ * @param int $offset
+ * @access public
+ */
function setTabOffset($offset)
{
$this->_tabOffset = $offset;
} // end func setTabOffset
+ /**
+ * Abstract method. Must be extended to return the objects HTML
+ *
+ * @access public
+ * @return string
+ * @abstract
+ */
+ function toHtml()
+ {
+ return "";
+ } // end func toHtml
+
+ /**
+ * Displays the HTML to the screen
+ *
+ * @access public
+ */
+ function display()
+ {
+ print $this->toHtml();
+ } // end func display
+
} // end class HTML_Common
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]