public function onContentPrepare($context, &$article, &$params, $page = 0) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $content = $article->text; require_once JPATH_ROOT . '/plugins/system/bt_shortcode_system/shortcode/core/generator.php'; global $shortcode_tags; Bt_shortcodeHelper::init(); $content = do_shortcode($content); $article->text = $content; }
public function onBeforeRender() { require_once dirname(__FILE__) . '/shortcode/core/generator.php'; # load language $lang = JFactory::getLanguage(); $extension = 'plg_system_bt_shortcode_system'; $base_dir = JPATH_ADMINISTRATOR; $language_tag = 'en-GB'; $reload = true; $lang->load($extension, $base_dir, $language_tag, $reload); #generator list shortcodes if (JRequest::getVar('btaction') === "bt_shortcode_system") { global $shortcode_tags; Bt_shortcodeHelper::init(); if (JRequest::getVar('task') === 'listview') { # Reading xml $xml = Bt_shortcodeHelper::loadXml(); # generate html shortcode list $shortcodeList = ''; foreach ($xml->children() as $shortcode) { if ((string) $shortcode->show === 'yes') { $shortcodeList .= '<span data-group="' . $shortcode->group . '" data-desc="' . $shortcode->desc . '" title="' . JText::_($shortcode->desc) . '" data-shortcode="' . $shortcode->tagcode . '" data-name="' . JText::_($shortcode->name) . '" >' . '<i class="fa fa-' . $shortcode->icon . '"></i>' . JText::_($shortcode->name) . '</span>'; } } # featch head echo '<!DOCTYPE html><html><head>' . Bt_shortcodeHelper::fetchHead() . '</head><body>'; # generate html code echo '<div id="bt-generator">' . '<input id="bt-generator-search" type="text" placeholder="' . JText::_('SEARCH_SHORTCODE') . '" value="" name="bt-generator-search">' . '<div id="bt-generator-filter">' . '<strong>' . JText::_('FILTER_BY_TYPE') . ' </strong>' . '<a data-filter="all" href="#">' . JText::_('ALL') . '</a>' . '<a data-filter="content" href="#">' . JText::_('CONTENT') . '</a>' . '<a data-filter="box" href="#">' . JText::_('BOX') . '</a>' . '<a data-filter="media" href="#">' . JText::_('MEDIA') . '</a>' . '<a data-filter="gallery" href="#">' . JText::_('GALLERY') . '</a>' . '<a data-filter="data" href="#">' . JText::_('DATA') . '</a>' . '<a data-filter="other" href="#">' . JText::_('OTHER') . '</a>' . '</div>' . '<div id="bt-generator-choices" class="bt-generator-clearfix">' . $shortcodeList . '</div>' . '<div id="bt-generator-settings">' . '</div>' . '<input id="bt-generator-selected" type="hidden" value="">' . '<input id="plg-url" type="hidden" value="' . JURI::base() . '">' . '<input type="hidden" name="bt-compatibility-mode-prefix" id="bt-compatibility-mode-prefix" value="' . Bt_shortcodeHelper::getPrefix() . '" />' . '</div>'; echo '</body></html>'; die; } elseif (JRequest::getVar("task") === "settings") { # setting attribute of shortcode Bt_shortcodeHelper::settings(); } elseif (JRequest::getVar("task") === 'preview') { # preview shortcode Bt_shortcodeHelper::preview(); } elseif (JRequest::getVar("task") === 'images') { $path = JRequest::getVar('folder'); # get images Bt_shortcodeHelper::getImages($path); } elseif (JRequest::getVar("task") === "upload") { #upload images Bt_shortcodeHelper::uploadImages(); } elseif (JRequest::getVar("task") === "imagescat") { # get images from cat Bt_shortcodeHelper::getCatImages(JRequest::getVar('cats'), JRequest::getVar('limit'), JRequest::getVar('prefix')); } elseif (JRequest::getVar("task") === "add_preset") { #get var $shortcode = JRequest::getVar("shortcode"); $id = JRequest::getVar("id"); $name = JRequest::getVar("name"); $settings = JRequest::getVar("settings"); # add preset Bt_shortcodeHelper::add_preset($shortcode, $id, $name, $settings); } elseif (JRequest::getVar("task") === "remove_preset") { $id = JRequest::getVar('id'); $shortcode = JRequest::getVar('shortcode'); # remove preset Bt_shortcodeHelper::remove_preset($shortcode, $id); } elseif (JRequest::getVar("task") === "load_preset") { $id = JRequest::getVar('id'); $shortcode = JRequest::getVar('shortcode'); #load preset Bt_shortcodeHelper::load_preset($shortcode, $id); } elseif (JRequest::getVar("task") === "icon") { Bt_shortcodeHelper::icons(); } } }
public static function carousel($atts = null, $content = null) { $mainframe = JFactory::getApplication(); $isAdmin = $mainframe->isAdmin(); $return = ''; $atts = shortcode_atts(array('source' => 'none', 'gallery' => null, 'target' => '_self', 'width' => 0, 'height' => 100, 'thumbnail_width' => 180, 'thumbnail_height' => 120, 'quality' => 80, 'crop_center' => true, 'items_visible' => 3, 'scroll' => 'page', 'show_title' => 'yes', 'align_center' => 'yes', 'arrows' => 'yes', 'pagination' => 'no', 'mousewheel' => 'yes', 'autoplay' => 3000, 'speed' => 600, 'class' => ''), $atts, 'carousel'); $atts['responsive'] = $atts['width'] ? false : true; do_shortcode($content); $slides = self::$images; // set up data attributes $data = ''; if ($atts['items_visible']) { $data .= ' data-item-per-page="' . $atts['items_visible'] . '"'; } if ($atts['scroll']) { $data .= ' data-scroll="' . $atts['scroll'] . '"'; } if ($atts['arrows'] == 'yes') { $data .= ' data-navigation="true"'; } if ($atts['pagination'] == 'none') { $data .= ' data-pagination="false"'; } else { if ($atts['pagination'] == 'number') { $data .= ' data-pagination="number"'; } } $data .= ' data-autoplay="' . $atts['autoplay'] . '"'; $data .= ' data-slide-speed="' . $atts['speed'] . '"'; // Loop slides if (count($slides)) { // Prepare unique ID $id = uniqid('btsc_carousel_'); // Links target if ($isAdmin) { $atts['target'] = 'popup'; } if ($atts['target'] === 'blank') { $target = ' target="_blank"'; } elseif ($atts['target'] === 'popup') { $target = "onclick='window.open(this.href,\"Popup\",\"height=600,width=800,resizable=1,scrollbars=1\"); return false;'"; } else { $target = ''; } // Prepare width and height $size = $atts['responsive'] ? 'width:100%' : 'width:' . intval($atts['width']) . 'px; max-width: ' . $atts['thumbnail_width'] * $atts['items_visible'] . 'px;'; // Open slider $return = '<div id="' . $id . '" class="btsc-carousel" style="' . $size . ($atts['align_center'] ? ' margin: auto;' : '') . '" ' . $data . '>'; $count_slide = 0; for ($i = 0; $i < count($slides); $i++) { // set url image $url = parse_url($slides[$i]['src']); if (!isset($url['host'])) { $slides[$i]['src'] = JURI::root() . $slides[$i]['src']; } if ($isAdmin) { // set link go to article $slides[$i]['link'] = str_replace('administrator/', '', $slides[$i]['link']); } else { // process to create image $slides[$i]['src'] = Bt_shortcodeHelper::createThumb($slides[$i]['src'], $atts['thumbnail_width'], $atts['thumbnail_height'], $atts['crop_center'], $atts['quality']); } // open item $return .= '<div class="bt-carousel-item" data-src="' . $slides[$i]['src'] . '" data-title="' . $slides[$i]['title'] . '" data-desc="" data-link="' . $slides[$i]['link'] . '">'; $return .= '<div class="item-image">'; if ($slides[$i]['link']) { $return .= '<a href="' . $slides[$i]['link'] . '" ' . $target . '><img src="' . $slides[$i]['src'] . '" alt=""></a>'; } else { $return .= '<img src="' . $slides[$i]['src'] . '" alt="">'; } if ($slides[$i]['title']) { $return .= '<h4 class="image-title">'; if ($slides[$i]['link']) { $return .= '<a href="' . $slides[$i]['link'] . '" ' . $target . '>' . $slides[$i]['title'] . '</a>'; } else { $return .= $slides[$i]['title']; } $return .= '</h4>'; } // close item $return .= '</div></div>'; } // Close slides $return .= '</div>'; // Open nav section // $return .= '<div class="btsc-carousel-nav">'; // Append direction nav // if ( $atts['arrows'] === 'yes') // $return .= '<div class="btsc-carousel-direction"><span class="btsc-carousel-prev"></span><span class="btsc-carousel-next"></span></div>'; // Append pagination nav // $return .= '<div class="btsc-carousel-pagination"></div>'; // Close nav section // $return .= '</div>'; // Close slider // $return .= '</div>'; // reset carousel self::$images = array(); // self::$image_count['carousel'] = 0; $style = bt_query_asset('css', 'galleries-shortcodes'); $style .= bt_query_asset('css', 'owl.carousel'); $jquery = bt_query_asset('js', 'jquery'); $swiper = bt_query_asset('js', 'owl.carousel.min'); $galleriesJs = bt_query_asset('js', 'galleries-shortcodes'); $return .= $style . $jquery . $swiper . $galleriesJs; } else { $return = '<p class="btsc-error">Slider: images not found.</p>'; } return $return; }
public static function border($id, $field) { $defaults = (string) $field->default === 'none' ? array('0', 'none', '#000000') : explode(' ', str_replace('px', '', $field->default)); $return = '<div class="bt-generator-border-picker"> <span class="bt-generator-border-picker-field"> <input type="number" min="0" max="10" step="1" value="' . $defaults[0] . '" class="bt-generator-border-size" /> <small>' . JText::_('BORDER_SIZE') . ' (px)</small> </span> <span class="bt-generator-border-picker-field">' . Bt_shortcodeHelper::select(array('class' => 'bt-generator-border-style', 'selected' => $defaults[1], 'options' => array('none' => JText::_('NONE'), 'solid' => JText::_('SOLID'), 'dotted' => JText::_('DOTTED'), 'dashed' => JText::_('DASHED'), 'double' => JText::_('DOUBLE'), 'groove' => JText::_('GROOVE'), 'ridge' => JText::_('RIDGE')))) . '<small>' . JText::_('BORDER_STYLE') . '</small> </span> <span class="bt-generator-border-picker-field bt-generator-picker-color"> <span class="bt-generator-border-picker-color-wheel"></span> <input type="text" value="' . $defaults[2] . '" class="bt-generator-border-picker-color-value" /> <small>' . JText::_('COLOR') . '</small> </span> <input type="hidden" name="' . $id . '" value="' . $field->default . '" id="bt-generator-attr-' . $id . '" class="bt-generator-attr" /> </div>'; return $return; }