/** * Prints the HTML for CSS resources * * @param string $collectionName the name of the collection * * @return string the result of the collection **/ public function outputCss($collectionName = null) { $collection = $this->collection($collectionName); if ($collection->getJoin()) { $filename = $collection->getTargetPath(); if (file_exists($filename)) { $time = 0; foreach ($collection->getResources() as $resource) { $tmp = filemtime($resource->getRealTargetPath()); if ($tmp > $time) { $time = $tmp; } } // If created if (filemtime($filename) > $time) { $collection->setTargetUri($collection->getTargetUri() . '?' . filemtime($filename)); return Tag::stylesheetLink($collection->getTargetUri()); } } // Else CREATE $res = parent::outputCss($collectionName); return $res; } return parent::outputCss($collectionName); }
/** * Print output Css * * @param string $name */ public function outputCss($name = null) { parent::outputCss($name); if ($name == null) { echo implode("", $this->cssDeclaration); } else { if (method_exists($this->_collections["{$name}"], "outputCss")) { $this->_collections["{$name}"]->outputCss(); } } }
/** * Tests custom filters * * @issue 1198 * @author Volodymyr Kolesnykov <*****@*****.**> * @since 2013-09-15 */ public function testAssetsFilterChainCustomFilterWithCssmin() { $this->specify("The chaining a custom filter with cssmin does not return the correct results", function () { $fileName = $this->tester->getNewFileName('assets_', 'css'); $assets = new Manager(); $assets->useImplicitOutput(false); $css = $assets->collection('css'); $css->setTargetPath(PATH_CACHE . $fileName); $css->addCss(PATH_DATA . 'assets/1198.css'); $css->addFilter(new UppercaseFilter()); $css->addFilter(new TrimFilter()); $css->join(true); $assets->outputCss('css'); $expected = 'A{TEXT-DECORATION:NONE;}B{FONT-WEIGHT:BOLD;}'; $actual = file_get_contents(PATH_CACHE . $fileName); $this->tester->cleanFile(PATH_CACHE, $fileName); expect($actual)->equals($expected); }); }
/** * Prints the HTML for CSS resources. * * @param string $collectionName the name of the collection * * @return string **/ public function outputCss($collectionName = self::DEFAULT_COLLECTION_CSS) { $remote = $this->_config->application->assets->get('remote'); $collection = $this->collection($collectionName); if (!$remote && $collection->getJoin()) { $local = $this->_config->application->assets->get('local'); $lifetime = $this->_config->application->assets->get('lifetime', 0); $filepath = $local . self::GENERATED_STORAGE_PATH . ($filename = $filename = $this->getCollectionFileName($collection, self::FILENAME_PATTERN_CSS)); $collection->setTargetPath($filepath)->setTargetUri($filepath); if ($this->_cache->exists($filename)) { return Tag::stylesheetLink($collection->getTargetUri()); } $res = parent::outputCss($collectionName); $this->_cache->save($filename, true, $lifetime); return $res; } return parent::outputCss($collectionName); }
public function outputCss($collectionName = null) { return parent::outputCss($collectionName); }