|
|
|
|
@ -1,46 +1,46 @@ |
|
|
|
|
<?php |
|
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Base class for all HTML classes |
|
|
|
|
* |
|
|
|
|
* PHP versions 4 and 5 |
|
|
|
|
* |
|
|
|
|
* LICENSE: This source file is subject to version 3.01 of the PHP license |
|
|
|
|
* that is available through the world-wide-web at the following URI: |
|
|
|
|
* http://www.php.net/license/3_01.txt If you did not receive a copy of |
|
|
|
|
* the PHP License and are unable to obtain it through the web, please |
|
|
|
|
* send a note to license@php.net so we can mail you a copy immediately. |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_Common |
|
|
|
|
* PHP versions 4 and 5 |
|
|
|
|
* |
|
|
|
|
* LICENSE: This source file is subject to version 3.01 of the PHP license |
|
|
|
|
* that is available through the world-wide-web at the following URI: |
|
|
|
|
* http://www.php.net/license/3_01.txt If you did not receive a copy of |
|
|
|
|
* the PHP License and are unable to obtain it through the web, please |
|
|
|
|
* send a note to license@php.net so we can mail you a copy immediately. |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_Common |
|
|
|
|
* @author Adam Daniel <adaniel1@eesus.jnj.com> |
|
|
|
|
* @copyright 2001-2009 The PHP Group |
|
|
|
|
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
|
|
|
|
* @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ |
|
|
|
|
* @link http://pear.php.net/package/HTML_Common/ |
|
|
|
|
* @copyright 2001-2009 The PHP Group |
|
|
|
|
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
|
|
|
|
* @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ |
|
|
|
|
* @link http://pear.php.net/package/HTML_Common/ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Base class for all HTML classes |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_Common |
|
|
|
|
* @author Adam Daniel <adaniel1@eesus.jnj.com> |
|
|
|
|
* @version Release: 1.2.5 |
|
|
|
|
/** |
|
|
|
|
* Base class for all HTML classes |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_Common |
|
|
|
|
* @author Adam Daniel <adaniel1@eesus.jnj.com> |
|
|
|
|
* @version Release: 1.2.5 |
|
|
|
|
* @abstract |
|
|
|
|
*/ |
|
|
|
|
class HTML_Common |
|
|
|
|
{ |
|
|
|
|
class HTML_Common |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* Associative array of attributes |
|
|
|
|
* Associative array of attributes |
|
|
|
|
* @var array |
|
|
|
|
* @access private |
|
|
|
|
*/ |
|
|
|
|
var $_attributes = array(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Tab offset of the tag |
|
|
|
|
* Tab offset of the tag |
|
|
|
|
* @var int |
|
|
|
|
* @access private |
|
|
|
|
*/ |
|
|
|
|
@ -139,7 +139,7 @@ class HTML_Common |
|
|
|
|
$strAttr = ''; |
|
|
|
|
|
|
|
|
|
if (is_array($attributes)) { |
|
|
|
|
$charset = HTML_Common::charset(); |
|
|
|
|
$charset = HTML_Common::charset(); |
|
|
|
|
foreach ($attributes as $key => $value) { |
|
|
|
|
// Modified by Ivan Tcholakov, 16-MAR-2010 |
|
|
|
|
//$strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; |
|
|
|
|
@ -154,7 +154,7 @@ class HTML_Common |
|
|
|
|
* 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 |
|
|
|
|
* @return array |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
function _parseAttributes($attributes) |
|
|
|
|
{ |
|
|
|
|
@ -182,9 +182,9 @@ class HTML_Common |
|
|
|
|
$arrAttr[strtolower(trim($name))] = strtolower(trim($name)); |
|
|
|
|
} else { |
|
|
|
|
if (substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") { |
|
|
|
|
$arrAttr[strtolower(trim($name))] = substr($value, 1, -1); |
|
|
|
|
} else { |
|
|
|
|
$arrAttr[strtolower(trim($name))] = trim($value); |
|
|
|
|
$arrAttr[strtolower(trim($name))] = substr($value, 1, -1); |
|
|
|
|
} else { |
|
|
|
|
$arrAttr[strtolower(trim($name))] = trim($value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -200,7 +200,7 @@ class HTML_Common |
|
|
|
|
* @param array $attributes Array of attribute |
|
|
|
|
* @since 1.0 |
|
|
|
|
* @access private |
|
|
|
|
* @return bool |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
function _getAttrKey($attr, $attributes) |
|
|
|
|
{ |
|
|
|
|
@ -233,7 +233,7 @@ class HTML_Common |
|
|
|
|
* @param string $attr Attribute name |
|
|
|
|
* @param array $attributes Attribute array |
|
|
|
|
* @since 1.4 |
|
|
|
|
* @access private |
|
|
|
|
* @access private |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
function _removeAttr($attr, &$attributes) |
|
|
|
|
@ -250,7 +250,7 @@ class HTML_Common |
|
|
|
|
* @param string $attr Attribute name |
|
|
|
|
* @since 1.5 |
|
|
|
|
* @access public |
|
|
|
|
* @return string|null returns null if an attribute does not exist |
|
|
|
|
* @return string|null returns null if an attribute does not exist |
|
|
|
|
*/ |
|
|
|
|
function getAttribute($attr) |
|
|
|
|
{ |
|
|
|
|
@ -262,22 +262,22 @@ class HTML_Common |
|
|
|
|
} //end func getAttribute |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the value of the attribute |
|
|
|
|
* |
|
|
|
|
* @param string Attribute name |
|
|
|
|
* @param string Attribute value (will be set to $name if omitted) |
|
|
|
|
* @access public |
|
|
|
|
*/ |
|
|
|
|
function setAttribute($name, $value = null) |
|
|
|
|
{ |
|
|
|
|
$name = strtolower($name); |
|
|
|
|
if (is_null($value)) { |
|
|
|
|
$value = $name; |
|
|
|
|
} |
|
|
|
|
$this->_attributes[$name] = $value; |
|
|
|
|
} // end func setAttribute |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the value of the attribute |
|
|
|
|
* |
|
|
|
|
* @param string Attribute name |
|
|
|
|
* @param string Attribute value (will be set to $name if omitted) |
|
|
|
|
* @access public |
|
|
|
|
*/ |
|
|
|
|
function setAttribute($name, $value = null) |
|
|
|
|
{ |
|
|
|
|
$name = strtolower($name); |
|
|
|
|
if (is_null($value)) { |
|
|
|
|
$value = $name; |
|
|
|
|
} |
|
|
|
|
$this->_attributes[$name] = $value; |
|
|
|
|
} // end func setAttribute |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the HTML attributes |
|
|
|
|
* @param mixed $attributes Either a typical HTML attribute string or an associative array |
|
|
|
|
* @access public |
|
|
|
|
@ -344,7 +344,7 @@ class HTML_Common |
|
|
|
|
case 'unix': |
|
|
|
|
$this->_lineEnd = "\12"; |
|
|
|
|
break; |
|
|
|
|
case 'mac': |
|
|
|
|
case 'mac': |
|
|
|
|
$this->_lineEnd = "\15"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
@ -435,40 +435,40 @@ class HTML_Common |
|
|
|
|
print $this->toHtml(); |
|
|
|
|
} // end func display |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the charset to use by htmlspecialchars() function |
|
|
|
|
* |
|
|
|
|
* Since this parameter is expected to be global, the function is designed |
|
|
|
|
* to be called statically: |
|
|
|
|
* <code> |
|
|
|
|
* HTML_Common::charset('utf-8'); |
|
|
|
|
* </code> |
|
|
|
|
* or |
|
|
|
|
* <code> |
|
|
|
|
* $charset = HTML_Common::charset(); |
|
|
|
|
* </code> |
|
|
|
|
* |
|
|
|
|
* @param string New charset to use. Omit if just getting the |
|
|
|
|
* current value. Consult the htmlspecialchars() docs |
|
|
|
|
* for a list of supported character sets. |
|
|
|
|
* @return string Current charset |
|
|
|
|
* @access public |
|
|
|
|
* @static |
|
|
|
|
*/ |
|
|
|
|
function charset($newCharset = null) |
|
|
|
|
{ |
|
|
|
|
// Modified by Ivan Tcholakov, 16-MAR-2010 |
|
|
|
|
//static $charset = 'ISO-8859-1'; |
|
|
|
|
static $charset; |
|
|
|
|
if (!isset($charset)) { |
|
|
|
|
$charset = api_get_system_encoding(); |
|
|
|
|
} |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
if (!is_null($newCharset)) { |
|
|
|
|
$charset = $newCharset; |
|
|
|
|
} |
|
|
|
|
return $charset; |
|
|
|
|
} // end func charset |
|
|
|
|
/** |
|
|
|
|
* Sets the charset to use by htmlspecialchars() function |
|
|
|
|
* |
|
|
|
|
* Since this parameter is expected to be global, the function is designed |
|
|
|
|
* to be called statically: |
|
|
|
|
* <code> |
|
|
|
|
* HTML_Common::charset('utf-8'); |
|
|
|
|
* </code> |
|
|
|
|
* or |
|
|
|
|
* <code> |
|
|
|
|
* $charset = HTML_Common::charset(); |
|
|
|
|
* </code> |
|
|
|
|
* |
|
|
|
|
* @param string New charset to use. Omit if just getting the |
|
|
|
|
* current value. Consult the htmlspecialchars() docs |
|
|
|
|
* for a list of supported character sets. |
|
|
|
|
* @return string Current charset |
|
|
|
|
* @access public |
|
|
|
|
* @static |
|
|
|
|
*/ |
|
|
|
|
function charset($newCharset = null) |
|
|
|
|
{ |
|
|
|
|
// Modified by Ivan Tcholakov, 16-MAR-2010 |
|
|
|
|
//static $charset = 'ISO-8859-1'; |
|
|
|
|
static $charset; |
|
|
|
|
if (!isset($charset)) { |
|
|
|
|
$charset = api_get_system_encoding(); |
|
|
|
|
} |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
if (!is_null($newCharset)) { |
|
|
|
|
$charset = $newCharset; |
|
|
|
|
} |
|
|
|
|
return $charset; |
|
|
|
|
} // end func charset |
|
|
|
|
} // end class HTML_Common |
|
|
|
|
?> |
|
|
|
|
?> |