コード例 #1
0
ファイル: element.php プロジェクト: mirkoargentino/bbn
 /**
  * Returns the corresponding HTML string
  * 
  * @param bool $with_js Includes the javascript
  * @return string HTML string
  */
 public function html($with_js = 1)
 {
     $html = '';
     if ($this->tag) {
         $this->update();
         // TAG
         $html .= '<' . $this->tag;
         foreach ($this->attr as $key => $val) {
             if (is_string($key)) {
                 $html .= ' ' . htmlspecialchars($key) . '="';
                 if (is_numeric($val)) {
                     $html .= $val;
                 } else {
                     if (is_string($val)) {
                         $html .= htmlspecialchars($val);
                     }
                 }
                 $html .= '"';
             }
         }
         if (count($this->css) > 0) {
             $html .= self::css_to_string($this->css);
         }
         if ($this->xhtml) {
             $html .= ' /';
         }
         $html .= '>';
         if (!in_array($this->tag, self::$self_closing_tags)) {
             if (isset($this->text)) {
                 $html .= $this->text;
             }
             if (isset($this->content)) {
                 // @todo: Add the ability to imbricate elements
                 if (is_string($this->content)) {
                     $html .= $this->content;
                 } else {
                     if (is_array($this->content)) {
                         foreach ($this->content as $c) {
                             if (is_array($c)) {
                                 $c = new \bbn\html\element($c);
                             }
                             $html .= $c->html($with_js);
                         }
                     }
                 }
             }
             $html .= '</' . $this->tag . '>';
         }
         if (isset($this->placeholder) && strpos($this->placeholder, '%s') !== false) {
             $html = sprintf($this->placeholder, $html);
         }
     }
     return $html;
 }
コード例 #2
0
ファイル: builder.php プロジェクト: mirkoargentino/bbn
 public function fieldset($title = null, $force = false)
 {
     $this->record('fieldset', $title);
     if (is_array($title)) {
         $title['tag'] = 'fieldset';
         if (isset($title['legend'])) {
             $legend_txt = $title['legend'];
             unset($title['legend']);
         }
         $fieldset = new \bbn\html\element($title);
         if (isset($legend_txt)) {
             $legend = new \bbn\html\element('legend');
             $legend->text($legend_txt);
             $fieldset->append($legend);
         }
     } else {
         $fieldset = new \bbn\html\element('fieldset');
         if (!is_null($title)) {
             $legend = new \bbn\html\element('legend');
             $legend->text($title);
             $fieldset->append($legend);
         }
     }
     if ($this->_root_element) {
         $this->_root_element->append($fieldset);
     } else {
         $this->_root_element =& $fieldset;
     }
     $this->_current_element =& $fieldset;
     return $this->_chainable && !$force ? $this : $fieldset;
 }