PHP Класс FluentDOM\Query

Наследование: extends Nodes
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__call ( string $name, array $arguments ) : Query declaring an empty() or clone() method will crash the parser so we use some magic
__get ( string $name ) : mixed Virtual properties, read property
__isset ( string $name ) : boolean Virtual properties, validate existence
__set ( string $name, mixed $value ) Block changing the readonly dynamic property
__unset ( string $name ) Throws an exception if somebody tries to unset one of the dynamic properties
add ( string $selector, array | Traversable $context = NULL ) : Query Adds more elements, matched by the given expression, to the set of matched elements.
addBack ( ) : Query Add the previous selection to the current selection.
addClass ( string | callable $class ) : Query Adds the specified class(es) to each of the set of matched elements.
after ( string | array | DOMNode | DOMNodeList | Traversable | callable $content ) : Query Insert content after each of the matched elements.
andSelf ( ) : Query Alias for addBack()
append ( string | array | DOMNode | Traversable | callable $content ) : Query Append content to the inside of every matched element.
appendTo ( string | array | DOMNode | DOMNodeList | Query $selector ) : Query Append all of the matched elements to another, specified, set of elements.
attr ( string | array $attribute, variadic<[callable | string]> $arguments ) : Query | string Access a property on the first matched element or set the attribute(s) of all matched elements
before ( string | array | DOMNode | Traversable | callable $content ) : Query Insert content before each of the matched elements.
children ( string $selector = NULL ) : Query Get a set of elements containing of the unique immediate child nodes including only elements (not text nodes) of each of the matched set of elements.
closest ( string $selector, array | Traversable $context = NULL ) : Query Get a set of elements containing the closest parent element that matches the specified selector, the starting element included.
contents ( ) : Query Get a set of elements containing all of the unique immediate child nodes including elements and text nodes of each of the matched set of elements.
css ( string | array $property, variadic<[string | object | callable]> $arguments ) : string | null | $this get or set CSS values in style attributes
data ( string | array $name, $arguments ) : mixed Read a data attribute from the first node or set data attributes on all selected nodes.
eq ( integer $position ) : Query Reduce the set of matched elements to a single element.
filter ( string | callable $selector ) : Query Removes all elements from the set of matched elements that do not match the specified expression(s).
first ( ) : Query Get a set of elements containing only the first of the currently selected elements.
get ( $position = NULL ) : array Retrieve the matched DOM elements in an array. A negative position will be counted from the end.
has ( string | DOMNode $selector ) : Query Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
hasAttr ( string $name ) : boolean Returns true if the specified attribute is present on at least one of the set of matched elements.
hasClass ( string $class ) : boolean Returns true if the specified class is present on at least one of the set of matched elements.
hasData ( DOMElement $element = NULL ) : boolean Validate if the element has an data attributes attached. If it is called without an actual $element parameter, it will check the first matched node.
html ( string | callable | null $html = NULL ) : string | self Get html contents of the first matched element or set the html contents of all selected element nodes.
insertAfter ( string | array | DOMNode | Traversable $selector ) : Query Insert all of the matched elements after another, specified, set of elements.
insertBefore ( string | array | DOMNode | Traversable $selector ) : Query Insert all of the matched elements before another, specified, set of elements.
is ( string $selector ) : boolean Checks the current selection against an expression and returns true, if at least one element of the selection fits the given expression.
last ( ) : Query Get a set of elements containing only the last of the currently selected elements.
map ( callable $function ) : array Translate a set of elements in the FluentDOM\Query object into another set of values in an array (which may, or may not contain elements).
next ( string $selector = NULL ) : Query Get a set of elements containing the unique next siblings of each of the given set of elements.
nextAll ( string $selector = NULL ) : Query Find all sibling elements after the current element.
nextUntil ( string $selector = NULL, string $filter = NULL ) : Query Get all following siblings of each element up to but not including the element matched by the selector.
not ( string | callback $selector ) : Query Removes elements matching the specified expression from the set of matched elements.
outerHtml ( string | callable | null $html = NULL ) : string | self Get the first matched node as HTML or replace each matched nodes with the provided fragment.
outerXml ( string | callable | null $xml = NULL ) : string | self Get the first matched node as XML or replace each matched nodes with the provided fragment.
parent ( ) : Query Get a set of elements containing the unique parents of the matched set of elements.
parents ( string $selector = NULL ) : Query Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
parentsUntil ( string $stopAt = NULL, string $filter = NULL ) : Query Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector.
prepend ( string | array | DOMNode | Traversable $content ) : Query Prepend content to the inside of every matched element.
prependTo ( string | array | DOMNode | DOMNodeList | Query $selector ) : Query Prepend all of the matched elements to another, specified, set of elements.
prev ( string $selector = NULL ) : Query Get a set of elements containing the unique previous siblings of each of the matched set of elements.
prevAll ( string $selector = NULL ) : Query Find all sibling elements in front of the current element.
prevUntil ( string $selector = NULL, string $filter = NULL ) : Query Get all preceding siblings of each element up to but not including the element matched by the selector.
remove ( string $selector = NULL ) : Query Removes all matched elements from the DOM.
removeAttr ( string | array $name ) : Query Remove an attribute from each of the matched elements. If $name is NULL or *, all attributes will be deleted.
removeClass ( string | callable $class = '' ) : Query Removes all or the specified class(es) from the set of matched elements.
removeData ( string | array | null $name = NULL ) : Query Remove an data - attribute from each of the matched elements. If $name is NULL or *, all data attributes will be deleted.
replaceAll ( string | array | DOMNode | Traversable $selector ) : Query Replaces the elements matched by the specified selector with the matched elements.
replaceWith ( string | array | DOMNode | Traversable | callable $content ) : Query Replaces all matched elements with the specified HTML or DOM elements.
reverse ( ) : Query Reverse the order of the matched elements.
siblings ( string $selector = NULL ) : Query Get a set of elements containing all of the unique siblings of each of the matched set of elements.
slice ( integer $start, integer $end = NULL ) : Query Selects a subset of the matched elements.
text ( string | callable $text = NULL ) : string | Query Get the combined text contents of all matched elements or set the text contents of all matched elements.
toggleClass ( string | callable $class, null | boolean $switch = NULL ) : Query Adds the specified classes if the switch is TRUE, removes the specified classes if the switch is FALSE, toggles the specified classes if the switch is NULL.
wrap ( string | array | DOMNode | Traversable | callable $content ) : Query Wrap each matched element with the specified content.
wrapAll ( string | array | DOMNode | Traversable $content ) : Query Wrap al matched elements with the specified content
wrapInner ( string | array | DOMNode | Traversable $content ) : Query Wrap the inner child contents of each matched element (including text nodes) with an XML structure.
xml ( string | callable | null $xml = NULL ) : string | self Get xml contents of the first matched element or set the xml contents of all selected element nodes.

