Esempio n. 1
0
 public function process($content)
 {
     preg_match_all($this->_shortcodeSyntax, $content, $out);
     if (count($out[0])) {
         $elemenPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/element.php';
         $childPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/child.php';
         $parentPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/parent.php';
         if (file_exists($elemenPath) && file_exists($childPath) && file_exists($parentPath)) {
             include_once $elemenPath;
             include_once $parentPath;
             include_once $childPath;
             // Autoload all helper classes.
             JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder', 'JSNPagebuilder');
             // Autoload all shortcode
             JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode', 'JSNPBShortcode');
             // Backward compatible for all JSN PageBuilder version =< 1.0.4
             if (is_dir(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements')) {
                 JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/', 'JSNPBShortcode');
             } else {
                 JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode');
             }
             global $JSNPbElements;
             $pcontent = '';
             $this->addScript();
             $JSNPbElements = new JSNPagebuilderHelpersElements();
             $objJSNPagebuilderHelpersBuilder = new JSNPagebuilderHelpersBuilder();
             $objJSNPagebuilderHelpersShortcode = new JSNPagebuilderHelpersShortcode();
             $content = $objJSNPagebuilderHelpersShortcode::removeAutop($content);
             $pcontent .= $objJSNPagebuilderHelpersBuilder->generateShortCode($content);
             $content = '<div id="jsnpa-pagebuilder-form-container" class="jsn-layout">' . $pcontent . '</div>';
         }
     }
     return $content;
 }
 public function onJSNPAPBReplaceContent($content)
 {
     //Check if the component is not installed.
     $isInstalledComponent = $this->isInstalledComponent();
     if ($isInstalledComponent != null && $isInstalledComponent == '1') {
         $apiPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/joomlashine/api/api.php';
         if (file_exists($apiPath)) {
             include_once $apiPath;
             $objJSNPageBuilderAPI = new JSNPageBuilderAPI();
             $content = $objJSNPageBuilderAPI->process($content);
         } else {
             //Backward compatible for JSN PageBuilder < 1.0.5
             preg_match_all('#\\[(\\[?)(pb_row)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)#', $content, $out);
             if (count($out[0])) {
                 $elemenPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/element.php';
                 $childPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/child.php';
                 $parentPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/parent.php';
                 if (file_exists($elemenPath) && file_exists($childPath)) {
                     include_once $elemenPath;
                     if (file_exists($parentPath)) {
                         include_once $parentPath;
                     }
                     include_once $childPath;
                     // Autoload all helper classes.
                     JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder', 'JSNPagebuilder');
                     // Autoload all shortcode
                     JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode', 'JSNPBShortcode');
                     // Backward compatible for all JSN PageBuilder version =< 1.0.4
                     if (is_dir(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements')) {
                         JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/', 'JSNPBShortcode');
                     } else {
                         JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode');
                     }
                     global $JSNPbElements;
                     $pcontent = '';
                     $this->addScript();
                     $JSNPbElements = new JSNPagebuilderHelpersElements();
                     $objJSNPagebuilderHelpersBuilder = new JSNPagebuilderHelpersBuilder();
                     $objJSNPagebuilderHelpersShortcode = new JSNPagebuilderHelpersShortcode();
                     $content = $objJSNPagebuilderHelpersShortcode::removeAutop($content);
                     $pcontent .= $objJSNPagebuilderHelpersBuilder->generateShortCode($content);
                     $content = '<div id="jsnpa-pagebuilder-form-container" class="jsn-layout">' . $pcontent . '</div>';
                 }
             }
         }
     }
     return $content;
 }
Esempio n. 3
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     JSNPagebuilderHelpersFunctions::loadFancyboxJS();
     $document = JFactory::getDocument();
     $document->addScript(JSNPB_ELEMENT_URL . '/buttonbar/assets/js/buttonbar.js', 'text/javascript');
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/buttonbar/assets/css/buttonbar.css', 'text/css');
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     $html_element = '';
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $items = explode('<!--seperate-->', $sub_shortcode);
     // remove empty element
     $items = array_filter($items);
     $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open;
     foreach ($items as $idx => $item) {
         $open = $idx + 1 == $initial_open ? 'in' : '';
         $items[$idx] = $item;
     }
     $sub_htmls = implode('', $items);
     if ($arr_params['buttonbar_show_title'] == 'no') {
         $pattern = '\\[(\\[?)(title)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         $sub_htmls = preg_replace('/' . $pattern . '/s', '', $sub_htmls);
     } else {
         $sub_htmls = str_replace('[title]', '', $sub_htmls);
         $sub_htmls = str_replace('[/title]', '', $sub_htmls);
     }
     if ($arr_params['buttonbar_show_icon'] == 'no') {
         $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         $sub_htmls = preg_replace('/' . $pattern . '/s', '', $sub_htmls);
     } else {
         $sub_htmls = str_replace('[icon]', '', $sub_htmls);
         $sub_htmls = str_replace('[/icon]', '', $sub_htmls);
     }
     if ($arr_params['buttonbar_group'] == 'no') {
         $html_element = $sub_htmls;
     } else {
         $html_element = "<div class='btn-group' style='float: none;'>" . $sub_htmls . '</div>';
     }
     $cls_alignment = '';
     if (strtolower($arr_params['buttonbar_alignment']) != 'inherit') {
         if (strtolower($arr_params['buttonbar_alignment']) == 'left') {
             $cls_alignment = 'pull-left';
         }
         if (strtolower($arr_params['buttonbar_alignment']) == 'right') {
             $cls_alignment = 'pull-right';
         }
         if (strtolower($arr_params['buttonbar_alignment']) == 'center') {
             $cls_alignment = 'text-center';
         }
     }
     $html_element .= '<div style="clear: both"></div>';
     $html_element = "<div class='btn-toolbar {$cls_alignment}'>{$html_element}</div>";
     $html_element .= '<div style="clear: both"></div>';
     return $this->element_wrapper($html_element, $arr_params);
 }
    /**
     * Generate html for PageBuilder layout.
     * 
     * @return string
     */
    public function html()
    {
        $helper = new JSNPagebuilderHelpersBuilder();
        JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/elements-lang.js');
        JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/handle.js');
        JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/shortcodesetting/settings-handler.js');
        // Genrate pagebuilder element template.
        $helper->generateElementColumnTemplate();
        $helper->generateElementRowTemplate();
        $source_content = '';
        $data = array();
        $source_content = $_POST['form_data'];
        // Remove all p tags which auto added by the editor
        $source_content = JSNPagebuilderHelpersShortcode::removeAutop($source_content);
        $source_content = html_entity_decode($source_content, ENT_COMPAT, 'UTF-8');
        $html[] = '<link rel="stylesheet" href="' . JSNPB_ADMIN_URL . '/assets/css/jsn-element-font.css' . '" type="text/css" />';
        $html[] = '<link rel="stylesheet" href="' . JSNPB_ADMIN_URL . '/assets/css/pb-layout-font.css' . '" type="text/css" />';
        $html[] = '<div id="form-container" class="jsn-layout jsn-section-content">';
        if ($source_content) {
            //$shortcodeTags		= $helper->getShortcodeTags();
            $html[] = $helper->generateShortCode($source_content);
        } else {
            $html[] = $helper->getRowStructure();
        }
        $html[] = '<a href="javascript:void(0);" id="jsn-add-container"
						class="jsn-add-more jsn-add-more-row"><i class="icon-plus"></i> Add Row
					</a>';
        /**
         * Show thumbnail for default layouts
         */
        $html[] = '<div class="row-fluid pb-layout-thumbs">';
        $layouts = JSNPBShortcodeRow::$layouts;
        foreach ($layouts as $columns) {
            $columns_name = implode('x', $columns);
            $icon_class = implode('-', $columns);
            $data_columns = implode(',', $columns);
            $icon_class = 'pb-layout-' . $icon_class;
            $icon = '<i class="' . $icon_class . '"></i>';
            $html[] = '<div class="thumb-wrapper" data-columns="' . $data_columns . '" title="' . $columns_name . '">' . $icon . '</div>';
        }
        $html[] = '</div>';
        $html[] = JSNHtmlGenerate::footer(array(), false);
        $html[] = '</div>';
        $html[] = $helper->getAddShortcodesPopup();
        if (defined("JSN_PAGEBUILDER_EDITION")) {
            if (strtolower(JSN_PAGEBUILDER_EDITION) == "free") {
                if (file_exists(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/articles.php')) {
                    include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/articles.php';
                    $pbTotal = JSNPagebuilderHelpersArticles::getCountArticleUsedPageBuilderFromPlugin();
                    if ($pbTotal >= 5 && !JFactory::getApplication()->input->getInt('article_id') && JFactory::getApplication()->input->getInt('is_com_modules') != 1) {
                        $html = array();
                        $html[] = '<div class="jsn-bootstrap3"><div class="pb-element-container"><p class="jsn-bglabel">You have reached 5 pages limit of using JSN PageBuilder.</p><p style="font-size: 20px;text-align: center;color: #d3d3d3;">Please  to upgrade <a target=\'_blank\' href=\'' . JSN_PAGEBUILDER_INFO_LINK . '\'>Pro version</a> or remove your old pages that used JSN PageBuilder.</p><div style="text-align: center"><a href="index.php?option=com_pagebuilder&view=upgrade" target="_blank" class="btn-primary btn-large btn"> Upgrade </a></div></div></div>';
                    }
                }
            }
        }
        print_r(implode("\n", $html));
        exit;
    }
Esempio n. 5
0
 /**
  * DEFINE shortcode content
  *
  * @param array $atts
  * @param string $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     // seperate by cell
     $items_html = explode('<!--seperate-->', $sub_shortcode);
     // remove empty element
     $items_html = array_filter($items_html);
     $row = 0;
     $not_empty = 0;
     $updated_html = array();
     foreach ($items_html as $item) {
         $cell_html = '';
         $cell_wrap = $row == 0 ? 'th' : 'td';
         if (strpos($item, 'CELL_WRAPPER') === false) {
             $cell_html .= $item == 'tr_start' ? '<tr>' : '</tr>';
             if (strip_tags($item) == 'tr_end') {
                 $row++;
             }
         } else {
             if (strpos($item, '<!--empty-->') !== false) {
                 $item = str_replace('<!--empty-->', '', $item);
             } else {
                 $not_empty++;
             }
             $cell_html .= str_replace('CELL_WRAPPER', $cell_wrap, $item);
         }
         $updated_html[] = $cell_html;
     }
     $sub_shortcode = implode('', $updated_html);
     if ($not_empty == 0) {
         $sub_shortcode = '';
     }
     $html_element = "<table class='table {$arr_params['tb_style']}'>" . $sub_shortcode . '</table>';
     $html_element .= '<div class="clear:both"></div>';
     return $this->element_wrapper($html_element, $arr_params);
 }
Esempio n. 6
0
 /**
  * DEFINE shortcode content
  *
  * @param array|null $atts
  * @param array|null $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         $this->load_assets_frontend();
     }
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $initial_open = intval($initial_open);
     $tab_position = $tab_position;
     $random_id = JSNPagebuilderHelpersShortcode::generateRandomString();
     $tab_navigator = array();
     $tab_navigator[] = '<ul class="nav nav-tabs">';
     // extract icons of tab items
     $sub_sc_data = JSNPagebuilderHelpersShortcode::extractSubShortcode($content);
     $sub_sc_data = $sub_sc_data[$this->config['has_subshortcode']];
     $items_data = array('icons' => array(), 'heading' => array());
     foreach ($sub_sc_data as $idx => $shortcode) {
         $extract_params = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode);
         $items_data['icons'][] = !empty($extract_params['icon']) ? "<i class='{$extract_params['icon']}'></i>&nbsp;" : '';
         $items_data['heading'][] = isset($extract_params['heading']) ? $extract_params['heading'] : '';
     }
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $items = explode('<!--seperate-->', $sub_shortcode);
     $items = array_filter($items);
     $initial_open = $initial_open > count($items) ? 1 : $initial_open;
     if ($fade_effect == 'yes') {
         $fade_effect = 'fade in';
     } else {
         $fade_effect = '';
     }
     foreach ($items as $idx => $item) {
         $active = $idx + 1 == $initial_open ? 'active' : '';
         $item = str_replace('{index}', $random_id . '_' . $idx, $item);
         $item = str_replace('{active}', $active, $item);
         $item = str_replace('{fade_effect}', $fade_effect, $item);
         $items[$idx] = $item;
         $active_li = $idx + 1 == $initial_open ? "class='active'" : '';
         $href = "#pane_" . $random_id . '_' . $idx;
         $tab_navigator[] = "<li {$active_li}><a href='{$href}' data-toggle='tab'>{$items_data['icons'][$idx]}{$items_data['heading'][$idx]}</a></li>";
     }
     $sub_shortcode = implode('', $items);
     $tab_content = "<div class='tab-content'>{$sub_shortcode}</div>";
     // update min-height of each tab content in case tap position is left/right
     if (in_array($tab_position, array('left', 'right'))) {
         $min_height = 36 * count($items);
         $tab_content = str_replace('STYLE', "style='min-height: {$min_height}px'", $tab_content);
     }
     $tab_navigator[] = '</ul>';
     $tab_positions = array('top' => '', 'left' => 'tabs-left', 'right' => 'tabs-right', 'bottom' => 'tabs-below');
     $extra_class = $tab_positions[$tab_position];
     if ($tab_position == 'bottom') {
         $tab_content .= implode('', $tab_navigator);
     } else {
         $tab_content = implode('', $tab_navigator) . $tab_content;
     }
     $html_element = "<div class='tabbable {$extra_class}' id='tab_{ID}'>{$tab_content}</div>";
     $html_element = str_replace('{ID}', "{$random_id}", $html_element);
     return $this->element_wrapper($html_element, $arr_params);
 }
Esempio n. 7
0
 /**
  * Generate HTML code from shortcode content.
  *
  * @param   array  $atts    Shortcode attributes.
  * @param   string $content Current content.
  *
  * @return  string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $html_element = '';
     $arr_sub_shortcodes = self::sync_sub_content($content);
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $arr_elements = explode('__#__', $prtbl_elements);
     // Build html for cols label.
     $pr_tbl_label_html = '<div class="pb-prtbl-cols first">';
     // Append blank header
     $header_ = '<div class="pb-prtbl-title">';
     if (in_array('image', $arr_elements)) {
         $header_ .= '<div class="pb-prtbl-image"></div>';
     }
     $header_ .= '<h3>&nbsp;</h3></div>';
     if (in_array('price', $arr_elements) || in_array('description', $arr_elements)) {
         $header_ .= '<div class="pb-prtbl-meta">';
         // append blank price
         if (in_array('price', $arr_elements)) {
             $header_ .= '<div class="pb-prtbl-price">&nbsp;</div>';
         }
         // append blank price
         if (in_array('description', $arr_elements)) {
             $header_ .= '<p class="pb-prtbl-desc">&nbsp;</p>';
         }
         $header_ .= '</div>';
     }
     $pr_tbl_label_html .= sprintf('<div class="pb-prtbl-header">%s</div>', $header_);
     if (in_array('attributes', $arr_elements)) {
         if (isset($arr_sub_shortcodes['pb_pricingtableattr_item']) && !empty($arr_sub_shortcodes['pb_pricingtableattr_item'])) {
             $pr_tbl_label_html .= '<ul class="pb-prtbl-features">';
             $pr_tbl_label_html .= JSNPagebuilderHelpersBuilder::generateShortCode($arr_sub_shortcodes['pb_pricingtableattr_item'], false, 'frontend', true);
             $pr_tbl_label_html .= '</ul>';
         }
     }
     if (in_array('button', $arr_elements)) {
         $pr_tbl_label_html .= '<div class="pb-prtbl-footer"></div>';
     }
     $pr_tbl_label_html .= '</div>';
     // Build html for cols value.
     $pr_tbl_col_value_html = '';
     if (isset($arr_sub_shortcodes['pb_pricingtable_item']) && !empty($arr_sub_shortcodes['pb_pricingtable_item'])) {
         $pr_tbl_col_value_html = JSNPagebuilderHelpersBuilder::generateShortCode(implode('', $arr_sub_shortcodes['pb_pricingtable_item']), false, 'frontend', true);
         $pr_tbl_col_value_html = $this->check_field_allow('title', 'prtbl_item_title', $arr_elements, $pr_tbl_col_value_html);
         $pr_tbl_col_value_html = $this->check_field_allow('description', 'prtbl_item_desc', $arr_elements, $pr_tbl_col_value_html);
         $pr_tbl_col_value_html = $this->check_field_allow('image', 'prtbl_item_image', $arr_elements, $pr_tbl_col_value_html);
         $pr_tbl_col_value_html = $this->check_field_allow('button', 'prtbl_item_button', $arr_elements, $pr_tbl_col_value_html);
         $pr_tbl_col_value_html = $this->check_field_allow('price', 'prtbl_item_price', $arr_elements, $pr_tbl_col_value_html);
         $pr_tbl_col_value_html = $this->check_field_allow('attributes', 'prtbl_item_attributes', $arr_elements, $pr_tbl_col_value_html);
         if (!in_array('price', $arr_elements) && !in_array('description', $arr_elements)) {
             $pattern = '\\[(\\[?)(prtbl_item_meta)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
             $pr_tbl_col_value_html = preg_replace("/{$pattern}/s", '', $pr_tbl_col_value_html);
         } else {
             $pr_tbl_col_value_html = str_replace("[prtbl_item_meta]", '', $pr_tbl_col_value_html);
             $pr_tbl_col_value_html = str_replace("[/prtbl_item_meta]", '', $pr_tbl_col_value_html);
         }
     }
     $count_columns = isset($arr_sub_shortcodes['pb_pricingtable_item']) ? count($arr_sub_shortcodes['pb_pricingtable_item']) + 1 : 1;
     $html_element = $pr_tbl_label_html . $pr_tbl_col_value_html;
     return $this->element_wrapper($html_element, $arr_params, "table-{$count_columns}-col");
 }
Esempio n. 8
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         $this->load_assets_frontend();
     }
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $random_id = JSNPagebuilderHelpersShortcode::generateRandomString();
     $testimonial_id = "testimonial_{$random_id}";
     $styles = "style='width:100%'";
     $image_container_style = $author_image_style != 'no-styling' ? "{$author_image_style}" : '';
     $content_elements = array_filter(explode('__#__', $content_elements));
     $testimonial_indicators = array();
     $testimonial_indicators[] = '<ol class="carousel-indicators">';
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $testimonial_content = array();
     $items = explode('<!--seperate-->', $sub_shortcode);
     $items = array_filter($items);
     $count_items = count($items);
     foreach ($items as $idx => $item) {
         $pathRoot = JURI::root();
         $item = unserialize($item);
         $url_pattern = '/^(http|https)/';
         $image_file = @$item['image_file'];
         preg_match($url_pattern, $image_file, $m);
         if (count($m)) {
             $pathRoot = '';
         }
         if ($idx % $items_per_slide == 0) {
             $active = $idx == 0 ? 'active' : '';
             $testimonial_content[] = "<div class='item row {$active}'>";
             $active_li = $idx == 0 ? "class='active'" : '';
             $testimonial_indicators[] = "<li {$active_li}></li>";
         }
         $divide = $count_items > $items_per_slide ? $items_per_slide : $count_items;
         $colmd = 'col-md-' . 12 / $divide;
         $colsm = 'col-sm-' . 12 / $divide;
         $item_html = "<div class='pb-testimonial-item {$colmd} {$colsm}'>";
         $testimonial_info = array();
         if (in_array('content', $content_elements)) {
             $item_content = JSNPagebuilderHelpersShortcode::removeAutop($item['testimonial_content']);
             $item_content = JSNPagebuilderHelpersShortcode::pbTrimContent($item_content, $content_count, $content_type);
             $testimonial_info['content'] = "<div class='pb-testimonial-box top'><div class='arrow'></div><div class='pb-testimonial-content'><p>" . $item_content . '</p></div></div>';
         }
         $img = !empty($item['image_file']) ? "<div class='pb-testimonial-avatar'><img class='{$image_container_style}' src='{$pathRoot}{$item['image_file']}' /></div>" : '';
         $testimonial_info['image'] = in_array('image', $content_elements) ? $img : '';
         // Process company field
         if (isset($item['company']) && $item['company'] != '') {
             $company_link = "<a href='{$item['web_url']}' target='_blank'>{$item['company']}</a>";
         } else {
             $company_link = "<a href='{$item['web_url']}' target='_blank'>{$item['web_url']}</a>";
         }
         if (!isset($item['web_url']) || empty($item['web_url'])) {
             $company_link = $item['company'];
         }
         // Process testimonial metadata
         $arr_style = array();
         if (isset($item['name_height'])) {
             $arr_style[] = 'font-size: ' . $item['name_height'] . 'px';
         }
         if (isset($item['name_color'])) {
             $arr_style[] = 'color: ' . $item['name_color'];
         }
         $style = $arr_style ? "style='" . implode(';', $arr_style) . "'" : '';
         $name = in_array('name', $content_elements) ? "<strong {$style} class='pb-testimonial-name'>" . @$item['name'] . "</strong>" : '';
         $job_title = in_array('job_title', $content_elements) ? "<span class='pb-testimonial-jobtitle'>" . @$item['job_title'] . "</span>" : '';
         $country = in_array('country', $content_elements) ? "<span class='pb-testimonial-country'>" . @$item['country'] . "</span>" : '';
         if ($company_link) {
             $company = in_array('company', $content_elements) ? "<span class='pb-testimonial-company'>{$company_link}</span>" : '';
         }
         $html_metadata = '';
         if ($name != '' || $job_title != '' || $country != '' || $company != '') {
             $html_metadata .= '<div class="pb-testimonial-meta">';
             $html_metadata .= $name . $job_title . $country . $company;
             $html_metadata .= '</div>';
         }
         foreach ($content_elements as $element) {
             $item_html .= isset($testimonial_info[$element]) ? $testimonial_info[$element] : '';
         }
         $item_html .= $html_metadata;
         $item_html .= '</div>';
         $testimonial_content[] = $item_html;
         if (($idx + 1) % $items_per_slide == 0 || $idx + 1 == count($items)) {
             $testimonial_content[] = '</div>';
         }
     }
     $testimonial_content = "<div class='carousel-inner'>" . implode('', $testimonial_content) . '</div>';
     $testimonial_indicators[] = "</ol>";
     $testimonial_indicators = implode('', $testimonial_indicators);
     $slider_time = $slider_time . '000';
     if ($auto_play == 'yes') {
         $script = "<script type='text/javascript'>\n\t\t\t\t\t\t(function(\$){\n\t\t\t\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\t\t\tif(\$('#{$testimonial_id}').length){\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel({\n\t\t\t\t\t\t\t\t      interval: " . (int) $slider_time . "\n\t\t\t\t\t\t\t\t    });\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id} .carousel-indicators li').each(function(i){\n\t\t\t\t\t\t\t\t\t\t\$(this).on('click', function(){\n\t\t\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel(i);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})(jQuery)\n\t\t\t\t</script>";
     } else {
         $script = "<script type='text/javascript'>\n\t\t\t\t\t\t(function(\$){\n\t\t\t\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\t\t\tif(\$('#{$testimonial_id}').length){\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel({\n\t\t\t\t\t\t\t\t      interval: false\n\t\t\t\t\t\t\t\t    });\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id} .carousel-indicators li').each(function(i){\n\t\t\t\t\t\t\t\t\t\t\$(this).on('click', function(){\n\t\t\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel(i);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})(jQuery)\n\t\t\t\t</script>";
     }
     $slider_elements = explode('__#__', $slider_elements);
     if ($count_items <= (int) $items_per_slide || !in_array('indicator', $slider_elements)) {
         $testimonial_indicators = '';
     }
     $testimonial_navigator = $count_items > $items_per_slide && in_array('arrows', $slider_elements) ? "<a class='carousel-control left icon-arrow-left pb-arrow-left'></a><a class='carousel-control right icon-arrow-right pb-arrow-right'></a>" : '';
     $html = "<div class='carousel slide pb-testimonial' {$styles} id='{$testimonial_id}'> {$testimonial_content} {$testimonial_indicators} {$testimonial_navigator}</div>";
     return $this->element_wrapper($script . $html, $arr_params);
 }
Esempio n. 9
0
 /**
  * Method to generate shortcode preview
  * 
  * @return string
  */
 public function preview()
 {
     $session = JFactory::getSession();
     JHtml::_('jquery.framework');
     JHtml::_('bootstrap.framework');
     $document = JFactory::getDocument();
     $document->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . 'js/joomlashine.noconflict.js', 'text/javascript');
     $document->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/bootstrap3/js/bootstrap.min.js', 'text/javascript');
     $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/bootstrap3/css/bootstrap.min.css', 'text/css');
     $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/jsn-gui-frontend.css', 'text/css');
     $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/pagebuilder.css', 'text/css');
     $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/front_end.css', 'text/css');
     $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/front_end_responsive.css', 'text/css');
     $document->addStyleSheet(JSNPB_ASSETS_URL . 'css/preview.css', 'text/css');
     if (!$_POST['params']) {
         exit(JText::_("can not find input data"));
     }
     $shortcode_content = urldecode($_POST['params']);
     $session->set('JSNPA_SHORTCODECONTENT', $shortcode_content);
     $helper = new JSNPagebuilderHelpersBuilder();
     $html = $helper->generateShortCode($shortcode_content, false, 'frontend');
     echo '<div class="jsn-bootstrap3">' . $html . '</div>';
 }
Esempio n. 10
0
 /**
  * define shortcode structure of element
  * 
  * @return string
  */
 function element_shortcode($atts = null, $content = null)
 {
     extract(JSNPagebuilderHelpersShortcode::shortcodeAtts(array('span' => 'span6', 'style' => ''), $atts));
     $style = empty($style) ? '' : "style='{$style}'";
     $span = intval(substr($span, 4));
     $class = "col-md-{$span} col-sm-{$span} col-xs-12";
     $column_html = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, true, 'frontend');
     return '<div class="' . $class . '" ' . $style . '>' . $column_html . '</div>';
 }
