예제 #1
0
 public function render()
 {
     if (!empty($this->image)) {
         if (isset($this->_template)) {
             $vars = get_object_vars($this);
             extract($vars);
             ob_start();
             // If the PHP installation does not support short tags we'll
             // do a little string replacement, changing the short tags
             // to standard PHP echo statements.
             if (!ini_get('short_open_tag') and function_usable('eval')) {
                 echo eval('?>' . preg_replace('/;*\\s*\\?>/', '; ?>', str_replace('<?=', '<?php echo ', $this->_template)));
             } else {
                 echo eval('?>' . preg_replace('/;*\\s*\\?>/', '; ?>', $this->_template));
             }
             $output = ob_get_contents();
             ob_end_clean();
             return $output;
         } else {
             if (isset($this->link)) {
                 $output[] = new Link($this->image, $this->link);
                 $caption = new Link($this->caption, $this->link, ['class' => 'caption']);
             } else {
                 $output[] = $this->image;
                 $caption = new Tag('div', $this->caption, ['class' => 'caption']);
             }
             if (isset($this->description)) {
                 $caption->append_content($this->description);
             }
             if (!empty($this->buttons)) {
                 $button = new Tag('p', implode(PHP_EOL, $this->buttons), ['class' => 'thumbnail-buttons']);
                 $caption->append_content($button);
             }
             $output[] = $caption;
             return (new Tag($this->_tag, implode(PHP_EOL, $output), $this->_attributes))->render();
         }
     }
     return '';
 }
예제 #2
0
 public function render()
 {
     if (!empty($this->left_media) or !empty($this->right_media)) {
         if (isset($this->left_media)) {
             if (isset($this->link)) {
                 $media = clone $this->link;
                 $media->set_label($this->left_media);
             } else {
                 $media = $this->left_media;
             }
             $left_classes[] = 'media-left';
             if ($this->_is_align_bottom === TRUE) {
                 $left_classes[] = 'media-bottom';
             } elseif ($this->_is_align_middle === TRUE) {
                 $left_classes[] = 'media-middle';
             }
             $output['left'] = new Tag('div', $media, ['class' => $left_classes]);
         }
         $body = new Tag('div', ['class' => 'media-body']);
         if (isset($this->link)) {
             $heading = clone $this->link;
             $heading->set_label($this->heading);
         } else {
             $heading = $this->heading;
         }
         $body->append_content($heading);
         if (isset($this->description)) {
             $body->append_content($this->description);
         }
         if (!empty($this->childs)) {
             foreach ($this->childs as $child) {
                 $body->append_content($child);
             }
         }
         $output['body'] = $body;
         if (isset($this->right_media)) {
             if (isset($this->link)) {
                 $media = clone $this->link;
                 $media->set_label($this->right_media);
             } else {
                 $media = $this->right_media;
             }
             $right_classes[] = 'media-right';
             if ($this->_is_align_bottom === TRUE) {
                 $right_classes[] = 'media-bottom';
             } elseif ($this->_is_align_middle === TRUE) {
                 $right_classes[] = 'media-middle';
             }
             $output['right'] = new Tag('div', $media, ['class' => $right_classes]);
         }
         return (new Tag($this->_tag, implode(PHP_EOL, $output), $this->_attributes))->render();
     }
     return '';
 }
예제 #3
0
 /**
  * Render
  *
  * @return
  */
 public function render()
 {
     if (!empty($this->image)) {
         if (isset($this->link)) {
             $image = clone $this->link;
             $image->set_label($this->image);
             $this->link->set_label($this->caption);
             $caption = new Tag('div', $this->link, ['class' => 'carousel-caption']);
         } else {
             $image = $this->image;
             $caption = new Tag('div', $this->caption, ['class' => 'carousel-caption']);
         }
         if (isset($this->description)) {
             $caption->append_content($this->description);
         }
         if (!empty($this->buttons)) {
             $button = new Tag('p', implode(PHP_EOL, $this->buttons), ['class' => 'thumbnail-buttons']);
             $caption->append_content($button);
         }
         return $image . (new Tag($this->_tag, $caption, $this->_attributes))->render();
     }
     return '';
 }
