/**
         *
         * @param type $content		: inner shortcode elements of this row
         * @param type $shortcode_data : not used
         * @return string
         */
        public function element_in_megamenu($content = '', $shortcode_data = '')
        {
            if (empty($content)) {
                $column = new WR_Megamenu_Column();
                $column_html = $column->element_in_megamenu();
                $column_html = $column_html[0];
            } else {
                $column_html = WR_Megamenu_Helpers_Shortcode::do_shortcode_admin($content);
            }
            if (empty($shortcode_data)) {
                $shortcode_data = $this->config['shortcode_structure'];
            }
            // remove [/wr_megamenu_row][wr_megamenu_column...] from $shortcode_data
            $shortcode_data = explode('][', $shortcode_data);
            $shortcode_data = $shortcode_data[0] . ']';
            // Remove empty value attributes of shortcode tag.
            $shortcode_data = preg_replace('/\\[*([a-z_]*[\\n\\s\\t]*=[\\n\\s\\t]*"")/', '', $shortcode_data);
            $custom_style = WR_Megamenu_Helpers_Placeholder::get_placeholder('custom_style');
            $row[] = '<div class="jsn-row-container ui-sortable row-fluid shortcode-container" ' . $custom_style . '>
							<textarea class="hidden" data-sc-info="shortcode_content" name="shortcode_content[]" >' . $shortcode_data . '</textarea>
							<div class="jsn-iconbar left">
								<a href="javascript:void(0);" title="' . __('Move Up', WR_MEGAMENU_TEXTDOMAIN) . '" class="jsn-move-up disabled"><i class="icon-chevron-up"></i></a>
								<a href="javascript:void(0);" title="' . __('Move Down', WR_MEGAMENU_TEXTDOMAIN) . '" class="jsn-move-down disabled"><i class=" icon-chevron-down"></i></a>
							</div>
							<div class="wr-row-content">
							' . $column_html . '
							</div>
							<div class="jsn-iconbar jsn-vertical">
								<a href="javascript:void(0);" onclick="return false;" class="add-container" title="' . __('Add column', WR_MEGAMENU_TEXTDOMAIN) . '"><i class="wr-icon-add-col"></i></a>
								<a href="javascript:void(0);" onclick="return false;" title="Edit row" data-shortcode="' . $this->config['shortcode'] . '" class="element-edit row"><i class="icon-pencil"></i></a>
								<a href="javascript:void(0);" onclick="return false;" class="item-delete row" title="' . __('Delete row', WR_MEGAMENU_TEXTDOMAIN) . '"><i class="icon-trash"></i></a>
							</div>
							<textarea class="hidden" name="shortcode_content[]" >[/' . $this->config['shortcode'] . ']</textarea>
						</div>';
            return $row;
        }
