17 if (!defined(
"PSF_ENTRY_POINT"))
18 die(
"Not a valid psf entry point");
20 require_once (dirname(__FILE__) .
"/../object.php");
21 require_once (dirname(__FILE__) .
"/../../default_config.php");
22 require_once (dirname(__FILE__) .
"/../../functions.php");
23 require_once (dirname(__FILE__) .
"/primitive_object.php");
28 public $AutoInsertChilds =
false;
29 protected $Items = array();
30 protected $cIndent = 4;
32 function __construct($_parent = NULL)
34 global $psf_containers_auto_insert_child;
35 $this->AutoInsertChilds = $psf_containers_auto_insert_child;
36 parent::__construct($_parent);
39 protected function ReplaceControl($text)
41 return str_replace(
"\n",
"<br>", $text);
58 $this->
AppendHtmlLine(
"<h$level>" . htmlspecialchars($text) .
"</h$level>");
61 public function AppendHtml($html, $indent = -1)
63 $lines = explode(
"\n", $html);
64 foreach ($lines as $l)
68 public function AppendParagraph($text, $class = NULL)
70 $this->
AppendHtmlLine($this->html_p($this->ReplaceControl(htmlspecialchars($text)), $class));
73 public function AppendPreformatted($text)
78 $this->AppendObject($pre, -1,
true);
81 public function AppendPre($text)
83 $this->AppendPreformatted($text);
86 public function AppendLine()
91 public function AppendLineBreak()
96 public function AppendObject($object, $indent = -1, $force =
false)
100 $object->Parent = $this;
101 if ($force || !in_array($object, $this->Items))
102 array_push($this->Items, $object);
105 public function AddChild($_child)
107 if ($_child === NULL)
109 if ($this->AutoInsertChilds)
111 $this->AppendObject($_child);
115 public function _gen_html_tag($name, $value, $param =
"")
117 if (strlen($param) == 0)
118 return "<$name>" . $value .
"</$name>";
120 return "<$name $param>" . $value .
"</$name>";
123 public function html_b($text) {
return $this->_gen_html_tag(
"b", $text); }
124 public function html_div($text) {
return $this->_gen_html_tag(
"div", $text); }
125 public function html_font($text, $param =
"") {
return $this->_gen_html_tag(
"font", $text, $param); }
126 public function html_p($text, $class = NULL)
129 return $this->_gen_html_tag(
"p", $text);
131 return $this->_gen_html_tag(
"p", $text,
'class="' . $class .
'"');
134 public function InsertFileToBody($f)
136 $tx = file_get_contents($f);
138 throw new Exception(
"File couldn't be read: " . $f);
142 public function ToHtml()
146 foreach ($this->Items as $html)
149 if ($this->Indent && $html->Indent)
150 $_b .= psf_indent_text($html->ToHtml(), $indent);
152 $_b .= $html->ToHtml() .
"\n";
AppendHtmlLine($html, $indent=-1)
Insert a line of html into body of a page (to bottom of the body). If $indent contains anything else ...
Represent a single Html container, usually used by htmlpage or htmltable or any other element that is...
AppendHeader($text, $level=1)
Insert a header on bottom of current body of the page.