Esempio n. 11
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addStyleSheet(JSNPB_ELEMENT_URL . "/list/assets/css/list.css", 'text/css');
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     $link = '';
     $exclude_params = array('tag', 'text', 'preview');
     $arr_styles = array();
     if (strtolower($arr_params['font_face_type']) == 'google fonts' and $arr_params['font'] != 'inherit') {
         $document->addStyleSheet("http://fonts.googleapis.com/css?family={$arr_params['font_face_value']}", 'text/css');
     }
     if ($arr_params['font'] != 'inherit') {
         if ($arr_params['font_face_value']) {
             $arr_styles[] = 'font-family: ' . $arr_params['font_face_value'];
         }
         if ($arr_params['font_size_value']) {
             $arr_styles[] = 'font-size: ' . $arr_params['font_size_value'] . 'px';
         }
         if ($arr_params['color']) {
             $arr_styles[] = 'color: ' . $arr_params['color'];
         }
         if ($arr_params['font_style'] == 'bold') {
             $arr_styles[] = 'font-weight: 700 !important';
         } else {
             if ($arr_params['font_style'] == 'normal') {
                 $arr_styles[] = 'font-weight: normal !important';
             } else {
                 $arr_styles[] = 'font-style: ' . $arr_params['font_style'];
             }
         }
     }
     $arr_icon_styles = array();
     $arr_icon_class = array();
     $arr_icon_class[] = '';
     if ($arr_params['icon_position']) {
         $icon_position = strtolower($arr_params['icon_position']);
         $arr_icon_class[] = $icon_position != 'inherit' ? "pb-position-{$icon_position}" : '';
     }
     if (strtolower($arr_params['icon_background_type']) != '') {
         $arr_icon_class[] = "pb-shape-{$arr_params['icon_background_type']}";
     }
     if ($arr_params['icon_size_value']) {
         $arr_icon_class[] = "pb-icon-{$arr_params['icon_size_value']}";
     }
     if ($arr_params['icon_background_color']) {
         $arr_icon_styles[] = 'background-color: ' . $arr_params['icon_background_color'];
     }
     if ($arr_params['icon_c_color']) {
         $arr_icon_styles[] = 'color: ' . $arr_params['icon_c_color'];
     }
     $html_elements = '';
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $items = explode('<!--seperate-->', $sub_shortcode);
     // remove empty element
     $items = array_filter($items);
     $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open;
     foreach ($items as $idx => $item) {
         $open = $idx + 1 == $initial_open ? 'in' : '';
         $items[$idx] = $item;
     }
     if (!empty($sub_shortcode)) {
         $parent_class = implode(' ', $arr_icon_class);
         $html_elements = "<ul class='pb-list-icons {$parent_class}'>";
         $sub_htmls = $sub_shortcode;
         $sub_htmls = str_replace('pb-sub-icons', 'pb-icon-base', $sub_htmls);
         $sub_htmls = str_replace('pb-styles', implode(';', $arr_icon_styles), $sub_htmls);
         $sub_htmls = str_replace('pb-list-title', implode(';', $arr_styles), $sub_htmls);
         if ($arr_params['show_icon'] == 'no') {
             $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
             $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
         } else {
             $sub_htmls = str_replace('[icon]', '', $sub_htmls);
             $sub_htmls = str_replace('[/icon]', '', $sub_htmls);
         }
         if ($arr_params['show_heading'] == 'no') {
             $pattern = '\\[(\\[?)(heading)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
             $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
         } else {
             $sub_htmls = str_replace('[heading]', '', $sub_htmls);
             $sub_htmls = str_replace('[/heading]', '', $sub_htmls);
         }
         $html_elements .= $sub_htmls;
         $html_elements .= '</ul>';
         $html_elements .= '<div style="clear: both"></div>';
     }
     return $this->element_wrapper($link . $html_elements, $arr_params);
 }
