Class QueryPathCssEventHandler

(line 68)

Description


Located in File: /src/QueryPath/CssEventHandler.php

Handler that tracks progress of a query through a DOM.

The main idea is that we keep a copy of the tree, and then use an array to keep track of matches. To handle a list of selectors (using the comma separator), we have to track both the currently progressing match and the previously matched elements.

To use this handler:

  1.  $filter '#id'// Some CSS selector
  2.  $handler = new QueryPathCssParser(DOMNode $dom);
  3.  $parser = new CssParser();
  4.  $parser->parse($filter$handler);
  5.  $matches $handler->getMatches();

$matches will be an array of zero or more DOMElement objects.



Class Variables

Summary:
mixed $dom
mixed $matches

$alreadyMatched = NULL (line 71)

Data type : mixed

  • access: - protected

$dom = NULL (line 69)

Data type : mixed

  • access: - protected

$findAnyElement = TRUE (line 72)

Data type : mixed

  • access: - protected

$matches = NULL (line 70)

Data type : mixed

  • access: - protected

Class Constants

Summary:

Method Detail

Summary:
QueryPathCssEventHandler __construct ( $dom)
void adjacent ()
void anotherSelector ()
void anyDescendant ()
void anyElement ()
void anyElementInNS ( $ns)
void attachNodeList ( $nodeList,  $splos)
void attribute ( $name, [ $value = NULL], [ $operation = CssEventHandler::isExactly])
void attributeNS ( $lname,  $ns, [ $value = NULL], [ $operation = CssEventHandler::isExactly])
void attrValMatches ( $needle,  $haystack,  $operation)
void element ( $name)
void elementClass ( $name)
void elementID ($id $id)
void elementNS ( $lname, [ $namespace = NULL])
void emptyElement ()
QueryPathCssEventHandler find (string $filter)
void firstOfType ()
array getMatches ()
void has ( $filter)
void lang ( $value)
void lastOfType ()
void not (string $filter)
void nthChild (int $groupSize, int $elementInGroup, [boolean $lastChild = FALSE])
void nthLastChild ( $groupSize,  $elementInGroup)
void nthLastOfTypeChild ( $groupSize,  $elementInGroup)
void nthOfTypeChild ( $groupSize,  $elementInGroup,  $lastChild)
void onlyChild ()
void onlyOfType ()
Array parseAnB ($rule $rule)
void pseudoClass ( $name, [ $value = NULL])
void pseudoElement ( $name)
void searchForAttr ( $name, [ $value = NULL])
void sibling ()

Constructor __construct (line 78)

QueryPathCssEventHandler __construct( $dom)

Create a new event handler.

Parameters

  • $dom:

Info

  • access - public

Method adjacent (line 1277)

void adjacent( )


Implementation of:
CssEventHandler::adjacent()
Handle a adjacent combinator.
For an element to be adjacent to another, it must be THE NEXT NODE in the node list. So if an element is surrounded by pcdata, there are no adjacent nodes. E.g. in <a/>FOO<b/>, the a and b elements are not adjacent.

In a strict DOM parser, line breaks and empty spaces are nodes. That means nodes like this will not be adjacent: <test/> <test/>. The space between them makes them non-adjacent. If this is not the desired behavior, pass in the appropriate flags to your parser. Example:

  1.  $doc = new DomDocument();
  2.  $doc->loadXML('<test/> <test/>'LIBXML_NOBLANKS);

Info

  • access - public

Method anotherSelector (line 1290)

void anotherSelector( )


Implementation of:
CssEventHandler::anotherSelector()
Handle an another-selector combinator.

Info

  • access - public

Method anyDescendant (line 1337)

void anyDescendant( )


Implementation of:
CssEventHandler::anyDescendant()
Handle an any-descendant combinator.
Get any descendant.

Info

  • access - public

Method anyElement (line 258)

void anyElement( )


Implementation of:
CssEventHandler::anyElement()
Handle an any-element (*) operator.

Info

  • access - public

Method anyElementInNS (line 271)

void anyElementInNS( $ns)


Implementation of:
CssEventHandler::anyElementInNS()
Handle an any-element operator that is constrained to a namespace.

Parameters

  • $ns:

Info

  • access - public

Method attachNodeList (line 1402)

void attachNodeList( $nodeList, $splos)

Attach all nodes in a node list to the given SplObjectStorage.

Parameters

  • DOMNodeList $nodeList:
  • SplObjectStorage $splos:

Info

  • access - public

Method attribute (line 309)

void attribute( $name, [ $value = NULL], [ $operation = CssEventHandler::isExactly])


Implementation of:
CssEventHandler::attribute()
Handle an attribute selector.

Parameters

  • $name:
  • $value:
  • $operation:

Info

  • access - public

Method attributeNS (line 354)

void attributeNS( $lname, $ns, [ $value = NULL], [ $operation = CssEventHandler::isExactly])


Implementation of:
CssEventHandler::attributeNS()
Handle an attribute selector bound to a specific namespace.

Parameters

  • $lname:
  • $ns:
  • $value:
  • $operation:

Info

  • access - public

Method attrValMatches (line 1169)

void attrValMatches( $needle, $haystack, $operation)

Check for attr value matches based on an operation.

Parameters

  • $needle:
  • $haystack:
  • $operation:

Info

  • access - protected

Method directDescendant (line 1248)

void directDescendant( )


Implementation of:
CssEventHandler::directDescendant()
Handle a direct descendant combinator.

Info

  • access - public

Method element (line 189)

void element( $name)


Implementation of:
CssEventHandler::element()
Handle an element name.

Parameters

  • $name:

Info

  • access - public

Method elementClass (line 294)