Приватные методы

Метод Описание
apply ( array | DOMNodeList $targetNodes, string | array | DOMNode | DOMNodeList | Traversable | callable $content, callable $handler ) : array Use a handler callback to apply a content argument to each node $targetNodes. The content argument can be an easy setter function
applyToSelector ( string | array | DOMNode | Traversable $selector, callable $handler, boolean $remove = FALSE ) : Query Apply the handler the $handler to nodes defined by selector, using the currently selected nodes as context.
applyToSpawn ( array | DOMNodeList $targetNodes, string | array | DOMNode | DOMNodeList | Traversable | callable $content, callable $handler, boolean $remove = FALSE ) : Query Apply the content to the target nodes using the handler callback and push them into a spawned Query object.
build ( ) : Builder
changeClassString ( string $current, string $toggle, boolean | null $switch ) : FALSE | string Change a class string
cloneNodes ( ) : Query Clone matched DOM Elements and select the clones.
content ( string | callable | null $content, callable $export, callable $import, callable $insert )
emptyNodes ( ) : Query Remove all child nodes from the set of matched elements.
getFirstElement ( ) : null | DOMElement Returns the item from the internal array if if the index exists and is an DOMElement
getGroupedNodes ( ) : array | boolean group selected elements by previous node - ignore whitespace text nodes
getNamesList ( string | array | null $names ) : array
getSetterValues ( string | array | Traversable $name, string | float | integer | null | callable $value ) : array | Traversable
modify ( DOMNode $node ) : Modifier
outerContent ( string | callable | null $content, callable $export, callable $import )
wrapGroupedNodes ( array $groups, DOMElement $template ) : array Wrap grouped nodes
wrapNodes ( array $elements, string | array | DOMNode | Traversable | callable $content ) : Query Wrap $content around a set of elements

