. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * * @copyright 2008-2009, KnowledgeTree Inc. * @license GNU General Public License version 3 * @author KnowledgeTree Team * @package Installer * @version Version 0.1 */ class htmlHelper { private $tags = array( 'meta' => '', 'metalink' => '', 'link' => '%s', 'mailto' => '%s', 'form' => '
', 'formend' => '
', 'input' => '', 'textarea' => '', 'hidden' => '', 'checkbox' => '', 'checkboxmultiple' => '', 'radio' => '%s', 'selectstart' => '', 'selectempty' => '', 'selectoption' => '', 'selectend' => '', 'optiongroup' => '', 'optiongroupend' => '', 'checkboxmultiplestart' => '', 'checkboxmultipleend' => '', 'password' => '', 'file' => '', 'file_no_model' => '', 'submit' => '', 'submitimage' => '', 'button' => '', 'image' => '', 'tableheader' => '%s', 'tableheaderrow' => '%s', 'tablecell' => '%s', 'tablerow' => '%s', 'block' => '%s', 'blockstart' => '', 'blockend' => '', 'tag' => '<%s%s>%s', 'tagstart' => '<%s%s>', 'tagend' => '', 'para' => '%s

', 'parastart' => '', 'label' => '', 'fieldset' => '%s', 'fieldsetstart' => '
%s', 'fieldsetend' => '
', 'legend' => '%s', 'css' => '', 'style' => '', 'charset' => '', 'ul' => '%s', 'ol' => '%s', 'li' => '%s', 'error' => '%s' ); function __construct() { } function js($name) { return ""; } function css($name) { return ""; } function image($name, $options = array()) { $path = "../wizard/resources/graphics/$name"; $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); return $image; } function url() { } function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { if (is_array($options)) { $options = array_merge(array('escape' => true), $options); if (!is_array($exclude)) { $exclude = array(); } $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape'))); $values = array_intersect_key(array_values($options), $keys); $escape = $options['escape']; $attributes = array(); foreach ($keys as $index => $key) { $attributes[] = $this->__formatAttribute($key, $values[$index], $escape); } $out = implode(' ', $attributes); } else { $out = $options; } return $out ? $insertBefore . $out . $insertAfter : ''; } function __formatAttribute($key, $value, $escape = true) { $attribute = ''; $attributeFormat = '%s="%s"'; $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); if (is_array($value)) { $value = ''; } if (in_array($key, $minimizedAttributes)) { if ($value === 1 || $value === true || $value === 'true' || $value == $key) { $attribute = sprintf($attributeFormat, $key, $key); } } else { $attribute = sprintf($attributeFormat, $key, $this->ife($escape, $this->h($value), $value)); } return $attribute; } function ife($condition, $val1 = null, $val2 = null) { if (!empty($condition)) { return $val1; } return $val2; } function h($text, $charset = 'UTF-8') { if (is_array($text)) { return array_map('h', $text); } return htmlspecialchars($text, ENT_QUOTES, $charset); } } ?>