• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Minify_CSS_Compressor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Minify_CSS_Compressor的典型用法代码示例。如果您正苦于以下问题:PHP Minify_CSS_Compressor类的具体用法?PHP Minify_CSS_Compressor怎么用?PHP Minify_CSS_Compressor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Minify_CSS_Compressor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * Minify a CSS string
  * 
  * @param string $css
  * 
  * @param array $options (currently ignored)
  * 
  * @return string
  */
 public static function process($css, $options = array())
 {
     static $instance;
     if (!$instance) {
         $instance = new Minify_CSS_Compressor($options);
     }
     return $instance->_process($css);
 }
开发者ID:sajawa,项目名称:lib,代码行数:17,代码来源:CSS.php


示例2: minify

 /**
  * Minify a CSS string
  * 
  * @param string $css
  * 
  * @param array $options available options:
  * 
  * 'preserveComments': (default true) multi-line comments that begin
  * with "/*!" will be preserved with newlines before and after to
  * enhance readability.
  *
  * 'removeCharsets': (default true) remove all @charset at-rules
  * 
  * 'prependRelativePath': (default null) if given, this string will be
  * prepended to all relative URIs in import/url declarations
  * 
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files. For this to work, the files *must* exist and be
  * visible by the PHP process.
  *
  * 'symlinks': (default = array()) If the CSS file is stored in 
  * a symlink-ed directory, provide an array of link paths to
  * target paths, where the link paths are within the document root. Because 
  * paths need to be normalized for this to work, use "//" to substitute 
  * the doc root in the link paths (the array keys). E.g.:
  * <code>
  * array('//symlink' => '/real/target/path') // unix
  * array('//static' => 'D:\\staticStorage')  // Windows
  * </code>
  *
  * 'docRoot': (default = $_SERVER['DOCUMENT_ROOT'])
  * see Minify_CSS_UriRewriter::rewrite
  * 
  * @return string
  */
 public static function minify($css, $options = array())
 {
     $options = array_merge(array('compress' => true, 'removeCharsets' => true, 'preserveComments' => true, 'currentDir' => null, 'docRoot' => $_SERVER['DOCUMENT_ROOT'], 'prependRelativePath' => null, 'symlinks' => array()), $options);
     if ($options['removeCharsets']) {
         $css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
     }
     if ($options['compress']) {
         if (!$options['preserveComments']) {
             require_once 'Compressor.php';
             $css = Minify_CSS_Compressor::process($css, $options);
         } else {
             require_once 'CommentPreserver.php';
             require_once 'Compressor.php';
             $css = Minify_CommentPreserver::process($css, array('Minify_CSS_Compressor', 'process'), array($options));
         }
     }
     if (!$options['currentDir'] && !$options['prependRelativePath']) {
         return $css;
     }
     require_once 'UriRewriter.php';
     if ($options['currentDir']) {
         return Minify_CSS_UriRewriter::rewrite($css, $options['currentDir'], $options['docRoot'], $options['symlinks']);
     } else {
         return Minify_CSS_UriRewriter::prepend($css, $options['prependRelativePath']);
     }
 }
开发者ID:rswiders,项目名称:core,代码行数:63,代码来源:CSS.php


