You are here

public function QueryPathCssEventHandler::pseudoElement in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::pseudoElement()
  2. 7.2 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::pseudoElement()

Overrides CssEventHandler::pseudoElement

File

QueryPath/CssEventHandler.php, line 943

Class

QueryPathCssEventHandler

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;
}