FluentDOM
[ class tree: FluentDOM ] [ index: FluentDOM ] [ all elements ]

Class: FluentDOMCore

Source Location: /FluentDOM/Core.php

Class Overview


FluentDOMCore implements the core and interface functions for FluentDOM


Author(s):

Implements interfaces:

  • IteratorAggregate (internal interface)
  • Countable (internal interface)
  • ArrayAccess (internal interface)

Variables

Methods


Child classes:

FluentDOM
FluentDOM implements a jQuery like replacement for DOMNodeList

Class Details

[line 36]
FluentDOMCore implements the core and interface functions for FluentDOM



Tags:

property:  string $contentType: Output type - text/xml or text/html
property-read:  integer $length: The amount of elements found by selector.
property-read:  DOMDocument $document: Internal DOMDocument object
property-read:  DOMXPath $xpath: Internal XPath object


[ Top ]


Class Variables

$_array = array()

[line 78]

Seleted element and text nodes



Tags:

access:  protected

Type:   array


[ Top ]

$_contentType =  'text/xml'

[line 66]

Content type for output (xml, text/xml, html, text/html).



Tags:

access:  protected

Type:   string


[ Top ]

$_document =  NULL

[line 42]

Associated DOMDocument object.



Tags:

access:  protected

Type:   DOMDocument


[ Top ]

$_loaders =  NULL

[line 88]

Document loader list.



Tags:

see:  FluentDOMCore::_initLoaders()
see:  _setLoader
access:  protected

Type:   array


[ Top ]

$_namespaces = array()

[line 54]

List of namespaces to be registered for xpath expressions



Tags:

access:  protected

Type:   array


[ Top ]

$_parent =  NULL

[line 72]

Parent FluentDOM object (previous selection in chain).



Tags:

access:  protected

Type:   FluentDOM


[ Top ]

$_useDocumentContext =  TRUE

[line 60]

Use document context for expression (not selected nodes).



Tags:

access:  protected

Type:   boolean


[ Top ]

$_xpath =  NULL

[line 48]

XPath object used to execute selectors



Tags:

access:  protected

Type:   DOMXPath


[ Top ]



Class Methods


constructor __construct [line 95]

FluentDOM __construct( )

Constructor



Tags:

access:  public


[ Top ]

method count [line 351]

integer count( )

Get element count (Countable interface)



Tags:

access:  public
example:  Usage Example: Countable Interface



Implementation of:
Countable::count
[ Top ]

method evaluate [line 509]

void evaluate( string $expr, [ $context = NULL])

Gives access to an xpath evaluate on the current document



Tags:

access:  public


Parameters:

string   $expr  
DOMNode   $context  

[ Top ]

method formatOutput [line 310]

FluentDOM formatOutput( [ $contentType = NULL])

Formats the current document, resets internal node array and other properties.

The document is saved and reloaded, all variables with DOMNodes of this document will get invalid.




Tags:

access:  public


Parameters:

   $contentType  

[ Top ]

method getIterator [line 337]

FluentDOMIterator getIterator( )

Get an iterator for this object.



Tags:




Implementation of:
IteratorAggregate::getIterator
[ Top ]

method item [line 295]

DOMNode item( integer $position)

The item() method is used to access elements in the node list, like in a DOMNodelist.



Tags:

access:  public


Parameters:

integer   $position  

[ Top ]

method load [line 106]

void load( mixed $source, [string $contentType = 'text/xml'])

Load a $source. The type of the source depends on the loaders. If no explicit loaders are set FluentDOM will use a set of default loaders for xml/html and DOM.



Tags:

access:  public


Parameters:

mixed   $source  
string   $contentType   optional, default value 'text/xml'

[ Top ]

method namespaces [line 523]

array|FluentDOMCore namespaces( [ $namespaces = NULL])

Register namespaces and or get namespaces



Tags:

access:  public


Parameters:

array   $namespaces   If this parameter is empty the current namespaces are returned

[ Top ]

method offsetExists [line 378]

boolean offsetExists( integer $offset)

Check if index exists in internal array



Tags:

access:  public
example:  Usage Example: ArrayAccess Interface



Implementation of:
ArrayAccess::offsetExists

Parameters:

integer   $offset  

[ Top ]

method offsetGet [line 400]

DOMNode|NULL offsetGet( integer $offset)

Get element from internal array



Tags:

