function yjsg_shortcodes_replace($shortcode, $text) { preg_match_all($shortcode['match'], $text, $matches, PREG_SET_ORDER); switch ($shortcode['type']) { case "yjsgparse": foreach ($matches as $index => $match) { if (!empty($matches[$index][1])) { $days = $matches[$index][2]; $hours = $matches[$index][3]; $allowjs = false; if (strpos($matches[$index][0], 'allowjs') !== false) { $allowjs = true; } $replacement = yjsg_parse($matches[$index][1], $days, $hours, $allowjs); } $text = str_replace($matches[$index][0], $replacement, $text); } break; case "yjsgmedia": $media_enabled = false; if (strpos($text, 'mediaelement-and-player.min.js') !== false) { $media_enabled = true; } foreach ($matches as $index => $match) { $medialink = $matches[$index][1]; $poster = ''; if (!empty($matches[$index][2])) { $poster = ' poster="' . $matches[$index][2] . '"'; } $width = ' width="' . $matches[$index][3] . '"'; $height = ' height="' . $matches[$index][4] . '"'; $tag = 'video'; $type = 'video/mp4'; $respond = ' yjsg-media-respond'; if ($matches[$index][5] == 'no') { $respond = ''; } $addclass = ''; $mediaid = $matches[$index][6]; if (strpos($medialink, 'mp3') !== false) { $poster = ''; $width = ''; $height = ''; $tag = 'audio'; $type = 'audio/mp3'; $addclass = ' yjsg-audio'; } if (strpos($medialink, 'vimeo') !== false) { $poster = ''; $type = 'video/vimeo'; $addclass = ' yjsg-vimeo'; } if (strpos($medialink, 'youtu') !== false) { $poster = ''; $type = 'video/youtube'; $addclass = ' yjsg-youtube'; } $replacement = '<' . $tag . ' id="' . $mediaid . '" class="yjsg-media' . $addclass . $respond . '"' . $poster . $width . $height . '>'; $replacement .= '<source src="' . $medialink . '" type="' . $type . '">'; $replacement .= '</' . $tag . '>'; if ($media_enabled) { $text = str_replace($matches[$index][0], $replacement, $text); } else { $replacement = '<div class="yjtbox yjtb_yellow lineup">'; $replacement .= '<span class="yjtb_close"></span>'; $replacement .= '<span class="yjtboxicon fa fa-warning"></span>'; $replacement .= '<h4 class="yjtboxtitle">' . JText::_('YJSG_MEDIA_ELEMENT_MISSING_TITLE') . ':</h4>'; $replacement .= JText::_('YJSG_MEDIA_ELEMENT_MISSING'); $replacement .= '</div>'; $text = str_replace($matches[$index][0], $replacement, $text); break; } } break; case "yjsgnote": foreach ($matches as $index => $match) { $color = $matches[$index][1]; $close = $matches[$index][2]; $title = $matches[$index][3]; $border = ''; if ($matches[$index][4] != 'default') { $border = ' ' . $matches[$index][4]; } $radius = ''; if ($matches[$index][5] != '0') { $radius = ' ' . $matches[$index][5]; } $icon = ''; $lineup = ''; if ($matches[$index][6] != '') { $icon = '<span class="yjtboxicon ' . $matches[$index][6] . '"></span>'; $lineup = ' lineup'; } $content = $matches[$index][7]; $replacement = '<div class="yjtbox yjtb_' . $color . $radius . $border . $lineup . '">'; if ($close == 'yes') { $replacement .= '<span class="yjtb_close"></span>'; } $replacement .= $icon; if (!empty($title)) { $replacement .= '<h4 class="yjtboxtitle">' . $title . '</h4>'; } $replacement .= $content; $replacement .= '</div>'; $text = str_replace($matches[$index][0], $replacement, $text); } break; case "yjsgacs": foreach ($matches as $index => $match) { $re = '/\\[yjsgacgroup.*?title\\=\\"((?><[^>]+>|[^"])*?)\\".*?active\\=\\"(.*?)\\"](.*?)\\[\\/yjsgacgroup\\]/s'; preg_match_all($re, $matches[$index][2], $groups, PREG_SET_ORDER); $replacement = '<div id="' . $matches[$index][1] . '" class="yjsgaccChrome">'; foreach ($groups as $gindex => $group) { $active = ''; if ($group[2] == 1) { $active = ' active'; } /* group start */ $replacement .= '<div class="yjsgaccGroup">'; $replacement .= '<div class="yjsgaccTrigger' . $active . '">'; $replacement .= '<a href="#">'; $replacement .= $group[1]; $replacement .= '</a>'; $replacement .= '</div>'; $replacement .= '<div class="yjsgaccContent">'; $replacement .= $group[3]; $replacement .= '</div>'; $replacement .= '</div>'; /* group end */ } $replacement .= '</div>'; $text = str_replace($matches[$index][0], $replacement, $text); } break; case "yjsgstabs": foreach ($matches as $index => $match) { $re = '/\\[yjsgstabsgroup.*?title\\=\\"((?>\\[[^]]+]|[^"])*?)\\".*?active\\=\\"(.*?)\\"](.*?)\\[\\/yjsgstabsgroup\\]/s'; preg_match_all($re, $matches[$index][3], $groups, PREG_SET_ORDER); $type = ' yjsgtabsnav'; if ($matches[$index][2] != 'tabnav') { $type = ' ' . $matches[$index][2]; } global $text_direction; if ($text_direction == 1 && $matches[$index][2] == 'tabsleft') { $type = ' tabsright'; } if ($text_direction == 1 && $matches[$index][2] == 'tabsright') { $type = ' tabsleft'; } $replacement = '<div id="' . $matches[$index][1] . '" class="yjsgSimpleTabs yjsgtabs' . $type . '">'; $replacement .= '<ul class="yjsgsliderPaginationTabs yjsgShortcodeTabs">'; foreach ($groups as $gindex => $group) { $activetab = ''; if ($group[2] == 1) { $activetab = ' class="active"'; } $replacement .= '<li' . $activetab . '><a class="tabbutton" href="#' . $matches[$index][1] . 'tab' . $gindex . '">' . $group[1] . '</a></li>'; } $replacement .= '</ul>'; foreach ($groups as $gindex => $group) { $activecontent = ''; if ($group[2] == 1) { $activecontent = ' activeContent'; } $replacement .= '<div id="' . $matches[$index][1] . 'tab' . $gindex . '" class="yjsgTabContent' . $activecontent . '">'; $replacement .= $group[3]; $replacement .= '</div>'; } $replacement .= '</div>'; $text = str_replace($matches[$index][0], $replacement, $text); } break; case "yjsgfa": foreach ($matches as $index => $match) { $replacement = '<span class="' . $matches[$index][1] . '"></span>'; $text = str_replace($matches[$index][0], $replacement, $text); } break; case "yjsgimgs": foreach ($matches as $index => $match) { $image = $matches[$index][1]; $class = $matches[$index][2]; $title = $matches[$index][3]; $link = $matches[$index][4]; $target = $matches[$index][5]; $effect = $matches[$index][6]; $parenttag = 'span'; $href = ''; $linktarget = ''; $fadedata = ''; $effectclass = ' yjt_' . $effect; if (!empty($link)) { $parenttag = 'a'; $href = 'href="' . $link . '" '; if ($target == 'blank') { $linktarget = ' target="_blank"'; } } if (strpos($effect, '|') !== false) { $effect = explode('|', $effect); $fadedata = ' data-yjt_fadeto="' . $effect[1] . '" data-yjt_fadespeed="' . $effect[2] . '"'; $effectclass = ' yjt_fade'; } $replacement = '<' . $parenttag . ' class="yjt_imgs ' . $class . $effectclass . '" ' . $href . 'title="' . $title . '"' . $linktarget . $fadedata . '>'; $replacement .= '<img src="' . $image . '" alt="' . $title . '" />'; $replacement .= '</' . $parenttag . '>'; $text = str_replace($matches[$index][0], $replacement, $text); } break; case "yjsgpre": foreach ($matches as $index => $match) { $pretty = ''; $scroll = ''; $preclass = ''; if ($matches[$index][1] == 1) { $pretty = 'prettyprint linenums'; } if ($matches[$index][2] == 1) { $scroll = ' pre-scrollable'; } if ($matches[$index][1] == 1 || $matches[$index][2] == 1) { $preclass = ' class="' . $pretty . $scroll . '"'; } $get_pre = str_replace(array('{/', '{yj', 'yjsgpre}', 'group}', 'yjsgstabs}', 'yjsgnote}', 'yjsgacs}', '"}'), array('[/', '[yj', 'yjsgpre]', 'group]', 'yjsgstabs]', 'yjsgnote]', 'yjsgacs]', '"]'), $matches[$index][3]); $get_pre = clean_html_code($get_pre, " "); $replacement = '<pre' . $preclass . '>'; $replacement .= htmlentities($get_pre, ENT_QUOTES, 'UTF-8'); $replacement .= '</pre>'; $text = str_replace($matches[$index][0], $replacement, $text); } break; } if (JFile::exists(YJSGCUSTOMFOLDER . 'yjsgshortcodes' . YJDS . 'yjsg_shortcodes_replace.php')) { include YJSGCUSTOMFOLDER . 'yjsgshortcodes' . YJDS . 'yjsg_shortcodes_replace.php'; } return $text; }
function clean($html) { return clean_html_code($html); }