示例3: minify

 /**
  * Minify a CSS string
  * 
  * @param string $css
  * 
  * @param array $options available options:
  * 
  * 'preserveComments': (default true) multi-line comments that begin
  * with "/*!" will be preserved with newlines before and after to
  * enhance readability.
  * 
  * 'prependRelativePath': (default null) if given, this string will be
  * prepended to all relative URIs in import/url declarations
  * 
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files. For this to work, the files *must* exist and be
  * visible by the PHP process.
  *
  * 'symlinks': (default = array()) If the CSS file is stored in 
  * a symlink-ed directory, provide an array of link paths to
  * target paths, where the link paths are within the document root. Because 
  * paths need to be normalized for this to work, use "//" to substitute 
  * the doc root in the link paths (the array keys). E.g.:
  * <code>
  * array('//symlink' => '/real/target/path') // unix
  * array('//static' => 'D:\\staticStorage')  // Windows
  * </code>
  * 
  * @return string
  */
 static public function minify($css, $options = array()) 
 {
     require_once 'Minify/CSS/Compressor.php';
     if (isset($options['preserveComments']) 
         && !$options['preserveComments']) {
         $css = Minify_CSS_Compressor::process($css, $options);
     } else {
         require_once 'Minify/CommentPreserver.php';
         $css = Minify_CommentPreserver::process(
             $css
             ,array('Minify_CSS_Compressor', 'process')
             ,array($options)
         );
     }
     if (! isset($options['currentDir']) && ! isset($options['prependRelativePath'])) {
         return $css;
     }
     require_once 'Minify/CSS/UriRewriter.php';
     if (isset($options['currentDir'])) {
         return Minify_CSS_UriRewriter::rewrite(
             $css
             ,$options['currentDir']
             ,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']
             ,isset($options['symlinks']) ? $options['symlinks'] : array()
         );  
     } else {
         return Minify_CSS_UriRewriter::prepend(
             $css
             ,$options['prependRelativePath']
         );
     }
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:64,代码来源:CSS.php


示例4: doProcessFile

 public function doProcessFile($file, $replace = false)
 {
     $optimizedContent = Minify_CSS_Compressor::process(file_get_contents($file));
     if ($replace) {
         return parent::replaceFile($file, $optimizedContent);
     } else {
         return $optimizedContent;
     }
 }
开发者ID:rande,项目名称:swCombinePlugin,代码行数:9,代码来源:swDriverMinifyCssCompressor.class.php


示例5: buildApiCss

 private function buildApiCss()
 {
     // copy file
     $this->getFilesystem()->copy(sfConfig::get('sf_web_dir') . '/css/api_sources/button.css', sfConfig::get('sf_web_dir') . '/css/v1/button.css', array('override' => true));
     // replace wildcards
     $this->getFilesystem()->replaceTokens(sfConfig::get('sf_web_dir') . '/css/v1/button.css', '##', '##', array('YIID_WIDGET_HOST' => sfConfig::get('app_settings_widgets_host'), 'YIID_BUTTON_HOST' => sfConfig::get('app_settings_button_url')));
     $lCssMin = Minify_CSS_Compressor::process(file_get_contents(sfConfig::get('sf_web_dir') . '/css/v1/button.css'));
     $lCssMinFile = fopen(sfConfig::get('sf_web_dir') . '/css/v1/button.css', 'w+');
     $lDone = fwrite($lCssMinFile, $lCssMin);
     fclose($lCssMinFile);
 }
开发者ID:42medien,项目名称:spreadly,代码行数:11,代码来源:BuildCssTask.class.php


示例6: minify

 /**
  * Minify a CSS string
  * 
  * @param string $css
  * 
  * @param array $options available options:
  * 
  * 'preserveComments': (default true) multi-line comments that begin
  * with "/*!" will be preserved with newlines before and after to
  * enhance readability.
  *
  * 'removeCharsets': (default true) remove all @charset at-rules
  * 
  * 'prependRelativePath': (default null) if given, this string will be
  * prepended to all relative URIs in import/url declarations
  * 
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files. For this to work, the files *must* exist and be
  * visible by the PHP process.
  *
  * 'symlinks': (default = array()) If the CSS file is stored in 
  * a symlink-ed directory, provide an array of link paths to
  * target paths, where the link paths are within the document root. Because 
  * paths need to be normalized for this to work, use "//" to substitute 
  * the doc root in the link paths (the array keys). E.g.:
  * <code>
  * array('//symlink' => '/real/target/path') // unix
  * array('//static' => 'D:\\staticStorage')  // Windows
  * </code>
  *
  * 'docRoot': (default = $_SERVER['DOCUMENT_ROOT'])
  * see Minify_CSS_UriRewriter::rewrite
  * 
  * @return string
  */
 public static function minify($css, $options = array())
 {
     $options = array_merge(array('removeCharsets' => true, 'preserveComments' => true), $options);
     if ($options['removeCharsets']) {
         $css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
     }
     if (!$options['preserveComments']) {
         $css = Minify_CSS_Compressor::process($css, $options);
     } else {
         $css = Minify_CommentPreserver::process($css, array('Minify_CSS_Compressor', 'process'), array($options));
     }
     return $css;
 }
开发者ID:jarridb,项目名称:Compressor,代码行数:50,代码来源:CSS.php


示例7: minify

 /**
  * Minify a CSS string
  *
  * @param string $css
  *
  * @param array $options available options:
  *
  * 'preserveComments': (default true) multi-line comments that begin
  * with "/*!" will be preserved with newlines before and after to
  * enhance readability.
  *
  * 'prependRelativePath': (default null) if given, this string will be
  * prepended to all relative URIs in import/url declarations
  *
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files. For this to work, the files *must* exist and be
  * visible by the PHP process.
  *
  * 'symlinks': (default = array()) If the CSS file is stored in
  * a symlink-ed directory, provide an array of link paths to
  * target paths, where the link paths are within the document root. Because
  * paths need to be normalized for this to work, use "//" to substitute
  * the doc root in the link paths (the array keys). E.g.:
  * <code>
  * array('//symlink' => '/real/target/path') // unix
  * array('//static' => 'D:\\staticStorage')  // Windows
  * </code>
  *
  * @return string
  */
 public static function minify($css, $options = array())
 {
     require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/Compressor.php';
     if (isset($options['preserveComments']) && $options['preserveComments']) {
         require_once W3TC_LIB_MINIFY_DIR . '/Minify/CommentPreserver.php';
         $css = Minify_CommentPreserver::process($css, array('Minify_CSS_Compressor', 'process'), array($options));
     } else {
         $css = Minify_CSS_Compressor::process($css, $options);
     }
     require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/UriRewriter.php';
     $css = Minify_CSS_UriRewriter::rewrite($css, $options);
     return $css;
 }
开发者ID:nxtclass,项目名称:NXTClass,代码行数:45,代码来源:CSS.php


示例8: min

 public function min()
 {
     $this->_options = array_merge(array('remove_charsets' => true, 'preserve_comments' => true, 'current_dir' => null, 'doc_root' => $_SERVER['DOCUMENT_ROOT'], 'prepend_relative_path' => null, 'symlinks' => array()), $this->_options);
     if ($this->_options['remove_charsets']) {
         $this->_css = preg_replace('/@charset[^;]+;\\s*/', '', $this->_css);
     }
     if (!$this->_options['preserve_comments']) {
         $this->_css = Minify_CSS_Compressor::process($this->_css, $this->_options);
     } else {
         $this->_css = Minify_CSS_Comment_Preserver::process($this->_css, array('Minify_CSS_Compressor', 'process'), array($this->_options));
     }
     if (!$this->_options['current_dir'] && !$this->_options['prepend_relative_path']) {
         return $this->_css;
     }
     if ($this->_options['current_dir']) {
         return Minify_CSS_Uri_Rewriter::rewrite($this->_css, $this->_options['current_dir'], $this->_options['doc_root'], $this->_options['symlinks']);
     } else {
         return Minify_CSS_Uri_Rewriter::prepend($this->_css, $this->_options['prepend_relative_path']);
     }
 }
开发者ID:nguyennv,项目名称:kohana-minify,代码行数:20,代码来源:css.php


示例9: execute

 /**
  * Execute preprocessor
  *
  * This will take all CSS files from the source dir, minify each one and 
  * then combine them into one file.
  *
  * @param array $options Options for execution
  * @return void
  */
 public function execute($options = array())
 {
     $cssFiles = FileOps::rglob("*.css", 0, $this->getSourceDir());
     if (empty($cssFiles)) {
         return false;
     }
     FileOps::ensurePathExists($this->getDestinationDir());
     // Just get the basename of the main style sheet, this will be written
     // to the destination dir
     $mainStylesheet = basename($options['main_stylesheet']);
     $mainStylesheet = $this->getDestinationDir() . DIRECTORY_SEPARATOR . $mainStylesheet;
     $buffer = array();
     foreach ($cssFiles as $file) {
         $content = file_get_contents($file);
         $newContent = \Minify_CSS_Compressor::process($content);
         $buffer[] = $newContent;
     }
     if ($buffer) {
         file_put_contents($mainStylesheet, implode("\n", $buffer));
     }
 }
开发者ID:sumpygump,项目名称:holograph,代码行数:30,代码来源:Minify.php


示例10: doExecute

 /**
  * doExecute
  *
  * @return  int
  */
 protected function doExecute()
 {
     $path = $this->getArgument(0);
     $package = $this->getOption('p');
     $folder = $this->console->get('asset.folder', 'asset');
     if ($package = PackageHelper::getPackage($package)) {
         $path = $package->getDir() . '/Resources/asset/' . $path;
     } else {
         $path = WINDWALKER_PUBLIC . '/' . trim($folder, '/') . '/' . $path;
     }
     if (is_file($path)) {
         $files = array(new \SplFileInfo($path));
     } elseif (is_dir($path)) {
         $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::FOLLOW_SYMLINKS));
     } else {
         throw new \InvalidArgumentException('No path');
     }
     /** @var \SplFileInfo $file */
     foreach ($files as $file) {
         $ext = File::getExtension($file->getPathname());
         if (StringHelper::endsWith($file->getBasename(), '.min.' . $ext)) {
             continue;
         }
         if ($ext == 'css') {
             $this->out('[<comment>Compressing</comment>] ' . $file);
             $data = \Minify_CSS_Compressor::process(file_get_contents($file));
             $data = str_replace("\n", ' ', $data);
         } elseif ($ext == 'js') {
             $this->out('[<comment>Compressing</comment>] ' . $file);
             $data = \JSMinPlus::minify(file_get_contents($file));
             $data = str_replace("\n", ';', $data);
         } else {
             continue;
         }
         $newName = $file->getPath() . '/' . File::stripExtension($file->getBasename()) . '.min.' . $ext;
         file_put_contents($newName, $data);
         $this->out('[<info>Compressed</info>] ' . $newName);
     }
 }
