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


PHP csstidy::is_token方法代码示例

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


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

示例1: parse

 /**
  * Parses CSS in $string. The code is saved as array in $this->css
  * @param string $string the CSS code
  * @access public
  * @return bool
  * @version 1.1
  */
 function parse($string)
 {
     // Temporarily set locale to en_US in order to handle floats properly
     $old = @setlocale(LC_ALL, 0);
     @setlocale(LC_ALL, 'C');
     // PHP bug? Settings need to be refreshed in PHP4
     $this->print = new csstidy_print($this);
     $this->optimise = new csstidy_optimise($this);
     $all_properties =& $GLOBALS['csstidy']['all_properties'];
     $at_rules =& $GLOBALS['csstidy']['at_rules'];
     $quoted_string_properties =& $GLOBALS['csstidy']['quoted_string_properties'];
     $this->css = array();
     $this->print->input_css = $string;
     $string = str_replace("\r\n", "\n", $string) . ' ';
     $cur_comment = '';
     for ($i = 0, $size = strlen($string); $i < $size; $i++) {
         if ($string[$i] === "\n" || $string[$i] === "\r") {
             ++$this->line;
         }
         switch ($this->status) {
             /* Case in at-block */
             case 'at':
                 if (csstidy::is_token($string, $i)) {
                     if ($string[$i] === '/' && @$string[$i + 1] === '*') {
                         $this->status = 'ic';
                         ++$i;
                         $this->from[] = 'at';
                     } elseif ($string[$i] === '{') {
                         $this->status = 'is';
                         $this->at = $this->css_new_media_section($this->at);
                         $this->_add_token(AT_START, $this->at);
                     } elseif ($string[$i] === ',') {
                         $this->at = trim($this->at) . ',';
                     } elseif ($string[$i] === '\\') {
                         $this->at .= $this->_unicode($string, $i);
                     } elseif (in_array($string[$i], array('(', ')', ':', '.'))) {
                         $this->at .= $string[$i];
                     }
                 } else {
                     $lastpos = strlen($this->at) - 1;
                     if (!((ctype_space($this->at[$lastpos]) || csstidy::is_token($this->at, $lastpos) && $this->at[$lastpos] === ',') && ctype_space($string[$i]))) {
                         $this->at .= $string[$i];
                     }
                 }
                 break;
                 /* Case in-selector */
             /* Case in-selector */
             case 'is':
                 if (csstidy::is_token($string, $i)) {
                     if ($string[$i] === '/' && @$string[$i + 1] === '*' && trim($this->selector) == '') {
                         $this->status = 'ic';
                         ++$i;
                         $this->from[] = 'is';
                     } elseif ($string[$i] === '@' && trim($this->selector) == '') {
                         // Check for at-rule
                         $this->invalid_at = true;
                         foreach ($at_rules as $name => $type) {
                             if (!strcasecmp(substr($string, $i + 1, strlen($name)), $name)) {
                                 $type === 'at' ? $this->at = '@' . $name : ($this->selector = '@' . $name);
                                 if ($type === "atis") {
                                     $this->next_selector_at = $this->next_selector_at ? $this->next_selector_at : ($this->at ? $this->at : DEFAULT_AT);
                                     $this->at = $this->css_new_media_section(' ');
                                     $type = "is";
                                 }
                                 $this->status = $type;
                                 $i += strlen($name);
                                 $this->invalid_at = false;
                             }
                         }
                         if ($this->invalid_at) {
                             $this->selector = '@';
                             $invalid_at_name = '';
                             for ($j = $i + 1; $j < $size; ++$j) {
                                 if (!ctype_alpha($string[$j])) {
                                     break;
                                 }
                                 $invalid_at_name .= $string[$j];
                             }
                             $this->log('Invalid @-rule: ' . $invalid_at_name . ' (removed)', 'Warning');
                         }
                     } elseif ($string[$i] === '"' || $string[$i] === "'") {
                         $this->cur_string[] = $string[$i];
                         $this->status = 'instr';
                         $this->str_char[] = $string[$i];
                         $this->from[] = 'is';
                         /* fixing CSS3 attribute selectors, i.e. a[href$=".mp3" */
                         $this->quoted_string[] = $string[$i - 1] == '=';
                     } elseif ($this->invalid_at && $string[$i] === ';') {
                         $this->invalid_at = false;
                         $this->status = 'is';
                         if ($this->next_selector_at) {
                             $this->at = $this->css_new_media_section($this->next_selector_at);
                             $this->next_selector_at = '';
//.........这里部分代码省略.........
开发者ID:nicolasembleton,项目名称:CSSTidy,代码行数:101,代码来源:class.csstidy.php

示例2: parse

 /**
  * Parses CSS in $string. The code is saved as array in $this->css
  * @param string $string the CSS code
  * @access public
  * @return bool
  * @version 1.1
  */
 function parse($string)
 {
     // PHP bug? Settings need to be refreshed in PHP4
     $this->print = new csstidy_print($this);
     $this->optimise = new csstidy_optimise($this);
     $all_properties =& $GLOBALS['csstidy']['all_properties'];
     $at_rules =& $GLOBALS['csstidy']['at_rules'];
     $this->css = array();
     $this->print->input_css = $string;
     $string = str_replace("\r\n", "\n", $string) . ' ';
     $cur_comment = '';
     for ($i = 0, $size = strlen($string); $i < $size; $i++) {
         if ($string[$i] == "\n" || $string[$i] == "\r") {
             ++$this->line;
         }
         switch ($this->status) {
             /* Case in at-block */
             case 'at':
                 if (csstidy::is_token($string, $i)) {
                     if ($string[$i] == '/' && @$string[$i + 1] == '*') {
                         $this->status = 'ic';
                         ++$i;
                         $this->from = 'at';
                     } elseif ($string[$i] == '{') {
                         $this->status = 'is';
                         $this->_add_token(AT_START, $this->at);
                     } elseif ($string[$i] == ',') {
                         $this->at = trim($this->at) . ',';
                     } elseif ($string[$i] == '\\') {
                         $this->at .= $this->_unicode($string, $i);
                     }
                 } else {
                     $lastpos = strlen($this->at) - 1;
                     if (!((ctype_space($this->at[$lastpos]) || csstidy::is_token($this->at, $lastpos) && $this->at[$lastpos] == ',') && ctype_space($string[$i]))) {
                         $this->at .= $string[$i];
                     }
                 }
                 break;
                 /* Case in-selector */
             /* Case in-selector */
             case 'is':
                 if (csstidy::is_token($string, $i)) {
                     if ($string[$i] == '/' && @$string[$i + 1] == '*' && trim($this->selector) == '') {
                         $this->status = 'ic';
                         ++$i;
                         $this->from = 'is';
                     } elseif ($string[$i] == '@' && trim($this->selector) == '') {
                         // Check for at-rule
                         $this->invalid_at = true;
                         foreach ($at_rules as $name => $type) {
                             if (!strcasecmp(substr($string, $i + 1, strlen($name)), $name)) {
                                 $type == 'at' ? $this->at = '@' . $name : ($this->selector = '@' . $name);
                                 $this->status = $type;
                                 $i += strlen($name);
                                 $this->invalid_at = false;
                             }
                         }
                         if ($this->invalid_at) {
                             $this->selector = '@';
                             $invalid_at_name = '';
                             for ($j = $i + 1; $j < $size; ++$j) {
                                 if (!ctype_alpha($string[$j])) {
                                     break;
                                 }
                                 $invalid_at_name .= $string[$j];
                             }
                             $this->log('Invalid @-rule: ' . $invalid_at_name . ' (removed)', 'Warning');
                         }
                     } elseif ($string[$i] == '"' || $string[$i] == "'") {
                         $this->cur_string = $string[$i];
                         $this->status = 'instr';
                         $this->str_char = $string[$i];
                         $this->from = 'is';
                     } elseif ($this->invalid_at && $string[$i] == ';') {
                         $this->invalid_at = false;
                         $this->status = 'is';
                     } elseif ($string[$i] == '{') {
                         $this->status = 'ip';
                         $this->_add_token(SEL_START, $this->selector);
                         $this->added = false;
                     } elseif ($string[$i] == '}') {
                         $this->_add_token(AT_END, $this->at);
                         $this->at = '';
                         $this->selector = '';
                         $this->sel_separate = array();
                     } elseif ($string[$i] == ',') {
                         $this->selector = trim($this->selector) . ',';
                         $this->sel_separate[] = strlen($this->selector);
                     } elseif ($string[$i] == '\\') {
                         $this->selector .= $this->_unicode($string, $i);
                     } else {
                         if (!($string[$i] == '*' && @in_array($string[$i + 1], array('.', '#', '[', ':')))) {
                             $this->selector .= $string[$i];
//.........这里部分代码省略.........
开发者ID:robertsonmello,项目名称:projetos,代码行数:101,代码来源:class.csstidy.php

示例3: parse

 /**
  * Parses CSS in $string. The code is saved as array in $this->css
  * @param string $string the CSS code
  * @access public
  * @return bool
  * @version 1.1
  */
 function parse($string)
 {
     // Temporarily set locale to en_US in order to handle floats properly
     $old = @setlocale(LC_ALL, 0);
     @setlocale(LC_ALL, 'C');
     // PHP bug? Settings need to be refreshed in PHP4
     $this->print = new csstidy_print($this);
     $this->optimise = new csstidy_optimise($this);
     $all_properties =& $GLOBALS['csstidy']['all_properties'];
     $at_rules =& $GLOBALS['csstidy']['at_rules'];
     $this->css = array();
     $this->print->input_css = $string;
     $string = str_replace("\r\n", "\n", $string) . ' ';
     $cur_comment = '';
     for ($i = 0, $size = strlen($string); $i < $size; $i++) {
         if ($string[$i] === "\n" || $string[$i] === "\r") {
             ++$this->line;
         }
         switch ($this->status) {
             /* Case in at-block */
             case 'at':
                 if (csstidy::is_token($string, $i)) {
                     if ($string[$i] === '/' && @$string[$i + 1] === '*') {
                         $this->status = 'ic';
                         ++$i;
                         $this->from = 'at';
                     } elseif ($string[$i] === '{') {
                         $this->status = 'is';
                         $this->at = $this->css_new_media_section($this->at);
                         $this->_add_token(AT_START, $this->at);
                     } elseif ($string[$i] === ',') {
                         $this->at = trim($this->at) . ',';
                     } elseif ($string[$i] === '\\') {
                         $this->at .= $this->_unicode($string, $i);
                     } elseif (in_array($string[$i], array('(', ')', ':'))) {
                         $this->at .= $string[$i];
                     }
                 } else {
                     $lastpos = strlen($this->at) - 1;
                     if (!((ctype_space($this->at[$lastpos]) || csstidy::is_token($this->at, $lastpos) && $this->at[$lastpos] === ',') && ctype_space($string[$i]))) {
                         $this->at .= $string[$i];
                     }
                 }
                 break;
                 /* Case in-selector */
             /* Case in-selector */
             case 'is':
                 if (csstidy::is_token($string, $i)) {
                     if ($string[$i] === '/' && @$string[$i + 1] === '*' && trim($this->selector) == '') {
                         $this->status = 'ic';
                         ++$i;
                         $this->from = 'is';
                     } elseif ($string[$i] === '@' && trim($this->selector) == '') {
                         // Check for at-rule
                         $this->invalid_at = true;
                         foreach ($at_rules as $name => $type) {
                             if (!strcasecmp(substr($string, $i + 1, strlen($name)), $name)) {
                                 $type === 'at' ? $this->at = '@' . $name : ($this->selector = '@' . $name);
                                 $this->status = $type;
                                 $i += strlen($name);
                                 $this->invalid_at = false;
                             }
                         }
                         if ($this->invalid_at) {
                             $this->selector = '@';
                             $invalid_at_name = '';
                             for ($j = $i + 1; $j < $size; ++$j) {
                                 if (!ctype_alpha($string[$j])) {
                                     break;
                                 }
                                 $invalid_at_name .= $string[$j];
                             }
                             $this->log('Invalid @-rule: ' . $invalid_at_name . ' (removed)', 'Warning');
                         }
                     } elseif ($string[$i] === '"' || $string[$i] === "'") {
                         $this->cur_string = $string[$i];
                         $this->status = 'instr';
                         $this->str_char = $string[$i];
                         $this->from = 'is';
                         /* fixing CSS3 attribute selectors, i.e. a[href$=".mp3" */
                         $this->quoted_string = $string[$i - 1] == '=';
                     } elseif ($this->invalid_at && $string[$i] === ';') {
                         $this->invalid_at = false;
                         $this->status = 'is';
                     } elseif ($string[$i] === '{') {
                         $this->status = 'ip';
                         if ($this->at == '') {
                             $this->at = $this->css_new_media_section(DEFAULT_AT);
                         }
                         $this->selector = $this->css_new_selector($this->at, $this->selector);
                         $this->_add_token(SEL_START, $this->selector);
                         $this->added = false;
                     } elseif ($string[$i] === '}') {
//.........这里部分代码省略.........
开发者ID:lunavod,项目名称:bunker_stable,代码行数:101,代码来源:class.csstidy.php


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