/** * get params & structure of shortcode * OVERWRIGE parent function */ public function shortcode_data() { $params = JSNPagebuilderHelpersShortcode::generateShortcodeParams($this->items); $this->config['params'] = array_merge(array('div_margin_top' => '', 'div_margin_bottom' => '', 'disabled_el' => 'no', 'css_suffix' => ''), $params); // get content of sub-shortcode $sub_items_content = array(); $sub_items = isset($this->config['params']['sub_sc_content']) ? $this->config['params']['sub_sc_content'] : array(); foreach ($sub_items as $sub_item_type => &$sub_shortcodes) { foreach ($sub_shortcodes as $sub_shortcode) { $sub_sc = new $sub_item_type(); // $sub_sc->init_element(); // empty std if (empty($sub_shortcode['std'])) { // only empty 'std' if (count($sub_shortcode) == 1) { // get default shortcode structure of sub-shortcode $sub_sc->config['params'] = JSNPagebuilderHelpersShortcode::generateShortcodeParams($sub_sc->items, null, null, false, true); // re-generate shortcode structure $sub_shortcode['std'] = JSNPagebuilderHelpersShortcode::generateShortcodeStructure($sub_sc->config['shortcode'], $sub_sc->config['params']); } else { // MODIFY $instance->items JSNPagebuilderHelpersShortcode::generateShortcodeParams($sub_sc->items, NULL, $sub_shortcode, TRUE); // re-generate shortcode structure $sub_sc->shortcode_data(); // get updated std of sub-shortcode $sub_shortcode['std'] = $sub_sc->config['shortcode_structure']; } } else { // if std of sub-shortcode is predefined ( such as GoogleMap ) $params = stripslashes($sub_shortcode['std']); $extract_params = JSNPagebuilderHelpersShortcode::generateShortcodeParams(urldecode($params)); // MODIFY $instance->items JSNPagebuilderHelpersShortcode::generateShortcodeParams($sub_sc->items, NULL, $extract_params, TRUE); // re-generate shortcode structure $sub_sc->shortcode_data(); } $sub_items_content[] = $sub_shortcode['std']; } } $sub_items_content = implode('', $sub_items_content); // END get content of sub-shortcode $this->config['shortcode_structure'] = JSNPagebuilderHelpersShortcode::generateShortcodeStructure($this->config['shortcode'], $this->config['params'], $sub_items_content); }
/** * get params & structure of shortcode * * @return void */ public function shortcode_data() { $this->config['params'] = JSNPagebuilderHelpersShortcode::generateShortcodeParams($this->items, null, null, false, true); $this->config['shortcode_structure'] = JSNPagebuilderHelpersShortcode::generateShortcodeStructure($this->config['shortcode'], $this->config['params']); }
/** * DEFINE shortcode content * * @param type $atts * @param type $content * * @return string */ public function element_shortcode($atts = null, $content = null) { if (!empty($atts) and is_array($atts)) { if (!isset($atts['border_bottom_width_value_'])) { $atts['border_bottom_width_value_'] = ''; $atts['border_bottom_style'] = ''; $atts['border_bottom_color'] = ''; } if (!isset($atts['padding_bottom_value_'])) { $atts['padding_bottom_value_'] = ''; } if (!isset($attrs['font_size_value_'])) { $attrs['font_size_value_'] = ''; } } // reload shortcode params: because we get Heading Text from "text" param JSNPagebuilderHelpersShortcode::generateShortcodeParams($this->items, NULL, $atts); $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); $style = array(); $exclude_params = array('tag', 'text', 'preview'); $stylesheet = $font_style = ''; // Override custom style if (!empty($arr_params) and is_array($arr_params)) { if ($arr_params['font'] == 'inherit' || $arr_params['font'] == 'Inherit') { unset($arr_params['font']); unset($arr_params['font_face_type']); unset($arr_params['font_face_value']); unset($arr_params['font_size_value_']); unset($arr_params['font_style']); unset($arr_params['color']); } if (isset($arr_params['font']) && $arr_params['font'] == 'custom') { unset($arr_params['font']); if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'bold') { $arr_params['font_weight'] = '700'; unset($arr_params['font_style']); } if (isset($arr_params['font_style']) && strtolower($arr_params['font_style']) == 'normal') { $arr_params['font_weight'] = 'normal'; unset($arr_params['font_style']); } } if (isset($arr_params['font_size_value_']) && $arr_params['font_size_value_'] == '') { unset($arr_params['font_size_value_']); } if ($arr_params['border_bottom_width_value_'] == '') { unset($arr_params['border_bottom_width_value_']); unset($arr_params['border_bottom_style']); unset($arr_params['border_bottom_color']); } if ($arr_params['padding_bottom_value_'] == '') { unset($arr_params['padding_bottom_value_']); } if ($arr_params['text_align'] == 'inherit' || $arr_params['text_align'] == 'Inherit') { unset($arr_params['text_align']); } } foreach ($arr_params as $key => $value) { if ($value != '') { if ($key == 'font_face_type') { if ($value == JText::_('JSN_PAGEBUILDER_DEFAULT_ELEMENT_FONT_STANDARD') || $value == 'standard fonts') { $font_style = 'font-family:' . $arr_params['font_face_value']; } else { if ($value == JText::_('JSN_PAGEBUILDER_DEFAULT_ELEMENT_FONT_GOOGLE') || $value == 'google fonts') { $document = JFactory::getDocument(); $document->addStyleSheet("http://fonts.googleapis.com/css?family={$arr_params['font_face_value']}", 'text/css'); $font_style = 'font-family:' . $arr_params['font_face_value']; } } } else { if ($key != 'font_face_value') { $key = JSNPagebuilderHelpersShortcode::removeTag($key); if (!in_array($key, $exclude_params)) { switch ($key) { case 'border_bottom_width_value_': $style[$key] = 'border-bottom-width:' . $value . 'px'; break; case 'text_align': $style[$key] = 'text-align:' . $value; break; case 'font_size_value_': $style[$key] = 'font-size:' . $value . 'px'; break; case 'font_style': $style[$key] = 'font-style:' . $value; break; case 'border_bottom_style': $style[$key] = 'border-bottom-style:' . $value; break; case 'border_bottom_color': $style[$key] = 'border-bottom-color:' . $value; break; case 'padding_bottom_value_': $style[$key] = 'padding-bottom:' . $value . 'px'; break; case 'font_weight': $style[$key] = 'font-weight:' . $value; break; case 'color': $style[$key] = 'color:' . $value; break; } } } } } } $style = implode(';', $style); $style .= ';' . $font_style; $style = $style == ';' ? '' : $style; $true_element = "<{$arr_params['tag']} style='{$style}'>" . JSNPagebuilderHelpersShortcode::removeAutop($content) . "</{$arr_params['tag']}>"; $true_element .= ''; return $this->element_wrapper($true_element, $arr_params); }
/** * Generate HTML in Pagebuilder for Table type * * @param sub_item_type $element * * @return type */ static function table($element) { $sub_items = $element["sub_items"]; $sub_item_type = $element['sub_item_type']; $items_html = array(); $element_name = $element['name']; // Get HTML of Each Cell $shortcode_data_arr = array(); foreach ($sub_items as $idx => $item) { $element = new $sub_item_type(); $shortcode_data = ""; $content = " "; // don't leave it empty if (!empty($item["std"])) { // keep shortcode data as it is $shortcode_data = $item["std"]; // reassign params for shortcode base on std string $extract_params = JSNPagebuilderHelpersShortcode::extractParams($item["std"]); $params = JSNPagebuilderHelpersShortcode::generateShortcodeParams($element->items, NULL, $extract_params, TRUE, FALSE, $content); $element->shortcode_data(); if (!empty($params["assign_title"])) { $content = $params["assign_title"]; $shortcode_data = $element->config['shortcode_structure']; } $shortcode_data_arr[$idx] = $shortcode_data; } $items_html[] = $element->element_in_pgbldr($content, $shortcode_data); } // Wrap cell to a Table to display in Pagebuilder $row = 0; $updated_html = array(); $columns_count = array(); foreach ($items_html as $idx => $cell) { if (!isset($columns_count[$row])) { $columns_count[$row] = 0; } else { $columns_count[$row]++; } $cell_html = ""; $cell_wrap = $row == 0 ? "th" : "td"; if (strpos($cell, '[pb_table_item tagname="tr_start" ][/pb_table_item]') !== false) { $cell_html .= "<tr>"; } else { if (strpos($cell, '[pb_table_item tagname="tr_end" ][/pb_table_item]') !== false) { // Delete button on right side of table $action_html = $row == 0 ? "" : "<a href='#' title='" . JText::_('JSN_PAGEBUILDER_LIB_SHORTCODE_HTML_DELETE') . "' onclick='return false;' data-target='row_table' class='element-delete'><i class='icon-trash'></i></a>"; $cell_html .= "<{$cell_wrap} valign='middle' class='pb-delete-column-td'><div class='jsn-iconbar'>{$action_html}</div></{$cell_wrap}>"; $cell_html .= "</tr>"; $row++; } else { extract(JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode_data_arr[$idx])); $width = !empty($width_value) ? "width='{$width_value}{$width_type}'" : ""; $cell_html .= "<{$cell_wrap} rowspan='{$rowspan}' colspan='{$colspan}' {$width}>{$cell}</{$cell_wrap}>"; } } $updated_html[] = $cell_html; } // Delete button below the table $bottom_row = "<tr class='pb-row-of-delete'>"; for ($i = 0; $i < max($columns_count) - 1; $i++) { $bottom_row .= "<td><div class='jsn-iconbar'><a href='#' title='" . JText::_('JSN_PAGEBUILDER_LIB_SHORTCODE_HTML_DELETE') . "' onclick='return false;' data-target='column_table' class='element-delete'><i class='icon-trash'></i></a></div></td>"; } $bottom_row .= "</tr>"; $updated_html[] = $bottom_row; $items_html = "<table class='table table-bordered' id='table_content'>" . implode("", $updated_html) . "</table>"; // end Wrap $buttons = '<button class="btn table_action" data-target="table_row">' . JText::_('JSN_PAGEBUILDER_LIB_SHORTCODE_HTML_ADD_ROW') . '</button> <button class="btn table_action" data-target="table_column">' . JText::_('JSN_PAGEBUILDER_HELPER_ROW_ADD_COLUMN') . '</button>'; return "<div class='item-container has_submodal table_element'>\n <input type='hidden' id='param-el_table' value='table'>\n\t\t\t\t\t\t\t<label for='control-label'>{$element_name}</label>\n\t\t\t\t\t\t\t<div class='jsn-fieldset-filter'><div class='btn-toolbar clearafter'>{$buttons}</div></div>\n\t\t\t\t\t\t\t<div class='ui-sortable item-container-content'>\n\t\t\t\t\t\t\t\t{$items_html}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>"; }
/** * Method to print element settings */ public function settings() { $js = ' var JSNPbParams = {pbstrings : {}}; JSNPbParams.rootUrl = \'' . JUri::root() . '\'; JSNPbParams.pbstrings.NO_ITEM_FOUND = \'' . JText::_('No %s found') . '\'; JSNPbParams.pbstrings.SINGLE_ENTRY = \'' . JText::_('Single %s') . '\'; JSNPbParams.pbstrings.SETTINGS = \'' . JText::_('Settings') . '\'; JSNPbParams.pbstrings.INVALID_LINK = \'' . JText::_('The link is invalid') . '\'; JSNPbParams.pbstrings.COPY = \'' . JText::_('copy') . '\'; JSNPbParams.pbstrings.EMPTY = \'' . JText::_('(Untitled)') . '\'; JSNPbParams.pbstrings.SELECT_DES_MARKER = \'' . JText::_('Select Destination Marker') . '\'; JSNPbParams.pbstrings.ALERT_DELETE_ROW = \'' . JText::_('Are you sure you want to delete the whole row including all elements it contains?') . '\'; JSNPbParams.pbstrings.ALERT_DELETE_COLUMN = \'' . JText::_('Are you sure you want to delete the whole column including all elements it contains?') . '\'; JSNPbParams.pbstrings.ALERT_DELETE_ELEMENT = \'' . JText::_('Are you sure you want to delete the element?') . '\'; '; JSNPagebuilderHelpersFunctions::print_asset_tag($js, 'js', null, true); $shortcode = JRequest::getString('shortcode'); $params = isset($_POST['params']) ? $_POST['params'] : ''; // TODO: move under assets inside shortcode // Add common js library for elements. JSNPagebuilderHelpersFunctions::print_asset_tag(JSNPB_FRAMEWORK_ASSETS . '/3rd-party/jquery-tipsy/jquery.tipsy.js', 'js'); JSNPagebuilderHelpersFunctions::print_asset_tag(JSNPB_FRAMEWORK_ASSETS . '/3rd-party/jquery-tipsy/tipsy.css', 'css'); JSNPagebuilderHelpersFunctions::print_asset_tag(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-general.css', 'css'); // for accordion_item, buttonbar_item, JSNPagebuilderHelpersFunctions::print_asset_tag(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-fonticomoon.css', 'css'); // for accordion_item, buttonbar_item, $extract_params = ''; $shortcodeHelper = new JSNPagebuilderHelpersShortcode(); $data = array(); if (!empty($shortcode)) { // elements $class = $shortcodeHelper->getShortcodeClass($shortcode); if (class_exists($class)) { // Get all regitered element shortcodes global $JSNPbElements; $elements = $JSNPbElements->getElements(); $instance = isset($elements[strtolower($class)]) ? $elements[strtolower($class)] : null; // Init and register new instance if it not if (!is_object($instance)) { $instance = new $class(); } if (!empty($params)) { $params = stripslashes($params); $params = urldecode($params); } else { $params = $instance->config['shortcode_structure']; } // Add neccessary assets for the shortcode $instance->backend_element_assets(); if (!empty($params)) { $extract_params = JSNPagebuilderHelpersShortcode::extractParams($params, $shortcode); // if have sub-shortcode, get content if (!empty($instance->config['has_subshortcode'])) { $sub_sc_data = JSNPagebuilderHelpersShortcode::extractSubShortcode($params, true); $extract_params['sub_sc_content'] = $sub_sc_data; } // MODIFY $instance->items $shortcodeHelper->generateShortcodeParams($instance->items, NULL, $extract_params, TRUE); // recall this to re-extract params $instance->shortcode_data(); } // get Modal setting box $settings = $instance->items; $shortcodeAterfix = substr($shortcode, -5); $showPreview = true; if ($shortcodeAterfix == '_item') { $showPreview = false; } if ($shortcode == 'pb_row') { $showPreview = false; } $modalContent = $shortcodeHelper->getShortcodeModalSettings($settings, $shortcode, $extract_params); } } $html[] = ''; if ($showPreview) { $html[] = '<div id="jsn_column1" class="pull-left">'; } $html[] = '<div class="jsn-bootstrap" id="settings-form-container"> <div id="modalOptions" class="form-horizontal"> ' . $modalContent . ' <div id="modalAction"></div> </div> <textarea class="hidden" id="shortcode_content" name="shortcode_content">' . $params . '</textarea> <textarea class="hidden" id="pb_share_data" ></textarea> <textarea class="hidden" id="pb_merge_data" ></textarea> <textarea class="hidden" id="pb_extract_data" ></textarea> <input type="hidden" id="pb_previewing" value="0" /> <input id="shortcode_name" name="shortcode_name" type="hidden" value="' . $shortcode . '" /> </div>'; if ($showPreview) { $html[] = '</div>'; } if ($showPreview) { $html[] = '<div id="jsn_column2" class="pull-left"> <div class="preview_title">' . JText::_("Preview") . '</div> <div id="framePreview" class="preview_border"> <div id="iframeLoading" class="iframe_loading_border"><div class="iframe_loading_image"><img src="components/com_pagebuilder/assets/images/icons-32/ajax-loader.gif"></div></div> <div class="control-group"> <div id="preview_container"> <iframe id="shortcode_preview_iframe" scrolling="auto" name="shortcode_preview_iframe" class="shortcode_preview_iframe" width="100%"></iframe> <div id="preview"></div> </div> </div> </div> </div>'; } $html[] = '<div class="clearfix"></div>'; echo implode('', $html); exit; }
/** * Get params & structure of shortcode * * @return type */ public function shortcode_data() { $params = JSNPagebuilderHelpersShortcode::generateShortcodeParams($this->items, null, null, false, true); // add Margin parameter for Not child shortcode if (strpos($this->config['shortcode'], '_item') === false) { $this->config['params'] = array_merge(array('div_margin_top' => '', 'div_margin_bottom' => '', 'css_suffix' => ''), $params); } else { $this->config['params'] = $params; } $this->config['shortcode_structure'] = JSNPagebuilderHelpersShortcode::generateShortcodeStructure($this->config['shortcode'], $this->config['params']); }
public function display($tpl = null) { JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/shortcodesetting/settings-handler.js'); $js = ' var JSNPbParams = {pbstrings : {}}; JSNPbParams.rootUrl = \'' . JUri::root() . '\'; JSNPbParams.pbstrings.NO_ITEM_FOUND = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_NO_ITEM_FOUND') . '\'; JSNPbParams.pbstrings.SINGLE_ENTRY = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_SINGLE_ENTRY') . '\'; JSNPbParams.pbstrings.SETTINGS = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_SETTINGS') . '\'; JSNPbParams.pbstrings.INVALID_LINK = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_THE_LINK_IS_INVALID') . '\'; JSNPbParams.pbstrings.COPY = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_COPY') . '\'; JSNPbParams.pbstrings.EMPTY = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_EMPTY') . '\'; JSNPbParams.pbstrings.SELECT_DES_MARKER = \'' . JText::_('JSN_PAGEBUILDER_CONTROLLERS_SHORTCODE_SELECT_DES_MARKER') . '\'; '; JSNHtmlAsset::addInlineScript($js); $shortcode = JRequest::getString('shortcode'); $params = ''; // Get params from session then clear the session if (isset($_SESSION[JSNPB_SHORTCODE_SESSION_NAME][$shortcode]['params'])) { $params = $_SESSION[JSNPB_SHORTCODE_SESSION_NAME][$shortcode]['params']; $params = json_decode($params); $_SESSION[JSNPB_SHORTCODE_SESSION_NAME][$shortcode]['params'] = ''; } // TODO: move under assets inside shortcode // Add common js library for elements. JSNHtmlAsset::addScript(JSNPB_FRAMEWORK_ASSETS . '/3rd-party/jquery-tipsy/jquery.tipsy.js'); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/3rd-party/jquery-tipsy/tipsy.css'); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-general.css'); // for accordion_item, buttonbar_item, JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-fonticomoon.css'); // for accordion_item, buttonbar_item, $extract_params = ''; $shortcodeHelper = new JSNPagebuilderHelpersShortcode(); $data = array(); if (!empty($shortcode)) { // elements $class = $shortcodeHelper->getShortcodeClass($shortcode); if (class_exists($class)) { // Get all regitered element shortcodes global $JSNPbElements; $elements = $JSNPbElements->getElements(); $instance = isset($elements[strtolower($class)]) ? $elements[strtolower($class)] : null; // Init and register new instance if it not if (!is_object($instance)) { $instance = new $class(); } if (!empty($params)) { $params = stripslashes($params); $params = urldecode($params); } else { $params = $instance->config['shortcode_structure']; } // Add neccessary assets for the shortcode $instance->backend_element_assets(); // process require_js at backend setting if (isset($instance->config['exception']['require_js'])) { $requires = $instance->config['exception']['require_js']; foreach ($requires as $i => $require) { if (file_exists(JSNPB_ASSETS_PATH . $require)) { JSNHtmlAsset::addScript(JSNPB_ASSETS_PATH . $require); } } } if (!empty($params)) { $extract_params = JSNPagebuilderHelpersShortcode::extractParams($params, $shortcode); // if have sub-shortcode, get content if (!empty($instance->config['has_subshortcode'])) { $sub_sc_data = JSNPagebuilderHelpersShortcode::extractSubShortcode($params, true); $extract_params['sub_sc_content'] = $sub_sc_data; } // MODIFY $instance->items $shortcodeHelper->generateShortcodeParams($instance->items, NULL, $extract_params, TRUE); // recall this to re-extract params $instance->shortcode_data(); } // get Modal setting box $settings = $instance->items; $shortcodeAterfix = substr($shortcode, -5); $showPreview = true; if ($shortcodeAterfix == '_item') { $showPreview = false; } if ($shortcode == 'pb_row') { $showPreview = false; } $modalContent = $shortcodeHelper->getShortcodeModalSettings($settings, $shortcode, $extract_params); $this->assign('content', $modalContent); $this->assign('params', $params); $this->assign('shortcodeName', $shortcode); $this->assign('showPreview', $showPreview); } } return parent::display(); }