Esempio n. 12
0
 /**
  * define shortcode structure of element
  *
  * @return string
  */
 function element_shortcode($atts = null, $content = null)
 {
     $extra_class = $style = $common_style = $data_attr = '';
     $extra_id = !empty($atts['id_wrapper']) ? $atts['id_wrapper'] : JSNPagebuilderHelpersShortcode::generateRandomString();
     if (isset($atts) && is_array($atts)) {
         $arr_styles = array();
         //            if(isset($atts['width'])){
         //                if($atts['width'] == 'full'){
         //                    $extra_class = 'pb_fullwidht';
         //                    $script = "$(body).addClass('pb_fullwidht');";
         //                    $custom_script = JSNPagebuilderHelpersShortcode::script_box($script);
         //                    $arr_styles[] = '-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;width: 100%;padding-left: 1000px;padding-right: 1000px;margin:0 -1000px;';
         //                }
         //            }
         $background = "";
         switch ($atts['background']) {
             case 'solid':
                 $solid_color = $atts['solid_color_value'];
                 $background = "background-color: {$solid_color};";
                 break;
             case 'gradient':
                 if (!isset($atts['gradient_color_css'])) {
                     $background = "background:linear-gradient(center top , #ffffff 0%, #000000 100%);background:-moz-linear-gradient(center top , #ffffff 0%, #000000 100%);    background: -webkit-linear-gradient(#FFFFFF, #000000);background:-o-linear-gradient(center top , #ffffff 0%, #000000 100%);background:-ms-linear-gradient(center top , #ffffff 0%, #000000 100%);";
                 } else {
                     $background = $atts['gradient_color_css'];
                 }
                 break;
             case 'pattern':
                 $pattern_img = isset($atts['pattern']) ? $atts['pattern'] : '';
                 $pattern_repeat = isset($atts['repeat']) ? $atts['repeat'] : '';
                 $background = "background-image:url('{$pattern_img}');";
                 switch ($pattern_repeat) {
                     case 'full':
                         $background_repeat = "repeat";
                         break;
                     case 'vertical':
                         $background_repeat = "repeat-y";
                         break;
                     case 'horizontal':
                         $background_repeat = "repeat-x";
                         break;
                     default:
                         $background_repeat = "repeat";
                 }
                 $background .= "background-repeat:{$background_repeat};";
                 break;
             case 'image':
                 if (isset($atts['image'])) {
                     $image = $atts['image'];
                 }
                 $image_position = $atts['position'];
                 $pattern_stretch = isset($atts['stretch']) ? $atts['stretch'] : '';
                 $background = "background-image:url('{$image}');background-position:{$image_position};";
                 switch ($pattern_stretch) {
                     case 'none':
                         $background_size = "";
                         break;
                     case 'full':
                         $background_size = "100% 100%";
                         break;
                     case 'cover':
                         $background_size = "cover";
                         break;
                     case 'contain':
                         $background_size = "contain";
                         break;
                 }
                 $background .= !empty($background_size) ? "background-size:{$background_size};" : "";
                 break;
             case 'video':
                 $url = $atts['video_url'];
                 // Youtube video
                 if (preg_match('/youtube\\.com/', $url)) {
                     $extra_class .= 'pb_video_bg';
                     parse_str($url, $youtube_url);
                     $data_attr = sprintf("data-property=\"{videoURL:'http://youtu.be/%s', containment:'%s', autoplay:%s, mute:true, startAt:0, opacity:1, showControls:false}\"", reset($youtube_url), "#{$extra_id}", $atts['autoplay']);
                     $script = "\r\n                        (function(\$){\r\n                            \$(document).ready(function(){\r\n                                \$('.pb_video_bg').mb_YTPlayer();\r\n                                    \$('.pb_video_bg').click(function(){ \$(this).playYTP()})\r\n                            })\r\n                            })(jQuery)\r\n                            ";
                     JFactory::getDocument()->addScriptDeclaration($script, 'text/javascript');
                     self::enqueue_player_scripts();
                 }
                 break;
         }
         $arr_styles[] = $background;
         if (isset($atts['paralax']) && $atts['paralax'] == 'yes') {
             $arr_styles[] = "background-attachment:fixed;";
         }
         if (isset($atts['parallax_scroll']) && $atts['parallax_scroll'] == 'yes') {
             $extra_class .= 'parallax';
             $document = JFactory::getDocument();
             $document->addScript(JUri::root(true) . '/administrator/components/com_pagebuilder/helpers/shortcode/row/assets/js/parallax.js', 'text/javascript');
         }
         if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) {
             $border = array();
             $border[] = $atts['border_width_value_'] . "px";
             $border[] = $atts['border_style'];
             $border[] = $atts['border_color'];
             $border = implode(" ", $border);
             $arr_styles[] = "border-top:{$border}; border-bottom:{$border};";
         }
         $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;";
         $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;";
         $arr_styles[] = "padding-left:{$atts['div_padding_left']}px;";
         $arr_styles[] = "padding-right:{$atts['div_padding_right']}px;";
         if (@$atts['width_value']) {
             $arr_styles[] = "width:" . $atts['width_value'] . $atts['width_unit'] . '; margin:0 auto';
         }
         $arr_styles = implode("", $arr_styles);
         $style = !empty($arr_styles) ? "style=\"{$arr_styles}\"" : "";
     }
     $column_html = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, true, 'frontend');
     $extra_class .= !empty($atts['css_suffix']) ? ' ' . htmlspecialchars($atts['css_suffix']) : '';
     $extra_class = ltrim($extra_class, ' ');
     return $common_style . "<div class='jsn-bootstrap3'><div id='{$extra_id}' class='{$extra_class} row' {$style} {$data_attr}>" . $column_html . "</div></div>";
 }
