Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | List of all members
CssStringParserPlugin Class Reference
Inheritance diagram for CssStringParserPlugin:
aCssParserPlugin

Public Member Functions

 getTriggerChars ()
 getTriggerStates ()
 parse ($index, $char, $previousChar, $state)
- Public Member Functions inherited from aCssParserPlugin
 __construct (CssParser $parser, array $configuration=null)

Additional Inherited Members

- Protected Attributes inherited from aCssParserPlugin
 $configuration = array()
 $parser = null
 $buffer = ""

Detailed Description

Definition at line 820 of file cssmin.php.

Member Function Documentation

CssStringParserPlugin::getTriggerChars ( )

Implements aCssParserPlugin::getTriggerChars().

Returns
array

Reimplemented from aCssParserPlugin.

Definition at line 833 of file cssmin.php.

{
return array("\"", "'", "\n");
}
CssStringParserPlugin::getTriggerStates ( )

Implements aCssParserPlugin::getTriggerStates().

Returns
array

Reimplemented from aCssParserPlugin.

Definition at line 842 of file cssmin.php.

{
return false;
}
CssStringParserPlugin::parse (   $index,
  $char,
  $previousChar,
  $state 
)

Implements aCssParserPlugin::parse().

Parameters
integer$indexCurrent index
string$charCurrent char
string$previousCharPrevious char
Returns
mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing

Reimplemented from aCssParserPlugin.

Definition at line 854 of file cssmin.php.

References CssMin\triggerError().

{
// Start of string
if (($char === "\"" || $char === "'") && $state !== "T_STRING")
{
$this->delimiterChar = $char;
$this->parser->pushState("T_STRING");
$this->parser->setExclusive(__CLASS__);
}
// Escaped LF in string => remove escape backslash and LF
elseif ($char === "\n" && $previousChar === "\\" && $state === "T_STRING")
{
$this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -2));
}
// Parse error: Unescaped LF in string literal
elseif ($char === "\n" && $previousChar !== "\\" && $state === "T_STRING")
{
$line = $this->parser->getBuffer();
$this->parser->popState();
$this->parser->unsetExclusive();
$this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -1) . $this->delimiterChar); // Replace the LF with the current string char
CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated string literal", $line . "_"));
$this->delimiterChar = null;
}
// End of string
elseif ($char === $this->delimiterChar && $state === "T_STRING")
{
// If the Previous char is a escape char count the amount of the previous escape chars. If the amount of
// escape chars is uneven do not end the string
if ($previousChar == "\\")
{
$source = $this->parser->getSource();
$c = 1;
$i = $index - 2;
while (substr($source, $i, 1) === "\\")
{
$c++; $i--;
}
if ($c % 2)
{
return false;
}
}
$this->parser->popState();
$this->parser->unsetExclusive();
$this->delimiterChar = null;
}
else
{
return false;
}
return true;
}

The documentation for this class was generated from the following file: