PHP 클래스 QueryPath\CSS\QueryPathEventHandler

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:
상속: implements QueryPath\CSS\EventHandler, implements QueryPath\CSS\Traverser
파일 보기 프로젝트 열기: microweber/microweber 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$alreadyMatched The matches
$dom
$findAnyElement Matches found before current selector.
$matches Always points to the top level.

공개 메소드들

메소드 설명
__construct ( $dom ) Create a new event handler.
adjacent ( ) 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 FOO, the a and b elements are not adjacent.
anotherSelector ( )
anyDescendant ( ) Get any descendant.
anyElement ( )
anyElementInNS ( $ns )
attachNodeList ( DOMNodeList $nodeList, SplObjectStorage $splos ) Attach all nodes in a node list to the given \SplObjectStorage.
attribute ( $name, $value = null, $operation = EventHandler::isExactly )
attributeNS ( $lname, $ns, $value = null, $operation = EventHandler::isExactly )
directDescendant ( )
element ( $name ) Inherited
elementClass ( $name )
elementID ( $id ) Find any element with the ID that matches $id.
elementNS ( $lname, $namespace = null ) Inherited
find ( string $filter ) : QueryPathEventHandler Generic finding method.
getMatches ( ) : array Get the elements that match the evaluated selector.
has ( $filter ) Pseudo-class handler for :has(filter).
matches ( )
pseudoClass ( $name, $value = null ) 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)).
pseudoElement ( $name ) 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.
sibling ( ) Get all nodes that are siblings to currently selected nodes.

보호된 메소드들

메소드 설명
attrValMatches ( $needle, $haystack, $operation ) Check for attr value matches based on an operation.
emptyElement ( ) Pseudo-class handler for :empty.
firstOfType ( ) Pseudo-class handler for :first-of-type.
lang ( $value ) Pseudo-class handler for :lang.
lastOfType ( ) Pseudo-class handler for :last-of-type.
not ( string $filter ) Pseudo-class handler for :not(filter).
nthChild ( integer $groupSize, integer $elementInGroup, boolean $lastChild = false ) Pseudo-class handler for nth-child and all related pseudo-classes.
nthLastChild ( $groupSize, $elementInGroup ) Pseudo-class handler for :nth-last-child and related pseudo-classes.
nthLastOfTypeChild ( $groupSize, $elementInGroup ) Pseudo-class handler for nth-last-of-type-child.
nthOfTypeChild ( $groupSize, $elementInGroup, $lastChild ) Pseudo-class handler for nth-of-type-child.
onlyChild ( ) Pseudo-class handler for :only-child.
onlyOfType ( ) Pseudo-class handler for :only-of-type.
parseAnB ( $rule ) Parse an an+b rule for CSS pseudo-classes.
searchForAttr ( $name, $value = null ) Helper function to find all elements with exact matches.

비공개 메소드들

메소드 설명
candidateList ( ) Determine what candidates are in the current scope.
getAllCandidates ( $elements ) Get a list of all of the candidate elements.
getByPosition ( $operator, $pos ) Pseudo-class handler for a variety of jQuery pseudo-classes.
removeQuotes ( $str ) Remove leading and trailing quotes.

메소드 상세

__construct() 공개 메소드

Create a new event handler.
public __construct ( $dom )

adjacent() 공개 메소드

In a strict DOM parser, line breaks and empty spaces are nodes. That means nodes like this will not be adjacent: . The space between them makes them non-adjacent. If this is not the desired behavior, pass in the appropriate flags to your parser. Example: $doc = new DomDocument(); $doc->loadXML(' ', LIBXML_NOBLANKS);
public adjacent ( )

anotherSelector() 공개 메소드

public anotherSelector ( )

anyDescendant() 공개 메소드

Get any descendant.
public anyDescendant ( )

anyElement() 공개 메소드

public anyElement ( )

anyElementInNS() 공개 메소드

public anyElementInNS ( $ns )

attachNodeList() 공개 메소드

