Esempio n. 1
0
    public function elementInMegamenu($content = '', $shortcodeData = '')
    {
        if (empty($content)) {
            $column = new JSNTplMMShortcodeColumn();
            $columnHtml = $column->elementInMegamenu();
            $columnHtml = $columnHtml[0];
        } else {
            $columnHtml = JSNTplMMHelperShortcode::doShortcodeAdmin($content);
        }
        if (empty($shortcodeData)) {
            $shortcodeData = $this->config['shortcode_structure'];
        }
        $shortcodeData = explode('][', $shortcodeData);
        $shortcodeData = $shortcodeData[0] . ']';
        // Remove empty value attributes of shortcode tag.
        $shortcodeData = preg_replace('/\\[*([a-z_]*[\\n\\s\\t]*=[\\n\\s\\t]*"")/', '', $shortcodeData);
        $customStyle = JSNTplMMHelperPlaceholder::getPlaceholder('custom_style');
        $row[] = '<div class="jsn-row-container ui-sortable row-fluid shortcode-container" ' . $customStyle . '>
					<textarea class="hidden" data-sc-info="shortcode_content" name="shortcode_content[]" >' . $shortcodeData . '</textarea>
					<div class="jsn-iconbar left">
						<a href="javascript:void(0);" title="' . JText::_('JSN_TPLFW_MEGAMENU_MOVE_UP', true) . '" class="jsn-move-up disabled"><i class="icon-chevron-up"></i></a>
						<a href="javascript:void(0);" title="' . JText::_('JSN_TPLFW_MEGAMENU_MOVE_DOWN', true) . '" class="jsn-move-down disabled"><i class=" icon-chevron-down"></i></a>
					</div>
					<div class="jsn-mm-row-content">
						' . $columnHtml . '
					</div>
					<div class="jsn-iconbar jsn-vertical">
						<a href="javascript:void(0);" onclick="return false;" class="add-container" title="' . JText::_('JSN_TPLFW_MEGAMENU_ADD_COLUMN', true) . '"><i class="icon-plus"></i></a>
						<a href="javascript:void(0);" onclick="return false;" class="jsn-mm-item-delete row" title="' . JText::_('JSN_TPLFW_MEGAMENU_DELETE_ROW', true) . '"><i class="icon-trash"></i></a>
					</div>
					<textarea class="hidden" name="shortcode_content[]" >[/' . $this->config['shortcode'] . ']</textarea>
				</div>';
        return $row;
    }
Esempio n. 2
0
    /**
     * Get html item
     *
     * @param array $data
     *
     * @return string
     */
    static function getElementItemHtml($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 = JSNTplMMHelperPlaceholder::getPlaceholder('extra_class');
        $custom_style = JSNTplMMHelperPlaceholder::getPlaceholder('custom_style');
        $other_class = '';
        $tag = $shortcode;
        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 = $content;
        //$content = apply_filters( 'jsn_mm_content', $content, $shortcode_data, $shortcode );
        // action buttons
        $buttons = array('edit' => '<a href="#" onclick="return false;" title="' . JText::_('JSN_TPLFW_MEGAMENU_EDIT_ELEMENT', true) . '" data-shortcode="' . $shortcode . '" class="element-edit"><i class="icon-pencil"></i></a>', 'clone' => '<a href="#" onclick="return false;" title="' . JText::_('JSN_TPLFW_MEGAMENU_DUPLICATE_ELEMENT', true) . '" data-shortcode="' . $shortcode . '" class="element-clone"><i class="icon-copy"></i></a>', 'delete' => '<a href="#" onclick="return false;" title="' . JText::_('JSN_TPLFW_MEGAMENU_DELETE_ELEMENT', true) . '" 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::_('Activate element') . '" 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( 'jsn_mm_button', "<div class='jsn-iconbar'>$action_btns</div>", $shortcode_data, $shortcode );
        $buttons = "<div class='jsn-iconbar'>{$action_btns}</div>";
        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<i class='drag-element-icon'></i>\n\t\t<textarea class='hidden shortcode-content' shortcode-name='{$shortcode}' data-sc-info='shortcode_content' name='shortcode_content[]' >{$shortcode_data}</textarea>\n\t\t<div class='{$content_class}'>{$content}</div>\n\t\t{$buttons}\n\t\t{$preview_html}\n\t\t</{$element_wrapper}>";
    }
Esempio n. 3
0
 /**
  * Get style info
  *
  * @param array $element
  * @param type $output
  * @return type
  */
 static function getStyle($element, $output)
 {
     $style = !empty($element['style']) ? $element['style'] : '';
     if (is_array($element['style'])) {
         $styles = array();
         foreach ($element['style'] as $att_name => $att_value) {
             $styles[] = "{$att_name} : {$att_value}";
         }
         $styles = "style = '" . implode(';', $styles) . "'";
     } else {
         $styles = '';
     }
     $output = JSNTplMMHelperPlaceholder::removePlaceholder($output, 'custom_style', $styles);
     return $output;
 }
Esempio n. 4
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 generateShortcodeParams(&$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::$groupShortcodes)) {
                             // 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'], JSNTplMMHelperPlaceholder::getPlaceholder('index')) !== false) {
                                     $option['std'] = '';
                                     $params['extract_title'] = JText::_('Untitled');
                                 } 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'] = JSNTplMMHelperCommon::sliceContent($option['std']);
                                         }
                                     } else {
                                         if (isset($option['role']) && $option['role'] == 'title_prepend' && !empty($option['title_prepend_type']) && !empty($option['std'])) {
                                             $params['extract_title'] = JSNTplMMHelperPlaceholder::removePlaceholder(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('self', 'arrWalkSubsc'), $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('self', 'arrWalk'), $new_values);
                         }
                     }
                     if (isset($option['extended_ids'])) {
                         foreach ($option['extended_ids'] as $_id) {
                             $params[$_id] = isset($option[$_id]['std']) ? $option[$_id]['std'] : '';
                         }
                     }
                 }
             }
         }
     }
     return $params;
 }