Описание методов

__call() публичный Метод

declaring an empty() or clone() method will crash the parser so we use some magic
public __call ( string $name, array $arguments ) : Query
$name string
$arguments array
Результат Query

__get() публичный Метод

Virtual properties, read property
public __get ( string $name ) : mixed
$name string
Результат mixed

__isset() публичный Метод

Virtual properties, validate existence
public __isset ( string $name ) : boolean
$name string
Результат boolean

__set() публичный Метод

Block changing the readonly dynamic property
public __set ( string $name, mixed $value )
$name string
$value mixed

__unset() публичный Метод

Throws an exception if somebody tries to unset one of the dynamic properties
public __unset ( string $name )
$name string

add() публичный Метод

Adds more elements, matched by the given expression, to the set of matched elements.
public add ( string $selector, array | Traversable $context = NULL ) : Query
$selector string selector
$context array | Traversable
Результат Query

addBack() публичный Метод

Add the previous selection to the current selection.
public addBack ( ) : Query
Результат Query

addClass() публичный Метод

Adds the specified class(es) to each of the set of matched elements.
public addClass ( string | callable $class ) : Query
$class string | callable
Результат Query

after() публичный Метод

Insert content after each of the matched elements.
public after ( string | array | DOMNode | DOMNodeList | Traversable | callable $content ) : Query
$content string | array | DOMNode | DOMNodeList | Traversable | callable
Результат Query

andSelf() публичный Метод

Alias for addBack()
Устаревший:
public andSelf ( ) : Query
Результат Query

append() публичный Метод

Append content to the inside of every matched element.
public append ( string | array | DOMNode | Traversable | callable $content ) : Query
$content string | array | DOMNode | Traversable | callable DOMNode or DOMNodeList or xml fragment string
Результат Query

appendTo() публичный Метод

Returns all of the inserted elements.
public appendTo ( string | array | DOMNode | DOMNodeList | Query $selector ) : Query
$selector string | array | DOMNode | DOMNodeList | Query
Результат Query

attr() публичный Метод

Access a property on the first matched element or set the attribute(s) of all matched elements
public attr ( string | array $attribute, variadic<[callable | string]> $arguments ) : Query | string
$attribute string | array attribute name or attribute list
$arguments variadic<[callable | string]>
Результат Query | string attribute value or $this

before() публичный Метод

Insert content before each of the matched elements.
public before ( string | array | DOMNode | Traversable | callable $content ) : Query
$content string | array | DOMNode | Traversable | callable
Результат Query

children() публичный Метод

Get a set of elements containing of the unique immediate child nodes including only elements (not text nodes) of each of the matched set of elements.
public children ( string $selector = NULL ) : Query
$selector string selector
Результат Query

closest() публичный Метод

Get a set of elements containing the closest parent element that matches the specified selector, the starting element included.
public closest ( string $selector, array | Traversable $context = NULL ) : Query
$selector string selector
$context array | Traversable
Результат Query

contents() публичный Метод

Get a set of elements containing all of the unique immediate child nodes including elements and text nodes of each of the matched set of elements.
public contents ( ) : Query
Результат Query

css() публичный Метод

get or set CSS values in style attributes
public css ( string | array $property, variadic<[string | object | callable]> $arguments ) : string | null | $this
$property string | array
$arguments variadic<[string | object | callable]>
Результат string | null | $this

data() публичный Метод

Read a data attribute from the first node or set data attributes on all selected nodes.
public data ( string | array $name, $arguments ) : mixed
$name string | array data attribute identifier or array of data attributes to set
Результат mixed

