function js($files, $inline = false, $duress = false) { // Register in header to prevent duplicates $registry = ClassRegistry::getObject('javascript'); if (is_array($files)) { $out = ''; foreach ($files as $i) { if ($duress || !isset($registry[$i])) { $out .= "\n\t" . $this->js($i, $inline, $duress); } } if ($out != '' && $inline) { echo $out . "\n"; } return; } ClassRegistry::setObject($files, 1, 'javascript'); if (substr($files, -3) != '.js') { $files = $files . '.js'; } if (false !== strpos($files, MVC_ADMIN)) { // Automatic routing to admin path $files = str_replace(MVC_ADMIN . '/', '', $files); $jsUrl = $this->locateScript($files, true); } else { $jsUrl = $this->locateScript($files); } if ($jsUrl) { $out = sprintf($this->tags['javascriptlink'], $jsUrl); cmsFramework::addScript($out, $inline, $duress); } }
function addScript($text, $inline = false, $duress = false) { $scripts = ClassRegistry::getObject('scripts'); if ($text != '' && ($duress || !isset($scripts[md5($text)]))) { if ($inline) { echo $text; } else { global $mainframe; $mainframe->addCustomHeadTag($text); } $scripts[md5($text)] = true; ClassRegistry::setObject('scripts', $scripts); } }
function onContentBeforeDisplay($context, &$article, &$params) { /*********************************************************************** * BELOW BLOCK HERE BECAUSE J16 DOESN'T MAKE THE WHOLE ARTICLE OBJECT * AVAILABLE IN THE ONCONTENTPREPARE CALLBACK IN BLOG LAYOUT PAGES ***********************************************************************/ if (!class_exists('cmsFramework') || !class_exists('Sanitize')) { return; } $this->setCmsVersion(); // Check whether to perform the replacement or not $option = Sanitize::getString($_REQUEST, 'option', ''); $view = Sanitize::getString($_REQUEST, 'view', ''); $layout = Sanitize::getString($_REQUEST, 'layout', ''); $id = Sanitize::getInt($_REQUEST, 'id'); if ($option == 'com_content' && ($layout == 'blog' || $view == 'featured')) { $row =& $article; $row->text =& $row->introtext; if ((isset($row->params) || isset($row->parameters)) && isset($row->id) && $row->id > 0 && isset($row->catid) && $row->catid > 0) { $Dispatcher = new S2Dispatcher('jreviews', true); if ($option == 'com_content' && $view == 'article' & $id > 0) { $_GET['url'] = 'com_content/com_content_view'; } elseif ($option == 'com_content' && ($layout == 'blog' && $view == 'category' || $view == 'featured')) { $_GET['url'] = 'com_content/com_content_blog'; } $passedArgs = array('params' => $params, 'row' => $row, 'component' => 'com_content'); $passedArgs['cat'] = $row->catid; $passedArgs['listing_id'] = $row->id; $output = $Dispatcher->dispatch($passedArgs); if ($output) { $row =& $output['row']; unset($params); $params =& $output['params']; } /** * Store a copy of the $listing and $crumbs arrays in memory for use in the onBeforeDisplayContent method */ ClassRegistry::setObject(array('listing' => &$output['listing'], 'crumbs' => &$output['crumbs']), 'jreviewsplugin'); // Destroy pathway if (!empty($output['crumbs'])) { cmsFramework::setPathway(array()); } unset($output, $passedArgs, $Dispatcher); } } /*********************************************************************** * ABOVE BLOCK HERE BECAUSE J16 DOESN'T MAKE THE WHOLE ARTICLE OBJECT * AVAILABLE IN THE ONCONTENTPREPARE CALLBACK IN BLOG LAYOUT PAGES ***********************************************************************/ return $this->onBeforeDisplayContent($article, $params); }
function addScript($text, $inline = false, $duress = false) { $scripts = ClassRegistry::getObject('scripts'); if ($text != '' && ($duress || !isset($scripts[md5($text)]))) { if ($inline) { echo $text; } else { $doc =& JFactory::getDocument(); method_exists($doc, 'addCustomTag') and $doc->addCustomTag($text); } $scripts[md5($text)] = true; ClassRegistry::setObject('scripts', $scripts); } }