Esempio n. 13
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/carousel/assets/css/carousel.css', 'text/css');
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/carousel/assets/css/carousel-responsive.css', 'text/css');
     $document->addScriptDeclaration("if (typeof jQuery != 'undefined' && typeof MooTools != 'undefined' ) {\n\t\t\t\t\t\t\t\t\t\t    Element.implement({\n\t\t\t\t\t\t\t\t\t\t        slide: function(how, mode){\n\t\t\t\t\t\t\t\t\t\t            return this;\n\t\t\t\t\t\t\t\t\t\t        }\n\t\t\t\t\t\t\t\t\t\t    });\n\n\t\t\t\t\t\t\t\t\t\t}", 'text/javascript');
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $random_id = JSNPagebuilderHelpersShortcode::generateRandomString();
     $carousel_id = "carousel_{$random_id}";
     // Set fixed stylesheet
     $document->addStyleDeclaration("#{$carousel_id} .item{\n\t\t\twidth: 100% !important;\n\t\t\tmargin: 0;\n\t\t}", 'text/css');
     $interval_time = !empty($cycling_interval) ? intval($cycling_interval) * 1000 : 5000;
     $interval = $automatic_cycling == 'yes' ? $interval_time : 'false';
     $pause = $pause_mouseover == 'yes' ? 'pause : "hover"' : 'pause : "false"';
     $script = "<script type='text/javascript'>\n\t\t\t(function (\$){ \n\t\t\t\t\$( document ).ready(function(){\n\t\t\t\t\tif( \$( '#{$carousel_id}' ).length ){ \n\t\t\t\t\t\t\$( '#{$carousel_id}' ).carousel( {interval: {$interval},{$pause}} );\n\t\t\t\t\t\t\n\t\t\t\t\t\t\$( '#{$carousel_id} .carousel-indicators li' ).each(function (i) {\n\t\t\t\t\t\t\t\$(this).on('click', function () {\n\t\t\t\t\t\t\t\t\$('#{$carousel_id}').carousel(i);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} )( JoomlaShine.jQuery );\n\t\t</script>";
     $styles = array();
     if (!empty($dimension_width)) {
         $styles[] = "width : {$dimension_width}{$dimension_width_unit};";
     }
     if (!isset($atts['dimension_height'])) {
         $styles[] = "min-height : 0px;";
     } else {
         if (!empty($dimension_height)) {
             $styles[] = "min-height : {$dimension_height}px;";
         }
     }
     if (in_array($align, array('left', 'right', 'inherit'))) {
         $styles[] = 'float : ' . $align . ';';
     } else {
         if ($align == 'center') {
             $styles[] = 'margin : 0 auto;';
         }
     }
     $styles = trim(implode(' ', $styles));
     $styles = !empty($styles) ? "style='{$styles}'" : '';
     $carousel_indicators = array();
     $carousel_indicators[] = '<ol class="carousel-indicators">';
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $items = explode('<!--seperate-->', $sub_shortcode);
     $items = array_filter($items);
     $initial_open = isset($initial_open) ? $initial_open > count($items) ? 1 : $initial_open : 1;
     foreach ($items as $idx => $item) {
         $active = $idx + 1 == $initial_open ? 'active' : '';
         $item = str_replace('{active}', $active, $item);
         $item = str_replace('{WIDTH}', !empty($dimension_width) ? 'width : ' . $dimension_width . $dimension_width_unit . ';' : '', $item);
         $item = str_replace('{HEIGHT}', !empty($dimension_height) ? 'height : ' . $dimension_height . 'px;' : '', $item);
         $items[$idx] = $item;
         $active_li = $idx + 1 == $initial_open ? "class='active'" : '';
         $carousel_indicators[] = "<li data-target='#{$carousel_id}' {$active_li}></li>";
     }
     $carousel_content = "<div class='carousel-inner'>" . implode('', $items) . '</div>';
     $carousel_indicators[] = '</ol>';
     $carousel_indicators = implode('', $carousel_indicators);
     if ($show_indicator == 'no') {
         $carousel_indicators = '';
     }
     $carousel_navigator = '';
     if ($show_arrows == 'yes') {
         $carousel_navigator = "<a class='left carousel-control' href='#{$carousel_id}' data-slide='prev'><span class='icon-arrow-left'></span></a><a class='right carousel-control' href='#{$carousel_id}' data-slide='next'><span class='icon-arrow-right'></span></a>";
     }
     $html = "<div class='carousel slide' {$styles} id='{$carousel_id}'>{$carousel_indicators} {$carousel_content} {$carousel_navigator}</div><div style=\"clear: both\"></div>";
     return $this->element_wrapper($html . $script, $arr_params);
 }
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addScript(JSNPB_ELEMENT_URL . '/socialicon/assets/js/socialicon.js', 'text/javascript');
     $document->addStyleSheet(JSNPB_ADMIN_URL . '/assets/3rd-party/font-awesome/css/font-awesome.css', 'text/css');
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/socialicon/assets/css/socialicon.css', 'text/css');
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $style = '';
     if ($icon_bg_color == 'custom') {
         $style .= 'background:' . $custom_bg_color . ';';
     }
     if ($shape == 'square') {
         if (!empty($rounded_corner)) {
             $style .= 'border-radius:' . $rounded_corner . 'px;';
         }
     } elseif ($shape == 'circle') {
         $style .= 'border-radius:50px;';
     }
     $html_elements = '';
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     if (!empty($sub_shortcode)) {
         $html_elements = "<ul class='pb-social-icons {$shape} {$icon_bg_color}'>";
         $sub_htmls = $sub_shortcode;
         $sub_htmls = str_replace('{icon_size}', $icon_size, $sub_htmls);
         $sub_htmls = str_replace('STYLE', "style='{$style}'", $sub_htmls);
         $html_elements .= $sub_htmls;
         $html_elements .= '</ul>';
         $html_elements .= '<div style="clear: both"></div>';
     }
     return $this->element_wrapper($html_elements, $arr_params);
 }
Esempio n. 15
0
 public function element_shortcode($atts = null, $content = null)
 {
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $href = 'href="' . $button_type_url . '"';
     $target = $script = '';
     if ($open_in) {
         switch ($open_in) {
             case 'current_browser':
                 $target = '';
                 break;
             case 'new_browser':
                 $target = ' target="_blank"';
                 break;
             case 'new_window':
                 $cls_button_fancy = 'pb-button-new-window';
                 break;
             case 'lightbox':
                 $cls_button_fancy = 'pb-prtbl-button-fancy';
                 break;
         }
     }
     $button_type = " type='button'";
     $cls_button_fancy = !isset($cls_button_fancy) ? '' : $cls_button_fancy;
     $script = !isset($script) ? '' : $script;
     // Process col title
     @($attr_title .= '<div class="pb-prtbl-title">');
     // Process for image
     $attr_title .= '[prtbl_item_image]<div class="pb-prtbl-image">';
     if ($prtbl_item_image) {
         $pathRoot = JURI::root();
         $url_pattern = '/^(http|https)/';
         $image_file = $prtbl_item_image;
         preg_match($url_pattern, $image_file, $m);
         if (count($m)) {
             $pathRoot = '';
         }
         $attr_title .= '<img src="' . $pathRoot . $prtbl_item_image . '" />';
     }
     $attr_title .= '</div>[/prtbl_item_image]';
     // Process for title
     $attr_title .= '[prtbl_item_title]<h3>' . $prtbl_item_title . '</h3>[/prtbl_item_title]';
     $attr_title .= '</div>';
     $attr_title .= '[prtbl_item_meta]<div class="pb-prtbl-meta">';
     $attr_title .= '[prtbl_item_price]<div class="pb-prtbl-price">';
     if ($prtbl_item_currency) {
         $attr_title .= '<sup class="pb-prtbl-currency">' . $prtbl_item_currency . '</sup>';
     }
     $attr_title .= $prtbl_item_price;
     if ($prtbl_item_time) {
         $attr_title .= '<sub class="pb-prtbl-time">' . $prtbl_item_time . '</sub>';
     }
     $attr_title .= '</div>[/prtbl_item_price]';
     // Process for description
     $attr_title .= '[prtbl_item_desc]<p class="pb-prtbl-desc">' . $prtbl_item_desc . '</p>[/prtbl_item_desc]';
     $attr_title .= '</div>[/prtbl_item_meta]';
     $featured = $prtbl_item_feature == 'yes' ? ' pb-prtbl-cols-featured' : '';
     $pr_tbl_col_html = "<div class='pb-prtbl-cols{$featured}'>";
     $pr_tbl_col_html .= '<div class="pb-prtbl-header">' . $attr_title . '</div>';
     if (!empty($content)) {
         $pr_tbl_col_html .= '<ul class="pb-prtbl-features">';
         $pr_tbl_col_html .= JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
         $pr_tbl_col_html .= '</ul>';
     }
     $pr_tbl_col_html .= "[prtbl_item_button]<div class='pb-prtbl-footer'><a class='btn btn-default {$cls_button_fancy}'{$href}{$target}{$button_type}>{$prtbl_item_button_text}</a></div>[/prtbl_item_button]";
     $pr_tbl_col_html .= '</div>';
     return $pr_tbl_col_html . $script;
 }
Esempio n. 16
0
 private static function loadElementAssets()
 {
     //BEGIN compress
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     // Require base shorcode element
     self::requireBaseShortCodeElement();
     $JSNPbElements = new JSNPagebuilderHelpersElements();
     if ($doc instanceof JDocumentHTML) {
         $content = $doc->getBuffer('component');
         $modules = JModuleHelper::getModuleList();
         if (count($modules)) {
             foreach ($modules as $module) {
                 if (trim($module->content) != '') {
                     $content .= $module->content;
                 }
             }
         }
         $content = str_replace('$', '&dollar;', $content);
         $helper = new JSNPagebuilderHelpersBuilder();
         $elementClass = $helper->getShortCodeClassBeforeRender($content);
         if (!$app->isAdmin()) {
             JHtml::_('jquery.framework');
             $doc->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . 'js/joomlashine.noconflict.js', 'text/javascript');
             $doc->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/bootstrap3/js/bootstrap.min.js', 'text/javascript');
             //$doc->addScript( JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/scrollreveal/scrollReveal.js', 'text/javascript' );
             $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/bootstrap3/css/bootstrap.min.css', 'text/css');
             $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/pagebuilder.css', 'text/css');
             $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/jsn-gui-frontend.css', 'text/css');
             $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/front_end.css', 'text/css');
             $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/front_end_responsive.css', 'text/css');
         }
         if (is_array($elementClass) && count($elementClass) > 0) {
             foreach ($elementClass as $class) {
                 $instance = new $class();
                 if (method_exists($instance, 'load_assets_frontend')) {
                     $instance->load_assets_frontend();
                 }
             }
         }
     }
 }