开发者ID:ventoviro,项目名称:phoenix,代码行数:44,代码来源:MinifyCommand.php


示例11: minify

 /**
  * @see sfCombineMinifierInterface
  */
 public static function minify($content, array $options = array())
 {
     return Minify_CSS_Compressor::process($content, $options);
 }
开发者ID:limitium,项目名称:uberlov,代码行数:7,代码来源:sfCombineMinifierMinifyCss.class.php


示例12: _minifyCss

 /**
  * Minify CSS
  *
  * @param  string $s CSS string to minify
  * @return string minified CSS string.
  */
 function _minifyCss($s)
 {
     require_once BX_DIRECTORY_PATH_PLUGINS . 'minify/lib/Minify/CSS/Compressor.php';
     return Minify_CSS_Compressor::process($s);
 }
开发者ID:noormcs,项目名称:studoro,代码行数:11,代码来源:BxDolTemplate.php


示例13: getStyles


//.........这里部分代码省略.........
                     $recache = true;
                     break;
                 }
             }
         }
         //end of check
         if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == '1')) {
             $webshopUrl = $registry->get('config')->get('config_ssl');
         } else {
             $webshopUrl = $registry->get('config')->get('config_url');
         }
         $webshopUrl = rtrim(preg_replace('~^https?\\:~i', '', $webshopUrl), '/');
         include_once $oc_root . DS . 'system' . DS . 'nitro' . DS . 'lib' . DS . 'minifier' . DS . 'CSSMin.php';
         foreach ($this->styles as $hash => $style) {
             if (empty($style)) {
                 continue;
             }
             if (!in_array(basename($style['href']), $cssExclude)) {
                 $target = '/assets/style/' . getSSLCachePrefix() . 'nitro-combined-' . $megaHashes[$style['rel'] . $style['media']] . '.css';
                 $targetAbsolutePath = $oc_root . DS . trim(str_replace('/', DS, $target), DS);
                 $filename = $oc_root . DS . trim(str_replace('/', DS, $style['href']), DS);
                 $comboHash = $megaHashes[$style['rel'] . $style['media']];
                 if (empty($combinedStyles[$style['rel'] . $style['media']])) {
                     $combinedStyles[$style['rel'] . $style['media']] = array('rel' => $style['rel'], 'media' => $style['media'], 'content' => '', 'megaHash' => $comboHash);
                 }
                 if ($recache || !file_exists($targetAbsolutePath)) {
                     if (empty($counters[$style['rel'] . $style['media']])) {
                         $counters[$style['rel'] . $style['media']] = 0;
                     }
                     $urlToCurrentDir = $webshopUrl . dirname('/' . trim($style['href'], '/'));
                     /* replace relative urls with absolute ones */
                     $tmpContent = preg_replace('/(url\\()(?![\'\\"]?https?\\:\\/\\/)([\'\\"]?)\\/?/', '$1$2' . $urlToCurrentDir . '/', file_get_contents($filename));
                     //minify
                     $tmpContent = Minify_CSS_Compressor::process($tmpContent);
                     $combinedStyles[$style['rel'] . $style['media']]['content'] .= $tmpContent;
                     unset($tmpContent);
                     $cache[$comboHash][$filename] = filemtime($filename);
                 }
             }
         }
         file_put_contents($cachefile, json_encode($cache));
         foreach ($combinedStyles as $key => $value) {
             $target = '/assets/style/' . getSSLCachePrefix() . 'nitro-combined-' . $megaHashes[$key] . '.css';
             $targetAbsolutePath = $oc_root . DS . trim(str_replace('/', DS, $target), DS);
             if ($recache || !file_exists($targetAbsolutePath)) {
                 file_put_contents($targetAbsolutePath, $value['content']);
             }
             $result[$megaHashes[$key]] = array('rel' => $value['rel'], 'media' => $value['media'], 'href' => trim($target, '/'));
         }
         if ($includedCSS > 0) {
             return array_merge($excludedCSS, $result);
         } else {
             return $excludedCSS;
         }
     } else {
         $cachefile = $oc_root . DS . 'assets' . DS . 'style' . DS . getSSLCachePrefix() . 'styles.cache';
         if (!file_exists($cachefile)) {
             touch($cachefile);
             file_put_contents($cachefile, json_encode(array()));
         }
         $cache = json_decode(file_get_contents($cachefile), true);
         if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == '1')) {
             $webshopUrl = $registry->get('config')->get('config_ssl');
         } else {
             $webshopUrl = $registry->get('config')->get('config_url');
         }