access:  public
example:  Usage Example: ArrayAccess Interface



Implementation of:
ArrayAccess::offsetGet

Parameters:

integer   $offset  

[ Top ]

method offsetSet [line 367]

void offsetSet( integer $offset, mixed $value)

If somebody tries to modify the internal array throw an exception.



Tags:

access:  public
example:  Usage Example: ArrayAccess Interface



Implementation of:
ArrayAccess::offsetSet

Parameters:

integer   $offset  
mixed   $value  

[ Top ]

method offsetUnset [line 389]

void offsetUnset( integer $offset)

If somebody tries to remove an element from the internal array throw an exception.



Tags:

access:  public
example:  Usage Example: ArrayAccess Interface



Implementation of:
ArrayAccess::offsetUnset

Parameters:

integer   $offset  

[ Top ]

method push [line 428]

void push( DOMNode|DOMNodeList|FluentDOM $elements, [boolean $ignoreTextNodes = FALSE])

Push new element(s) an the internal element list



Tags:

access:  public
uses:  FluentDOMCore::_inList()


Parameters:

DOMNode|DOMNodeList|FluentDOM   $elements  
boolean   $ignoreTextNodes   ignore text nodes

[ Top ]

method setLoaders [line 173]

FluentDOM setLoaders( $loaders $loaders)

Define own loading handlers



Tags:

access:  public
example:  example not found


Parameters:

$loaders   $loaders  

[ Top ]

method spawn [line 413]

FluentDOM spawn( )

Create a new instance of the same class with $this as the parent. This is used for the chaining.



Tags:

access:  public


[ Top ]

method unique [line 458]

array unique( $array)

Sorts an array of DOM nodes based on document position, in place, with the duplicates removed.

Note that this only works on arrays of DOM nodes, not strings or numbers.




Tags:

access:  public


Parameters:

array   $array   array of DOM nodes

[ Top ]

method _applyContentToNodes [line 912]

void _applyContentToNodes( array|DOMNodeList $targetNodes, string|array|DOMElement|DOMText|DOMNodeList|Iterator|callback|Closure $content, callback|Closure $handler)

Use a handler callback to apply a content argument to each node $targetNodes. The content argument can be an easy setter function



Tags:

access:  protected


Parameters:

array|DOMNodeList   $targetNodes  
string|array|DOMElement|DOMText|DOMNodeList|Iterator|callback|Closure   $content  
callback|Closure   $handler  

[ Top ]

method _executeEasySetter [line 943]

array _executeEasySetter( callback|Closure $easySetter, DOMNode $node, integer $index, string $value)

Execute the easy setter function for a node and return the new elements



Tags:

access:  protected


Parameters:

callback|Closure   $easySetter  
DOMNode   $node  
integer   $index  
string   $value  

[ Top ]

method _getContentElement [line 815]

DOMElement _getContentElement( string|array|DOMElement|DOMNodeList|Iterator $content)

Convert $content to a DOMElement. If $content contains several elements use the first.



Tags:

access:  protected


Parameters:

string|array|DOMElement|DOMNodeList|Iterator   $content  

[ Top ]

method _getContentFragment [line 746]

array _getContentFragment( string $content, [boolean $includeTextNodes = TRUE], [integer $limit = 0])

Convert a given content xml string into and array of nodes



Tags:

access:  protected


Parameters:

string   $content  
boolean   $includeTextNodes  
integer   $limit  

[ Top ]

method _getContentNodes [line 775]

array _getContentNodes( string|array|DOMElement|DOMText|Iterator $content, [boolean $includeTextNodes = TRUE], [integer $limit = 0])

Convert a given content into and array of nodes



Tags:

access:  protected


Parameters:

string|array|DOMElement|DOMText|Iterator   $content  
boolean   $includeTextNodes  
integer   $limit  

[ Top ]

method _getContextNodes [line 850]

void _getContextNodes( $selector)



Tags:

access:  protected


Parameters:

   $selector  

[ Top ]

method _getHandler [line 900]

string|object _getHandler( )

Get the class/object providing the handler functions



Tags:

access:  protected


[ Top ]

method _getInnerXml [line 863]

string _getInnerXml( DOMElement $node)

Get the inner xml of a given node or in other words the xml of all children.



Tags:

access:  protected


Parameters:

DOMElement   $node  

[ Top ]

method _getTargetNodes [line 832]

