/**
  * Prints the metabox markup
  * @param $post the current post
  * TODO: support for other input types and select :D
  */
 public function metabox_html($post)
 {
     wp_nonce_field($this->metaname, $this->metaname . '_nonce');
     $values = $this->get_meta($post->ID);
     $rows = '';
     foreach ($this->fields as $field) {
         $th = HtmlHelper::standard_tag('th', $field['label'], array('class' => ''));
         switch ($field['type']) {
             case 'callback':
                 $input = $this->_markup_callback($field, $values, $post);
                 break;
             case 'select':
                 $input = $this->_markup_select($field, $values);
                 break;
             case 'single-attachment':
                 $input = $this->_markup_single_attachment($field, $values);
                 break;
             case 'chebox-list':
                 $input = $this->_markup_checkbox_list($field, $values);
                 break;
             case 'checkbox':
                 $input = $this->_markup_checkbox($field, $values);
                 break;
             case 'text':
             default:
                 $input = $this->_markup_text($field, $values);
                 break;
         }
         if (!empty($field['description'])) {
             $input .= HtmlHelper::br() . HtmlHelper::paragraph($field['description'], array('class' => 'description'));
         }
         $td = HtmlHelper::standard_tag('td', $input, array('class' => ''));
         $tr = HtmlHelper::standard_tag('tr', $th . "\n" . $td);
         $rows .= $tr;
     }
     echo HtmlHelper::standard_tag('table', HtmlHelper::standard_tag('tbody', $rows), array('class' => 'form-table'));
 }
 public function get_markup()
 {
     $slides = '';
     $indicators = '';
     $slide_sub = new SubstitutionTemplate();
     $slide_sub->set_tpl($this->tpl_slide);
     foreach ($this->images as $k => $v) {
         $active = $k == 0 ? 'active' : '';
         $caption = '';
         $style = 'width: 100%; height: 100%; background: url(\'' . $this->get_image_src($k) . '\') no-repeat center center scroll transparent;';
         if ($this->get_image_title($k)) {
             $caption .= HtmlHelper::standard_tag('h2', $this->get_image_title($k));
         }
         if ($this->get_image_caption($k)) {
             $caption .= HtmlHelper::paragraph($this->get_image_caption($k));
         }
         $image = $slide_sub->set_markup('class', implode(' ', array('item', $active)))->set_markup('image', HtmlHelper::div('', array('alt' => $this->get_image_alt($k), 'style' => $style)))->set_markup('caption', HtmlHelper::div($caption, array('class' => 'carousel-caption')))->replace_markup();
         $indicator = HtmlHelper::list_item($inner_html, array('data-target' => '#' . $this->unid, 'data-slide-to' => $k, 'class' => $active));
         $slides .= $image . "\n";
         $indicators .= $indicator . "\n";
     }
     $subs = new SubstitutionTemplate();
     return $subs->set_tpl($this->tpl)->set_markup('id', $this->unid)->set_markup('container_classes', $this->container_classes)->set_markup('indicators', HtmlHelper::ordered_list($indicators, array('class' => 'carousel-indicators')))->set_markup('slides', HtmlHelper::div($slides, array('class' => 'carousel-inner')))->replace_markup();
 }
 /**
  * Prints the HTML markup for the metabox
  */
 public static function metabox_html($post)
 {
     if (is_null($post)) {
         global $post;
     }
     $template = self::get_template($post);
     if (count(self::$media_list)) {
         $is_first = true;
         foreach (self::$media_list as $k => $elem) {
             $template_checker = new TemplateChecker($elem['include'], $elem['exclude']);
             if (!$template_checker->check($template)) {
                 continue;
             }
             $name = self::META_KEY_NAME . '-' . $elem['id'];
             wp_nonce_field(__FILE__, $name . '_nonce');
             $value = get_post_meta($post->ID, $name, true);
             // main edit button
             $edit_button = HtmlHelper::anchor('javascript:;', HtmlHelper::span('', array('class' => 'wp-media-buttons-icon')) . __('Manage Media', 'wtu_framework'), array('id' => 'wtu-media-manager-button-' . $elem['id'], 'class' => 'button media-manager-button', 'data-target' => '#wtu-media-manager-element-' . $elem['id'], 'data-target-undo' => '#wtu-media-manager-undo-' . $elem['id'], 'data-target-delete' => '#wtu-media-manager-delete-' . $elem['id'], 'data-counter' => '#wtu-media-manager-counter-' . $elem['id'], 'data-frame-id' => 'wtu-media-manager-' . $elem['id'], 'data-title' => sprintf(__('Manage Media for %s', 'wtu_framework'), $elem['label']), 'data-button-label' => sprintf(__('Add selected media to %s set', 'wtu_framework'), $elem['label']), 'data-multiple' => 'true', 'data-elem-id' => $elem['id'], 'data-shortcode' => $elem['shortcode'], 'title' => sprintf(__('Manage Media for %s', 'wtu_framework'), $elem['label'])));
             // input to store temp values, use text instead of hidden to debug
             $input = HtmlHelper::input($name, 'hidden', array('id' => 'wtu-media-manager-element-' . $elem['id'], 'value' => $value));
             // Counter
             $number = 0;
             if (isset($value) && $value != '') {
                 $number = count(explode(',', $value));
             }
             $counter = ' ' . HtmlHelper::span($number > 0 ? sprintf(_n('1 element', '%s elements', $number, 'wtu_framework'), $number) : __('Empty', 'wtu_framework'), array('id' => 'wtu-media-manager-counter-' . $elem['id'], 'data-label-no-images' => __('Empty', 'wtu_framework'), 'data-label-one-image' => __('1 element', 'wtu_framework'), 'data-label-more-images' => __('%s elements', 'wtu_framework')));
             // delete button
             $delete = HtmlHelper::anchor('javascript:;', __('Delete', 'wtu_framework'), array('id' => 'wtu-media-manager-delete-' . $elem['id'], 'style' => $value ? '' : 'display:none;', 'class' => 'delete-media-manager-gallery submitdelete', 'data-counter' => '#wtu-media-manager-counter-' . $elem['id'], 'data-gallery' => $elem['id'], 'data-target' => '#wtu-media-manager-element-' . $elem['id'], 'data-target-undo' => '#wtu-media-manager-undo-' . $elem['id'], 'data-target-origin' => '#wtu-media-manager-button-' . $elem['id'], 'title' => __('Delete Media Set', 'wtu_framework')));
             // undo button
             $undo = HtmlHelper::anchor('javascript:;', __('Undo', 'wtu_framework'), array('id' => 'wtu-media-manager-undo-' . $elem['id'], 'style' => 'display:none;', 'class' => 'undo-media-manager-gallery', 'data-gallery' => $elem['id'], 'data-target' => '#wtu-media-manager-element-' . $elem['id'], 'data-elem-id' => $elem['id'], 'data-target-origin' => '#wtu-media-manager-button-' . $elem['id'], 'data-target-delete' => '#wtu-media-manager-delete-' . $elem['id'], 'data-counter' => '#wtu-media-manager-counter-' . $elem['id'], 'title' => __('Restore Media Set', 'wtu_framework')));
             $title = HtmlHelper::paragraph(HtmlHelper::strong($elem['label']));
             $inner_html = '';
             if (!$is_first) {
                 $inner_html .= HtmlHelper::br();
             }
             $inner_html .= '<table class="widefat"><thead>';
             $inner_html .= '<td width="33%">' . $title . '</td>';
             $inner_html .= '<td width="33%">&nbsp;</td>';
             $inner_html .= '<td width="33%">' . $edit_button . '</td></thead>';
             $inner_html .= '<tbody><tr style="line-height: 25px;"><td class="submitbox">' . $delete . $undo . '</td>';
             $inner_html .= '<td>&nbsp;</td>';
             $inner_html .= '<td>' . $counter . '</td>';
             $inner_html .= '</tr></tbody></table>';
             $inner_html .= $input;
             echo HtmlHelper::div($inner_html, array('class' => ''));
             $is_first = false;
         }
     }
     //var_dump($value);
 }