开发者ID:BulatSa,项目名称:Ctex,代码行数:67,代码来源:vq2-system_library_document.php


示例14: process

 /**
  * Process asset content
  *
  * @param   string  $content
  * @return  string
  */
 public static function process($content)
 {
     // Include the processor
     include_once Kohana::find_file('vendor', 'minify_css_compressor/Compressor');
     return Minify_CSS_Compressor::process($content);
 }
开发者ID:boomcms,项目名称:asset-merger,代码行数:12,代码来源:Csscompressor.php


示例15: minifyFile

 /**
  * Minify the given $content according to the file type indicated in $filename
  *
  * @param string $filename
  * @param string $content
  * @return string
  */
 protected function minifyFile($filename, $content)
 {
     // if we have a javascript file and jsmin is enabled, minify the content
     $isJS = stripos($filename, '.js');
     require_once 'thirdparty/jsmin/jsmin.php';
     require_once BASE_PATH . '/minify/code/thirdparty/Compressor.php';
     require_once BASE_PATH . '/minify/code/thirdparty/UriRewriter.php';
     increase_time_limit_to();
     if ($isJS) {
         $content = JSMin::minify($content) . ";\n";
     } else {
         $content = Minify_CSS_UriRewriter::rewrite($content, Director::baseFolder() . "/" . dirname($filename), Director::baseFolder());
         $content = Minify_CSS_Compressor::process($content) . "\n";
     }
     return $content;
 }