void elementClass( $name)


Implementation of:
CssEventHandler::elementClass()
Handle a CSS class selector.

Parameters

  • $name:

Info

  • access - public

Method elementID (line 174)

void elementID( $id $id)


Implementation of:
CssEventHandler::elementID()
This event is fired when a CSS ID is encountered.
Find any element with the ID that matches $id.

If this finds an ID, it will immediately quit. Essentially, it doesn't enforce ID uniqueness, but it assumes it.

Parameters

  • $id $id: String ID for an element.

Info

  • access - public

Method elementNS (line 209)

void elementNS( $lname, [ $namespace = NULL])


Implementation of:
CssEventHandler::elementNS()
Handle a namespaced element name.

Parameters

  • $lname:
  • $namespace:

Info

  • access - public

Method emptyElement (line 1116)

void emptyElement( )

Pseudo-class handler for :empty.

Info

  • access - protected

Method find (line 141)

QueryPathCssEventHandler find( string $filter)

Generic finding method.

This is the primary searching method used throughout QueryPath.

Parameters

  • string $filter: A valid CSS 3 filter.

Info

  • return - Returns itself.
  • access - public

Method firstOfType (line 1050)

void firstOfType( )

Pseudo-class handler for :first-of-type.

Info

  • access - protected

Method getMatches (line 157)

array getMatches( )

Get the elements that match the evaluated selector.

This should be called after the filter has been parsed.

Info

  • return - The matched items. This is almost always an array of DOMElement objects. It is always an instance of DOMNode objects.
  • access - public

Method has (line 1032)

void has( $filter)

Pseudo-class handler for :has(filter).

This can also be used as a general filtering routine.

Parameters

  • $filter:

Info

  • access - public

Method lang (line 973)

void lang( $value)

Pseudo-class handler for :lang

Parameters

  • $value:

Info

  • access - protected

Method lastOfType (line 1071)

void lastOfType( )

Pseudo-class handler for :last-of-type.

Info

  • access - protected

Method not (line 1012)

void not( string $filter)

Pseudo-class handler for :not(filter).

This does not follow the specification in the following way: The CSS 3 selector spec says the value of not() must be a simple selector. This function allows complex selectors.

Parameters

  • string $filter: A CSS selector.

Info

  • access - protected

Method nthChild (line 712)

void nthChild( int $groupSize, int $elementInGroup, [boolean $lastChild = FALSE])

Pseudo-class handler for nth-child and all related pseudo-classes.

Parameters

  • int $groupSize: The size of the group (in an+b, this is a).
  • int $elementInGroup: The offset in a group. (in an+b this is b).
  • boolean $lastChild: Whether counting should begin with the last child. By default, this is false. Pseudo-classes that start with the last-child can set this to true.

Info

  • access - protected

Method nthLastChild (line 795)

void nthLastChild( $groupSize, $elementInGroup)

Pseudo-class handler for :nth-last-child and related pseudo-classes.

Parameters

  • $groupSize:
  • $elementInGroup:

Info

  • access - protected

Method nthLastOfTypeChild (line 966)

void nthLastOfTypeChild( $groupSize, $elementInGroup)

Pseudo-class handler for nth-last-of-type-child.

Not implemented.

Parameters

  • $groupSize:
  • $elementInGroup:

Info

  • access - protected

Method nthOfTypeChild (line 902)

void nthOfTypeChild( $groupSize, $elementInGroup, $lastChild)

Pseudo-class handler for nth-of-type-child.

Not implemented.

Parameters

  • $groupSize:
  • $elementInGroup:
  • $lastChild:

Info

  • access - protected

Method onlyChild (line 1093)

void onlyChild( )

Pseudo-class handler for :only-child.

Info

  • access - protected

Method onlyOfType (line 1139)

void onlyOfType( )

Pseudo-class handler for :only-of-type.

Info

  • access - protected

Method parseAnB (line 678)

Array parseAnB( $rule $rule)

Parse an an+b rule for CSS pseudo-classes.

Parameters

  • $rule $rule: Some rule in the an+b format.

Info

  • return - (list($aVal, $bVal)) of the two values.
  • throws - CssParseException If the rule does not follow conventions.
  • access - protected

Method pseudoClass (line 392)

void pseudoClass( $name, [ $value = NULL])


Implementation of:
CssEventHandler::pseudoClass()
Handle a pseudo-class.
This also supports the following nonstandard pseudo classes:

  • :x-reset/:x-root (reset to the main item passed into the constructor. Less drastic than :root)
  • :odd/:even (shorthand for :nth-child(odd)/:nth-child(even))

Parameters

  • $name:
  • $value:

Info

  • access - public

Method pseudoElement (line 1200)

void pseudoElement( $name)


Implementation of:
CssEventHandler::pseudoElement()
Handle a pseudo-element.
As the spec mentions, these must be at the end of a selector or else they will cause errors. Most selectors return elements. Pseudo-elements do not.

Parameters

  • $name:

Info

  • access - public

Method searchForAttr (line 335)

void searchForAttr( $name, [ $value = NULL])

Helper function to find all elements with exact matches.

Parameters

  • $name:
  • $value:

Info

  • deprecated - All use cases seem to be covered by attribute().
  • access - protected

Method sibling (line 1311)

void sibling( )


Implementation of:
CssEventHandler::sibling()
Handle a sibling combinator.
Get all nodes that are siblings to currently selected nodes.

If two passed in items are siblings of each other, neither will be included in the list of siblings. Their status as being candidates excludes them from being considered siblings.

Info

  • access - public

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary


Documentation generated on Sun, 25 Jul 2010 16:09:03 -0500 by phpDocumentor 1.4.3