<?php
/**
* html.class.php
*
* This contains functions needed to generate html output.
*
* @copyright 2003-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: html.class.php 14840 2020年01月07日 07:42:38Z pdontthink $
* @package squirrelmail
*/
/**
* Undocumented class
* @package squirrelmail
*/
/**
* Constructor (PHP5 style, required in some future version of PHP)
*/
function __construct ($tag=
'', $text=
'', $style =
'', $class=
'', $id=
'',
$xtr_prop = '', $javascript = '') {
}
/**
* Constructor (PHP4 style, kept for compatibility reasons)
*/
function html ($tag=
'', $text=
'', $style =
'', $class=
'', $id=
'',
$xtr_prop = '', $javascript = '') {
self::__construct($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
}
function htmlAdd ($el, $last=
true) {
if ($last) {
} else {
$new_html_el = array();
$new_html_el[] = $el;
foreach ($this->html_el as $html_el) {
$new_html_el[] = $html_el;
}
}
}
function AddChild ($tag=
'', $text=
'', $style =
'', $class=
'', $id=
'',
$xtr_prop = '', $javascript = '') {
$el =
new html ($tag, $text, $style, $class, $id, $xtr_prop, $javascript);
}
$el = false;
if ($cnt) {
for ($i = 0 ; $i < $cnt; $i++) {
if ($this->html_el [$i]->id ==
$id) {
return $ret;
$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);
}
}
$s = "\n".'<!--'."\n".
$script .
"\n".'// -->'."\n";
$el =
new html ('script',$s,'','','',array('language' =>
'JavaScript',
'type' => 'text/javascript'));
}
function echoHtml ( $usecss=
false, $indent=
'x') {
if ($indent == 'x') {
$indent = ''; $indentmore = '';
} else {
$indentmore = $indent . ' ';
}
if ($xtr_prop) {
$prop = '';
foreach ($xtr_prop as $k => $v) {
$prop.=' '.$k.'="'.$v.'"';
} else {
$prop.=' '.$v;
}
}
}
if ($javascript) {
$js = '';
foreach ($javascript as $k => $v) { /* here we put the onclick, onmouseover etc entries */
$js.=' '.$k.'="'.$v.'";';
}
}
if ($tag) {
echo $indent . '<' . $tag;
} else {
echo $indent;
}
if ($class) {
echo ' class="'.$class.'"';
}
if ($id) {
echo ' id="'.$id.'"';
}
if ($xtr_prop) {
echo ' '.$prop;
}
if ($style &&
!$usecss &&
!is_array ($style)) {
/* last premisse is to prevent 'style="Array"' in the output */
echo ' style="'.$style.'"';
}
if ($javascript) {
echo ' '.$js;
}
if ($tag) echo '>';
$openstyles = '';
$closestyles = '';
if ($style && !$usecss) {
foreach ($style as $k => $v) {
$openstyles .= '<'.$k.'>';
}
foreach ($style as $k => $v) {
/* if value of key value = true close the tag */
if ($v) {
$closestyles .= '</'.$k.'>';
}
}
}
echo $openstyles;
if ($text) {
echo $text;
}
if ($cnt) {
echo "\n";
for($i = 0;$i<$cnt;$i++) {
$el->echoHtml($usecss,$indentmore);
}
echo $indent;
}
echo $closestyles;
if ($tag) {
echo '</'.$tag.'>'."\n";
} else {
echo "\n";
}
}
}