/** * Group items * * @param type $element * * @return string */ static function render($element) { $_element = $element; $label_item = isset($element['label_item']) ? $element['label_item'] : ''; $sub_items = $_element['sub_items']; $overwrite_shortcode_data = isset($element['overwrite_shortcode_data']) ? $element['overwrite_shortcode_data'] : true; $sub_item_type = $element['sub_item_type']; $items_html = array(); $shortcode_name = str_replace('WR_', '', $element['shortcode']); // get id of parameter to extract $extract_title = isset($element['extract_title']) ? $element['extract_title'] : ''; $extra_params = array('drag_handle' => false); if ($sub_items) { foreach ($sub_items as $idx => $item) { $el = new $sub_item_type(); $el->init_element(); // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . ' ' . ($idx + 1); } else { $content = $label_item . ($idx + 1); } if (isset($_element['no_title'])) { $content = $_element['no_title']; } if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($el->items, NULL, $extract_params, TRUE, FALSE, $content); $el->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_PBL) : $params['extract_title']; $content = $params['extract_title']; if ($overwrite_shortcode_data) { $shortcode_data = $el->config['shortcode_structure']; } } $element_type = (array) $el->element_in_pgbldr($content, $shortcode_data, '', '', true, $extra_params); foreach ($element_type as $element_structure) { $items_html[$shortcode_data] = $element_structure; } } } $style = isset($_element['style']) ? 'style="' . $_element['style'] . '"' : ''; // Wrap item html to table $html = ''; foreach ($items_html as $shortcode_data => $item_html) { if (!empty($extract_title)) { $attrs = shortcode_parse_atts($shortcode_data); $title = isset($attrs[$extract_title]) ? $attrs[$extract_title] : ''; $html .= sprintf('<tr><td><b>%s</b></td><td>%s</td></tr>', $title, $item_html); } } $html = sprintf('<table class="%s" %s>%s</table>', 'table table-bordered', $style, balanceTags($html)); $element_name = isset($_element['name']) ? $_element['name'] : __(ucwords(!$label_item ? $shortcode_name : $label_item), WR_PBL) . ' ' . __('Items', WR_PBL); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container submodal_frame_2 controls group-table {$_element['class']}'>\n <div class='item-container-content jsn-items-list'>\n {$html}\n </div>\n </div>\n </div>"; return $html_element; }
/** * Group items * * @param type $element * * @return string */ static function render($element) { $_element = $element; $add_item = isset($element['add_item_text']) ? $element['add_item_text'] : __('Add Item', WR_PBL); $sub_items = $_element['sub_items']; $overwrite_shortcode_data = isset($element['overwrite_shortcode_data']) ? $element['overwrite_shortcode_data'] : true; $sub_item_type = $element['sub_item_type']; $items_html = array(); $shortcode_name = str_replace('WR_', '', $element['shortcode']); if ($sub_items) { foreach ($sub_items as $idx => $item) { $element = new $sub_item_type(); $element->init_element(); $label_item = isset($element->config['exception']['item_text']) ? $element->config['exception']['item_text'] : ''; // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . ' ' . ($idx + 1); } else { $content = rtrim($label_item) . ' ' . ($idx + 1); } if (isset($_element['no_title'])) { $content = $_element['no_title']; } if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($element->items, NULL, $extract_params, TRUE, FALSE, $content); $element->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_PBL) : $params['extract_title']; $content = $params['extract_title']; if ($overwrite_shortcode_data) { $shortcode_data = $element->config['shortcode_structure']; } } $element_type = (array) $element->element_in_pgbldr($content, $shortcode_data, '', $idx + 1); foreach ($element_type as $element_structure) { $items_html[] = $element_structure; } } } $style = isset($_element['style']) ? 'style="' . $_element['style'] . '"' : ''; $items_html = implode('', $items_html); $element_name = isset($_element['name']) ? $_element['name'] : __(ucwords(!$label_item ? $shortcode_name : $label_item), WR_PBL); $element_name = str_replace('Item', '', $element_name) . ' ' . __('Items', WR_PBL); $group_heading = WR_Pb_Helper_Html_Fieldset::render(array('name' => $element_name, 'id' => '', 'type' => 'fieldset')); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'>{$group_heading}\n\t\t\t\t<div class='item-container has_submodal controls'>\n\t\t\t\t\t<ul {$style} class='ui-sortable jsn-items-list item-container-content jsn-rounded-medium' id='group_elements'>\n\t\t\t\t\t{$items_html}\n\t\t\t\t\t</ul>\n\t\t\t\t\t<a href='javascript:void(0);' class='jsn-add-more wr-more-element in-modal' item_common_title='" . __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . "' data-shortcode-item='" . strtolower($sub_item_type) . "'><i class='icon-plus'></i>" . __($add_item, WR_PBL) . '</a> </div></div>'; return $html_element; }
/** * get params & structure of shortcode * OVERWRIGE parent function */ public function shortcode_data() { $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items); $this->config['params'] = array_merge(array('div_margin_top' => '', 'div_margin_bottom' => '', 'disabled_el' => 'no', 'css_suffix' => ''), $params); // get content of sub-shortcode $sub_items_content = array(); $sub_items = isset($this->config['params']['sub_items_content']) ? $this->config['params']['sub_items_content'] : array(); foreach ($sub_items as $sub_item_type => &$sub_shortcodes) { foreach ($sub_shortcodes as $sub_shortcode) { $sub_sc = new $sub_item_type(); $sub_sc->init_element(); // empty std if (empty($sub_shortcode['std'])) { // only empty 'std' if (count($sub_shortcode) == 1) { // get default shortcode structure of sub-shortcode $sub_sc->config['params'] = WR_Pb_Helper_Shortcode::generate_shortcode_params($sub_sc->items, null, null, false, true); // re-generate shortcode structure $sub_shortcode['std'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($sub_sc->config['shortcode'], $sub_sc->config['params']); } else { // MODIFY $instance->items WR_Pb_Helper_Shortcode::generate_shortcode_params($sub_sc->items, NULL, $sub_shortcode, TRUE); // re-generate shortcode structure $sub_sc->shortcode_data(); // get updated std of sub-shortcode $sub_shortcode['std'] = $sub_sc->config['shortcode_structure']; } } else { // if std of sub-shortcode is predefined ( such as GoogleMap ) $params = stripslashes($sub_shortcode['std']); $extract_params = WR_Pb_Helper_Shortcode::extract_params(urldecode($params)); // MODIFY $instance->items WR_Pb_Helper_Shortcode::generate_shortcode_params($sub_sc->items, NULL, $extract_params, TRUE); // re-generate shortcode structure $sub_sc->shortcode_data(); } $sub_items_content[] = $sub_shortcode['std']; } } $sub_items_content = implode('', $sub_items_content); // END get content of sub-shortcode $this->config['shortcode_structure'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params'], $sub_items_content); }
/** * Generate Setting HTML for each shortcode * * @global object $Wr_Pb * @param string $shortcode The current shortcode * @param array $params The shortcode content * @param string $el_title Title of shortcode * @param bool $no_tab * * @return string */ public static function shortcode_modal_settings($shortcode, $params, $el_title = '', $no_tab = false) { $html = ''; // get shortcode class $class = WR_Pb_Helper_Shortcode::get_shortcode_class($shortcode); if (class_exists($class)) { global $Wr_Pb; $settings_html = ''; $elements = $Wr_Pb->get_elements(); $instance = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null; if (!is_object($instance)) { $instance = new $class(); } $instance->init_element(); $has_preview = false; // Generate default params if they were not posted. if (empty($params)) { $params = $instance->config['shortcode_structure']; } if (!empty($params)) { $params = str_replace('#_EDITTED', '', $params); $extract_params = WR_Pb_Helper_Shortcode::extract_params($params, $shortcode); // if have sub-shortcode, extract sub shortcodes content if (!empty($instance->config['has_subshortcode'])) { $sub_sc_data = WR_Pb_Helper_Shortcode::extract_sub_shortcode($params, true); $sub_sc_data = apply_filters('wr_pb_sub_items_filter', $sub_sc_data, $shortcode, isset($_COOKIE['wr_pb_data_for_modal']) ? $_COOKIE['wr_pb_data_for_modal'] : ''); $extract_params['sub_items_content'] = $sub_sc_data; } // Set auto title for the subitem if have $extract_title = isset($el_title) && $el_title != __('(Untitled)', WR_PBL) ? $el_title : ''; // MODIFY $instance->items WR_Pb_Helper_Shortcode::generate_shortcode_params($instance->items, NULL, $extract_params, TRUE, FALSE, $extract_title, $has_preview); // if have sub-shortcode, re-generate shortcode structure if (!empty($instance->config['has_subshortcode'])) { $instance->shortcode_data(); } } // get Modal setting box $settings = $instance->items; $settings_html .= WR_Pb_Objects_Modal::get_shortcode_modal_settings($settings, $shortcode, $extract_params, $params, $has_preview, $no_tab); // Add preview if ($has_preview) { $settings_html .= WR_Pb_Helper_Shortcode::render_parameter('preview'); } $html = balanceTags($settings_html); } return $html; }
/** * generate HTML in WR PageBuilder for Table type * @param sub_item_type $element * @return type */ static function render($element) { $label = parent::get_label($element); $sub_items = $element['sub_items']; $sub_item_type = $element['sub_item_type']; $items_html = array(); $sample_table_item = ''; // Get HTML of Each Cell $shortcode_data_arr = array(); // Add extra params to disable drag handle $extra_params = array('drag_handle' => false); foreach ($sub_items as $idx => $item) { $element_ = new $sub_item_type(); $element_->init_element(); $shortcode_data = ''; $content = ' '; // don't leave it empty if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($element_->items, NULL, $extract_params, TRUE, FALSE, $content); $element_->shortcode_data(); if (!empty($params['extract_title'])) { $content = $params['extract_title']; $shortcode_data = $element_->config['shortcode_structure']; } $shortcode_data_arr[$idx] = $shortcode_data; } $element_type = $element_->element_in_pgbldr($content, $shortcode_data, '', '', true, $extra_params); // Create sample table item data if (!$sample_table_item) { $sample_table_item = $element_->element_in_pgbldr(null, null, '', '', true, $extra_params); } foreach ($element_type as $element_structure) { $items_html[] = $element_structure; } } // Wrap cell to a Table to display in WR PageBuilder $row = 0; $updated_html = array(); $columns_count = array(); foreach ($items_html as $idx => $cell) { if (!isset($columns_count[$row])) { $columns_count[$row] = 0; } else { $columns_count[$row]++; } $cell_html = ''; $cell_wrap = $row == 0 ? 'th' : 'td'; if (strpos($cell, "[wr_item_table tagname='tr_start' ][/wr_item_table]") !== false) { $cell_html .= '<tr>'; } else { if (strpos($cell, "[wr_item_table tagname='tr_end' ][/wr_item_table]") !== false) { // Delete button on right side of table $action_html = $row == 0 ? '' : "<a href='#' title='" . __('Delete', WR_PBL) . "' onclick='return false;' data-target='row_table' class='element-delete'><i class='icon-trash'></i></a>"; $cell_html .= "<{$cell_wrap} valign='middle' class='wr-delete-column-td'><div class='jsn-iconbar'>{$action_html}</div></{$cell_wrap}>"; $cell_html .= '</tr>'; $row++; } else { extract(shortcode_parse_atts($shortcode_data_arr[$idx])); $width = !empty($width_value) ? "width='{$width_value}{$width_type}'" : ''; $cell_html .= "<{$cell_wrap} rowspan='{$rowspan}' colspan='{$colspan}' {$width}>{$cell}</{$cell_wrap}>"; } } $updated_html[] = $cell_html; } // Delete button below the table $bottom_row = "<tr class='wr-row-of-delete'>"; for ($i = 0; $i < max($columns_count) - 1; $i++) { $bottom_row .= "<td><div class='jsn-iconbar'><a href='#' title='" . __('Delete', WR_PBL) . "' onclick='return false;' data-target='column_table' class='element-delete'><i class='icon-trash'></i></a></div></td>"; } $bottom_row .= '</tr>'; $updated_html[] = $bottom_row; $items_html = "<table class='table table-bordered igpb-table-exceprt' id='table_content'>" . implode('', $updated_html) . '</table>'; // end Wrap $buttons = '<button class="btn btn-default table_action" data-target="table_row">' . __('Add Row', WR_PBL) . '</button> <button class="btn btn-default table_action" data-target="table_column">' . __('Add Column', WR_PBL) . '</button>'; $output = "<div class='item-container has_submodal table_element'>\n\t\t\t\t\t\t<div class='jsn-fieldset-filter'><div class='btn-toolbar clearafter'>{$buttons}</div></div>\n\t\t\t\t\t\t<div class='ui-sortable item-container-content'>\n\t\t\t\t\t\t{$items_html}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $sample_tmpl_id = strtolower($sub_item_type); $output .= isset($sample_table_item[0]) ? "<script id='tmpl-" . $sample_tmpl_id . "-sample' type='text/html'>" . $sample_table_item[0] . "</script>" : ''; return parent::final_element($element, $output, $label); }
/** * get params & structure of shortcode */ public function shortcode_data() { $this->config['params'] = WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items, null, null, false, true); $this->config['params']['span'] = !empty($this->params['span']) ? $this->params['span'] : 'span12'; $this->config['shortcode_structure'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params']); }
/** * Get params & structure of shortcode */ public function shortcode_data() { $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items, null, null, false, true); // add Margin parameter for Not child shortcode if (strpos($this->config['shortcode'], '_item') === false) { $this->config['params'] = array_merge(array('div_margin_top' => '10', 'div_margin_bottom' => '10', 'disabled_el' => 'no', 'css_suffix' => '', 'id_wrapper' => ''), $params); } else { $this->config['params'] = $params; } $this->config['shortcode_structure'] = WR_Pb_Helper_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params']); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $script = ''; if (!empty($atts) and is_array($atts)) { if (!isset($atts['border_bottom_width_value_'])) { $atts['border_bottom_width_value_'] = ''; $atts['border_bottom_style'] = ''; $atts['border_bottom_color'] = ''; } if (!isset($atts['padding_bottom_value_'])) { $atts['padding_bottom_value_'] = ''; } if (!isset($attrs['font_size_value_'])) { $attrs['font_size_value_'] = ''; } } // Reload shortcode params: because we get Heading Text from "text" param WR_Pb_Helper_Shortcode::generate_shortcode_params($this->items, NULL, $atts); $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $style = array(); $exclude_params = array('tag', 'text', 'preview'); $stylesheet = $font_style = ''; // Override custom style if (!empty($arr_params) and is_array($arr_params)) { if ($arr_params['font'] == 'inherit' || $arr_params['font'] == 'Inherit') { unset($arr_params['font']); unset($arr_params['font_face_type']); unset($arr_params['font_face_value']); unset($arr_params['font_size_value_']); unset($arr_params['font_style']); unset($arr_params['color']); } if (isset($arr_params['font']) && $arr_params['font'] == 'custom') { unset($arr_params['font']); if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'bold') { $arr_params['font_weight'] = '700'; unset($arr_params['font_style']); } if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'normal') { $arr_params['font_weight'] = 'normal'; unset($arr_params['font_style']); } } if (isset($arr_params['font_size_value_']) && $arr_params['font_size_value_'] == '') { unset($arr_params['font_size_value_']); } if ($arr_params['border_bottom_width_value_'] == '') { unset($arr_params['border_bottom_width_value_']); unset($arr_params['border_bottom_style']); unset($arr_params['border_bottom_color']); } if ($arr_params['padding_bottom_value_'] == '') { unset($arr_params['padding_bottom_value_']); } if ($arr_params['text_align'] == 'inherit' || $arr_params['text_align'] == 'Inherit') { unset($arr_params['text_align']); } } foreach ($arr_params as $key => $value) { if ($value != '') { if ($key == 'font_face_type') { if ($value == __('Standard fonts', WR_PBL) || $value == 'standard fonts') { $font_style = 'font-family:' . $arr_params['font_face_value']; } elseif ($value == __('Google fonts', WR_PBL) || $value == 'google fonts') { $script = WR_Pb_Helper_Functions::add_google_font_link_tag($arr_params['font_face_value']); $font_style = 'font-family:' . $arr_params['font_face_value']; } } elseif ($key != 'font_face_value') { $key = WR_Pb_Helper_Functions::remove_tag($key); if (!in_array($key, $exclude_params)) { switch ($key) { case 'border_bottom_width_value_': $style[$key] = 'border-bottom-width:' . $value . 'px'; break; case 'text_align': $style[$key] = 'text-align:' . $value; break; case 'font_size_value_': $style[$key] = 'font-size:' . $value . 'px'; break; case 'font_style': $style[$key] = 'font-style:' . $value; break; case 'border_bottom_style': $style[$key] = 'border-bottom-style:' . $value; break; case 'border_bottom_color': $style[$key] = 'border-bottom-color:' . $value; break; case 'padding_bottom_value_': $style[$key] = 'padding-bottom:' . $value . 'px'; break; case 'font_weight': $style[$key] = 'font-weight:' . $value; break; case 'color': $style[$key] = 'color:' . $value; break; } } } } } // Finalize style $style = implode(';', $style) . ';' . $font_style; if ($style == ';') { $style = ''; } extract($arr_params); if ($enable_underline == 'yes') { } // Process heading margins if (isset($arr_params['heading_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['heading_margin_top']; } if (isset($arr_params['heading_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['heading_margin_bottom']; } if (isset($arr_params['heading_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['heading_margin_right']; } if (isset($arr_params['heading_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['heading_margin_left']; } // Finalize HTML code $true_element = "<{$arr_params['tag']} style='{$style}'>" . do_shortcode($content) . "</{$arr_params['tag']}>"; return $this->element_wrapper($script . $stylesheet . $true_element, $arr_params); }