Esempio n. 5
0
 /**
  * DEFINE html structure of shortcode in MegaMenu area
  *
  * @param string $content
  * @param string $shortcode_data: string stores params (which is modified default value) of shortcode
  * @param string $el_title: Element Title used to identifying elements in WR MegaMenu
  * Ex:  param-tag=h6&param-text=Your+heading&param-font=custom&param-font-family=arial
  * @return string
  */
 public function elementInMegamenu($content = '', $shortcode_data = '', $el_title = '', $index = '')
 {
     $shortcode = $this->config['shortcode'];
     $is_sub_element = isset($this->config['sub_element']) ? true : false;
     $parent_shortcode = $is_sub_element ? str_replace('jsn_tpl_mm_item_', '', $shortcode) : $shortcode;
     $type = !empty($this->config['el_type']) ? $this->config['el_type'] : 'widget';
     // 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;
     $modal_title = '';
     // if content is still empty, Generate it
     if (empty($content)) {
         if (!$is_sub_element) {
             $content = ucfirst(str_replace('jsn_tpl_mm_', '', $shortcode));
         } else {
             if (isset($exception['item_text'])) {
                 if (!empty($exception['item_text'])) {
                     $content = JSNTplMMHelperPlaceholder::addPlaceholder($exception['item_text'] . ' %s', 'index');
                 }
             } else {
                 $content = JSNTplMMHelperPlaceholder::addPlaceholder(ucfirst($parent_shortcode) . ' ' . 'Item' . ' %s', 'index');
             }
         }
     }
     $content = !empty($el_title) ? $content . ': ' . "<span>{$el_title}</span>" : $content;
     // element name
     if ($type == 'element') {
         if (!$is_sub_element) {
             $name = ucfirst(str_replace('jsn_tpl_mm_', '', $shortcode));
         } else {
             $name = ucfirst($parent_shortcode) . ' ' . 'Item';
         }
     } else {
         $name = $content;
     }
     if (empty($shortcode_data)) {
         $shortcode_data = $this->config['shortcode_structure'];
     }
     // Process index for subitem element
     if (!empty($index)) {
         $shortcode_data = str_replace('_JSN_TPL_MM_INDEX_', $index, $shortcode_data);
     }
     $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' : 'jsn-mm-element';
     $modal_title = empty($modal_title) ? !empty($exception['data-modal-title']) ? "data-modal-title='{$exception['data-modal-title']}'" : '' : $modal_title;
     $element_type = "data-el-type='{$type}'";
     $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']);
     $extra = array();
     if (isset($this->config['exception']['disable_preview_container'])) {
         $extra = array('has_preview' => FALSE);
     }
     $data = array_merge($data, $extra);
     $html_preview = JSNTplMMHelperFunctions::getElementItemHtml($data);
     return array($html_preview);
 }