Esempio n. 17
0
 /**
  * Check the whole site content then replace found
  * PageBuilder shortcodes by Elements
  *
  * @return  Changed HTML format
  */
 public function onAfterRender()
 {
     // Get requested component, view and task
     $app = JFactory::getApplication();
     $tpl = $app->input->getInt('tp', 0);
     $option = $app->input->getCmd('option', '');
     $view = $app->input->getCmd('view', '');
     $layout = $app->input->getCmd('layout', '');
     $user = JFactory::getUser();
     // Remove scrollspy jQuery conflict
     if ($app->isAdmin() && $option == 'com_pagebuilder') {
         if ($view == 'configuration') {
             $html = $app->getBody();
             if (preg_match_all("/\\\$\\('\\.subhead'\\)\\.scrollspy\\(\\{[^\r\n]+\\}\\);/", $html, $matches, PREG_SET_ORDER)) {
                 $html = preg_replace("/\\\$\\('\\.subhead'\\)\\.scrollspy\\(\\{[^\r\n]+\\}\\);/", '', $html);
                 $app->setBody($html);
             }
         }
     }
     if ($app->isAdmin() || $tpl) {
         return;
     }
     $doc = JFactory::getDocument();
     if (get_class($doc) != "JDocumentHTML") {
         return;
     }
     if ($app->isSite() && $option == 'com_content' && $view == 'form' && $layout == 'edit' && $user->get('id') > 0) {
         return;
     }
     // Check if JoomlaShine extension framework is enabled?
     $framework = JTable::getInstance('Extension');
     $framework->load(array('element' => 'jsnframework', 'type' => 'plugin', 'folder' => 'system'));
     // Do nothing if JSN Extension framework not found.
     if (!$framework->extension_id) {
         return;
     }
     // Require base shorcode element
     require_once JSNPB_ADMIN_ROOT . '/libraries/innotheme/shortcode/element.php';
     require_once JSNPB_ADMIN_ROOT . '/libraries/innotheme/shortcode/parent.php';
     require_once JSNPB_ADMIN_ROOT . '/libraries/innotheme/shortcode/child.php';
     global $JSNPbElements;
     $JSNPbElements = new JSNPagebuilderHelpersElements();
     // Get PageBuilder configuration.
     $params = JSNConfigHelper::get('com_pagebuilder');
     // Check if it's enabled or not.
     $isEnabled = $params->get('enable_pagebuilder', 1);
     // Do nothing if PageBuilder not enabled;
     if (!$isEnabled) {
     }
     $data = $doc->getHeadData();
     JHtml::_('jquery.framework');
     $doc->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . 'js/joomlashine.noconflict.js', 'text/javascript');
     $doc->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/bootstrap3/js/bootstrap.min.js', 'text/javascript');
     $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/bootstrap3/css/bootstrap.min.css', 'text/css');
     $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/pagebuilder.css', 'text/css');
     $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/jsn-gui-frontend.css', 'text/css');
     $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/front_end.css', 'text/css');
     $doc->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/front_end_responsive.css', 'text/css');
     // Store the assets before transforming.
     $inlineScriptBefore = isset($data['script']['text/javascript']) ? $data['script']['text/javascript'] : '';
     $inlineStyleBefore = isset($data['style']['text/css']) ? $data['style']['text/css'] : '';
     $scriptsBefore = $data['scripts'];
     $styleSheetsBefore = $data['styleSheets'];
     $scriptCount = count($scriptsBefore);
     $styleSheetCount = count($styleSheetsBefore);
     // Analyze page content and use PageBuilder to
     // transform code if Pb structure found.
     // Get the responsed body
     $content = JResponse::getBody();
     // preg_replace falsely process $ symobols as commands in text copy.
     $content = str_replace('$', '&dollar;', $content);
     $body_content = '';
     preg_match("/<body.*\\/body>/si", $content, $body_content);
     if (!isset($body_content[0])) {
         return;
     }
     $body_content = $body_content[0];
     $helper = new JSNPagebuilderHelpersBuilder();
     // Transform the content inside body tag only
     $body_content = $helper->generateShortCode($body_content, false, 'frontend');
     // Apply the body content into page content
     $content = preg_replace("/(<body.*\\/body>)/si", $body_content, $content);
     /*
      * Arrange the assets loaded from PageBuilder
      * Because onAfterRender not accept add assets by JFactory::getDocument()
      * so we need under code to modify document's header 
      */
     $data = $doc->getHeadData();
     $inlineScriptAfter = isset($data['script']['text/javascript']) ? $data['script']['text/javascript'] : '';
     $inlineStyleAfter = isset($data['style']['text/css']) ? $data['style']['text/css'] : '';
     $scriptsAfter = $data['scripts'];
     $styleSheetsAfter = $data['styleSheets'];
     // Separate assets of page builder.
     $pbInlineScript = str_replace($inlineScriptBefore, '', $inlineScriptAfter);
     $pbInlineStyle = str_replace($inlineStyleBefore, '', $inlineStyleAfter);
     $pbScripts = array_splice($scriptsAfter, $scriptCount);
     $pbStyleSheets = array_splice($styleSheetsAfter, $styleSheetCount);
     // Append PageBuilder's assets
     // Only support css file with type is "text/css"
     // and js type with type is "text/javascript"
     // in this period.
     $pbAssets = array();
     if (count($pbStyleSheets)) {
         foreach ($pbStyleSheets as $css => $v) {
             $pbAssets[] = '<link rel="stylesheet" href="' . $css . '" type="text/css" />';
         }
     }
     if (count($pbScripts)) {
         foreach ($pbScripts as $js => $v) {
             $pbAssets[] = '<script src="' . $js . '" type="text/javascript"></script>';
         }
     }
     $pbAssets[] = '<script type="text/javascript">' . $pbInlineScript . '</script>';
     $pbAssets[] = '<style>' . $pbInlineStyle . '</style>';
     $pbAssets = implode("\n", $pbAssets);
     // Append assets to content
     $content = str_replace("</head>", $pbAssets . "\n</head>", $content);
     // preg_replace falsely process $ symobols as commands in text copy.
     $content = str_replace('&dollar;', '$', $content);
     JResponse::setBody($content);
 }
Esempio n. 18
0
 /**
  * Method to transform source text to pagebuilder HTML
  * 
  * @return string
  */
 public static function transFormTextToHTML($content = '', $column = false, $refine = false)
 {
     if (empty($content)) {
         return '';
     }
     self::$pattern = self::shortcodes_pattern();
     $content = trim($content);
     if ($refine) {
         $row_start = '\\[pb_row';
         $col_start = '\\[pb_column';
         $row_end = '\\[\\/pb_row\\]';
         $col_end = '\\[\\/pb_column\\]';
         $content = preg_replace("/{$row_start}([^({$row_start})|({$col_start})]*){$col_start}/", "[pb_row][pb_column", $content);
         $content = preg_replace("/{$col_end}([^({$row_end})|({$col_end})]*){$row_end}/", "[/pb_column][/pb_row]", $content);
     }
     // wrap alone text
     $text_nodes = preg_split(self::$pattern, $content, -1, PREG_SPLIT_OFFSET_CAPTURE);
     $idx_change = 0;
     $content_flag = "X";
     $append_ = $column ? "[pb_text]{$content_flag}[/pb_text]" : "[pb_row][pb_column][pb_text]{$content_flag}[/pb_text][/pb_column][/pb_row]";
     foreach ($text_nodes as $node) {
         if (strlen(trim($node[0])) != 0 && strlen(trim(strip_tags($node[0]))) != 0) {
             $offset = intval($node[1]) + $idx_change;
             $replace = $node[0];
             $replace_html = $replace;
             $content = substr_replace($content, str_replace($content_flag, $replace_html, $append_), $offset, strlen($replace));
             $idx_change += strlen($append_) - strlen($content_flag) - (strlen($replace) - strlen($replace_html));
         }
     }
     return preg_replace_callback(self::$pattern, array('self', 'do_shortcode_tag'), $content);
 }