Exemple #2
0
    /**
     * Get html item
     *
     * @param array $data
     *
     * @return string
     */
    static function get_element_item_html($data)
    {
        $default = array('element_wrapper' => '', 'modal_title' => '', 'element_type' => '', 'name' => '', 'shortcode' => '', 'shortcode_data' => '', 'content_class' => '', 'content' => '', 'action_btn' => '', 'has_preview' => true, 'this_' => '');
        $data = array_merge($default, $data);
        extract($data);
        $preview_html = '';
        if ($has_preview) {
            $preview_html = '<div class="shortcode-preview-container" style="display: none">
					<div class="shortcode-preview-fog"></div>
					<div class="jsn-overlay jsn-bgimage image-loading-24"></div>
				</div>';
        }
        $extra_class = WR_Megamenu_Helpers_Placeholder::get_placeholder('extra_class');
        $custom_style = WR_Megamenu_Helpers_Placeholder::get_placeholder('custom_style');
        $other_class = '';
        $tag = $shortcode;
        // Check if this element is deactivate
        if (strpos($shortcode_data, 'widget_id')) {
            $tag = 'wr_megamenu_widget';
        }
        preg_match_all('/\\[' . $tag . '\\s+([A-Za-z0-9_-]+=\\"[^"\']*\\"\\s*)*\\s*\\]/', $shortcode_data, $rg_sc_params);
        if (!empty($rg_sc_params[0])) {
            $sc_name_params = !empty($rg_sc_params[0][0]) ? $rg_sc_params[0][0] : $rg_sc_params[0];
            if (strpos($sc_name_params, 'disabled_el="yes"') !== false) {
                $other_class = 'disabled';
            }
        }
        // Remove empty value attributes of shortcode tag.
        $shortcode_data = preg_replace('/\\[*([a-z_]*[\\n\\s\\t]*=[\\n\\s\\t]*""\\s)/', '', $shortcode_data);
        // Content
        $content = balanceTags($content);
        $content = apply_filters('wr_mm_content', $content, $shortcode_data, $shortcode);
        // action buttons
        $buttons = array('edit' => '<a href="#" onclick="return false;" title="' . __('Edit element', WR_MEGAMENU_TEXTDOMAIN) . '" data-shortcode="' . $shortcode . '" class="element-edit"><i class="icon-pencil"></i></a>', 'clone' => '<a href="#" onclick="return false;" title="' . __('Duplicate element', WR_MEGAMENU_TEXTDOMAIN) . '" data-shortcode="' . $shortcode . '" class="element-clone"><i class="icon-copy"></i></a>', 'deactivate' => '<a href="#" onclick="return false;" title="' . __('Deactivate element', WR_MEGAMENU_TEXTDOMAIN) . '" data-shortcode="' . $shortcode . '" class="element-deactivate"><i class="icon-checkbox-unchecked"></i></a>', 'delete' => '<a href="#" onclick="return false;" title="' . __('Delete element', WR_MEGAMENU_TEXTDOMAIN) . '" class="element-delete"><i class="icon-trash"></i></a>');
        if (!empty($other_class)) {
            $buttons = array_merge($buttons, array('deactivate' => '<a href="#" onclick="return false;" title="' . __('Activate element', WR_MEGAMENU_TEXTDOMAIN) . '" data-shortcode="' . $shortcode . '" class="element-deactivate"><i class="icon-checkbox-partial"></i></a>'));
        }
        $action_btns = empty($action_btn) ? implode('', $buttons) : $buttons[$action_btn];
        $buttons = apply_filters('wr_mm_button', "<div class='jsn-iconbar'>{$action_btns}</div>", $shortcode_data, $shortcode);
        return "<{$element_wrapper} class='jsn-item jsn-element ui-state-default jsn-iconbar-trigger shortcode-container {$extra_class} {$other_class}' {$modal_title} {$element_type} data-name='{$name}' {$custom_style}>\n\t\t\t\t<i class='drag-element-icon'></i>\n\t\t\t\t<textarea class='hidden shortcode-content' shortcode-name='{$shortcode}' data-sc-info='shortcode_content' name='shortcode_content[]' >{$shortcode_data}</textarea>\n\t\t\t\t<div class='{$content_class}'>{$content}</div>\n\t\t\t\t{$buttons}\n\t\t\t\t{$preview_html}\n\t\t\t</{$element_wrapper}>";
    }
