Beispiel #1
0
 /**
  * @param string $title document's title. Default: "(untitled)"
  * @param string $doctype DOCTYPE code (see <code>$this->set_doctype()</code>). Default: "xhtml-t". 
  * @param string $encoding encoding used in the current document. Default: utf-8
  */
 public function __construct($title = "(untitled)", $doctype = "xhtml-t", $encoding = "utf-8")
 {
     parent::__construct();
     $this->htdoc = $this;
     $this->set('title', $title);
     $this->set('encoding', $encoding);
     $this->attr = array();
     $this->set_doctype($doctype);
     $this->set('head', $this->head = new html_head($this));
     $this->set('body', new html_element('body'));
 }
Beispiel #2
0
 public function __construct($tpl_name = null)
 {
     if (func_num_args() > 1) {
         $args = func_get_args();
         array_shift($args);
         parent::__construct($args);
     } else {
         parent::__construct();
     }
     if (!empty($tpl_name)) {
         $this->load_template($tpl_name);
     }
 }
Beispiel #3
0
 public function __construct($zone)
 {
     global $phpAds_context;
     parent::__construct();
     $this->zone = $zone;
     $phpAds_raw = view_local('', $this->zone, 0, 0, '', '', '0', $phpAds_context, '');
     if (!empty($phpAds_raw['html'])) {
         $phpAds_context[] = array('!=' => 'bannerid:' . $phpAds_raw['bannerid']);
         $html = $phpAds_raw['html'];
         $this->add(iconv('utf-8', 'windows-1255', $html));
     } else {
         $this->active = false;
     }
 }
Beispiel #4
0
 public function __construct($tag, $attr = null)
 {
     $this->tag = $tag;
     if (in_array(strtolower($tag), self::$force_no_self_close)) {
         $this->self_closing = false;
     }
     if (is_array($attr)) {
         $this->attr = $attr;
     }
     if (func_num_args() > 2) {
         $args = func_get_args();
         array_shift($args);
         array_shift($args);
         parent::__construct($args);
     } else {
         parent::__construct();
     }
 }
 public function apply(html_block $block)
 {
     $res = '';
     $ops = array();
     $this->current_path = null;
     for ($i = 0; isset($this->tpl[$i]); $i++) {
         $val = $this->tpl[$i];
         if ($val instanceof html_tpl_c_control) {
             switch ($val->op) {
                 case 'foreach':
                     $fe_path = $this->get_realpath($val->param);
                     if (!$block->valid_path($fe_path)) {
                         // skip after the ${:end}
                         $i = $this->skip_to_endelse($i);
                         if ($this->tpl[$i]->op != 'end') {
                             throw new html_tpl_syntax_ex($this->name, "unexpected: " . $this->tpl[$i]->op);
                         }
                         continue;
                     }
                     $fe_subp = $block->get_subpaths($fe_path);
                     if (empty($fe_subp)) {
                         $fe_subp = array($fe_path);
                     }
                     $fe_newcp = array_shift($fe_subp);
                     $op = array($val->op, $fe_subp, $i, $this->current_path);
                     $this->current_path = rtrim($fe_newcp, '/');
                     $ops[] = $op;
                     break;
                 case 'delim':
                     $op = end($ops);
                     if (empty($op[1])) {
                         // last entry in foreach, skip the delim block and ${:end}
                         $i = $this->skip_to_endelse($i);
                         if ($this->tpl[$i]->op != 'end') {
                             throw new html_tpl_syntax_ex($this->name, "unexpected: " . $this->tpl[$i]->op);
                         }
                         $this->current_path = rtrim($op[3], '/');
                         array_pop($ops);
                     }
                     break;
                 case 'ifdef':
                     $real_path = $this->get_realpath($val->param);
                     $is_true = $block->valid_path($real_path);
                     $op = array($val->op, $is_true);
                     $ops[] = $op;
                     if (!$is_true) {
                         $i = $this->skip_to_endelse($i);
                         if ($this->tpl[$i]->op == 'end') {
                             array_pop($ops);
                         }
                     }
                     break;
                 case 'else':
                     $op = array_pop($ops);
                     $i = $this->skip_to_endelse($i);
                     if ($this->tpl[$i]->op == 'else') {
                         throw new html_tpl_syntax_ex($this->name, "Duplicate else");
                     }
                     break;
                 case 'end':
                     $op = array_pop($ops);
                     if ($op[0] == 'foreach') {
                         if (!empty($op[1])) {
                             $this->current_path = array_shift($op[1]);
                             $i = $op[2];
                             $ops[] = $op;
                         } else {
                             $this->current_path = rtrim($op[3], '/');
                         }
                     }
                     if (is_null($op)) {
                         throw new html_tpl_syntax_ex($this->name, "Unexpected op: {$val->op}");
                     }
                     break;
                 default:
                     throw new html_tpl_syntax_ex($this->name, "Unexpected op: {$val->op}");
             }
             continue;
         }
         if (is_string($val)) {
             $res .= $val;
         } elseif ($val instanceof html_tpl_c_elm) {
             // MK: this is a fix to allow HTML entities in the output
             // not sure, it's good idea ;-)
             if (!$val->plaintext) {
                 $res .= $val->render($block);
             } else {
                 $res .= preg_replace('/&amp;([#a-z0-9]+);/i', '&$1;', htmlspecialchars($val->render($block)));
             }
         }
     }
     return $res;
 }