Esempio n. 19
0
 /**
  * define shortcode content
  * 
  * @param type $atts
  * @param type $content
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/module/assets/css/module.css', 'text/css');
     $html_element = '';
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $module_class = 0;
     $container_style = '';
     $container_class = '';
     if ($arr_params['module_alignment'] === 'right') {
         $container_style .= 'float: right;';
     } else {
         if ($arr_params['module_alignment'] === 'center') {
             $container_style .= 'margin: 0 auto;';
             $container_class = 'center';
         } else {
             if ($arr_params['module_alignment'] === 'left') {
                 $container_style .= 'float: left;';
             }
         }
     }
     $container_style = $container_style ? ' style=" ' . $container_style . ' " ' : '';
     $container_class = $container_class ? 'center' : '';
     if (empty($module_name)) {
         $html_element = "<p class='jsn-bglabel'>" . JText::_('No module selected') . '</p>';
     } else {
         $module_id = preg_replace("/[^0-9^]/", "", substr($module_name, 0, 5));
         $show_title = $arr_params['module_show_title'];
         if (isset($module_id)) {
             $html_element .= '<div class="jsn-pb-module-element pb-element-container pb-element-module ' . $container_class . '"' . $container_style . '>';
             $html_element .= $this->jsn_load_module($module_id, $module_class, $style = 'none', $show_title);
             $html_element .= '</div>';
             $html_element .= '<div style="clear: both"></div>';
         }
     }
     $html_element = JSNPagebuilderHelpersBuilder::generateShortCode($html_element, false, 'frontend', true);
     return $this->element_wrapper($html_element, $arr_params);
 }
Esempio n. 20
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  * 
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/accordion/assets/css/accordion.css', 'text/css');
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     $initial_open = intval($arr_params['initial_open']);
     $multi_open = $arr_params['multi_open'];
     $filter = $arr_params['filter'];
     $random_id = JSNPagebuilderHelpersShortcode::generateRandomString();
     $script = "";
     $scriptFilter = "";
     if ($multi_open == "yes") {
         $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t\t{\n\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-title a' ).click( function(e ){\n\t\t\t\t\t\t\tvar collapse_item = \$( '#accordion_{$random_id} '+this.hash )\n\t\t\t\t\t\t\tcollapse_item.collapse( 'toggle' )\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t} )( JoomlaShine.jQuery );</script>";
     } else {
         // some case the collapse doesn't work, need this code
         $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t\t{\n\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-collapse' ).click( function(e ){\n\t\t\t\t\t\t\tvar collapse_item = \$( '#accordion_{$random_id} '+this.hash )\n\t\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-body' ).each(function(){\n\t\t\t\t\t\t\t\t\$( this ).addClass( 'panel-collapse' );\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcollapse_item.removeClass( 'panel-collapse' );\n\t\t\t\t\t\t\tcollapse_item.attr( 'style', '' );\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t} )( JoomlaShine.jQuery );</script>";
     }
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $items = explode("<!--seperate-->", $sub_shortcode);
     // remove empty element
     $items = array_filter($items);
     $initial_open = $initial_open > count($items) ? 1 : $initial_open;
     foreach ($items as $idx => $item) {
         $open = $idx + 1 == $initial_open ? "in" : "";
         $item = str_replace("{index}", $random_id . $idx, $item);
         $item = str_replace("{show_hide}", $open, $item);
         $items[$idx] = $item;
     }
     $sub_shortcode = implode("", $items);
     $filter_html = "";
     if ($filter == "yes") {
         $sub_sc_data = JSNPagebuilderHelpersShortcode::extractSubShortcode($content);
         $sub_sc_data = $sub_sc_data[$this->config['has_subshortcode']];
         $tags = array();
         $tags[] = 'all';
         foreach ($sub_sc_data as $shortcode) {
             $extract_params = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode);
             $tags[] = isset($extract_params["tag"]) ? $extract_params["tag"] : '';
         }
         $tags = array_filter($tags);
         if (count($tags) > 1) {
             $tags = implode(",", $tags);
             $tags = explode(",", $tags);
             $tags = array_unique($tags);
             $filter_html = "<ul id='filter_{$random_id}' class='nav nav-pills elementFilter' style='margin-bottom:2px;'>";
             foreach ($tags as $idx => $value) {
                 $active = $idx == 0 ? "active" : "";
                 $filter_html .= "<li class='{$active}'><a href='#' class='" . str_replace(" ", "_", $value) . "'>" . ucfirst($value) . "</a></li>";
             }
             $filter_html .= "</ul>";
             // remove "All" tag
             array_shift($tags);
             $inner_tags = implode(',', $tags);
             $scriptFilter .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.parent.jQuery.noConflict()( '#jsn_view_modal').contents().find( 'data-tag' ).text( '{$inner_tags}')\n\t\t\t\t\t\tvar parent_criteria = '#filter_{$random_id}'\n\t\t\t\t\t\tvar clientsClone = \$( '#accordion_{$random_id}' );\n\t\t\t\t\t\tvar tag_to_filter = 'div';\n\t\t\t\t\t\tvar class_to_filter = '.panel-default';\n\t\n\t\t\t\t\t\t\$( parent_criteria + ' a' ).click( function(e ) {\n\t\t\t\t\t\t\t// stop running filter\n\t\t\t\t\t\t\t\$( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\t\$( this ).stop( true )\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\te.preventDefault();\n\t\n\t\t\t\t\t\t\t//active clicked criteria\n\t\t\t\t\t\t\t\$( parent_criteria + ' li' ).removeClass( 'active' );\n\t\t\t\t\t\t\t\$( this ).parent().addClass( 'active' );\n\t\n\t\t\t\t\t\t\tvar filterData = \$( this ).attr( 'class' );\n\t\t\t\t\t\t\tvar filters;\n\t\t\t\t\t\t\tif( filterData == 'all' ){\n\t\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter + '[data-tag~='+ filterData +']' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclientsClone.find( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\t\$( this ).fadeOut();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tfilters.each(function(){\n\t\t\t\t\t\t\t\t\$( this ).fadeIn();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t} )( jQuery )</script>";
         }
     }
     $html = '<div class="panel-group" id="accordion_{ID}">' . $sub_shortcode . '</div>';
     $html = str_replace("{ID}", "{$random_id}", $html);
     $html .= $script . $scriptFilter;
     return $this->element_wrapper($filter_html . $html, $arr_params);
 }
Esempio n. 21
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         $this->load_assets_frontend();
     }
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     extract($arr_params);
     $style = '';
     if ($icon_bg_color == 'custom') {
         $style .= 'background:' . $custom_bg_color . ';';
     }
     if ($shape == 'square') {
         if (!empty($rounded_corner)) {
             $style .= 'border-radius:' . $rounded_corner . 'px;';
         }
     } elseif ($shape == 'circle') {
         $style .= 'border-radius:50px;';
     }
     $html_elements = '';
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     if (!empty($sub_shortcode)) {
         $html_elements = "<ul class='pb-social-icons {$shape} {$icon_bg_color}'>";
         $sub_htmls = $sub_shortcode;
         $sub_htmls = str_replace('{icon_size}', $icon_size, $sub_htmls);
         $sub_htmls = str_replace('STYLE', "style='{$style}'", $sub_htmls);
         $html_elements .= $sub_htmls;
         $html_elements .= '</ul>';
         $html_elements .= '<div style="clear: both"></div>';
     }
     return $this->element_wrapper($html_elements, $arr_params);
 }
Esempio n. 22
0
 /**
  * define shortcode structure of element
  *
  * @return string
  */
 function element_shortcode($atts = null, $content = null)
 {
     $extra_class = $style = $common_style = $data_attr = '';
     $extra_id = !empty($atts['id_wrapper']) ? $atts['id_wrapper'] : JSNPagebuilderHelpersShortcode::generateRandomString();
     if (isset($atts) && is_array($atts)) {
         $arr_styles = array();
         //            if(isset($atts['width'])){
         //                if($atts['width'] == 'full'){
         //                    $extra_class = 'pb_fullwidht';
         //                    $script = "$(body).addClass('pb_fullwidht');";
         //                    $custom_script = JSNPagebuilderHelpersShortcode::script_box($script);
         //                    $arr_styles[] = '-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;width: 100%;padding-left: 1000px;padding-right: 1000px;margin:0 -1000px;';
         //                }
         //            }
         $background = "";
         switch ($atts['background']) {
             case 'solid':
                 $solid_color = $atts['solid_color_value'];
                 $background = "background-color: {$solid_color};";
                 break;
             case 'gradient':
                 if (!isset($atts['gradient_color_css'])) {
                     $background = "background:linear-gradient(center top , #ffffff 0%, #000000 100%);background:-moz-linear-gradient(center top , #ffffff 0%, #000000 100%);    background: -webkit-linear-gradient(#FFFFFF, #000000);background:-o-linear-gradient(center top , #ffffff 0%, #000000 100%);background:-ms-linear-gradient(center top , #ffffff 0%, #000000 100%);";
                 } else {
                     $background = $atts['gradient_color_css'];
                 }
                 break;
             case 'pattern':
                 $pattern_img = isset($atts['pattern']) ? $atts['pattern'] : '';
                 $pattern_repeat = isset($atts['repeat']) ? $atts['repeat'] : '';
                 $background = "background-image:url('{$pattern_img}');";
                 switch ($pattern_repeat) {
                     case 'full':
                         $background_repeat = "repeat";
                         break;
                     case 'vertical':
                         $background_repeat = "repeat-y";
                         break;
                     case 'horizontal':
                         $background_repeat = "repeat-x";
                         break;
                     default:
                         $background_repeat = "repeat";
                 }
                 $background .= "background-repeat:{$background_repeat};";
                 break;
             case 'image':
                 if (isset($atts['image'])) {
                     $image = $atts['image'];
                 }
                 $image_position = $atts['position'];
                 $pattern_stretch = isset($atts['stretch']) ? $atts['stretch'] : '';
                 $url_pattern = '/^(http|https)/';
                 preg_match($url_pattern, $image, $_f);
                 if (!count($_f)) {
                     $image = JUri::root() . $image;
                 }
                 $background = "background-image:url('{$image}');background-position:{$image_position};";
                 switch ($pattern_stretch) {
                     case 'none':
                         $background_size = "";
                         break;
                     case 'full':
                         $background_size = "100% 100%";
                         break;
                     case 'cover':
                         $background_size = "cover";
                         break;
                     case 'contain':
                         $background_size = "contain";
                         break;
                 }
                 $background .= !empty($background_size) ? "background-size:{$background_size};" : "";
                 break;
             case 'video':
                 $url = $atts['video_url'];
                 // Youtube video
                 $pattern = '#^(?:https?://)?';
                 # Optional URL scheme. Either http or https.
                 $pattern .= '(?:www\\.)?';
                 #  Optional www subdomain.
                 $pattern .= '(?:';
                 #  Group host alternatives:
                 $pattern .= 'youtu\\.be/';
                 #    Either youtu.be,
                 $pattern .= '|youtube\\.com';
                 #    or youtube.com
                 $pattern .= '(?:';
                 #    Group path alternatives:
                 $pattern .= '/embed/';
                 #      Either /embed/,
                 $pattern .= '|/v/';
                 #      or /v/,
                 $pattern .= '|/watch\\?v=';
                 #      or /watch?v=,
                 $pattern .= '|/watch\\?.+&v=';
                 #      or /watch?other_param&v=
                 $pattern .= ')';
                 #    End path alternatives.
                 $pattern .= ')';
                 #  End host alternatives.
                 $pattern .= '([\\w-]{11})';
                 # 11 characters (Length of Youtube video ids).
                 $pattern .= '(?:.+)?$#x';
                 # Optional other ending URL parameters.
                 if (preg_match($pattern, $url, $matches)) {
                     $extra_class .= 'pb_video_bg';
                     $youtube_url = end($matches);
                     $data_attr = sprintf("data-property=\"{videoURL:'http://youtu.be/%s', containment:'%s', autoplay:%s, mute:true, startAt:0, opacity:1, showControls:false}\"", $youtube_url, "#{$extra_id}", $atts['autoplay']);
                     $script = "\n\t                        (function(\$){\n\t                            \$(document).ready(function(){\n\t                                \$('.pb_video_bg').mb_YTPlayer();\n\t                                    \$('.pb_video_bg').click(function(){ \$(this).playYTP()})\n\t                            })\n\t                            })(jQuery);\n\t                            ";
                     JFactory::getDocument()->addScriptDeclaration($script, 'text/javascript');
                     self::enqueue_player_scripts();
                 } else {
                     JSNPagebuilderHelpersFunctions::print_asset_tag(JUri::root(true) . '/administrator/components/com_pagebuilder/helpers/shortcode/row/assets/css/row.css', 'css');
                     $autoplay = $atts['autoplay'] == 1 ? 'autoplay="true"' : '';
                     $script = "\n\t\t\t\t\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\t\t\t\tvar bgwidth = \$('#{$extra_id}').width();\n\t\t\t\t\t\t\tvar bgheight = \$('#{$extra_id}').height();\n\t\t\t\t\t\t\tconsole.log(bgwidth)\n\t\t\t\t\t\t\t\$('#{$extra_id}').css({'position':'relative','z-index':'1','overflow':'hidden'})\n\t\t\t\t\t\t\t\$('video').attr({'width':bgheight, 'height': bgheight});\n\t\t\t\t\t\t\t\$('object').attr({'width':bgheight, 'height': bgheight});\n\t\t\t\t\t\t\t\t\$('video').mediaelementplayer({\n\t\t\t\t\t\t\t\t'loop':true,\n\t\t\t\t\t\t\t\t'clickToPlayPause': false,\n\t\t\t\t\t\t\t\t'controls': false,\n\t\t\t\t\t\t\t\tsuccess: function(player, dom, mediaelement){\n\t\t\t\t\t\t\t\t\tmediaelement.container[0].style.position = 'absolute';\n\t\t\t\t\t\t\t\t\tmediaelement.container[0].style.zIndex = '1';\n\t\t\t\t\t\t\t\t\t\$('.mejs-controls').css('display', 'none');\n\t\t\t\t\t\t\t\t\tplayer.play();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tvar source = \$('<object type=\"application/x-shockwave-flash\" width=\"'+bgwidth+'\" height=\"'+bgheight+'\" data=\"" . JSNPB_PLG_SYSTEM_ASSETS_URL . "/3rd-party/mediaelement/flashmediaelement.swf\">'+\n\t\t\t\t\t\t\t\t\t\t\t\t'<param name=\"movie\" value=\"" . JSNPB_PLG_SYSTEM_ASSETS_URL . "/3rd-party/mediaelement/flashmediaelement.swf\" />'+\n                            \t\t\t\t\t'<param name=\"flashVars\" value=\"controls=false&file=" . $url . "\" />'+\n                            \t\t\t\t\t'</object>'+\n                                                '<img src=\"" . JSNPB_PLG_SYSTEM_ASSETS_URL . "/3rd-party/mediaelement/bigplay.png\" width=\"'+bgwidth+'\" height=\"'+bgheight+'\" title=\"No video playback capabilities\" />');\n\t\t\t\t\t            var video = \$('<video controls=\"controls\" width=\"'+bgwidth+'\" height=\"\" {$autoplay} loop=\"true\" style=\"position: absolute; left: 0px; top: -20px; overflow: hidden; opacity: 1; transition-property: opacity; transition-duration: 2000ms; z-index: -1; min-width: 101%; min-height: 100%;\" ><source src=\"" . $url . "\" /></video>').append(source);\n\n\t\t\t\t\t            \$('#{$extra_id}').append(video);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t";
                     JFactory::getDocument()->addScriptDeclaration($script, 'text/javascript');
                     $document = JFactory::getDocument();
                     $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/mediaelement/mediaelementplayer.min.css', 'text/css');
                     $document->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/mediaelement/mediaelement-and-player.min.js', 'text/javascript');
                 }
                 break;
         }
         $arr_styles[] = $background;
         if (isset($atts['paralax']) && $atts['paralax'] == 'yes') {
             $arr_styles[] = "background-attachment:fixed;";
         }
         if (isset($atts['parallax_scroll']) && $atts['parallax_scroll'] == 'yes') {
             $extra_class .= 'parallax';
             $document = JFactory::getDocument();
             $document->addScript(JUri::root(true) . '/administrator/components/com_pagebuilder/helpers/shortcode/row/assets/js/parallax.js', 'text/javascript');
         }
         if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) {
             $border = array();
             $border[] = $atts['border_width_value_'] . "px";
             $border[] = $atts['border_style'];
             $border[] = $atts['border_color'];
             $border = implode(" ", $border);
             $arr_styles[] = "border-top:{$border}; border-bottom:{$border};";
         }
         $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;";
         $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;";
         $arr_styles[] = "padding-left:{$atts['div_padding_left']}px;";
         $arr_styles[] = "padding-right:{$atts['div_padding_right']}px;";
         if (@$atts['width_value']) {
             $arr_styles[] = "width:" . $atts['width_value'] . $atts['width_unit'] . '; margin:0 auto';
         }
         $arr_styles = implode("", $arr_styles);
         $style = !empty($arr_styles) ? "style=\"{$arr_styles}\"" : "";
     }
     $column_html = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, true, 'frontend');
     $extra_class .= !empty($atts['css_suffix']) ? ' ' . htmlspecialchars($atts['css_suffix']) : '';
     $extra_class = ltrim($extra_class, ' ');
     return $common_style . "<div class='jsn-bootstrap3'><div id='{$extra_id}' class='{$extra_class} row' {$style} {$data_attr}>" . $column_html . "</div></div>";
 }
