public function QueryPathCssEventHandler::pseudoElement in QueryPath 7.2
Same name and namespace in other branches
- 6 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::pseudoElement()
- 7.3 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::pseudoElement()
Overrides CssEventHandler::pseudoElement
File
- QueryPath/
CssEventHandler.php, line 943
Class
Code
public function pseudoElement($name) {
switch ($name) {
case 'first-line':
$matches = $this
->candidateList();
$found = new SplObjectStorage();
$o = new stdClass();
foreach ($matches as $item) {
$str = $item->textContent;
$lines = explode("\n", $str);
if (!empty($lines)) {
$line = trim($lines[0]);
if (!empty($line)) {
$o->textContent = $line;
}
$found
->attach($o);
}
}
$this->matches = $found;
break;
case 'first-letter':
$matches = $this
->candidateList();
$found = new SplObjectStorage();
$o = new stdClass();
foreach ($matches as $item) {
$str = $item->textContent;
if (!empty($str)) {
$str = substr($str, 0, 1);
$o->textContent = $str;
$found
->attach($o);
}
}
$this->matches = $found;
break;
case 'before':
case 'after':
case 'selection':
throw new NotImplementedException("The {$name} pseudo-element is not implemented.");
break;
}
$this->findAnyElement = FALSE;
}