开发者ID:andrelohmann,项目名称:silverstripe-minify,代码行数:23,代码来源:Minify_Requirements_Backend.php


示例16: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $asset->setContent(\Minify_CSS_Compressor::process($asset->getContent()));
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:4,代码来源:MinifyCssCompressorFilter.php


示例17: process

 private function process($content, $type, $compress, $file = null)
 {
     switch ($type) {
         case 'css':
             if (!empty($file)) {
                 $content = preg_replace('#url\\((?!\\s*[\'"]?(data\\:image|/|http([s]*)\\:\\/\\/))\\s*([\'"])?#i', "url(\$3{$this->getPath($file)}", $content);
             }
             $content = trim($compress ? Minify_CSS_Compressor::process($content) : $content);
             break;
         case 'js':
             $content = trim($compress ? JSMin::minify($content) : $content, ';') . ';';
             break;
     }
     return $content;
 }
开发者ID:myindexlike,项目名称:MinifyX-for-Evolution,代码行数:15,代码来源:MinifyX.core.php


示例18: process

 /**
  * Minify a CSS string
  *
  * @param string $css
  *
  * @param array $options (currently ignored)
  *
  * @return string
  */
 public static function process($css, $options = array())
 {
     $obj = new Minify_CSS_Compressor($options);
     return $obj->_process($css);
 }
开发者ID:JxLib,项目名称:JxLib,代码行数:14,代码来源:minify_css.php