Esempio n. 23
0
 /**
  * DEFINE shortcode content
  *
  * @param array $attributes
  * @param mixed $content
  *
  * @return string
  */
 function element_shortcode($attributes = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addScript(JSNPB_ELEMENT_URL . '/market/assets/js/3rd-party/slick/slick.min.js', 'text/javascript');
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/market/assets/js/3rd-party/slick/slick.css', 'text/css');
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/market/assets/css/market.css', 'text/css');
     $arrParams = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $attributes);
     $htmlElement = '';
     $itemShortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $itemsData = explode('<!--separate-->', $itemShortcode);
     // remove empty element
     $itemsData = array_filter($itemsData);
     $dataMarket = array();
     // decode
     foreach ($itemsData as $_key => $_value) {
         $dataMarket[] = json_decode($_value, true);
     }
     $randomMarketId = "market-" . JSNPagebuilderHelpersShortcode::generateRandomString();
     $marketLayoutClass = $attributes['market_layout'] == self::PB_MARKET_CAROUSEL_LAYOUT ? 'pb-market-carousel' : 'pb-market-table';
     $htmlElement .= "<div id='{$randomMarketId}' class='pb-market-wrapper {$marketLayoutClass}'><div class='pb-market-header'><div class='pb-market-title'>{$attributes['market_title']}</div>";
     if (count($dataMarket) <= 0) {
     } else {
         if ($attributes['market_show_time_update'] == 'yes') {
             $timeStamp = new DateTime($dataMarket[0]['time_stamp']);
             $timeStamp->setTimezone(new DateTimeZone('UTC'));
             $htmlElement .= "<div class='pb-market-update-time'>{$timeStamp->format('D, M d, Y, g:iA e')}</div>";
         }
         $headerList = explode("__#__", $attributes['market_show_data']);
         foreach ($headerList as $_key => $_value) {
             if ($_value == null || $_value == " ") {
                 unset($headerList[$_key]);
             }
         }
         $marketDataType = JSNPbMarketHelper::getMarketDataType();
         if ($attributes['market_layout'] == self::PB_MARKET_CAROUSEL_LAYOUT) {
             if ($attributes['market_show_carousel_control'] == JSNPagebuilderHelpersType::PB_HELPER_ANSWER_YES) {
                 $htmlElement .= "<div class='pb-market-carousel-control'>";
                 if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) {
                     $htmlElement .= "<div class='button pb-market-carousel-up'><i class='fa fa-chevron-up'></i></div>";
                     $htmlElement .= "<div class='button pb-market-carousel-down'><i class='fa fa-chevron-down'></i></div>";
                 } else {
                     $htmlElement .= "<div class='button pb-market-carousel-back'><i class='fa fa-chevron-left'></i></div>";
                     $htmlElement .= "<div class='button pb-market-carousel-next'><i class='fa fa-chevron-right'></i></div>";
                 }
                 $htmlElement .= "</div>";
             }
             // End of header
             $htmlElement .= "</div>";
             $htmlElement .= "<div class='pb-market-content pb-market-layout-{$attributes['market_slide_dimension']}'>";
             // Show carousel layout
             foreach ($dataMarket as $_key => $_item) {
                 if (strpos($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE], "+") !== false) {
                     $htmlElement .= "<div class='pb-market-carousel-item change-up'>";
                 } else {
                     $htmlElement .= "<div class='pb-market-carousel-item change-down'>";
                 }
                 $style = "";
                 if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) {
                     $style .= "style='width: " . 100 / count($headerList) . "%'";
                 }
                 if ($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE] == null) {
                     $index = 0;
                     foreach ($headerList as $_value) {
                         if ($_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_NAME || $_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_SYMBOL) {
                             $htmlElement .= "<div {$style} class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</div>";
                             $index++;
                         }
                     }
                     if (count($headerList) - $index > 0) {
                         if (isset($_item['error'])) {
                             $htmlElement .= "<div class='error'>" . $_item['error'] . "</div>";
                         } else {
                             $htmlElement .= "<div class='error'>" . JText::_('JSN_PAGEBUILDER_MARKET_ERROR_SYMBOL') . "</div>";
                         }
                     }
                 } else {
                     foreach ($headerList as $_value) {
                         if (isset($_item['data'][$_value])) {
                             $htmlElement .= "<div {$style} class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</div>";
                         }
                     }
                 }
                 $htmlElement .= "</div>";
             }
         } else {
             // End of header
             $htmlElement .= "</div>";
             $htmlElement .= "<div class='pb-market-content'>";
             // Show table layout
             $htmlElement .= "<table class='table'>";
             $htmlElement .= "<thead><tr>";
             foreach ($headerList as $_key => $_value) {
                 if (isset($marketDataType[$_value]) && $_value != JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHART) {
                     $htmlElement .= "<th class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$marketDataType[$_value]}</th>";
                 }
             }
             $htmlElement .= "</tr></thead>";
             $htmlElement .= "<tbody>";
             foreach ($dataMarket as $_key => $_item) {
                 if ($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE] == null) {
                     $htmlElement .= "<tr class='error'>";
                     $index = 0;
                     foreach ($headerList as $_value) {
                         if ($_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_NAME || $_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_SYMBOL) {
                             $htmlElement .= "<td class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</td>";
                             $index++;
                         }
                     }
                     if (count($headerList) - $index > 0) {
                         $htmlElement .= "<td colspan='" . (count($headerList) - 1) . "'>" . JText::_('JSN_PAGEBUILDER_MARKET_ERROR_SYMBOL') . "</td>";
                     }
                 } else {
                     if (strpos($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE], "+") !== false) {
                         $htmlElement .= "<tr class='change-up'>";
                     } else {
                         $htmlElement .= "<tr class='change-down'>";
                     }
                     foreach ($headerList as $_value) {
                         if (isset($_item['data'][$_value])) {
                             $htmlElement .= "<td class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</td>";
                         }
                     }
                 }
                 $htmlElement .= "</tr>";
             }
             $htmlElement .= "</tbody>";
             $htmlElement .= "</table>";
         }
     }
     $htmlElement .= "</div></div>";
     if ($attributes['market_layout'] == self::PB_MARKET_CAROUSEL_LAYOUT) {
         $scriptCarousel = "<script type='text/javascript'>(function (\$) {\n\t\t\t\t\t\$(document).ready(function ()\n\t\t\t\t\t{\n                        \$('#{$randomMarketId} .pb-market-content').slick({\n                            infinite: true";
         if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) {
             $scriptCarousel .= ", vertical: true, slidesToShow: " . (int) $attributes['market_number_to_show'];
         } else {
             $scriptCarousel .= ", variableWidth: true";
         }
         if ($attributes['market_auto_play_carousel'] == JSNPagebuilderHelpersType::PB_HELPER_ANSWER_YES) {
             $scriptCarousel .= ", autoplay: true";
             if (is_numeric($attributes['market_auto_play_speed']) && (int) $attributes['market_auto_play_speed'] > 0) {
                 $scriptCarousel .= ", autoplaySpeed: {$attributes['market_auto_play_speed']}000";
             } else {
                 $scriptCarousel .= ", autoplaySpeed: 3000";
             }
         }
         if ($attributes['market_show_carousel_control'] == JSNPagebuilderHelpersType::PB_HELPER_ANSWER_YES) {
             if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) {
                 $scriptCarousel .= ", prevArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-up'), nextArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-down')";
             } else {
                 $scriptCarousel .= ", prevArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-back'), nextArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-next')";
             }
         } else {
             $scriptCarousel .= ", arrows: false";
         }
         $scriptCarousel .= ", swipe: false\n                        });\n\t\t\t\t\t});\n\t\t\t\t})(JoomlaShine.jQuery);</script>";
         $htmlElement .= $scriptCarousel;
     }
     return $this->element_wrapper($htmlElement, $arrParams);
 }
Esempio n. 24
0
 /**
  * DEFINE shortcode content
  *
  * @param type $atts
  * @param type $content
  *
  * @return string
  */
 public function element_shortcode($atts = null, $content = null)
 {
     $document = JFactory::getDocument();
     $document->addStyleSheet(JSNPB_ELEMENT_URL . '/progressbar/assets/css/progressbar.css', 'text/css');
     $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
     $html_element = '';
     if ($arr_params['progress_bar_stack_active'] == 'yes') {
         $content = str_replace('pbar_item_style="solid"', 'pbar_item_style="striped"', $content);
     }
     $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
     $items = explode('<!--seperate-->', $sub_shortcode);
     // remove empty element
     $items = array_filter($items);
     $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open;
     foreach ($items as $idx => $item) {
         $open = $idx + 1 == $initial_open ? 'in' : '';
         $items[$idx] = $item;
     }
     $sub_htmls = implode('', $items);
     if ($arr_params['progress_bar_show_icon'] == 'no') {
         $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
     } else {
         $sub_htmls = str_replace('[icon]', '', $sub_htmls);
         $sub_htmls = str_replace('[/icon]', '', $sub_htmls);
     }
     if ($arr_params['progress_bar_show_title'] == 'no') {
         $pattern = '\\[(\\[?)(text)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
     } else {
         $sub_htmls = str_replace('[text]', '', $sub_htmls);
         $sub_htmls = str_replace('[/text]', '', $sub_htmls);
     }
     if ($arr_params['progress_bar_show_percent'] == 'no') {
         $pattern = '\\[(\\[?)(percentage)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
     } else {
         $sub_htmls = str_replace('[percentage]', '', $sub_htmls);
         $sub_htmls = str_replace('[/percentage]', '', $sub_htmls);
     }
     if ($arr_params['progress_bar_show_percent'] == 'no' and $arr_params['progress_bar_show_title'] == 'no' and $arr_params['progress_bar_show_icon'] == 'no') {
         $pattern = '\\[(\\[?)(sub_content)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
     }
     if ($arr_params['progress_bar_style'] == 'stacked') {
         $sub_htmls = str_replace('{active}', '', $sub_htmls);
         $active = $arr_params['progress_bar_stack_active'] == 'yes' ? ' progress-striped active' : '';
         $stacked = ' pb_stacked';
         $html_titles = '';
         $pattern = '\\[(\\[?)(sub_content)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
         preg_match_all("/{$pattern}/s", $sub_htmls, $matches);
         $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls);
         foreach ($matches as $i => $items) {
             if (is_array($items)) {
                 foreach ($items as $j => $item) {
                     if ($item != '' and strpos($item, '[sub_content]') !== false) {
                         $item = str_replace('[sub_content]', '', $item);
                         $item = str_replace('[/sub_content]', '', $item);
                         $html_titles .= $item;
                     }
                 }
             }
         }
         $html_element = $html_titles;
         $html_element .= "<div class='progress{$active}{$stacked}'>";
         $html_element .= $sub_htmls;
         $html_element .= '</div>';
         $html_element .= "<div style='clear: both'></div>";
     } else {
         $sub_htmls = str_replace('[sub_content]', '', $sub_htmls);
         $sub_htmls = str_replace('[/sub_content]', '', $sub_htmls);
         if ($arr_params['progress_bar_stack_active'] == 'yes') {
             $sub_htmls = str_replace('{active}', ' active', $sub_htmls);
         } else {
             $sub_htmls = str_replace('{active}', '', $sub_htmls);
         }
         $html_element = $sub_htmls;
     }
     return $this->element_wrapper($html_element, $arr_params);
 }