예제 #4
0
 public function render()
 {
     switch ($this->_type) {
         case 'text':
             $this->_attributes['type'] = 'text';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'password':
             $this->_attributes['type'] = 'password';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'radio':
             $this->_attributes['type'] = 'radio';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'checkbox':
             $this->_attributes['type'] = 'checkbox';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'number':
             $this->_attributes['type'] = 'number';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'date':
             $this->_attributes['type'] = 'date';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'color':
             $this->_attributes['type'] = 'color';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'month':
             $this->_attributes['type'] = 'month';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'week':
             $this->_attributes['type'] = 'week';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'time':
             $this->_attributes['type'] = 'time';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'datetime':
             $this->_attributes['type'] = 'datetime';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'datetime-local':
             $this->_attributes['type'] = 'datetime-local';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'email':
             $this->_attributes['type'] = 'email';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'search':
             $this->_attributes['type'] = 'search';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'tel':
             $this->_attributes['type'] = 'tel';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'url':
             $this->_attributes['type'] = 'url';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'select':
             $field = new Tag('select', $this->_attributes);
             if (!empty($this->_options)) {
                 foreach ($this->_options as $group => $option) {
                     if (is_array($option)) {
                         $group = new Tag('optgroup', ['label' => $group]);
                         foreach ($option as $value => $label) {
                             $attr = ['value' => $value];
                             if (isset($this->_value)) {
                                 if ($this->_value == $value) {
                                     $attr['selected'] = 'selected';
                                 }
                             }
                             $group->append_content(new Tag('option', $label, $attr));
                         }
                         $field->append_content($group);
                     } elseif (is_string($option) or is_numeric($option)) {
                         $attr = ['value' => $group];
                         if (isset($this->_value)) {
                             if ($this->_value == $group) {
                                 $attr['selected'] = 'selected';
                             }
                         }
                         $field->append_content(new Tag('option', $option, $attr));
                     }
                 }
             }
             break;
         case 'textarea':
             $this->_attributes['type'] = 'textarea';
             $field = new Tag('textarea', $this->_attributes);
             break;
         case 'file':
             $this->_attributes['type'] = 'file';
             $field = new Tag('input', $this->_attributes);
             break;
         case 'featured-image':
             $field = new Tag('div', ['data-role' => 'featured-image']);
             $properties['size'] = isset($this->_properties['size']) ? $this->_properties['size'] : ['width' => 270, 'height' => 270];
             $properties['text'] = isset($this->_properties['text']) ? $this->_properties['text'] : 'Featured Image';
             $image_holder = new Tag('img', array('src' => 'holder.js/' . implode('x', $properties['size']) . '?text=' . $this->_properties['text'], 'data-pattern' => 'image-preview'));
             if (!empty($this->_value)) {
                 $image_holder->add_class('hidden');
                 $image_preview = new Tag('img', array('src' => $this->_value, 'data-role' => 'image-preview'));
                 $field->append_content($image_preview);
             }
             $field->append_content($image_holder);
             $this->_attributes['type'] = 'file';
             $this->_attributes['data-role'] = 'image-input';
             $this->_attributes['accept'] = 'image/*';
             $input_group = new Group(Group::INPUT_GROUP);
             $input_group->add_item(new Tag('span', new Tag('span', '<i class="fa fa-camera"></i>' . new Tag('input', $this->_attributes), array('class' => 'btn btn-file', 'data-role' => 'image-browse', 'title' => 'Browse', 'data-toggle' => 'tooltip')), ['class' => 'input-group-btn']));
             $field->append_content($input_group);
             break;
         case 'textarea':
             $this->_attributes['type'] = 'textarea';
             $field = new Tag('textarea', $this->_attributes);
             break;
         default:
             $field = new Tag($this->_tag, $this->_attributes);
             break;
     }
     $field->add_class('form-control');
     if (isset($this->label)) {
         $group = new Group(Group::FORM_GROUP);
         $group->add_item($this->label);
         $group->add_item($field);
         if (isset($this->help)) {
             $group->add_item($this->help);
         }
         return $group->render();
     }
     return $field->render();
 }
예제 #5
0
 /**
  * Render
  *
  * @access  public
  * @return  string
  */
 public function render(array $attr = array())
 {
     if (!empty($this->_rows)) {
         // Set Table Caption
         if (!empty($this->_caption)) {
             $output[] = $this->_caption;
         }
         // Set Table Headers
         $thead = new Tag('tr');
         foreach ($this->_headers as $column) {
             $thead->append_content(new Tag('th', $column));
         }
         $output[] = new Tag('thead', $thead->render());
         // Set Table Body
         $output[] = new Tag('tbody', implode(PHP_EOL, $this->_rows));
         // Set Table Footers
         if (!empty($this->_footers)) {
             $tfoot = new Tag('tr');
             foreach ($this->_footers as $column) {
                 $tfoot->append_content(new Tag('th', $column));
             }
             $output[] = new Tag('tfoot', $tfoot);
         }
         $table = new Tag($this->_tag, implode(PHP_EOL, $output), $this->_attributes);
         if ($this->_is_responsive) {
             return (new Tag('div', $table, ['class' => 'table-responsive']))->render();
         }
         return $table->render();
     }
     return '';
 }