Exemplo n.º 1
0
    /**
     * Get html item
     *
     * @param array $data
     *
     * @return string
     */
    public static function getElementItemHtml($data)
    {
        $default = array('element_wrapper' => '', 'modal_title' => '', 'element_type' => '', 'name' => '', 'shortcode' => '', 'shortcode_data' => '', 'content_class' => '', 'content' => '', 'action_btn' => '', 'exclude_gen_shortcode' => '', 'has_preview' => true, 'this_' => '');
        $data = array_merge($default, $data);
        extract($data);
        $input_html = '';
        $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 = 'EXTRA_CLASS';
        $custom_style = 'STYLE';
        $other_class = '';
        if (!empty($this_)) {
            $match = preg_match("/\\[{$shortcode}" . '\\s' . '([^\\]])*' . 'disabled="yes"' . '([^\\]])*' . '\\]/', $shortcode_data);
            if ($match) {
                $other_class = 'disabled';
            }
        }
        $buttons = array('edit' => '<a href="#" onclick="return false;" title="' . JText::_('JSN_PAGEBUILDER_HELPER_BUILDER_EDIT_ELEMENT') . '" data-shortcode="' . $shortcode . '" class="element-edit"><i class="icon-pencil"></i></a>', 'clone' => '<a href="#" onclick="return false;" title="' . JText::_('JSN_PAGEBUILDER_HELPER_BUILDER_DUPLICATE_ELEMENT') . '" data-shortcode="' . $shortcode . '" class="element-clone"><i class="icon-copy"></i></a>', 'delete' => '<a href="#" onclick="return false;" title="' . JText::_('JSN_PAGEBUILDER_HELPER_BUILDER_DELETE_ELEMENT') . '" 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="' . JText::_('JSN_PAGEBUILDER_HELPER_BUILDER_REACTIVE_ELEMENT') . '" data-shortcode="' . $shortcode . '" class="element-deactivate"><i class="icon-checkmark"></i></a>'));
        }
        // Add drag handle
        if ($shortcode === 'pb_table_item') {
            $drag_handle_html = "";
        } else {
            $drag_handle_html = "<div class='heading'><a class='element-drag'></a></div>";
        }
        $action_btns = empty($action_btn) ? implode('', $buttons) : $buttons[$action_btn];
        if (!empty($shortcode_data) && $shortcode == 'pb_pricingtable_item_item') {
            $attrs = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode_data);
            $matchtype = preg_match("/\\[{$shortcode}" . '\\s' . '([^\\]])*' . 'prtbl_item_attr_type="checkbox"' . '([^\\]])*' . '\\]/', $shortcode_data);
            if ($matchtype == 1) {
                $check_value = isset($attrs['prtbl_item_attr_value']) && $attrs['prtbl_item_attr_value'] != '' ? $attrs['prtbl_item_attr_value'] : 'no';
                $option = array('id' => 'prtbl_item_attr_type_' . $attrs['prtbl_item_attr_id'], 'type' => 'radio', 'std' => $check_value, 'options' => array('yes' => JText::_('JSN_PAGEBUILDER_HELPER_BUILDER_YES'), 'no' => JText::_('JSN_PAGEBUILDER_HELPER_BUILDER_NO')), 'parent_class' => 'no-hover-subitem prtbl_item_attr_type');
                $content = IG_Pb_Helper_Html::radio($option);
                return "<{$element_wrapper} class='jsn-item jsn-element ui-state-default shortcode-container radio-type ' {$element_type} data-name='{$name}' {$custom_style}>\n\t\t\t<textarea class='hidden {$exclude_gen_shortcode} shortcode-content' shortcode-name='{$shortcode}' data-sc-info='shortcode_content' name='shortcode_content[]' >{$shortcode_data}</textarea>\n\t\t\t{$content}\n\t\t\t</{$element_wrapper}>";
            }
        }
        // 		if (strpos($shortcode_data,'system-readmore') !== false) {
        // 		    return "<$element_wrapper id='read-more' class='jsn-item jsn-element ui-state-default jsn-iconbar-trigger shortcode-container $extra_class $other_class' $modal_title $element_type data-name='Read more' $custom_style>
        // 			<textarea class='hidden $exclude_gen_shortcode shortcode-content' shortcode-name='$shortcode' data-sc-info='shortcode_content' name='shortcode_content[]' >$shortcode_data</textarea>
        // 	        <div class='pb-plg-element'>Read more</div>
        // 			</$element_wrapper>";
        // 		} else {
        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\n\t\t\t\t<textarea class='hidden {$exclude_gen_shortcode} shortcode-content' shortcode-name='{$shortcode}' data-sc-info='shortcode_content' name='shortcode_content[]' >{$shortcode_data}</textarea>\n\t\t\t\t{$drag_handle_html}\n\t\t        <div class='{$content_class}'>{$content}</div>\n\t\t        {$input_html}\n\t\t\t\t<div class='jsn-iconbar'>{$action_btns}</div>\n\t\t\t\t{$preview_html}\n\t\t\t\t</{$element_wrapper}>";
        //}
    }