Beispiel #1
0
 /**
  * DEFINE html structure of shortcode in Page Builder area
  *
  * @param type $content
  * @param type $shortcode_data: string stores params (which is modified default value) of shortcode
  * @param type $el_title: Element Title used to identifying elements in Pagebuilder
  * Ex:  param-tag=h6&param-text=Your+heading&param-font=custom&param-font-family=arial
  * 
  * @return type
  */
 public function element_in_pgbldr($content = '', $shortcode_data = '', $el_title = '')
 {
     // Assign Untitled
     $shortcode = $this->config['shortcode'];
     if ($el_title == '<i class=""></i>' && empty($content) || empty($el_title) && empty($content)) {
         if (strpos($shortcode, '_item') !== false) {
             $el_title = JText::_('JSN_PAGEBUILDER_LIB_SHORTCODE_ELEMENT_UNTITLED');
         } else {
             $el_title = '';
         }
     }
     $is_sub_element = isset($this->config['sub_element']) ? true : false;
     $parent_shortcode = $is_sub_element ? str_replace(array('pb_', '_item'), "", $shortcode) : $shortcode;
     $type = !empty($this->config['el_type']) ? $this->config['el_type'] : 'element';
     $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>');
     // Empty content if this is not sub element
     if (!$is_sub_element) {
         $content = "";
     }
     $exception = isset($this->config['exception']) ? $this->config['exception'] : array();
     $content = isset($exception['default_content']) ? $exception['default_content'] : $content;
     // if content is still empty, Generate it
     if (empty($content)) {
         if (!$is_sub_element) {
             $content = ucfirst(str_replace(JSNPB_SHORTCODE_PREFIX, "", $shortcode));
         } else {
             if (isset($exception['item_text'])) {
                 if (!empty($exception['item_text'])) {
                     $content = $exception['item_text'] . " PB_INDEX_TRICK";
                 }
             } else {
                 $content = JText::_(ucfirst($parent_shortcode)) . " " . JText::_('JSN_PAGEBUILDER_LIB_SHORTCODE_ELEMENT_ITEM') . " PB_INDEX_TRICK";
             }
         }
     }
     $content = !empty($el_title) ? $content . ": " . "<span>{$el_title}</span>" : $content;
     $content = !empty($el_title) && $is_sub_element == true ? $el_title : $content;
     // element name
     if ($type == "element") {
         if (!$is_sub_element) {
             $name = ucfirst(str_replace(JSNPB_SHORTCODE_PREFIX, "", $shortcode));
         } else {
             $name = JText::_(ucfirst($parent_shortcode)) . " " . JText::_('JSN_PAGEBUILDER_LIB_SHORTCODE_ELEMENT_ITEM');
         }
     } else {
         $name = $content;
     }
     if (empty($shortcode_data)) {
         $shortcode_data = $this->config['shortcode_structure'];
     }
     $shortcode_data = stripslashes($shortcode_data);
     $element_wrapper = !empty($exception['item_wrapper']) ? $exception['item_wrapper'] : ($is_sub_element ? "li" : "div");
     $content_class = $is_sub_element ? "jsn-item-content" : "pb-plg-element";
     $action_btns = empty($exception['action_btn']) ? implode("", $buttons) : $buttons[$exception['action_btn']];
     $modal_title = !empty($exception['data-modal-title']) ? "data-modal-title='{$exception['data-modal-title']}'" : "";
     $element_type = "data-el-type='{$type}'";
     $exclude_gen_shortcode = isset($exception['exclude_gen_shortcode']) ? 'exclude_gen_shortcode' : '';
     $data = array('element_wrapper' => $element_wrapper, 'modal_title' => $modal_title, 'element_type' => $element_type, 'name' => $name, 'shortcode' => $shortcode, 'shortcode_data' => $shortcode_data, 'content_class' => $content_class, 'content' => $content, 'action_btn' => empty($exception['action_btn']) ? '' : $exception['action_btn'], 'exclude_gen_shortcode' => $exclude_gen_shortcode);
     $extra = array();
     if (isset($this->config['exception']['disable_preview_container'])) {
         $extra = array('has_preview' => FALSE);
     }
     $data = array_merge($data, $extra);
     $html_preview = JSNPagebuilderHelpersFunctions::getElementItemHtml($data);
     return $html_preview;
 }