Beispiel #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;
    }
Beispiel #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}>";
    }
Beispiel #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 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;
 }