/** * Get Scriptegrator plugin params * * @param $param * @param $default * @return string or array */ function pluginParam($param = '', $default = '') { $plugin =& JPluginHelper::getPlugin('system', JScriptegrator::properties('name')); $params = new JParameter($plugin->params); if (!$param) { return $params; } return $params->get($param, $default); }
/** * Return list of available themes * * @return array */ function themeList() { jimport('joomla.filesystem.folder'); $path = JScriptegrator::folder(true) . DS . 'libraries' . DS . 'jquery' . DS . 'theme'; $files = array(); $files = JFolder::folders($path, '.', false, false); return $files; }
/** * Script declaration * * @param $params * @return string */ function scriptDeclaration($params = null) { // define database parameters $outlineType = $params->get('outlineType', 'rounded-white'); $outlineWhileAnimating = (int) $params->get('outlineWhileAnimating', 1); $showCredits = (int) $params->get('showCredits', 1); $expandDuration = (int) $params->get('expandDuration', 250); $anchor = $params->get('anchor', 'auto'); $align = $params->get('align', 'auto'); $transitions = $params->get('transitions', 'expand'); $dimmingOpacity = $params->get('dimmingOpacity', '0'); // end // define script parameters switch ($outlineWhileAnimating) { case 1: $outlineWhileAnimating = 'true'; break; case 0: $outlineWhileAnimating = 'false'; break; default: $outlineWhileAnimating = 'true'; break; } if ($showCredits) { $showCredits = 'true'; } else { $showCredits = 'false'; } switch ($transitions) { case 'expand': $transitions = '["expand"]'; break; case 'fade': $transitions = '["fade"]'; break; case 'expand+fade': $transitions = '["expand", "fade"]'; break; case 'fade+expand': $transitions = '["fade", "expand"]'; break; default: $transitions = '["expand"]'; break; } // end $script = "\n\t\t<!--\n\t\tvar cdhs = hs;\n\t\ths.graphicsDir = '" . JScriptegrator::folder() . "/libraries/highslide/graphics/';\n \ths.outlineType = '" . $outlineType . "';\n \ths.outlineWhileAnimating = " . $outlineWhileAnimating . ";\n \ths.showCredits = " . $showCredits . ";\n \ths.expandDuration = " . $expandDuration . ";\n\t\ths.anchor = '" . $anchor . "';\n\t\ths.align = '" . $align . "';\n\t\ths.transitions = " . $transitions . ";\n\t\ths.dimmingOpacity = " . $dimmingOpacity . ";\n\t\ths.lang = {\n\t\t loadingText : '" . JText::_('CDS_LOADING') . "',\n\t\t loadingTitle : '" . JText::_('CDS_CANCELCLICK') . "',\n\t\t focusTitle : '" . JText::_('CDS_FOCUSCLICK') . "',\n\t\t fullExpandTitle : '" . JText::_('CDS_FULLEXPANDTITLE') . "',\n\t\t fullExpandText : '" . JText::_('CDS_FULLEXPANDTEXT') . "',\n\t\t creditsText : '" . JText::_('CDS_CREDITSTEXT') . "',\n\t\t creditsTitle : '" . JText::_('CDS_CREDITSTITLE') . "',\n\t\t previousText : '" . JText::_('CDS_PREVIOUSTEXT') . "',\n\t\t previousTitle : '" . JText::_('CDS_PREVIOUSTITLE') . "',\n\t\t nextText : '" . JText::_('CDS_NEXTTEXT') . "',\n\t\t nextTitle : '" . JText::_('CDS_NEXTTITLE') . "',\n\t\t moveTitle : '" . JText::_('CDS_MOVETITLE') . "',\n\t\t moveText : '" . JText::_('CDS_MOVETEXT') . "',\n\t\t closeText : '" . JText::_('CDS_CLOSETITLE') . "',\n\t\t closeTitle : '" . JText::_('CDS_CLOSETEXT') . "',\n\t\t resizeTitle : '" . JText::_('CDS_RESIZETITLE') . "',\n\t\t playText : '" . JText::_('CDS_PLAYTEXT') . "',\n\t\t playTitle : '" . JText::_('CDS_PLAYTITLE') . "',\n\t\t pauseText : '" . JText::_('CDS_PAUSETEXT') . "',\n\t\t pauseTitle : '" . JText::_('CDS_PAUSETITLE') . "', \n\t\t number : '" . JText::_('CDS_NUMBER') . "',\n\t\t restoreTitle : '" . JText::_('CDS_RESTORETITLE') . "'\n\t\t};\n\t\t//-->\n\t\t"; return $script; }
/** * Plugin replacer * * @return string */ function replacer(&$match) { $document =& JFactory::getDocument(); $default_tabstyle = $this->params->get('default_tabstyle', 'smoothness'); if ($default_tabstyle == '-1') { $default_tabstyle = 'smoothness'; } $default_animated = $this->params->get('default_animated', 'both'); $tabwidth = $this->params->get('default_tabwidth', '80px'); $default_boxwidth = $this->params->get('default_boxwidth', '0'); $default_tabalign = $this->params->get('default_tabalign', 'left'); $default_taboffset = $this->params->get('default_taboffset', '0px'); $default_tabrotate = (int) $this->params->get('default_tabrotate', 0); $default_tabevent = $this->params->get('default_tabevent', 'click'); $def_navigation = $this->params->get('navigation', 0); $readmore = $this->params->get('readmore', 0); $process_plugins = (int) $this->params->get('plugins', 0); // define regex parameters $tabs_settings = isset($match[1]) ? $match[1] : ''; $tabs_text = isset($match[2]) ? $match[2] : ''; unset($match); // Mode preg_match("#^[0-9:]*?\$#", $tabs_text, $mode); $mode = isset($mode[0]) ? 'id' : 'manually'; // tab id preg_match('#id\\s?=\\s?"([0-9a-zA-Z]{1,})"#', $tabs_settings, $tab_id); $tab_id = isset($tab_id[1]) ? $tab_id[1] : $this->random(5); // style $files = implode('|', JScriptegrator::themeList()); preg_match('#theme\\s?=\\s?"(' . $files . ')?"#', $tabs_settings, $tab_style); $tab_style = isset($tab_style[1]) ? $tab_style[1] : $default_tabstyle; if ($tab_style) { JScriptegrator::importUITheme($tab_style, 'ui.tabs'); } // tab animated preg_match('#animation\\s?=\\s?"(both|slide|fade|none)"#', $tabs_settings, $animation); $animation = isset($animation[1]) ? $animation[1] : $default_animated; switch ($animation) { case 'none': $animation = null; break; case 'both': $animation = 'fx: { height: \'toggle\', opacity: \'toggle\' }'; break; case 'slide': $animation = 'fx: { height: \'toggle\' }'; break; case 'fade': $animation = 'fx: { opacity: \'toggle\' }'; break; default: $animation = null; break; } // end // box width preg_match('#boxwidth\\s?=\\s?"([0-9empx%.]{1,})"#', $tabs_settings, $tab_boxwidth); $tab_boxwidth = isset($tab_boxwidth[1]) ? $tab_boxwidth[1] : $default_boxwidth; // tab align (float - left, right) preg_match('#tabalign\\s?=\\s?"(left|right)"#', $tabs_settings, $tab_align); $tab_align = isset($tab_align[1]) ? $tab_align[1] : $default_tabalign; switch ($tab_align) { case 'left': $tab_align = 'left'; break; case 'right': $tab_align = 'right'; break; default: break; } // end // tab offset (padding-left) preg_match('#offset\\s?=\\s?"([0-9empx%.]{1,})"#', $tabs_settings, $tab_offset); $tab_offset = isset($tab_offset[1]) ? $tab_offset[1] : $default_taboffset; // tab select preg_match('#select\\s?=\\s?"([1-9]{1,})"#', $tabs_settings, $tab_select); $tab_select = isset($tab_select[1]) ? 'selected: ' . --$tab_select[1] : null; // event preg_match('#event\\s?=\\s?"(click|mouseover)"#', $tabs_settings, $tab_event); $tab_event = isset($tab_event[1]) ? $tab_event[1] : $default_tabevent; switch ($tab_event) { case 'click': $tab_event = 'click'; break; case 'mouseover': $tab_event = 'mouseover'; break; default: $tab_event = 'click'; break; } $tab_event = "event: '{$tab_event}'"; // end if ($tab_event and $animation and $tab_select) { $settings = $tab_event . ', ' . $animation . ', ' . $tab_select; } elseif ($tab_event and $animation) { $settings = $tab_event . ', ' . $animation; } elseif ($tab_event and $tab_select) { $settings = $tab_event . ', ' . $tab_select; } else { $settings = $tab_event; } // tab rotate preg_match('#rotate\\s?=\\s?"([0-9]{1,})"#', $tabs_settings, $tab_rotate); $tab_rotate = isset($tab_rotate[1]) ? $tab_rotate[1] : $default_tabrotate; if ($tab_rotate) { $tab_rotate = '.tabs(\'rotate\', ' . $tab_rotate . ')'; } else { $tab_rotate = ''; } // tab navigation preg_match('#navigation\\s?=\\s?"(yes|no)"#', $tabs_settings, $navigation); $navigation = isset($navigation[1]) ? $navigation[1] : ''; if ($navigation) { $navigation = $navigation == 'yes' ? 1 : 0; } else { $navigation = $def_navigation; } $custom_setting_js = "\n\t\t<!--\n\t\tjQuery(function(\$) {\n\t\t\t// tabs element\n\t\t\tvar tab_instance = \$('#magictabs_{$tab_id}');\n\t\t\t\n\t\t\t// create tabs instance\n\t\t\ttab_instance.tabs({ {$settings} }){$tab_rotate};\n\t\t"; // prev next links script if ($navigation) { $custom_setting_js .= "\n\t\t\t// prev - next buttons\n\t\t\t\$('#magictabs_{$tab_id}').find('div.buttons a').each(function(n, el) {\n\t\t\t\t\$(this).click(function (){\n\t\t\t\t\tvar selected = tab_instance.tabs('option', 'selected');\n\t\t\t\t\t" . ($tab_align == "left" ? "var count = selected + 1;" : "var count = selected - 1;") . "\n\t\t\t\t\t" . ($tab_align == "left" ? "if (\$(el).hasClass('prev')) count = selected - 1;" : "if (\$(el).hasClass('prev')) count = selected + 1;") . "\n\t\t\t\t\ttab_instance.tabs('select', count);\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t});\n\t\t\t"; } $custom_setting_js .= "\n\t\t});\n\t\t//-->\n\t\t"; $document->addScriptDeclaration($custom_setting_js); $this->customScript($tab_id, $tab_style, $tab_boxwidth, $tab_align, $tab_offset); // load custom CSS // end $tabed_text = ''; $tabed_bullet_text = '<ul>'; // open <ul> tag switch ($mode) { case 'id': $tabs_text = trim(strip_tags($tabs_text)); // prevent HTML characters in article ids if (explode(':', $tabs_text)) { $set_articles = explode(':', $tabs_text); } else { return; } foreach ($set_articles as $key => $article_id) { if ($article_id) { $article = $this->renderItem($article_id); if ($article->text) { $user =& JFactory::getUser(); $aid = $user->get('aid'); if ($article->access <= $aid) { $title = strip_tags($article->title); $fulltext = $article->fulltext; $text = $article->text; if ($fulltext and $readmore) { $text = $text . $article->link; } else { $text = $text . ''; } $tab_name = $title ? $title : ''; $text = $text ? $text : ''; $ahref = 'magictabs_' . $tab_id . '_' . ++$key; $tabed_bullet_text .= '<li><a href="#' . $ahref . '">' . $tab_name . '</a></li>'; // process plugins $text = $process_plugins ? JHTML::_('content.prepare', $text) : $text; $prevlink = '<a href="#magictabs_' . $tab_id . '_' . ($key - 1) . '" class="ui-icon ui-icon-circle-arrow-w prev" title="' . JText::_('CDMT_PREVIOUS') . '"></a>'; $nextlink = '<a href="#magictabs_' . $tab_id . '_' . ($key + 1) . '" class="ui-icon ui-icon-circle-arrow-e next" title="' . JText::_('CDAMT_NEXT') . '"></a>'; $links = '<div class="buttons">'; if ($tab_align == 'left') { if ($key + 1 <= count($set_articles)) { $links .= $nextlink; } $links .= ' '; if ($key - 1 !== 0) { $links .= $prevlink; } } else { // right $key = count($set_articles) - $key + 1; if ($key + 1 <= count($set_articles)) { $links .= $nextlink; } $links .= ' '; if ($key - 1 !== 0) { $links .= $prevlink; } } $links .= '</div>'; $tabed_text .= '<div id="' . $ahref . '">' . $text . ($navigation ? $links : '') . '</div>'; } } } } break; case 'manually': if (preg_split('#\\|\\|\\|\\|#', $tabs_text, -1, PREG_SPLIT_NO_EMPTY)) { // echo"<script>alert('Đăng ')</script>"; $tabs_text_array = preg_split('#\\|\\|\\|\\|#', $tabs_text, -1, PREG_SPLIT_NO_EMPTY); } else { return ''; } foreach ($tabs_text_array as $key => $text) { $tabs_array = explode('::', $text); $tab_name = isset($tabs_array[0]) ? trim(strip_tags($tabs_array[0])) : ''; $text = isset($tabs_array[1]) ? $tabs_array[1] : ''; $ahref = 'magictabs_' . $tab_id . '_' . ++$key; $tabed_bullet_text .= '<li><a href="#' . $ahref . '">' . $tab_name . '</a></li>'; $prevlink = '<a href="#magictabs_' . $tab_id . '_' . ($key - 1) . '" class="ui-icon ui-icon-circle-arrow-w prev" title="' . JText::_('CDMT_PREVIOUS') . '"></a>'; $nextlink = '<a href="#magictabs_' . $tab_id . '_' . ($key + 1) . '" class="ui-icon ui-icon-circle-arrow-e next" title="' . JText::_('CDAMT_NEXT') . '"></a>'; $links = '<div class="buttons">'; if ($tab_align == 'left') { if ($key + 1 <= count($tabs_text_array)) { $links .= $nextlink; } $links .= ' '; if ($key - 1 !== 0) { $links .= $prevlink; } } else { // right $key = count($tabs_text_array) - $key + 1; if ($key + 1 <= count($tabs_text_array)) { $links .= $nextlink; } $links .= ' '; if ($key - 1 !== 0) { $links .= $prevlink; } } $links .= '</div>'; $tabed_text .= '<div id="' . $ahref . '">' . $text . ($navigation ? $links : '') . '</div>'; } break; default: return; break; } $tabed_bullet_text .= '</ul>'; // close </ul> tag $html = ' <div class="' . $tab_style . '"> <div id="magictabs_' . $tab_id . '" class="ui-tabs ui-widget ui-widget-content ui-corner-all"> ' . $tabed_bullet_text . $tabed_text . ' </div> </div> '; return $html; }
/** * Load library * @return void */ function load() { // attach jQuery UI core script JScriptegrator::importUI('ui.core'); }