eq() публичный Метод

Reduce the set of matched elements to a single element.
public eq ( integer $position ) : Query
$position integer Element index (start with 0)
Результат Query

filter() публичный Метод

Removes all elements from the set of matched elements that do not match the specified expression(s).
public filter ( string | callable $selector ) : Query
$selector string | callable selector or callback function
Результат Query

first() публичный Метод

Get a set of elements containing only the first of the currently selected elements.
public first ( ) : Query
Результат Query

get() публичный Метод

Retrieve the matched DOM elements in an array. A negative position will be counted from the end.
public get ( $position = NULL ) : array
Результат array

has() публичный Метод

Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
public has ( string | DOMNode $selector ) : Query
$selector string | DOMNode selector or DOMNode
Результат Query

hasAttr() публичный Метод

Returns true if the specified attribute is present on at least one of the set of matched elements.
public hasAttr ( string $name ) : boolean
$name string
Результат boolean

hasClass() публичный Метод

Returns true if the specified class is present on at least one of the set of matched elements.
public hasClass ( string $class ) : boolean
$class string
Результат boolean

hasData() публичный Метод

Validate if the element has an data attributes attached. If it is called without an actual $element parameter, it will check the first matched node.
public hasData ( DOMElement $element = NULL ) : boolean
$element DOMElement
Результат boolean

html() публичный Метод

Get html contents of the first matched element or set the html contents of all selected element nodes.
public html ( string | callable | null $html = NULL ) : string | self
$html string | callable | null
Результат string | self

insertAfter() публичный Метод

Insert all of the matched elements after another, specified, set of elements.
public insertAfter ( string | array | DOMNode | Traversable $selector ) : Query
$selector string | array | DOMNode | Traversable
Результат Query

insertBefore() публичный Метод

Insert all of the matched elements before another, specified, set of elements.
public insertBefore ( string | array | DOMNode | Traversable $selector ) : Query
$selector string | array | DOMNode | Traversable
Результат Query

is() публичный Метод

Checks the current selection against an expression and returns true, if at least one element of the selection fits the given expression.
public is ( string $selector ) : boolean
$selector string selector
Результат boolean

last() публичный Метод

Get a set of elements containing only the last of the currently selected elements.
public last ( ) : Query
Результат Query

map() публичный Метод

If the callback function returns an array each element of the array will be added to the result array. All other variable types are put directly into the result array.
public map ( callable $function ) : array
$function callable
Результат array

next() публичный Метод

Get a set of elements containing the unique next siblings of each of the given set of elements.
public next ( string $selector = NULL ) : Query
$selector string
Результат Query

nextAll() публичный Метод

Find all sibling elements after the current element.
public nextAll ( string $selector = NULL ) : Query
$selector string selector
Результат Query

nextUntil() публичный Метод

Get all following siblings of each element up to but not including the element matched by the selector.
public nextUntil ( string $selector = NULL, string $filter = NULL ) : Query
$selector string selector
$filter string selector
Результат Query

not() публичный Метод

Removes elements matching the specified expression from the set of matched elements.
public not ( string | callback $selector ) : Query
$selector string | callback selector or callback function
Результат Query

outerHtml() публичный Метод

Get the first matched node as HTML or replace each matched nodes with the provided fragment.
public outerHtml ( string | callable | null $html = NULL ) : string | self
$html string | callable | null
Результат string | self

outerXml() публичный Метод

Get the first matched node as XML or replace each matched nodes with the provided fragment.
public outerXml ( string | callable | null $xml = NULL ) : string | self
$xml string | callable | null
Результат string | self

parent() публичный Метод

Get a set of elements containing the unique parents of the matched set of elements.
public parent ( ) : Query
Результат Query

parents() публичный Метод

Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
public parents ( string $selector = NULL ) : Query
$selector string selector
Результат Query

parentsUntil() публичный Метод

Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector.
public parentsUntil ( string $stopAt = NULL, string $filter = NULL ) : Query
$stopAt string selector
$filter string selector
Результат Query

prepend() публичный Метод

