/** * @param JBlankTemplate $tpl */ public function __construct(JBlankTemplate $tpl) { parent::__construct($tpl); $this->_path = $this->_tpl->lessFull; }
/** * @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 = $this->_getExtension($filename); $prefix = !empty($prefix) ? $prefix . '_' : ''; if ($ext == 'css') { // include external if ($this->_isExternal($filename)) { $this->doc->addStylesheet($filename, 'text/css', $type); return $this; } // include in css folder $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; } // include related root site path $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; }
/** * @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; }