Exemple #3
0
 /**
  * Generate options list of shortcode (from $this->items array) OR get value of a option
  * @param array $arr ($this->items)
  * @param string|null $paramID (get std of a option by ID)
  * @param array $new_values (set std for some options ( "pram id" => "new std value" ) )
  * @param bool $assign_content (set $option['std'] = $new_values['_shortcode_content'] of option which has role = 'content' )
  * @param bool $extract_content (get $option['std'] of option which has role = 'content' )
  * @param string $extract_title (get $option['std'] of option which has role|role_2 = 'title' )
  * @return array
  */
 static function generate_shortcode_params(&$arr, $paramID = NULL, $new_values = NULL, $assign_content = FALSE, $extract_content = FALSE, $extract_title = '')
 {
     $params = array();
     if ($arr) {
         foreach ($arr as $tab => &$options) {
             foreach ($options as &$option) {
                 $type = isset($option['type']) ? $option['type'] : '';
                 $option['std'] = !isset($option['std']) ? '' : $option['std'];
                 // option has role = 'content'
                 if (isset($option['role']) && $option['role'] == 'content') {
                     // set std of this option
                     if ($assign_content) {
                         if (!empty($new_values) && isset($new_values['_shortcode_content'])) {
                             $option['std'] = $new_values['_shortcode_content'];
                         }
                     }
                     // get std of this option
                     if ($extract_content) {
                         $params['extract_shortcode_content'][$option['id']] = $option['std'];
                     } else {
                         // remove option which role = content from shortcode structure ( except option which has another role: title )
                         if (!(isset($option['role']) && $option['role'] == 'title' || isset($option['role_2']) && $option['role_2'] == 'title' || isset($option['role']) && $option['role'] == 'title_prepend')) {
                             unset($option);
                             continue;
                         }
                     }
                 }
                 if ($type != 'preview') {
                     // single option : $option['type'] => string
                     if (!is_array($type)) {
                         // if is not parent/nested shortcode
                         if (!in_array($type, self::$group_shortcodes)) {
                             // default content
                             if (empty($new_values)) {
                                 if (!empty($paramID)) {
                                     if ($option['id'] == $paramID) {
                                         return $option['std'];
                                     }
                                 } else {
                                     if (isset($option['id'])) {
                                         $params[$option['id']] = $option['std'];
                                     }
                                 }
                             } else {
                                 if (isset($option['id']) && array_key_exists($option['id'], $new_values)) {
                                     $option['std'] = $new_values[$option['id']];
                                 }
                             }
                             // extract title for element like Table
                             if (!empty($extract_title)) {
                                 // default std
                                 if (strpos($option['std'], WR_Megamenu_Helpers_Placeholder::get_placeholder('index')) !== false) {
                                     $option['std'] = '';
                                     $params['extract_title'] = __('(Untitled)', WR_MEGAMENU_TEXTDOMAIN);
                                 } else {
                                     if (isset($option['role']) && $option['role'] == 'title' || isset($option['role_2']) && $option['role_2'] == 'title') {
                                         if ($option['role'] == 'title') {
                                             $params['extract_title'] = $option['std'];
                                         } else {
                                             $params['extract_title'] = WR_Megamenu_Helpers_Common::slice_content($option['std']);
                                         }
                                     } else {
                                         if (isset($option['role']) && $option['role'] == 'title_prepend' && !empty($option['title_prepend_type']) && !empty($option['std'])) {
                                             $params['extract_title'] = WR_Megamenu_Helpers_Placeholder::remove_placeholder(self::$item_html_template[$option['title_prepend_type']], 'standard_value', $option['std']) . $params['extract_title'];
                                         }
                                     }
                                 }
                             }
                         } else {
                             // default content
                             if (empty($new_values)) {
                                 foreach ($option['sub_items'] as &$sub_items) {
                                     $sub_items['std'] = !isset($sub_items['std']) ? '' : $sub_items['std'];
                                     if (!empty($paramID)) {
                                         if ($sub_items['id'] == $paramID) {
                                             return $sub_items['std'];
                                         }
                                     } else {
                                         $params['sub_items_content'][$option['sub_item_type']][] = $sub_items;
                                     }
                                 }
                             } else {
                                 $count_default = count($option['sub_items']);
                                 $count_real = isset($new_values['sub_items_content'][$option['sub_item_type']]) ? count($new_values['sub_items_content'][$option['sub_item_type']]) : 0;
                                 if ($count_real > 0) {
                                     // there are new sub items
                                     if ($count_default < $count_real) {
                                         for ($index = $count_default; $index < $count_real; $index++) {
                                             $option['sub_items'][$index] = array('std' => '');
                                         }
                                     } else {
                                         if ($count_default > $count_real) {
                                             for ($index = $count_real; $index < $count_default; $index++) {
                                                 unset($option['sub_items'][$index]);
                                             }
                                         }
                                     }
                                     // update content for sub items
                                     array_walk($option['sub_items'], array('WR_Megamenu_Helpers_Functions', 'wr_arr_walk_subsc'), $new_values['sub_items_content'][$option['sub_item_type']]);
                                 }
                             }
                         }
                     } else {
                         // default content
                         if (empty($new_values)) {
                             foreach ($option['type'] as &$sub_options) {
                                 $sub_options['std'] = !isset($sub_options['std']) ? '' : $sub_options['std'];
                                 if (!empty($paramID)) {
                                     if ($sub_options['id'] == $paramID) {
                                         return $sub_options['std'];
                                     }
                                 } else {
                                     $params[$sub_options['id']] = $sub_options['std'];
                                 }
                             }
                         } else {
                             array_walk($option['type'], array('WR_Megamenu_Helpers_Functions', 'wr_arr_walk'), $new_values);
                         }
                     }
                     if (isset($option['extended_ids'])) {
                         foreach ($option['extended_ids'] as $_id) {
                             $params[$_id] = isset($option[$_id]['std']) ? $option[$_id]['std'] : '';
                         }
                     }
                 }
             }
         }
     }
     return $params;
 }