array _getTargetNodes( string|array|DOMNode|DOMNodeList|Iterator $selector)

Get the target nodes from a given $selector.

A string will be used as XPath expression.




Tags:

access:  protected


Parameters:

string|array|DOMNode|DOMNodeList|Iterator   $selector  

[ Top ]

method _initLoaders [line 146]

void _initLoaders( )

Initialize default loaders if they are not already initialized



Tags:

access:  protected


[ Top ]

method _inList [line 602]

boolean _inList( DOMNode $node)

Check if object is already in internal list



Tags:

access:  protected
usedby:  FluentDOMCore::push()


Parameters:

DOMNode   $node  

[ Top ]

method _isCallback [line 719]

boolean _isCallback( callback $callback, boolean $allowGlobalFunctions, boolean $silent)

check if parameter is a valid callback function



Tags:

access:  protected


Parameters:

callback   $callback  
boolean   $allowGlobalFunctions  
boolean   $silent   (no InvalidArgumentException)

[ Top ]

method _isNCName [line 637]

boolean _isNCName( string $name, [integer $offset = 0], [integer $length = 0])

Validate string as qualified node name part (namespace or local name)



Tags:

access:  protected


Parameters:

string   $name   full QName
integer   $offset   Offset of NCName part in QName
integer   $length   Length of NCName part in QName

[ Top ]

method _isNode [line 680]

boolean _isNode( DOMNode $node, [boolean $ignoreTextNodes = FALSE])

Check if the DOMNode is DOMElement or DOMText with content



Tags:

access:  protected


Parameters:

DOMNode   $node  
boolean   $ignoreTextNodes  

[ Top ]

method _isNodeList [line 700]

boolean _isNodeList( $elements, DOMNodeList|DOMDocumentFragment|Iterator|IteratorAggregate|array $list)

Check if $elements is a iterateable node list



Tags:

access:  protected


Parameters:

DOMNodeList|DOMDocumentFragment|Iterator|IteratorAggregate|array   $list  
   $elements  

[ Top ]

method _isQName [line 617]

boolean _isQName( string $name)

Validate string as qualified node name



Tags:

access:  protected


Parameters:

string   $name  

[ Top ]

method _match [line 568]

DOMNodeList _match( string $expr, [DOMNode $context = NULL])

Match XPath expression agains context and return matched elements.



Tags:

access:  protected


Parameters:

string   $expr  
DOMNode   $context   optional, default value NULL

[ Top ]

method _removeNodes [line 883]

array _removeNodes( string|array|DOMNode|DOMNodeList|Iterator $selector)

Remove nodes from document tree



Tags:

return:  removed nodes
access:  protected


Parameters:

string|array|DOMNode|DOMNodeList|Iterator   $selector  

[ Top ]

method _setContentType [line 189]

void _setContentType( string $value)

Setter for FluentDOM::_contentType property



Tags:

access:  protected


Parameters:

string   $value  

[ Top ]

method _test [line 583]

boolean _test( string $expr, [DOMNode $context = NULL])

Test xpath expression against context and return true/false



Tags:

access:  protected


Parameters:

string   $expr  
DOMNode   $context   optional, default value NULL

[ Top ]

method _uniqueSort [line 499]

array _uniqueSort( array $array)

Sorts the selected nodes, with the duplicates removed.



Tags:

access:  protected
uses:  FluentDOMCore::unique


Parameters:

array   $array   array of DOM nodes

[ Top ]

method _xpath [line 542]

DOMXPath _xpath( )

Get a XPath object associated with the internal DOMDocument and register default namespaces from the document element if availiable.



Tags:

access:  protected


[ Top ]

method __get [line 217]

mixed __get( string $name)

implement dynamic properties using magic methods



Tags:

access:  public


Parameters:

string   $name  

[ Top ]

method __isset [line 260]

boolean __isset( string $name)

support isset for dynamic properties length and document



Tags:

access:  public


Parameters:

string   $name  

[ Top ]

method __set [line 239]

void __set( string $name, mixed $value)

block changes of dynamic readonly property length



Tags:

access:  public


Parameters:

string   $name  
mixed   $value  

[ Top ]

method __toString [line 278]

string __toString( )

Return the XML output of the internal dom document



Tags:

access:  public


[ Top ]


Documentation generated on Fri, 30 Jul 2010 01:00:33 +0200 by phpDocumentor 1.4.3