/** * 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'] : ''; if ($sub_items) { foreach ($sub_items as $idx => $item) { $element = new $sub_item_type(); // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_MEGAMENU_TEXTDOMAIN) . ' ' . __('Item', WR_MEGAMENU_TEXTDOMAIN) . ' ' . ($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_Megamenu_Helpers_Shortcode::extract_params($item['std']); $params = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($element->items, NULL, $extract_params, TRUE, FALSE, $content); $element->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_MEGAMENU_TEXTDOMAIN) : $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); 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_MEGAMENU_TEXTDOMAIN) . ' ' . __('Items', WR_MEGAMENU_TEXTDOMAIN); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='col-xs-3 control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container submodal_frame_2 controls col-xs-9 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; $label_item = isset($element['label_item']) ? $element['label_item'] : ''; $add_item = isset($element['add_item_text']) ? $element['add_item_text'] : __('Add Item', WR_MEGAMENU_TEXTDOMAIN); $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(); // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_MEGAMENU_TEXTDOMAIN) . ' ' . __('Item', WR_MEGAMENU_TEXTDOMAIN) . ' ' . ($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_Megamenu_Helpers_Shortcode::extract_params($item['std']); $params = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($element->items, NULL, $extract_params, TRUE, FALSE, $content); $element->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_MEGAMENU_TEXTDOMAIN) : $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_MEGAMENU_TEXTDOMAIN) . ' ' . __('Items', WR_MEGAMENU_TEXTDOMAIN); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='col-xs-3 control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container has_submodal controls col-xs-9'>\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\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' data-shortcode-item='" . strtolower($sub_item_type) . "'><i class='icon-plus'></i>" . __($add_item, WR_MEGAMENU_TEXTDOMAIN) . '</a> </div></div>'; return $html_element; }
/** * get params & structure of shortcode * OVERWRIGE parent function */ public function shortcode_data() { $params = WR_Megamenu_Helpers_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(); // 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_Megamenu_Helpers_Shortcode::generate_shortcode_params($sub_sc->items, null, null, false, true); // re-generate shortcode structure $sub_shortcode['std'] = WR_Megamenu_Helpers_Shortcode::generate_shortcode_structure($sub_sc->config['shortcode'], $sub_sc->config['params']); } else { // MODIFY $instance->items WR_Megamenu_Helpers_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_Megamenu_Helpers_Shortcode::extract_params(urldecode($params)); // MODIFY $instance->items WR_Megamenu_Helpers_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_Megamenu_Helpers_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params'], $sub_items_content); }
/** * get params & structure of shortcode */ public function shortcode_data() { $this->config['params'] = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($this->items, null, null, false, true); $this->config['shortcode_structure'] = WR_Megamenu_Helpers_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params']); }
global $wr_megamenu_element; $elements = $wr_megamenu_element->get_elements(); $instance = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null; if (!is_object($instance)) { $instance = new $class(); } if (!empty($params)) { $extract_params = WR_Megamenu_Helpers_Shortcode::extract_params($params, $shortcode); // if have sub-shortcode, extract sub shortcodes content if (!empty($instance->config['has_subshortcode'])) { $sub_sc_data = WR_Megamenu_Helpers_Shortcode::extract_sub_shortcode($params, true); $sub_sc_data = apply_filters('wr_mm_sub_items_filter', $sub_sc_data, $shortcode, isset($_COOKIE['wr_mm_data_for_modal']) ? $_COOKIE['wr_mm_data_for_modal'] : ''); $extract_params['sub_items_content'] = $sub_sc_data; } // MODIFY $instance->items WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($instance->items, NULL, $extract_params, TRUE); // 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 = ''; if ($shortcode == 'wr_megamenu_row') { $settings_html .= '<div class="col-sm-12 wr-row-setting">' . WR_Megamenu_Helpers_Modal::get_shortcode_modal_settings($settings, $shortcode, $extract_params, $params) . '</div>'; } else { $settings_html .= '<div class="wr-setting-resize">' . WR_Megamenu_Helpers_Modal::get_shortcode_modal_settings($settings, $shortcode, $extract_params, $params) . '</div>'; $settings_html .= '<div class="wr-preview-resize">' . WR_Megamenu_Helpers_Shortcode::render_parameter('preview') . '</div>'; } echo balanceTags($settings_html);
/** * generate HTML in WR MegaMenu 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(); // Get HTML of Each Cell $shortcode_data_arr = array(); foreach ($sub_items as $idx => $item) { $element_ = new $sub_item_type(); $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_Megamenu_Helpers_Shortcode::extract_params($item['std']); $params = WR_Megamenu_Helpers_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); foreach ($element_type as $element_structure) { $items_html[] = $element_structure; } } // Wrap cell to a Table to display in WR MegaMenu $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_MEGAMENU_TEXTDOMAIN) . "' 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_MEGAMENU_TEXTDOMAIN) . "' 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 wrpb-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_MEGAMENU_TEXTDOMAIN) . '</button> <button class="btn btn-default table_action" data-target="table_column">' . __('Add Column', WR_MEGAMENU_TEXTDOMAIN) . '</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\t{$items_html}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; return parent::final_element($element, $output, $label); }
/** * Get params & structure of shortcode */ public function shortcode_data() { $params = WR_Megamenu_Helpers_Shortcode::generate_shortcode_params($this->items, null, null, false, true); // add Margin parameter for Not child shortcode if (strpos($this->config['shortcode'], '_item') === false) { if ($this->config['shortcode'] == 'wr_submenu') { $this->config['params'] = array_merge(array('disabled_el' => 'no', 'css_suffix' => '', 'id_wrapper' => ''), $params); } else { $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_Megamenu_Helpers_Shortcode::generate_shortcode_structure($this->config['shortcode'], $this->config['params']); }