Beispiel #1
0
 private function parseIdentifier($bAllowFunctions = false, $bAllowColors = false)
 {
     $sResult = $this->parseCharacter(true);
     if ($sResult === null) {
         throw new Exception("Identifier expected, got {$this->peek(5)}");
     }
     $sCharacter;
     while (($sCharacter = $this->parseCharacter(true)) !== null) {
         $sResult .= $sCharacter;
     }
     if ($bAllowColors) {
         // is it a color name ?
         if ($aColor = CSSColorUtils::namedColor2rgb($sResult)) {
             $oColor = new CSSColor();
             return $oColor->fromRGB($aColor);
         }
     }
     if ($bAllowFunctions && $this->comes('(')) {
         $this->consume('(');
         $sResult = new CSSFunction($sResult, $this->parseValue(array('=', ',')));
         $this->consume(')');
     }
     return $sResult;
 }
 public function fromNamedColor($sValue)
 {
     $aRGB = CSSColorUtils::namedColor2rgb($sValue);
     return $this->fromRGB($aRGB);
 }