Prepend content to the inside of every matched element.
public prepend ( string | array | DOMNode | Traversable $content ) : Query
$content string | array | DOMNode | Traversable
Результат Query

prependTo() публичный Метод

Returns all of the inserted elements.
public prependTo ( string | array | DOMNode | DOMNodeList | Query $selector ) : Query
$selector string | array | DOMNode | DOMNodeList | Query
Результат Query list of all new elements

prev() публичный Метод

Get a set of elements containing the unique previous siblings of each of the matched set of elements.
public prev ( string $selector = NULL ) : Query
$selector string selector
Результат Query

prevAll() публичный Метод

Find all sibling elements in front of the current element.
public prevAll ( string $selector = NULL ) : Query
$selector string selector
Результат Query

prevUntil() публичный Метод

Get all preceding siblings of each element up to but not including the element matched by the selector.
public prevUntil ( string $selector = NULL, string $filter = NULL ) : Query
$selector string selector
$filter string selector
Результат Query

remove() публичный Метод

Removes all matched elements from the DOM.
public remove ( string $selector = NULL ) : Query
$selector string selector
Результат Query removed elements

removeAttr() публичный Метод

Remove an attribute from each of the matched elements. If $name is NULL or *, all attributes will be deleted.
public removeAttr ( string | array $name ) : Query
$name string | array
Результат Query

removeClass() публичный Метод

Removes all or the specified class(es) from the set of matched elements.
public removeClass ( string | callable $class = '' ) : Query
$class string | callable
Результат Query

removeData() публичный Метод

Remove an data - attribute from each of the matched elements. If $name is NULL or *, all data attributes will be deleted.
public removeData ( string | array | null $name = NULL ) : Query
$name string | array | null
Результат Query

replaceAll() публичный Метод

Replaces the elements matched by the specified selector with the matched elements.
public replaceAll ( string | array | DOMNode | Traversable $selector ) : Query
$selector string | array | DOMNode | Traversable
Результат Query

replaceWith() публичный Метод

This returns the element that was just replaced, which has been removed from the DOM.
public replaceWith ( string | array | DOMNode | Traversable | callable $content ) : Query
$content string | array | DOMNode | Traversable | callable
Результат Query

reverse() публичный Метод

Reverse the order of the matched elements.
public reverse ( ) : Query
Результат Query

siblings() публичный Метод

Get a set of elements containing all of the unique siblings of each of the matched set of elements.
public siblings ( string $selector = NULL ) : Query
$selector string selector
Результат Query

slice() публичный Метод

Selects a subset of the matched elements.
public slice ( integer $start, integer $end = NULL ) : Query
$start integer
$end integer
Результат Query

text() публичный Метод

Get the combined text contents of all matched elements or set the text contents of all matched elements.
public text ( string | callable $text = NULL ) : string | Query
$text string | callable
Результат string | Query

toggleClass() публичный Метод

Adds the specified classes if the switch is TRUE, removes the specified classes if the switch is FALSE, toggles the specified classes if the switch is NULL.
public toggleClass ( string | callable $class, null | boolean $switch = NULL ) : Query
$class string | callable
$switch null | boolean toggle if NULL, add if TRUE, remove if FALSE
Результат Query

wrap() публичный Метод

If $content contains several elements the first one is used
public wrap ( string | array | DOMNode | Traversable | callable $content ) : Query
$content string | array | DOMNode | Traversable | callable
Результат Query

wrapAll() публичный Метод

If the matched elements are not siblings, wrap each group of siblings.
public wrapAll ( string | array | DOMNode | Traversable $content ) : Query
$content string | array | DOMNode | Traversable
Результат Query

wrapInner() публичный Метод

Wrap the inner child contents of each matched element (including text nodes) with an XML structure.
public wrapInner ( string | array | DOMNode | Traversable $content ) : Query
$content string | array | DOMNode | Traversable
Результат Query

xml() публичный Метод

Get xml contents of the first matched element or set the xml contents of all selected element nodes.
public xml ( string | callable | null $xml = NULL ) : string | self
$xml string | callable | null XML fragment
Результат string | self