示例19: styles

 /**
  * merges and minifies the styles
  * @param  array $styles 
  * @param  string $theme  
  * @return string         HTML
  */
 public static function styles($styles, $theme = NULL)
 {
     if ($theme === NULL) {
         $theme = self::$theme;
     }
     $ret = '';
     if (Kohana::$environment == Kohana::DEVELOPMENT or Core::config('config.minify') == FALSE) {
         foreach ($styles as $file => $type) {
             $file = self::public_path($file, $theme);
             $ret .= HTML::style($file, array('media' => $type));
         }
     } else {
         $files = array();
         foreach ($styles as $file => $type) {
             //not external file we need the public link
             if (!Valid::url($file)) {
                 $files[] = $file;
             } else {
                 $ret .= HTML::style($file, array('media' => $type));
             }
         }
         //name for the minify js file
         $css_minified_name = URL::title('minified-' . str_replace('css', '', implode('-', $files))) . '.css';
         //check if file exists.
         $file_name = self::theme_folder($theme) . '/css/' . $css_minified_name;
         //only generate if file doesnt exists or older than 1 week
         if (!file_exists($file_name) or time() > strtotime('+1 week', filemtime($file_name))) {
             $min = '';
             require_once Kohana::find_file('vendor', 'minify/css', 'php');
             //getting the content from files
             foreach ($files as $file) {
                 if (($version = strpos($file, '?')) > 0) {
                     $file = substr($file, 0, $version);
                 }
                 if (file_exists(self::theme_folder($theme) . '/' . $file)) {
                     $min .= file_get_contents(self::theme_folder($theme) . '/' . $file);
                 }
             }
             File::write($file_name, Minify_CSS_Compressor::process($min));
         }
         $ret .= HTML::style(self::public_path('css/' . $css_minified_name, $theme), array('media' => 'screen'));
     }
     return $ret;
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:50,代码来源:theme.php


示例20: optimizecss


//.........这里部分代码省略.........
					}

					$stylesheets = array($url => $stylesheet); // empty - begin a new group
					$selcounts = $selcount;
				} else {

					$stylesheets[$url] = $stylesheet;
					$selcounts += $selcount;
				}

			} else {
				// first get all the stylsheets up to this point, and get them into
				// the items array
				if(count($stylesheets)){
					$cssgroup = array();
					$groupname = array();
					foreach ( $stylesheets as $gurl => $gsheet ) {
						$cssgroup[$gurl] = $gsheet;
						$groupname[] = $gurl;
					}

					$cssgroup['groupname'] = implode('', $groupname);
					$cssgroups[] = $cssgroup;
				}

				//mark ignore current stylesheet
				$cssgroup = array($url => $stylesheet, 'ignore' => true);
				$cssgroups[] = $cssgroup;

				$stylesheets = array(); // empty - begin a new group
			}
		}
		
		if(count($stylesheets)){
			$cssgroup = array();
			$groupname = array();
			foreach ( $stylesheets as $gurl => $gsheet ) {
				$cssgroup[$gurl] = $gsheet;
				$groupname[] = $gurl;
			}

			$cssgroup['groupname'] = implode('', $groupname);
			$cssgroups[] = $cssgroup;
		}
		
		//======================= Group css ================= //

		$output = array();
		foreach ($cssgroups as $cssgroup) {
			if(isset($cssgroup['ignore'])){
				
				unset($cssgroup['ignore']);
				foreach ($cssgroup as $furl => $fsheet) {
					$output[$furl] = $fsheet;
				}

			} else {

				$groupname = 'css-' . substr(md5($cssgroup['groupname']), 0, 5) . '.css';
				$groupfile = $outputpath . '/' . $groupname;
				$grouptime = JFile::exists($groupfile) ? @filemtime($groupfile) : -1;
				$rebuild = $grouptime < 0; //filemtime == -1 => rebuild

				unset($cssgroup['groupname']);
				foreach ($cssgroup as $furl => $fsheet) {
					if(!$rebuild && @filemtime($fsheet['path']) > $grouptime){
						$rebuild = true;
					}
				}

				if($rebuild){

					$cssdata = array();
					foreach ($cssgroup as $furl => $fsheet) {
						$cssdata[] = "\n\n/*===============================";
						$cssdata[] = $furl;
						$cssdata[] = "================================================================================*/";
						
						$cssmin = Minify_CSS_Compressor::process($fsheet['data']);
						$cssmin = T3Path::updateUrl($cssmin, T3Path::relativePath($outputurl, dirname($furl)));

						$cssdata[] = $cssmin;
					}

					$cssdata = implode("\n", $cssdata);
					JFile::write($groupfile, $cssdata);
					@chmod($groupfile, 0644);
				}

				$output[$outputurl . '/' . $groupname] = array(
					'mime' => 'text/css',
					'media' => null,
					'attribs' => array()
					);
			}
		}

		//apply the change make change
		$doc->_styleSheets = $output;
	}
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:101,代码来源:minify.php



注:本文中的Minify_CSS_Compressor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Minify_CSS_UriRewriter类代码示例发布时间:2022-05-23
下一篇:
PHP Minify类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap