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


PHP csstidy::parse方法代码示例

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


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

示例1: 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

示例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: 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

示例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: csstidy

 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: post_format

 /**
  * @access public
  * @param $source
  * @return string
  */
 public function post_format($source, $scaffold)
 {
     $css = new csstidy();
     $css->set_cfg('case_properties', false);
     $css->set_cfg('lowercase_s', true);
     $css->set_cfg('compress_colors', false);
     $css->set_cfg('compress_font-weight', false);
     $css->set_cfg('merge_selectors', true);
     $css->set_cfg('optimise_shorthands', true);
     $css->set_cfg('remove_bslash', false);
     $css->set_cfg('preserve_css', true);
     $css->set_cfg('sort_selectors', true);
     $css->set_cfg('sort_properties', true);
     $css->set_cfg('remove_last_;', true);
     $css->set_cfg('discard_invalid_properties', true);
     $css->set_cfg('css_level', '2.1');
     $css->set_cfg('timestamp', false);
     $css->load_template('highest_compression');
     $result = $css->parse($source->contents);
     $output = $css->print->plain();
     $source->contents = $output;
 }
开发者ID:BaylorRae,项目名称:Borealis-MVC-bk,代码行数:27,代码来源:CSSTidy.php

示例11: firmasite_sanitize_customcss

function firmasite_sanitize_customcss($css)
{
    // Sadly we cant include csstidy. WordPress Theme Directory's automatic code checking system is not accepting it.
    // You have 2 option for including css checker: install jetpack and activate custom css or copy csstidy's folder to theme's functions folder from jetpack's plugin
    firmasite_safecss_class();
    if (class_exists('safecss') || class_exists('firmasite_safecss')) {
        $csstidy = new csstidy();
        if (class_exists('firmasite_safecss')) {
            $csstidy->optimise = new firmasite_safecss($csstidy);
        } else {
            $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('optimise_shorthands', 0);
        $csstidy->set_cfg('remove_last_;', false);
        $csstidy->set_cfg('case_properties', false);
        $csstidy->set_cfg('discard_invalid_properties', true);
        $csstidy->set_cfg('css_level', 'CSS3.0');
        $csstidy->set_cfg('preserve_css', true);
        $csstidy->set_cfg('template', dirname(__FILE__) . '/csstidy/wordpress-standard.tpl');
        $css = stripslashes($css);
        // Some people put weird stuff in their CSS, KSES tends to be greedy
        $css = str_replace('<=', '&lt;=', $css);
        // Why KSES instead of strip_tags?  Who knows?
        $css = wp_kses_split($prev = $css, array(), array());
        $css = str_replace('&gt;', '>', $css);
        // kses replaces lone '>' with &gt;
        // Why both KSES and strip_tags?  Because we just added some '>'.
        $css = strip_tags($css);
        $csstidy->parse($css);
        $safe_css = $csstidy->print->plain();
    } else {
        $safe_css = $css;
    }
    return $safe_css;
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:38,代码来源:custom-custom-css.php

示例12: validate

 /**
  * Field Render Function.
  * Takes the vars and validates them
  *
  * @since ReduxFramework 3.0.0
  */
 function validate()
 {
     require_once dirname(__FILE__) . '/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('optimise_shorthands', 0);
     $csstidy->set_cfg('remove_last_;', false);
     $csstidy->set_cfg('case_properties', false);
     $csstidy->set_cfg('discard_invalid_properties', true);
     $csstidy->set_cfg('css_level', 'CSS3.0');
     $csstidy->set_cfg('preserve_css', true);
     $csstidy->set_cfg('template', dirname(__FILE__) . '/csstidy/wordpress-standard.tpl');
     $css = $orig = $this->value;
     $css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev = $css);
     if ($css != $prev) {
         $this->warning = true;
     }
     // Some people put weird stuff in their CSS, KSES tends to be greedy
     $css = str_replace('<=', '&lt;=', $css);
     // Why KSES instead of strip_tags?  Who knows?
     $css = wp_kses_split($prev = $css, array(), array());
     $css = str_replace('&gt;', '>', $css);
     // kses replaces lone '>' with &gt;
     // Why both KSES and strip_tags?  Because we just added some '>'.
     $css = strip_tags($css);
     if ($css != $prev) {
         $this->warning = true;
     }
     $csstidy->parse($css);
     $this->value = $csstidy->print->plain();
     if (isset($this->warning) && $this->warning) {
         $this->warning = __('Unsafe strings were found in your CSS and have been filtered out.', 'redux-framework');
     }
 }
开发者ID:justinwool,项目名称:vortago,代码行数:42,代码来源:validation_css.php

示例13: 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->print) {
         $this->actual = $css->print->plain($this->default_media);
     } else {
         $this->actual = $css->css;
     }
     return $this->expect === $this->actual;
 }
开发者ID:nicolasembleton,项目名称:CSSTidy,代码行数:19,代码来源:class.csstidy_csst.php

示例14: csstidy

 /**
  * 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

示例15: CompressCss

 /**
  * Выполняет преобразование CSS файлов
  *
  * @param  string $sContent
  * @return string 
  */
 protected function CompressCss($sContent)
 {
     $this->InitCssCompressor();
     if (!$this->oCssCompressor) {
         return $sContent;
     }
     /**
      * Парсим css и отдаем обработанный результат
      */
     $this->oCssCompressor->parse($sContent);
     return $this->oCssCompressor->print->plain();
 }
开发者ID:randomtoy,项目名称:livestreet,代码行数:18,代码来源:Viewer.class.php


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