00001 <?php
00037 class Renderer {
00038 private $r = NULL;
00039 private $c = NULL;
00040 private $rc = "";
00048 function __construct($id_renderer, $id_container) {
00049
00050 $this->r = $this->getRenderer($id_renderer);
00051 if (!is_null($id_container)) { $this->c = $this->getRenderer($id_container); }
00052 }
00053
00059 public function appendRendered($cnt) {
00060 if (is_null($this->r)) { return; }
00061 $r = $this->r;
00062 foreach ($cnt as $key => $value) {
00063 $r = ereg_replace("@" . $key . "@", $value, $r);
00064 }
00065 $this->rc .= $r;
00066 }
00067
00075 private function getRenderer($id) {
00076 $res = mysql_query("SELECT renderer FROM renderers WHERE id = " . $id);
00077 $line = mysql_fetch_assoc($res);
00078 mysql_free_result($res);
00079 return $line['renderer'];
00080 }
00081
00087 public function getRendered() {
00088 if (is_null($this->c)) {
00089 return $this->rc;
00090 } else {
00091 return ereg_replace("@CONTENT@", $this->rc, $this->c);
00092 }
00093 }
00094 }
00095 ?>