cvs: pear /HTML_CSS CSS.php

From: Date: Sun, 13 Jan 2008 16:01:01 +0000
Subject: cvs: pear /HTML_CSS CSS.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-50266@lists.php.net to get a copy of this message
farell Sun Jan 13 16:01:01 2008 UTC Modified files: /pear/HTML_CSS CSS.php Log: code optimization + parseString() run fine for both at-rules, simple declarations, and allow dupplicates http://cvs.php.net/viewvc.cgi/pear/HTML_CSS/CSS.php?r1=1.73&r2=1.74&diff_format=u Index: pear/HTML_CSS/CSS.php diff -u pear/HTML_CSS/CSS.php:1.73 pear/HTML_CSS/CSS.php:1.74 --- pear/HTML_CSS/CSS.php:1.73 Sat Jan 12 18:04:20 2008 +++ pear/HTML_CSS/CSS.php Sun Jan 13 16:01:01 2008 @@ -38,7 +38,7 @@ * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2003-2008 Klaus Guenther, Laurent Laville * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: CSS.php,v 1.73 2008/01/12 18:04:20 farell Exp $ + * @version CVS: $Id: CSS.php,v 1.74 2008/01/13 16:01:01 farell Exp $ * @link http://pear.php.net/package/HTML_CSS * @since File available since Release 0.2.0 */ @@ -1821,46 +1821,30 @@ if (strlen(trim($code)) == 0) { continue; } + $code = ltrim($code, "\r\n}"); - $property - = trim(substr($code, 0, strpos($code, ':'))); - $value - = substr($code, strpos($code, ':') + 1); + $p = trim(substr($code, 0, strpos($code, ':'))); + $v = trim(substr($code, strpos($code, ':') + 1)); // IE hack only - if (strcasecmp($property, 'voice-family') == 0) { - $value = str_replace('#34#125#34', '"\"}\""', - $value); + if (strcasecmp($p, 'voice-family') == 0) { + $v = str_replace('#34#125#34', '"\"}\""', + $v); } - list($atKeyword, $arguments) = explode(' ', $key); - if ($nested_bloc) { - $declarations = explode(';', $properties[$i]); - foreach ($declarations as $decla) { - if (strlen(trim($decla)) == 0) { - continue; - } - $p = trim(substr($decla, 0, strpos($decla, ':'))); - $v = trim(substr($decla, strpos($decla, ':') + 1)); - + if ($key{0} == '@') { + // at-rules + list($atKeyword, $arguments) = explode(' ', $key); + if ($nested_bloc) { $this->setAtRuleStyle($atKeyword, $arguments, $nestedsel, $p, $v, $duplicates); + } else { + $this->setAtRuleStyle($atKeyword, $arguments, '', + $p, $v, $duplicates); } - } else { - $declarations = explode(';', $properties[$i]); - foreach ($declarations as $decla) { - if (strlen(trim($decla)) == 0) { - continue; - } - $p = trim(substr($decla, 0, strpos($decla, ':'))); - $v = trim(substr($decla, strpos($decla, ':') + 1)); - if ($keystr{0} == '@') { - $this->setAtRuleStyle($atKeyword, $arguments, '', - $p, $v, $duplicates); - } else { - $this->setStyle($key, $p, $v, $duplicates); - } - } + } else { + // simple declarative style + $this->setStyle($key, $p, $v, $duplicates); } } } @@ -2301,7 +2285,10 @@ $strCss .= $strCssElements; } - $strAtRules = rtrim($strAtRules) . $lnEnd; + $strAtRules = rtrim($strAtRules); + if (!empty($strAtRules)) { + $strAtRules .= $lnEnd; + } $strCss = $strAtRules . $strCss; if ($this->options['oneline']) {

« previous php.pear.cvs (#50266) next »