当前位置: 首页>>代码示例>>PHP>>正文


PHP Minify_CSS_Compressor类代码示例

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


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


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