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

PHP csstidy类代码示例

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

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



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

示例1: parseCSS

 public function parseCSS($text)
 {
     $css = new \csstidy();
     $css->parse($text);
     $rules = array();
     $position = 0;
     foreach ($css->css as $declarations) {
         foreach ($declarations as $selectors => $properties) {
             foreach (explode(",", $selectors) as $selector) {
                 $rules[] = array('position' => $position, 'specificity' => self::calculateCSSSpecifity($selector), 'selector' => $selector, 'properties' => $properties);
             }
             $position += 1;
         }
     }
     usort($rules, function ($a, $b) {
         if ($a['specificity'] > $b['specificity']) {
             return 1;
         } else {
             if ($a['specificity'] < $b['specificity']) {
                 return -1;
             } else {
                 if ($a['position'] > $b['position']) {
                     return 1;
                 } else {
                     return -1;
                 }
             }
         }
     });
     return $rules;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:31,代码来源:CSSIN.php


示例2: minify_css

/**
 * 压缩css文件
 * 
 * @param mixed $sourceFile
 * @param mixed $targetFile
 * @return void
 */
function minify_css($sourceFile, $targetFile)
{
    $css = new csstidy();
    $css->load_template('highest_compression');
    /*	$css->set_cfg('remove_bslash',false);
    		$css->set_cfg('compress_colors',false);
    		$css->set_cfg('compress_font-weight',false);
    		$css->set_cfg('lowercase_s',true);
    		$css->set_cfg('optimise_shorthands',$_REQUEST['optimise_shorthands']);
    		$css->set_cfg('remove_last_;',true);
    		$css->set_cfg('case_properties',$_REQUEST['case_properties']);
    		$css->set_cfg('sort_properties',true);
    		$css->set_cfg('sort_selectors',true);
    		$css->set_cfg('merge_selectors', $_REQUEST['merge_selectors']);
    		$css->set_cfg('discard_invalid_properties',true);
    		$css->set_cfg('preserve_css',true);
    		$css->set_cfg('timestamp',true);
    		*/
    $strSourceCSS = file_get_contents($sourceFile);
    $strResult = $css->parse($strSourceCSS);
    $handle = fopen($targetFile, 'w');
    if ($handle) {
        if (fwrite($handle, $css->print->plain())) {
            $file_ok = true;
        }
    }
    fclose($handle);
}
开发者ID:BGCX067,项目名称:f2epacker-svn-to-git,代码行数:35,代码来源:minify.php


示例3: minify

 public static function minify($css, $options = array())
 {
     $options = array_merge(array('remove_bslash' => true, 'compress_colors' => true, 'compress_font-weight' => true, 'lowercase_s' => false, 'optimise_shorthands' => 1, 'remove_last_;' => false, 'case_properties' => 1, 'sort_properties' => false, 'sort_selectors' => false, 'merge_selectors' => 2, 'discard_invalid_properties' => false, 'css_level' => 'CSS2.1', 'preserve_css' => false, 'timestamp' => false, 'template' => 'default'), $options);
     set_include_path(get_include_path() . PATH_SEPARATOR . W3TC_LIB_CSSTIDY_DIR);
     require_once 'class.csstidy.php';
     $csstidy = new csstidy();
     foreach ($options as $option => $value) {
         $csstidy->set_cfg($option, $value);
     }
     $csstidy->load_template($options['template']);
     $csstidy->parse($css);
     $css = $csstidy->print->plain();
     if (isset($options['currentDir']) || isset($options['prependRelativePath'])) {
         require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/UriRewriter.php';
         $browsercache_id = isset($options['browserCacheId']) ? $options['browserCacheId'] : 0;
         $browsercache_extensions = isset($options['browserCacheExtensions']) ? $options['browserCacheExtensions'] : array();
         if (isset($options['currentDir'])) {
             $document_root = isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT'];
             $symlinks = isset($options['symlinks']) ? $options['symlinks'] : array();
             return Minify_CSS_UriRewriter::rewrite($css, $options['currentDir'], $document_root, $symlinks, $browsercache_id, $browsercache_extensions);
         } else {
             return Minify_CSS_UriRewriter::prepend($css, $options['prependRelativePath'], $browsercache_id, $browsercache_extensions);
         }
     }
     return $css;
 }
开发者ID:niko-lgdcom,项目名称:archives,代码行数:26,代码来源:CSSTidy.php


示例4: compress

 function compress($Media)
 {
     $Tidy = new csstidy();
     $Tidy->load_template($this->_template);
     $Tidy->parse($Media->contents['raw']);
     if ($compressed = $Tidy->print->plain()) {
         $Media->content['raw'] = $compressed;
         return true;
     }
     return false;
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:11,代码来源:css_tidy.php


示例5: minifyCss

 public static function minifyCss($path)
 {
     require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
     $css = new \csstidy();
     $css->set_cfg('allow_html_in_templates', false);
     $css->set_cfg('compress_colors', true);
     $css->set_cfg('compress_font-weight', true);
     $css->set_cfg('remove_last_', true);
     $css->set_cfg('remove_bslash', true);
     $css->set_cfg('template', 'highest');
     $css->set_cfg('preserve_css', true);
     $css->set_cfg('silent', true);
     $css->parse(file_get_contents($path));
     return $css->print->plain();
 }
开发者ID:RoxasShadow,项目名称:nerdz.eu,代码行数:15,代码来源:minification.class.php


示例6: minify

 public static function minify($css, $options = array())
 {
     $options = array_merge(array('remove_bslash' => true, 'compress_colors' => true, 'compress_font-weight' => true, 'lowercase_s' => false, 'optimise_shorthands' => 1, 'remove_last_;' => false, 'case_properties' => 1, 'sort_properties' => false, 'sort_selectors' => false, 'merge_selectors' => 2, 'discard_invalid_properties' => false, 'css_level' => 'CSS2.1', 'preserve_css' => false, 'timestamp' => false, 'template' => 'default'), $options);
     set_include_path(get_include_path() . PATH_SEPARATOR . W3TC_LIB_DIR . '/CSSTidy');
     require_once 'class.csstidy.php';
     $csstidy = new csstidy();
     foreach ($options as $option => $value) {
         $csstidy->set_cfg($option, $value);
     }
     $csstidy->load_template($options['template']);
     $csstidy->parse($css);
     $css = $csstidy->print->plain();
     $css = Minify_CSS_UriRewriter::rewrite($css, $options);
     return $css;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:15,代码来源:CSSTidy.php


示例7: test

 /**
  * Implements SimpleExpectation::test().
  * @param $filename Filename of test file to test.
  */
 function test($filename = false)
 {
     if ($filename) {
         $this->load($filename);
     }
     $css = new csstidy();
     $css->set_cfg($this->settings);
     $css->parse($this->css);
     if ($this->fullexpect) {
         $this->actual = var_export($css->css, true);
     } elseif (isset($css->css[41])) {
         $this->actual = var_export($css->css[41], true);
     } else {
         $this->actual = 'Key 41 does not exist';
     }
     return $this->expect === $this->actual;
 }
开发者ID:GerHobbelt,项目名称:CompactCMS,代码行数:21,代码来源:class.csstidy_csst.php


示例8: sanitize_css

 public static function sanitize_css($css)
 {
     if (!class_exists('csstidy')) {
         require_once 'class.csstidy.php';
     }
     $csstidy = new csstidy();
     $csstidy->set_cfg('remove_bslash', FALSE);
     $csstidy->set_cfg('compress_colors', FALSE);
     $csstidy->set_cfg('compress_font-weight', FALSE);
     $csstidy->set_cfg('discard_invalid_properties', TRUE);
     $csstidy->set_cfg('merge_selectors', FALSE);
     $csstidy->set_cfg('remove_last_;', FALSE);
     $csstidy->set_cfg('css_level', 'CSS3.0');
     $csstovalidateindiv = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css);
     $csstovalidateindiv = wp_kses_split($csstovalidateindiv, array(), array());
     $csstidy->parse($csstovalidateindiv);
     $cssvalidated = $csstidy->print->plain();
     return $cssvalidated;
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:19,代码来源:class.csstidy_sanitize_wp.php


示例9: pixopoint_validate_css

 function pixopoint_validate_css($css)
 {
     // SafeCSS / CSSTidy stuff
     require_once 'csstidy.php';
     // CSS sanitising gizmo
     $csstidy = new csstidy();
     $csstidy->optimise = new safecss($csstidy);
     $csstidy->set_cfg('remove_bslash', false);
     $csstidy->set_cfg('compress_colors', false);
     $csstidy->set_cfg('compress_font-weight', false);
     $csstidy->set_cfg('discard_invalid_properties', true);
     $csstidy->set_cfg('merge_selectors', false);
     $csstidy->set_cfg('preserve_css', true);
     // Outputs code comments
     // $csstidy->set_cfg( 'lowercase_s', false );
     // $csstidy->set_cfg( 'optimise_shorthands', 1 );
     // $csstidy->set_cfg( 'remove_last_;', false );
     // $csstidy->set_cfg( 'case_properties', 1 );
     // $csstidy->set_cfg( 'sort_properties', false );
     // $csstidy->set_cfg( 'sort_selectors', false );
     // Santisation stuff copied from SafeCSS by Automattic
     $css = stripslashes($css);
     $css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev = $css);
     $css = str_replace('<=', '&lt;=', $css);
     // Some people put weird stuff in their CSS, KSES tends to be greedy
     $css = wp_kses_split($prev = $css, array(), array());
     // Why KSES instead of strip_tags?  Who knows?
     $css = str_replace('&gt;', '>', $css);
     // kses replaces lone '>' with &gt;
     $css = strip_tags($css);
     // Why both KSES and strip_tags?  Because we just added some '>'.
     // Parse with CSS tidy
     $csstidy->parse($css);
     // Parse with CSS Tidy
     $css = $csstidy->print->plain();
     // Grab CSS output
     // Make CSS look pretty
     $css = pixopoint_pretty_css($css);
     return $css;
 }
开发者ID:pemiu01,项目名称:wppaintbrush,代码行数:40,代码来源:csstidy.php


示例10: gvw_important

 /**
  * Returns a value without !important
  * @param string $value
  * @return string
  * @access public
  * @version 1.0
  */
 static function gvw_important($value)
 {
     if (csstidy::is_important($value)) {
         $value = trim($value);
         $value = substr($value, 0, -9);
         $value = trim($value);
         $value = substr($value, 0, -1);
         $value = trim($value);
         return $value;
     }
     return $value;
 }
开发者ID:nicolasembleton,项目名称:CSSTidy,代码行数:19,代码来源:class.csstidy.php


示例11: escaped

 /**
  * Checks if a character is escaped (and returns true if it is)
  * @param string $string
  * @param integer $pos
  * @access public
  * @return bool
  * @version 1.02
  */
 static function escaped(&$string, $pos)
 {
     return !(@($string[$pos - 1] !== '\\') || csstidy::escaped($string, $pos - 1));
 }
开发者ID:cbrspc,项目名称:LIVESTREET-1-DISTRIB,代码行数:12,代码来源:class.csstidy.php


示例12: sanitize_css

 /**
  * sanitize user entered css
  * as seen here: http://wordpress.stackexchange.com/questions/53970/sanitize-user-entered-css
  *
  * @param type $css
  */
 function sanitize_css($css)
 {
     if (!class_exists('csstidy')) {
         include_once 'csstidy/class.csstidy.php';
     }
     $csstidy = new csstidy();
     $csstidy->set_cfg('remove_bslash', false);
     $csstidy->set_cfg('compress_colors', false);
     $csstidy->set_cfg('compress_font-weight', false);
     $csstidy->set_cfg('discard_invalid_properties', true);
     $csstidy->set_cfg('merge_selectors', false);
     $csstidy->set_cfg('remove_last_;', false);
     $csstidy->set_cfg('css_level', 'CSS3.0');
     $css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css);
     $css = wp_kses_split($css, array(), array());
     $csstidy->parse($css);
     return $csstidy->print->plain();
 }
开发者ID:bigkey,项目名称:php-getting-started,代码行数:24,代码来源:bm-custom-login.php


示例13: file_get_contents

//die();
// Get scripts from servlet
$json = file_get_contents($getScripts);
$scripts = json_decode($json, true);
//print_r($scripts);
//$css_core = array();
$core_files = array();
$errors = array();
$warnings = array();
$completed = array();
$script_hash = array();
$script_size = array();
$full_script_size = array();
// Load, concat and minify css
foreach ($scripts['css'] as $core_name => $core_group) {
    $cssTidy = new csstidy();
    $cssTidy->load_template('highest_compression');
    $cssTidy->settings['merge_selectors'] = 2;
    $core_files[$core_name] = "";
    $script_hash[$core_name] = getFileHash($pathToCore . "/{$core_name}");
    $script_size[$core_name] = getFileSize($pathToCore . "/{$core_name}");
    $full_script_size[$core_name] = 0;
    foreach ($core_group as $script) {
        $filePath = $pathToRoot . $script;
        if (file_exists($filePath)) {
            /*
            $core_files[$core_name] .= Minify_CSS::minify(file_get_contents($filePath), array(
                'currentDir' => dirname($filePath)
                ));
            */
            //echo "Proccessing: $filePath<br />\n";
开发者ID:uksubs66,项目名称:java-v2,代码行数:31,代码来源:index.php


示例14: __process

 function __process($type, $assets)
 {
     $path = $this->__getPath($type);
     $folder = new Folder($this->paths['wwwRoot'] . $this->cachePaths[$type], true);
     //check if the cached file exists
     $scripts = Set::extract('/script', $assets);
     $fileName = $folder->find($this->__generateFileName($scripts) . '_([0-9]{10}).' . $type);
     if ($fileName) {
         //take the first file...really should only be one.
         $fileName = $fileName[0];
     }
     //make sure all the pieces that went into the packed script
     //are OLDER then the packed version
     if ($this->checkTs && $fileName) {
         $packed_ts = filemtime($this->paths['wwwRoot'] . $this->cachePaths[$type] . DS . $fileName);
         $latest_ts = 0;
         foreach ($assets as $asset) {
             $assetFile = $this->__findFile($asset, $type);
             if (!$assetFile) {
                 continue;
             }
             $latest_ts = max($latest_ts, filemtime($assetFile));
         }
         //an original file is newer. need to rebuild
         if ($latest_ts > $packed_ts) {
             unlink($this->paths['wwwRoot'] . $this->cachePaths[$type] . DS . $fileName);
             $fileName = null;
         }
     }
     //file doesn't exist. create it.
     if (!$fileName) {
         $ts = time();
         switch ($type) {
             case 'js':
                 if (PHP5) {
                     App::import('Vendor', 'jsmin/jsmin');
                 }
                 break;
             case 'css':
                 App::import('Vendor', 'csstidy', array('file' => 'class.csstidy.php'));
                 $tidy = new csstidy();
                 $tidy->load_template($this->cssCompression);
                 break;
         }
         //merge the script
         $scriptBuffer = '';
         foreach ($assets as $asset) {
             $buffer = $this->__getFileContents($asset, $type);
             $origSize = strlen($buffer);
             switch ($type) {
                 case 'js':
                     //jsmin only works with PHP5
                     if (PHP5) {
                         $buffer = trim(JSMin::minify($buffer));
                     }
                     break;
                 case 'css':
                     $tidy->parse($buffer);
                     $buffer = $tidy->print->plain();
                     break;
             }
             $delta = 0;
             if ($origSize > 0) {
                 $delta = strlen($buffer) / $origSize * 100;
             }
             $scriptBuffer .= sprintf("/* %s.%s (%d%%) */\n", $asset['script'], $type, $delta);
             $scriptBuffer .= $buffer . "\n\n";
         }
         //write the file
         $fileName = $this->__generateFileName($scripts) . '_' . $ts . '.' . $type;
         $file = new File($this->paths['wwwRoot'] . $this->cachePaths[$type] . DS . $fileName);
         $file->write(trim($scriptBuffer));
     }
     if ($type == 'css') {
         //$html->css doesn't check if the file already has
         //the .css extension and adds it automatically, so we need to remove it.
         $fileName = str_replace('.css', '', $fileName);
     }
     return $fileName;
 }
开发者ID:risnandar,项目名称:testing,代码行数:80,代码来源:asset.php


示例15: gvw_important

 /**
  * Returns a value without !important
  * @param string $value
  * @return string
  * @access public
  * @version 1.0
  */
 function gvw_important($value)
 {
     // Apenas para evitar o erro por passar a referencia do objeto diretamente a função
     // Maikon.Will - 21/06/2012
     $value0 = $value;
     if (csstidy::is_important($value0)) {
         $value = trim($value);
         $value = substr($value, 0, -9);
         $value = trim($value);
         $value = substr($value, 0, -1);
         $value = trim($value);
         return $value;
     }
     return $value;
 }
开发者ID:robertsonmello,项目名称:projetos,代码行数:22,代码来源:class.csstidy.php


示例16: get_css_html

 private function get_css_html($cachefile)
 {
     if (Configure::read('debug') > 0) {
         $ret = "";
         foreach ($this->libs['css'] as $lib) {
             $ret .= $this->Html->css($lib);
         }
         return $ret;
     }
     if (file_exists($this->cachePath['css'] . '/' . $cachefile)) {
         return $this->Html->css($cachefile);
     }
     // Get the content
     $file_content = '';
     foreach ($this->libs['css'] as $lib) {
         $file_content .= "\n\n" . file_get_contents($this->basePath['css'] . '/' . $lib);
     }
     // Get inline code if exist
     if (!empty($this->inline_code['css'])) {
         foreach ($this->inline_code['css'] as $inlineCss) {
             $file_content .= "\n\n" . $inlineCss;
         }
     }
     // If compression is enable, compress it !
     if ($this->__options['css']['enableCompression']) {
         App::import('Vendor', 'csstidy', array('file' => 'class.csstidy.php'));
         $tidy = new csstidy();
         $tidy->load_template($this->__options['css']['compression']);
         $tidy->set_cfg('sort_selectors', FALSE);
         $tidy->set_cfg('sort_properties', FALSE);
         $tidy->parse($file_content);
         $file_content = $tidy->print->plain();
     }
     if ($fp = fopen($this->cachePath['css'] . '/' . $cachefile, 'wb')) {
         fwrite($fp, $file_content);
         fclose($fp);
     }
     return $this->Html->css($cachefile);
 }
开发者ID:acerato,项目名称:cntcetp,代码行数:39,代码来源:combinator.php


示例17: merge_font

 /**
  * Merges all fonts properties
  * @param array $input_css
  * @return array
  * @version 1.3
  * @see dissolve_short_font()
  */
 function merge_font($input_css)
 {
     $font_prop_default =& $GLOBALS['csstidy']['font_prop_default'];
     $new_font_value = '';
     $important = '';
     // Skip if not font-family and font-size set
     if (isset($input_css['font-family']) && isset($input_css['font-size'])) {
         foreach ($font_prop_default as $font_property => $default_value) {
             // Skip if property does not exist
             if (!isset($input_css[$font_property])) {
                 continue;
             }
             $cur_value = $input_css[$font_property];
             // Skip if default value is used
             if ($cur_value === $default_value) {
                 continue;
             }
             // Remove !important
             if (csstidy::is_important($cur_value)) {
                 $important = '!important';
                 $cur_value = csstidy::gvw_important($cur_value);
             }
             $new_font_value .= $cur_value;
             // Add delimiter
             $new_font_value .= $font_property === 'font-size' && isset($input_css['line-height']) ? '/' : ' ';
         }
         $new_font_value = trim($new_font_value);
         // Delete all font-properties
         foreach ($font_prop_default as $font_property => $default_value) {
             unset($input_css[$font_property]);
         }
         // Add new font property
         if ($new_font_value !== '') {
             $input_css['font'] = $new_font_value . $important;
         }
     }
     return $input_css;
 }
开发者ID:harrylongworth,项目名称:tv-bb,代码行数:45,代码来源:class.csstidy_optimise.php


示例18: filter_attr

 static function filter_attr($css, $element = 'div')
 {
     safecss_class();
     $css = $element . ' {' . $css . '}';
     $csstidy = new csstidy();
     $csstidy->optimise = new safecss($csstidy);
     $csstidy->set_cfg('remove_bslash', false);
     $csstidy->set_cfg('compress_colors', false);
     $csstidy->set_cfg('compress_font-weight', false);
     $csstidy->set_cfg('discard_invalid_properties', true);
     $csstidy->set_cfg('merge_selectors', false);
     $csstidy->set_cfg('remove_last_;', false);
     $csstidy->set_cfg('css_level', 'CSS3.0');
     $css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css);
     $css = wp_kses_split($css, array(), array());
     $csstidy->parse($css);
     $css = $csstidy->print->plain();
     $css = str_replace(array("\n", "\r", "\t"), '', $css);
     preg_match("/^{$element}\\s*{(.*)}\\s*\$/", $css, $matches);
     if (empty($matches[1])) {
         return '';
     }
     return $matches[1];
 }
开发者ID:pcuervo,项目名称:wp-carnival,代码行数:24,代码来源:custom-css.php


示例19: pfcResponse

 function &loadStyles($theme = 'default', &$xml_reponse)
 {
     if ($xml_reponse == null) {
         $xml_reponse =& new pfcResponse();
     }
     $c =& pfcGlobalConfig::Instance();
     // do not overload the theme parameter as long as
     // the ajax request do not give the correct one
     //    $c->theme = $theme;
     $u =& pfcUserConfig::Instance();
     $js = '';
     //file_get_contents(dirname(__FILE__).'/client/createstylerule.js');
     $js .= 'var c = $H();';
     $path = $c->getFilePathFromTheme('style.css.php');
     require_once dirname(__FILE__) . '/../lib/ctype/ctype.php';
     // to keep compatibility for php without ctype support
     require_once dirname(__FILE__) . '/../lib/csstidy-1.2/class.csstidy.php';
     $css = new csstidy();
     $css->set_cfg('preserve_css', false);
     $css_code = '';
     $t = new pfcTemplate();
     $t->assignObject($u, "u");
     $t->assignObject($c, "c");
     if (!$c->isDefaultFile('style.css.php')) {
         $t->setTemplate($c->theme_default_path . '/default/style.css.php');
         $css_code .= $t->getOutput();
     }
     $t->setTemplate($c->getFilePathFromTheme('style.css.php'));
     $css_code .= $t->getOutput();
     $css->parse($css_code);
     foreach ($css->css as $k => $v) {
         foreach ($v as $k2 => $v2) {
             $rules = '';
             foreach ($v2 as $k3 => $v3) {
                 $rules .= $k3 . ':' . $v3 . ';';
             }
             $js .= "c['" . $k2 . "']='" . str_replace("\n", "", $rules) . "';\n";
         }
     }
     $js .= "var pfccss = new pfcCSS(); var k = c.keys(); c.each(function (a) { pfccss.applyRule(a[0],a[1]); });";
     $xml_reponse->script($js);
     return $xml_reponse;
 }
开发者ID:codethics,项目名称:proteoerp,代码行数:43,代码来源:phpfreechat.class.php


示例20: checkSession

require_once '../../common.php';
require_once 'CSSTidy/class.csstidy.php';
checkSession();
error_reporting(0);
switch ($_GET['action']) {
    /**
     * Compress a css file.
     *
     * @param {string} path The path of the file to compress
     * @param {string} advanced Either advanced or standard_compression
     */
    case 'compressCSS':
        if (isset($_GET['path']) && isset($_POST['advanced'])) {
            $path = getWorkspacePath($_GET['path']);
            $css_code = file_get_contents($path);
            $css = new csstidy();
            $css->parse($css_code);
            if ($_POST['compression'] != "standard_compression") {
                $css->load_template($_POST['compression']);
            }
            if ($_POST['advanced']) {
                $css->set_cfg('compress_colors', $_POST['color']);
                $css->set_cfg('compress_font-weight', $_POST['fontw']);
                $css->set_cfg('remove_last_;', $_POST['bslash']);
                $css->set_cfg('remove_bslash', $_POST['last']);
            }
            $code = $css->print->plain();
            $nFile = substr($path, 0, strrpos($path, ".css"));
            $nFile = $nFile . ".min.css";
            file_put_contents($nFile, $code);
            echo '{"status":"success","message":"CSS tidied!"}';
开发者ID:Ultim4T0m,项目名称:Codiad-Compress,代码行数:31,代码来源:controller.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP csv_export_writer类代码示例发布时间:2022-05-23
下一篇:
PHP cssJSToolbox类代码示例发布时间: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