Attach all nodes in a node list to the given \SplObjectStorage.
public attachNodeList ( DOMNodeList $nodeList, SplObjectStorage $splos )
$nodeList DOMNodeList
$splos SplObjectStorage

attrValMatches() 보호된 메소드

Check for attr value matches based on an operation.
protected attrValMatches ( $needle, $haystack, $operation )

attribute() 공개 메소드

public attribute ( $name, $value = null, $operation = EventHandler::isExactly )

attributeNS() 공개 메소드

public attributeNS ( $lname, $ns, $value = null, $operation = EventHandler::isExactly )

directDescendant() 공개 메소드

public directDescendant ( )

element() 공개 메소드

Inherited
public element ( $name )

elementClass() 공개 메소드

public elementClass ( $name )

elementID() 공개 메소드

If this finds an ID, it will immediately quit. Essentially, it doesn't enforce ID uniqueness, but it assumes it.
public elementID ( $id )
$id String ID for an element.

elementNS() 공개 메소드

Inherited
public elementNS ( $lname, $namespace = null )

emptyElement() 보호된 메소드

Pseudo-class handler for :empty.
protected emptyElement ( )

find() 공개 메소드

This is the primary searching method used throughout QueryPath.
public find ( string $filter ) : QueryPathEventHandler
$filter string A valid CSS 3 filter.
리턴 QueryPathEventHandler Returns itself.

firstOfType() 보호된 메소드

Pseudo-class handler for :first-of-type.
protected firstOfType ( )

getMatches() 공개 메소드

This should be called after the filter has been parsed.
public getMatches ( ) : array
리턴 array The matched items. This is almost always an array of {@link DOMElement} objects. It is always an instance of {@link DOMNode} objects.

has() 공개 메소드

This can also be used as a general filtering routine.
public has ( $filter )

lang() 보호된 메소드

Pseudo-class handler for :lang.
protected lang ( $value )

lastOfType() 보호된 메소드

Pseudo-class handler for :last-of-type.
protected lastOfType ( )

matches() 공개 메소드

public matches ( )

not() 보호된 메소드

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.
protected not ( string $filter )
$filter string A CSS selector.

nthChild() 보호된 메소드

Pseudo-class handler for nth-child and all related pseudo-classes.
protected nthChild ( integer $groupSize, integer $elementInGroup, boolean $lastChild = false )
$groupSize integer The size of the group (in an+b, this is a).
$elementInGroup integer The offset in a group. (in an+b this is b).
$lastChild boolean 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.

nthLastChild() 보호된 메소드

Pseudo-class handler for :nth-last-child and related pseudo-classes.
protected nthLastChild ( $groupSize, $elementInGroup )

nthLastOfTypeChild() 보호된 메소드

Not implemented.
protected nthLastOfTypeChild ( $groupSize, $elementInGroup )

nthOfTypeChild() 보호된 메소드

Not implemented.
protected nthOfTypeChild ( $groupSize, $elementInGroup, $lastChild )

onlyChild() 보호된 메소드

Pseudo-class handler for :only-child.
protected onlyChild ( )

onlyOfType() 보호된 메소드

Pseudo-class handler for :only-of-type.
protected onlyOfType ( )

parseAnB() 보호된 메소드

Parse an an+b rule for CSS pseudo-classes.
protected parseAnB ( $rule )
$rule Some rule in the an+b format.

pseudoClass() 공개 메소드

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)).
public pseudoClass ( $name, $value = null )

pseudoElement() 공개 메소드

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.
public pseudoElement ( $name )

searchForAttr() 보호된 메소드

Helper function to find all elements with exact matches.
사용 중단: All use cases seem to be covered by attribute().
protected searchForAttr ( $name, $value = null )

sibling() 공개 메소드

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.
public sibling ( )

프로퍼티 상세

$alreadyMatched 보호되어 있는 프로퍼티

The matches
protected $alreadyMatched

$dom 보호되어 있는 프로퍼티

protected $dom

$findAnyElement 보호되어 있는 프로퍼티

Matches found before current selector.
protected $findAnyElement

$matches 보호되어 있는 프로퍼티

Always points to the top level.
protected $matches