Esempio n. 25
0
    /**
     * DEFINE shortcode content
     *
     * @param type $atts
     * @param type $content
     *
     * @return string
     */
    public function element_shortcode($atts = null, $content = null)
    {
        $html_element = $container_class = $str_scripts = '';
        $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts);
        extract($arr_params);
        $arrDefaultOptions = array('streetViewControl', 'zoomControl', 'panControl', 'mapTypeControl', 'scaleControl', 'overviewControl');
        if ($gmap_elements) {
            $arr_elements = array_filter(explode('__#__', $gmap_elements));
            foreach ($arrDefaultOptions as $i => $item) {
                if (in_array($item, $arr_elements)) {
                    $str_scripts .= $item . ':true, ';
                } else {
                    $str_scripts .= $item . ':false, ';
                }
            }
        }
        $random_id = JSNPagebuilderHelpersShortcode::generateRandomString();
        $player_elements = '';
        if ($gmap_alignment == 'right') {
            $player_elements .= '$("#pb-gmap-' . $random_id . '").css({"float" : "right"});';
        } elseif ($gmap_alignment == 'center') {
            $player_elements .= '$("#pb-gmap-' . $random_id . '").css({"margin" : "0 auto", "display" : "block"});';
        } elseif ($gmap_alignment == 'left') {
            $player_elements .= '$("#pb-gmap-' . $random_id . '").css({"float" : "left"});';
        }
        $html_element .= '<script type="text/javascript">(function ($) {
			$( document ).ready( function () {
				' . $player_elements . '
				var map_' . $random_id . '				= "";
				var marker_locations_' . $random_id . ' = [];
				var jsnpbPathRoot = "' . JURI::root() . '"
				function get_latlong(obj) {
					var myLatlng		 = new google.maps.LatLng( obj.gmi_lat, obj.gmi_long);
					return myLatlng;
				}

				function get_infobox(obj) {
					var infowindow		= "";
					var contentString	 = "<div class=\\"pb-gmi-info\\" style=\\"width:250px\\" >";
					contentString		 += "<div class=\\"pb-gmi-thumb\\">";
					if ( obj.gmi_image != "" && obj.gmi_image != "http://" )
					{					 
					
	                    if ((/\\.(gif|jpg|jpeg|tiff|png)$/i).test(obj.gmi_image) && !/\\b(http|https)/.test(obj.gmi_image))
	                    {
	                    	contentString		 += "<img src=\\"" + jsnpbPathRoot + obj.gmi_image + "\\" />";
	                    }	
	                    else
	                    {
	                    	contentString		 += "<img src=\\""  + obj.gmi_image + "\\" />";
	                    }
					}
					contentString		 += "</div>";
					contentString		 += "<span class=\\"pb-gmi-title\\"><b>" + obj.gmi_title + "</b></span>";
					if ( obj.gmi_desc_content )
						contentString		 += "<p>" + obj.gmi_desc_content + "</p>";
					if ( obj.gmi_url != "" && obj.gmi_url != "http://" )
						contentString		 += "<a href=\\"" + obj.gmi_url + "\\" target=\\"_blank\\">more...></a>";
					contentString		 += "</div>";
					infowindow		 = new google.maps.InfoWindow({
						content: contentString
					});
					infowindow.setOptions({maxWidth:300});
					return infowindow;
				}

				function markerAtPoint(latlng) {
					for (var i = 0; i < marker_locations_' . $random_id . '.length; ++i) {
						if (marker_locations_' . $random_id . '[i].equals(latlng)) return true;
					}
					return false;
				}

				function initialize_' . $random_id . '() {
					var gmap_zoom	= parseInt("' . $gmap_zoom . '");
					var gmap_lat	= "";
					var gmap_long	= "";
					var gmap_type	= google.maps.MapTypeId.' . $gmap_type . ';
					var directionsService_' . $random_id . '	 = new google.maps.DirectionsService();
					var has_direction		= false;

					var mapOptions_' . $random_id . ' = {
						zoom: gmap_zoom,
						center: new google.maps.LatLng(0,0),
						mapTypeId: gmap_type,
						' . $str_scripts . '
					};
					map_' . $random_id . ' = new google.maps.Map(document.getElementById(\'pb-gmap-' . $random_id . '\'), mapOptions_' . $random_id . ');
					var rendererOptions_' . $random_id . ' = {
						map: map_' . $random_id . ',
						suppressMarkers: true
					}
					var directionsDisplay_' . $random_id . ' = new google.maps.DirectionsRenderer(rendererOptions_' . $random_id . ');
					directionsDisplay_' . $random_id . '.setMap(map_' . $random_id . ');

					// Check has directions
					$( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (index) {
						var obj = JSON.parse($(this).val());
						if ( obj.gmi_lat != "" && obj.gmi_long != "" && obj.gmi_destination != "" ) {
							has_direction = true;
						}
					});

					// Add markers
					if ( has_direction == false ) {
						$( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (index) {
							var obj = JSON.parse($(this).val());
							if ( obj.gmi_lat != "" && obj.gmi_long != "" ) {
								var myLatlng	 = get_latlong(obj);
								var infowindow	 = get_infobox(obj);
								if ( map_' . $random_id . ' ) {
									var marker		= new google.maps.Marker({
										position: myLatlng,
										map: map_' . $random_id . ',
										title: obj.gmi_title
									});
									marker_locations_' . $random_id . '.push(myLatlng);
									map_' . $random_id . '.setCenter(marker.getPosition());
									google.maps.event.addListener(marker, \'click\', function() {
										infowindow.open(map_' . $random_id . ',marker);
									});
								}
							}
						});
					} else {

						$( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (i) {
							var obj = JSON.parse($(this).val());
							$( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (j) {
								var sub_obj	 = JSON.parse($(this).val());

								if ( sub_obj.gmi_title == obj.gmi_destination && sub_obj.gmi_lat != "" && sub_obj.gmi_long != "" ) {
									var start        = get_latlong(obj);
									var end			 = get_latlong(sub_obj);

									var infowindow	 = get_infobox(obj);
									if ( map_' . $random_id . ' ) {
										var marker			 = new google.maps.Marker({
											position: start,
											map: map_' . $random_id . ',
											title: obj.gmi_title
										});
										marker_locations_' . $random_id . '.push(start);
										google.maps.event.addListener(marker, \'click\', function() {
											infowindow.open(map_' . $random_id . ',marker);
										});
									}

									var sub_infowindow	 = get_infobox(sub_obj);
									if ( map_' . $random_id . ' ) {
										var sub_marker		 = new google.maps.Marker({
											position: end,
											map: map_' . $random_id . ',
											title: sub_obj.gmi_title
										});
										marker_locations_' . $random_id . '.push(end);
										google.maps.event.addListener(sub_marker, \'click\', function() {
											sub_infowindow.open(map_' . $random_id . ',sub_marker);
										});
									}

									var request = {
										origin:start,
										destination:end,
										travelMode: google.maps.DirectionsTravelMode.DRIVING
									};

									directionsService_' . $random_id . '.route(request, function(response, status) {
										if (status == google.maps.DirectionsStatus.OK) {
											directionsDisplay_' . $random_id . '.setDirections(response);
										}
									});
								}

								if ( markerAtPoint(new google.maps.LatLng( obj.gmi_lat, obj.gmi_long) ) == false ) {
									var myLatlng	 = get_latlong(obj);
									var infowindow	 = get_infobox(obj);
									if ( map_' . $random_id . ' ) {
										var marker		= new google.maps.Marker({
											position: myLatlng,
											map: map_' . $random_id . ',
											title: obj.gmi_title
										});
										marker_locations_' . $random_id . '.push(myLatlng);
										map_' . $random_id . '.setCenter(marker.getPosition());
										google.maps.event.addListener(marker, \'click\', function() {
											infowindow.open(map_' . $random_id . ',marker);
										});
									}
								}
							});
						});
					}
				}
				google.maps.event.addDomListener(window, \'load\', initialize_' . $random_id . ');
			});
		})(jQuery)</script>';
        $class = 'pb-googlemap';
        if ($gmap_container_style == 'img-thumbnail') {
            $class .= ' img-thumbnail';
        }
        if ($gmap_margin_top) {
            $gmap_styles[] = "margin-top:{$gmap_margin_top}px !important";
        }
        if ($gmap_margin_bottom) {
            $gmap_styles[] = "margin-bottom:{$gmap_margin_bottom}px !important";
        }
        if ($gmap_margin_right) {
            $gmap_styles[] = "margin-right:{$gmap_margin_right}px !important";
        }
        if ($gmap_margin_left) {
            $gmap_styles[] = "margin-left:{$gmap_margin_left}px !important";
        }
        if ($gmap_dimension_height) {
            $gmap_styles[] = "height:{$gmap_dimension_height}px !important";
        }
        if ($gmap_dimension_width) {
            $gmap_styles[] = "width:{$gmap_dimension_width}{$gmap_dimension_width_unit} !important";
        }
        $styles = count($gmap_styles) ? ' style="' . implode(';', $gmap_styles) . '"' : '';
        $html_element .= '<div id="pb-gmap-wrapper-' . $random_id . '">';
        $html_element .= '<div id="pb-gmap-' . $random_id . '" ' . $styles . ' class="' . $class . '"></div>';
        $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true);
        $items = explode('<!--seperate-->', $sub_shortcode);
        $items = array_filter($items);
        $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open;
        foreach ($items as $idx => $item) {
            $open = $idx + 1 == $initial_open ? 'in' : '';
            $items[$idx] = $item;
        }
        if (!empty($sub_shortcode)) {
            $sub_html = $sub_shortcode;
            $html_element .= $sub_html;
            $html_element .= '</div>';
        }
        $document = JFactory::getDocument();
        $document->addScript('https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false');
        $document->addStyleSheet(JSNPB_ELEMENT_URL . '/googlemap/assets/css/googlemap.css', 'text/css');
        return $this->element_wrapper($html_element, $arr_params);
    }