/** * Include files to document * @param array $files * @param $type */ protected function _include(array $files, $type) { static $includedFiles; if (!isset($includedFiles)) { $includedFiles = array(); } if (count($files) && !$this->app->jbrequest->isAjax()) { foreach ($files as $file) { $isExternal = strpos($file, 'http') !== false; $filePath = $file; if (!$isExternal) { $fullPath = $this->app->path->path($file); $filePath = $this->app->path->url($file); } if ($filePath) { if (!$isExternal) { $filePath = $filePath . '?ver=' . date("Ymd", filemtime($fullPath)); $filePath = $this->_getRoot() . $this->app->path->relative($filePath); } if ($type == 'css') { $this->_document->addStylesheet($filePath); } elseif ($type == 'js') { $this->_document->addScript($filePath); } } } } }
/** * Merging all css or js files (that already have been included via Joomla API) * USE IT ON YOUR OWN RISK!!! * @param string $type * @param bool $isCompress * @return $this */ public function merge($type = 'css', $isCompress = false) { $mergeFiles = array(); $dataKey = $type == 'css' ? 'styleSheets' : 'scripts'; if (method_exists($this->doc, 'getHeadData')) { $docData = $this->doc->getHeadData(); } if (isset($docData) && !empty($docData[$dataKey])) { foreach ($docData[$dataKey] as $pathOrig => $attrs) { // don't get external files $path = str_replace($this->baseurl, '', $pathOrig); $path = preg_replace('#(\\?.*)$#', '', $path); if ($this->_isExternal($path)) { continue; } if ($attrs['mime'] == 'text/css' && (!isset($attrs['media']) || strtolower($attrs['media']) == 'all') || $attrs['mime'] == 'text/javascript') { $fullPath = JPath::clean(JPATH_ROOT . '/' . $path); $fullPathFolder = JPath::clean($_SERVER['DOCUMENT_ROOT'] . '/' . $path); $resPath = false; if (JFile::exists($fullPath)) { $resPath = $fullPath; } else { if (JFile::exists($fullPathFolder)) { $resPath = $fullPathFolder; } } if ($resPath) { $mergeFiles[] = $resPath; unset($docData[$dataKey][$pathOrig]); } } } } if (count($mergeFiles)) { $processor = JBlankMinify::getProcessor($type, $this); if ($path = $processor->minify($mergeFiles, $isCompress)) { $this->setHeadData($dataKey, $docData); if ('css' == $type) { $this->doc->addStylesheet($path, 'text/css'); } else { if ('js' == $type) { $this->doc->addScript($path, "text/javascript", false, false); } } } } return $this; }
/** * @param $filename * @param string $prefix * @param string $type * @return $this */ public function css($filename, $type = 'all', $prefix = '') { if (is_array($filename)) { foreach ($filename as $file) { $this->css($file, $type, $prefix); } } else { if ($filename) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $prefix = !empty($prefix) ? $prefix . '_' : ''; if ($ext == 'css') { $path = JPath::clean($this->cssFull . '/' . $prefix . $filename); if ($mtime = $this->_checkFile($path)) { $cssPath = $this->css . '/' . $prefix . $filename . '?' . $mtime; $this->doc->addStylesheet($cssPath, 'text/css', $type); return $this; } $path = JPath::clean(JPATH_ROOT . '/' . $filename); if ($mtime = $this->_checkFile($path)) { $cssPath = rtrim($this->baseurl, '/') . '/' . ltrim($filename, '/') . '?' . $mtime; $this->doc->addStylesheet($cssPath, 'text/css', $type); return $this; } } else { if ($ext == 'less') { $lessMode = $this->params->get('less_processor', 'leafo'); $path = JPath::clean($this->lessFull . '/' . $prefix . $filename); if ($this->_checkFile($path)) { if ($cssPath = JBlankCss::getProcessor('less.' . $lessMode, $this)->compile($path)) { $this->doc->addStylesheet($cssPath, 'text/css', $type); } } } else { if ($ext == 'scss') { $path = JPath::clean($this->scssFull . '/' . $prefix . $filename); if ($this->_checkFile($path)) { if ($cssPath = JBlankCss::getProcessor('scss.leafo', $this)->compile($path)) { $this->doc->addStylesheet($cssPath, 'text/css', $type); } } } } } } } return $this; }
/** * Attach css, javascript files to document * @return void */ private function _addAssets() { $this->_getDefaultStyles(); $file = dirname(__FILE__) . '/assets/js/supports/' . $this->_defaultStyles['admin']->template . '.js'; if (!is_file($file)) { return; } require_once JPATH_ADMINISTRATOR . '/components/com_poweradmin/helpers/poweradmin.php'; $currentVersion = PoweradminHelper::getVersion(); $config = $this->_getJSConfiguration(); $language = $this->_getJSLanguage(); $uri = JUri::root(true); $template = $this->_defaultStyles['admin']->template; $this->_document->addStyleSheet(JSN_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-bootstrap.css'); $this->_document->addStylesheet($uri . '/plugins/system/jsnpoweradmin/assets/css/adminbar.css?v=' . $currentVersion); $this->_document->addStylesheet($uri . '/plugins/system/jsnpoweradmin/assets/css/window.css?v=' . $currentVersion); $this->_document->addStylesheet($uri . '/plugins/system/jsnpoweradmin/assets/css/print.css?v=' . $currentVersion, 'text/css', 'print'); if (in_array($template, array('minima', 'aplite'))) { $this->_document->addStylesheet($uri . '/plugins/system/jsnpoweradmin/assets/css/adminbar.menu.css?v=' . $currentVersion); } if ($template == 'hathor') { $this->_document->addStylesheet($uri . '/plugins/system/jsnpoweradmin/assets/css/adminbar.hathor.css?v=' . $currentVersion); } $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/jquery.noconflict.js?v=' . $currentVersion); if (file_exists('../media/system/js/mootools-core.js')) { $this->_document->addScript($uri . '/media/system/js/mootools-core.js'); $this->_document->addScript($uri . '/media/system/js/core.js'); $this->_document->addScript($uri . '/media/system/js/mootools-more.js'); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/mootool.conflict.js?v=' . $currentVersion); } else { JHtml::_('behavior.framework', true); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/mootool.conflict.js?v=' . $currentVersion); } $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/mootools/mooml.js?v=' . $currentVersion); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/scrollbar.js?v=' . $currentVersion); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/window.js?v=' . $currentVersion); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/supports/' . $template . '.js?v=' . $currentVersion); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/adminbar.js?v=' . $currentVersion); $this->_document->addScript($uri . '/plugins/system/jsnpoweradmin/assets/js/history.js?v=' . $currentVersion); $this->_document->addScriptDeclaration("\n\t\t\tif (JoomlaShine === undefined) { var JoomlaShine = {}; }\n\t\t\tif (typeof(jQuery) !== 'undefined') { jQuery.noConflict(); }\n\n\t\t\tJoomlaShine.language = {$language};\n\t\t\twindow.addEvent('domready', function () {\n\t\t\t\tif(!document.getElementById('jsn-adminbar-wrapper')){\n\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\tnew JSNAdminBar({$config});\n\t\t\t\t\t\t\tnew JSNHistory();\n\t\t\t\t\t\t}, 500);\t\t\t\t\n\t\t\t\t\t}\n\t\t\t});\n\t\t"); }