hQuery.php
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
duzun\hQuery\Node Class Reference
Inheritance diagram for duzun\hQuery\Node:
duzun\hQuery\Context duzun\hQuery\Element duzun\hQuery\HTML_Parser duzun\hQuery

Public Member Functions

 attr ($attr=NULL, $to_str=false)
 
 is_empty ()
 
 isEmpty ()
 
 isDoc ()
 
 doc ()
 
 find ($sel, $attr=NULL)
 
 exclude ($sel, $attr=NULL)
 
 __toString ()
 
 html ($id=NULL)
 
 outerHtml ($id=NULL)
 
 text ($id=NULL)
 
 nodeName ($caseFolding=NULL, $id=NULL)
 
 pos ($restore=true)
 
 _children ($ids=NULL, $n=NULL)
 
 _next ($ids=NULL, $n=0)
 
 _prev ($ids=NULL, $n=0)
 
 _all ($ids=NULL)
 
 _has ($el, $eq=false)
 $el < $this, with $eq == true -> $el <= $this
 
 _filter_contains ($el, $eq=false)
 
 __get ($name)
 
 __set ($name, $value)
 
 __isset ($name)
 
 __unset ($name)
 
 count ()
 
 current ()
 
 valid ()
 
 key ()
 
 next ()
 
 prev ()
 
 rewind ()
 

Static Public Member Functions

static html_normal_pseudoClass ($p)
 
static html_selector2struc ($sel)
 
static html_parseAttrStr ($str, $case_folding=true, $extended=false)
 
static html_attr2str ($attr, $quote='"')
 
static parseCSStr ($str, $case_folding=true)
 
static CSSArr2Str ($css)
 
static str_range ($comp, $pos=0, $len=NULL)
 
static array_select ($arr, $keys, $force_null=false)
 
static convert_encoding ($a, $to, $from=NULL)
 

Public Attributes

const VERSION = '2.0.2'
 
 $tag_map
 

Static Public Attributes

static $last_http_result
 
static $selected_doc = NULL
 
static $_ar_ = array()
 
static $_mi_ = PHP_INT_MAX
 
static $_nl_ = NULL
 
static $_fl_ = false
 
static $_tr_ = true
 

Protected Member Functions

 __construct ($doc, $ids, $is_ctx=false)
 
 _ctx_ids ($ids=NULL)
 
 _sub_ids ($eq=false)
 
 _doc_ids ($el, $force_array=true)
 
 _my_ids ($id=NULL, $keys=false)
 
 _parent ($ids=NULL, $n=0)
 

Static Protected Member Functions

static html_findTagClose ($str, $p)
 

Protected Attributes

 $_prop = array()
 
 $doc
 
 $ids
 
 $exc
 

Detailed Description

Base class for HTML Elements and Documents.

API Documentation at https://duzun.github.io/hQuery.php

MIT

Definition at line 12 of file Node.php.

Member Function Documentation

◆ _ctx_ids()

duzun\hQuery\Node::_ctx_ids (   $ids = NULL)
protected

Make a context array of ids: if x in $ids && exists y in $ids such that x in y then del x from $ids

Returns
array ids

Definition at line 256 of file Node.php.

Referenced by duzun\hQuery\Node\_has(), and duzun\hQuery\Context\intersect().

◆ _doc_ids()

duzun\hQuery\Node::_doc_ids (   $el,
  $force_array = true 
)
protected

Get and Normalize ids of $el

Returns
array ids

Definition at line 299 of file Node.php.

References duzun\hQuery\Node\doc().

Referenced by duzun\hQuery\Node\_filter_contains(), duzun\hQuery\Node\_has(), and duzun\hQuery\Context\intersect().

◆ _filter_contains()

duzun\hQuery\Node::_filter_contains (   $el,
  $eq = false 
)

Filter all ids of $el that are contained in(side) $this->ids

Parameters
hQuery_Node | array$elA node or list of ids
boolean$eqif false, filter strict contents, otherwise $el might be in $this->ids
Returns
hQuery_Node|array same type as $el

Definition at line 591 of file Node.php.

References duzun\hQuery\Node\_doc_ids().

◆ _sub_ids()

duzun\hQuery\Node::_sub_ids (   $eq = false)
protected

Get all ids from inside of this element

Returns
array ids

Definition at line 275 of file Node.php.

References duzun\hQuery\Node\doc().

◆ attr()

duzun\hQuery\Node::attr (   $attr = NULL,
  $to_str = false 
)

Get and attribute or all attributes of first element in the collection.

Parameters
string$attrattribute name, or NULL to get all
boolean$to_strWhen $attr is NULL, if true, get the list of attributes as string
Returns
array|string If no $attr, return a list of attributes, or attribute's value otherwise.

Definition at line 62 of file Node.php.

References duzun\hQuery\Node\doc().

◆ doc()

duzun\hQuery\Node::doc ( )

◆ find()

duzun\hQuery\Node::find (   $sel,
  $attr = NULL 
)

Finds a collection of nodes inside current document/context (similar to jQuery.fn.find()).

Parameters
string$sel- A valid CSS selector (some pseudo-selectors supported).
array | string$attr- OPTIONAL attributes as string or key-value pairs.
hQuery_Node$ctx- OPTIONAL the context where to search. If omitted, $this is used.
Returns
hQuery_Element collection of matched elements or NULL

Definition at line 101 of file Node.php.

References duzun\hQuery\Node\doc().

◆ html()

duzun\hQuery\Node::html (   $id = NULL)
Returns
string .innerHTML

Definition at line 142 of file Node.php.

Referenced by duzun\hQuery\Node\text().

◆ html_normal_pseudoClass()

static duzun\hQuery\Node::html_normal_pseudoClass (   $p)
static

Normalize a CSS selector pseudo-class string. ( int, string or array(name => value) )

Returns
int|array

Definition at line 663 of file Node.php.

◆ html_selector2struc()

static duzun\hQuery\Node::html_selector2struc (   $sel)
static

Parse a selector string into an array structure.

tn1::id1 .cl1.cl2:first tn2:5 , tn3.cl3 tn4::id2:eq(-1) > tn5:last-child > tn6:lt(3) –> [ [ [{ n: "tn1", i: "id1", c: [], p: [] }], [{ n: NULL, i: NULL, c: ["cl1","cl2"], p: [0] }], [{ n: "tn2", i: NULL, c: [], p: [5] }] ] , [ [{ n: "tn3", i: NULL, c: ["cl3"], p: [] }], [ { n: "tn4", i: "id2", c: [], p: [-1] }, { n: "tn5", i: NULL , c: [], p: [-1] }, { n: "tn6", i: NULL , c: [], p: ["<3"] } ] ] ]

Returns
array

Definition at line 723 of file Node.php.

◆ nodeName()

duzun\hQuery\Node::nodeName (   $caseFolding = NULL,
  $id = NULL 
)
Returns
string .nodeName

Definition at line 194 of file Node.php.

References duzun\hQuery\Node\doc().

◆ outerHtml()

duzun\hQuery\Node::outerHtml (   $id = NULL)
Returns
string .outerHtml

Definition at line 165 of file Node.php.

References duzun\hQuery\Node\doc().

◆ pos()

duzun\hQuery\Node::pos (   $restore = true)

Get string offset of the first/current element in the source HTML document.

Contents of #test

| pos()

Parameters
bool$restore- if true, restore internal pointer to previous position
Returns
int

Definition at line 237 of file Node.php.

◆ text()

duzun\hQuery\Node::text (   $id = NULL)
Returns
string .innerText

Definition at line 187 of file Node.php.

References duzun\hQuery\Node\html().


The documentation for this class was generated from the following file: