. ** ** UltraHTML 3000 tool layer. Tags are now objects, used by it_html ** **/ class it_tag extends ArrayObject { var $tag; var $attributes = array(); var $prefix = ""; var $suffix = ""; function __construct($tag, $values = array()) { $this->tag = $tag; $this->offsetSet(0, $values); } function offsetSet($index, $value) { if (is_string($index)) { $this->attributes[$index] = $value; } else if (is_array($value)) { foreach ($value as $key => $val) $this->offsetSet($key, $val); } else { if (is_string($value)) { if ($errortype = $GLOBALS['it_html']->p['reportquote']) trigger_error("Unquoted '$value' at " . it_debug::backtrace(), $errortype); if ($GLOBALS['it_html']->p['autoquote']) $value = new it_q($value); } parent::offsetSet($index, $value); } } function __toString() { $result = array($this->prefix, "<$this->tag"); foreach ($this->attributes as $key => $value) { if (($value === null) || ($value === false)) # null or false: omit whole tag ; else if (isset($value) && $value !== true) # normal case: value $result[] = " $key=\"" . (preg_match("/[<>&\"'\n\x80-\x9f]/", $value) ? str_replace("\n", " ", new it_q($value)) : $value) . '"'; else # true: tag without value $result[] = ($GLOBALS['it_html']->p['htmltype'] == 'html') ? " $key" : " $key=\"$key\""; } $newline = isset($GLOBALS['it_html']->hasnonewline[$this->tag]) ? "" : "\n"; if (count($this) || preg_match('/^(a|div|iframe|script|span|td|textarea)$/i', $this->tag)) { $result[] = ">"; $data = join("", $this->getArrayCopy()); # Ultra XML PrettyPrinter 3000 [\] by SCA if ($GLOBALS['it_html']->p['prettyprint'] && $newline && (substr($data, -1, 1) == "\n") && (strpos($data, 'p['htmltype'] == 'html') $result[] = ">$newline"; else $result[] = " />$newline"; if ($GLOBALS['debug_srclines']) array_unshift($result, ""); $result[] = $this->suffix; return join("", $result); } function clear() { $this->exchangeArray(array()); } } ?>