|
@@ -27,10 +27,58 @@ class html {
|
|
|
$this->javascript = $javascript;
|
|
|
}
|
|
|
|
|
|
- function htmlAdd($el) {
|
|
|
- $this->html_el[] = $el;
|
|
|
+ function htmlAdd($el, $last=true) {
|
|
|
+ if ($last) {
|
|
|
+ $this->html_el[] = $el;
|
|
|
+ } else {
|
|
|
+ echo 'JOPPPEEE';
|
|
|
+ $new_html_el = array();
|
|
|
+ $new_html_el[] = $el;
|
|
|
+ foreach ($this->html_el as $html_el) {
|
|
|
+ $new_html_el[] = $html_el;
|
|
|
+ }
|
|
|
+ $this->html_el = $new_html_el;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ function AddChild($tag='', $text='', $style ='', $class='', $id='',
|
|
|
+ $xtr_prop = '', $javascript = '') {
|
|
|
+ $el = new html ($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
|
|
|
+ $this->htmlAdd($el);
|
|
|
+ }
|
|
|
+
|
|
|
+ function FindId($id) {
|
|
|
+ $cnt = count($this->html_el);
|
|
|
+ $el = false;
|
|
|
+ if ($cnt) {
|
|
|
+ for ($i = 0 ; $i < $cnt; $i++) {
|
|
|
+ if ($this->html_el[$i]->id == $id) {
|
|
|
+ $ret = $this->html_el[$i];
|
|
|
+ return $ret;
|
|
|
+ } else if (count($this->html_el[$i]->html_el)) {
|
|
|
+ $el = $this->html_el[$i]->FindId($id);
|
|
|
+ }
|
|
|
+ if ($el) return $el;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $el;
|
|
|
+ }
|
|
|
+
|
|
|
+ function InsToId( $el, $id, $last=true) {
|
|
|
+ $html_el = &$this->FindId($id);
|
|
|
+ if ($html_el) {
|
|
|
+ $html_el->htmlAdd($el, $last);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function scriptAdd($script) {
|
|
|
+ $s = "\n".'<!--'."\n".
|
|
|
+ $script .
|
|
|
+ "\n".'// -->'."\n";
|
|
|
+ $el = new html ('script',$s,''.''.''.array('language' => 'JavaScript',
|
|
|
+ 'type' => 'text/javascript'));
|
|
|
+ $this->htmlAdd($el);
|
|
|
+ }
|
|
|
|
|
|
function echoHtml( $usecss=false, $indent='') {
|
|
|
$tag = $this->tag;
|
|
@@ -56,8 +104,11 @@ class html {
|
|
|
$js.=' '.$k.'="'.$v.'";';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- echo $indent . '<' . $tag;
|
|
|
+ if ($tag) {
|
|
|
+ echo $indent . '<' . $tag;
|
|
|
+ } else {
|
|
|
+ echo $indent;
|
|
|
+ }
|
|
|
if ($class) {
|
|
|
echo ' class="'.$class.'"';
|
|
|
}
|
|
@@ -73,7 +124,7 @@ class html {
|
|
|
if ($javascript) {
|
|
|
echo ' '.$js;
|
|
|
}
|
|
|
- echo '>';
|
|
|
+ if ($tag) echo '>';
|
|
|
if ($text) {
|
|
|
if ($style && !$usecss) { /* if use css then fallback to stylesheet for layout */
|
|
|
foreach ($style as $k => $v) {
|
|
@@ -91,14 +142,30 @@ class html {
|
|
|
}
|
|
|
$cnt = count($this->html_el);
|
|
|
if ($cnt) {
|
|
|
+ if ($style && !$usecss) {
|
|
|
+ foreach ($style as $k => $v) {
|
|
|
+ echo '<'.$k.'>';
|
|
|
+ }
|
|
|
+ }
|
|
|
echo "\n";
|
|
|
$indent.=' ';
|
|
|
for($i = 0;$i<$cnt;$i++) {
|
|
|
$el = $this->html_el[$i];
|
|
|
$el->echoHtml($usecss,$indent);
|
|
|
}
|
|
|
+ if ($style && !$usecss) {
|
|
|
+ foreach ($style as $k => $v) { /* if value of key value = true close the tag */
|
|
|
+ if ($v) {
|
|
|
+ echo '</'.$v.'>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($tag) {
|
|
|
+ echo '</'.$tag.'>'."\n";
|
|
|
+ } else {
|
|
|
+ echo "\n";
|
|
|
}
|
|
|
- echo '</'.$tag.'>'."\n";
|
|
|
}
|
|
|
}
|
|
|
|