PHP Class phpQuery, microweber

ファイルを表示 Open project: microweber/microweber Class Usage Examples

Public Properties

Property Type Description
$active
$ajaxAllowedHosts array Dot '.' means $_SERVER['HTTP_HOST'] (if any).
$ajaxSettings array AJAX settings.
$debug
$defaultCharset
$defaultDoctype unknown_type Applies only to HTML.
$defaultDocumentID
$documents
$dumpCount
$extendMethods
$extendStaticMethods
$lastModified
$mbstringSupport boolean XXX: Workaround for mbstring problems.
$plugins object Static namespace for plugins.
$pluginsLoaded unknown_type List of loaded plugins.
$pluginsMethods
$pluginsStaticMethods

Public Methods

Method Description
DOMNodeListToArray ( $DOMNodeList )
__callStatic ( $method, $params )
__destruct ( ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery | QueryTemplatesPhpQuery | false Multi-purpose function.
_markupToPHPCallback ( $m )
_phpToMarkupCallback ( $php, $charset = 'utf-8' )
ajax ( $options = [], $xhr = null ) : Zend_Http_Client Make an AJAX request.
ajaxAllowHost ( $host1, $host2 = null, $host3 = null )
ajaxAllowURL ( $url1, $url2 = null, $url3 = null )
ajaxSetup ( $options )
browser ( $ajaxSettings, $callback, $param1 = null, $param2 = null, $param3 = null ) : phpQueryObject
browserGet ( $url, $callback, $param1 = null, $param2 = null, $param3 = null ) : phpQueryObject
browserPost ( $url, $data, $callback, $param1 = null, $param2 = null, $param3 = null ) : phpQueryObject
callbackRun ( $callback, $params = [], $paramStructure = null ) : unknown_type
code ( $type, $code ) : string
data ( $node, $name, $data, $documentID = null )
debug ( $text )
each ( $object, $callback, $param1 = null, $param2 = null, $param3 = null ) : unknown_type
extend ( string | array $target, array $source ) : unknown_type Extend class namespace.
get ( $url, $data = null, $callback = null, $type = null )
getDOMDocument ( $source ) : string Get DOMDocument object related to $source.
getDocument ( unknown_type $id = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Returns document with id $id or last used as phpQueryObject.
getDocumentID ( $source ) : string Returns source's document ID.
getJSON ( $url, $data = null, $callback = null )
grep ( $array, $callback, $invert = false ) : unknown_type
inArray ( $value, $array )
isFunction ( $function ) : unknown_type
isMarkup ( string $input ) : boolean Checks if $input is HTML string, which has to start with '<'.
loadDocument ( $document ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Reuses existing DOMDocument object.
makeArray ( $obj ) : unknown_type
map ( $array, $callback, $param1 = null, $param2 = null, $param3 = null )
markupToPHP ( string | phpQueryObject $content ) : string Converts document markup containing PHP code generated by phpQuery::php() into valid (executable) PHP code syntax.
merge ( array $one, array $two ) Merge 2 phpQuery objects.
newDocument ( unknown_type $markup = null, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentFile ( string $file, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from file $file.
newDocumentFileHTML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentFilePHP ( $file, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentFileXHTML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentFileXML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentHTML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentPHP ( unknown_type $markup = null, $contentType = 'text/html' ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentXHTML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
newDocumentXML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery Creates new document from markup.
param ( array | phpQuery $data ) Enter description here.
parseJSON ( string $json ) : mixed Parses JSON into proper PHP type.
php ( $code ) : string
phpToMarkup ( $php, $charset = 'utf-8' )
plugin ( string $class, string $file = null ) Extend phpQuery with $class from $file.
post ( $url, $data = null, $callback = null, $type = null )
pq ( $arg1, $context = null )
removeData ( $node, $name, $documentID )
selectDocument ( unknown_type $id ) Sets default document to $id. Document has to be loaded prior to using this method.
toJSON ( mixed $data ) : string Returns JSON representation of $data.
trim ( $str )
unique ( $array )
unloadDocuments ( $id = null ) Unloades all or specified document from memory.
unsafePHPTags ( phpQuery | string $content ) : string Parses phpQuery object or HTML result against PHP tags and makes them active.

Protected Methods

Method Description
createDocumentWrapper ( unknown_type $html, $contentType = null, $documentID = null ) : unknown Enter description here.
dataRemoveNode ( $node, $documentID )
dataSetupNode ( $node, $documentID )
httpData ( $data, $type, $options )

Method Details

DOMNodeListToArray() public static method

public static DOMNodeListToArray ( $DOMNodeList )

__callStatic() public static method

public static __callStatic ( $method, $params )

__destruct() public method

Use pq() as shortcut. In below examples, $pq is any result of pq(); function. 1. Import markup into existing document (without any attaching): - Import into selected document: pq('
') // DOESNT accept text nodes at beginning of input string ! - Import into document with ID from $pq->getDocumentID(): pq('
', $pq->getDocumentID()) - Import into same document as DOMNode belongs to: pq('
', DOMNode) - Import into document from phpQuery object: pq('
', $pq) 2. Run query: - Run query on last selected document: pq('div.myClass') - Run query on document with ID from $pq->getDocumentID(): pq('div.myClass', $pq->getDocumentID()) - Run query on same document as DOMNode belongs to and use node(s)as root for query: pq('div.myClass', DOMNode) - Run query on document from phpQuery object and use object's stack as root node(s) for query: pq('div.myClass', $pq)
public __destruct ( ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery | QueryTemplatesPhpQuery | false
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery | QueryTemplatesPhpQuery | false phpQuery object or false in case of error.

_markupToPHPCallback() public static method

public static _markupToPHPCallback ( $m )

_phpToMarkupCallback() public static method

public static _phpToMarkupCallback ( $php, $charset = 'utf-8' )

ajax() public static method

Make an AJAX request.
public static ajax ( $options = [], $xhr = null ) : Zend_Http_Client
return Zend_Http_Client

ajaxAllowHost() public static method

public static ajaxAllowHost ( $host1, $host2 = null, $host3 = null )

ajaxAllowURL() public static method

public static ajaxAllowURL ( $url1, $url2 = null, $url3 = null )

ajaxSetup() public static method

public static ajaxSetup ( $options )

browser() public static method

public static browser ( $ajaxSettings, $callback, $param1 = null, $param2 = null, $param3 = null ) : phpQueryObject
$ajaxSettings
$callback
$param1
$param2
$param3
return phpQueryObject

browserGet() public static method

public static browserGet ( $url, $callback, $param1 = null, $param2 = null, $param3 = null ) : phpQueryObject
$url
$callback
$param1
$param2
$param3
return phpQueryObject

browserPost() public static method

public static browserPost ( $url, $data, $callback, $param1 = null, $param2 = null, $param3 = null ) : phpQueryObject
$url
$data
$callback
$param1
$param2
$param3
return phpQueryObject

callbackRun() public static method

public static callbackRun ( $callback, $params = [], $paramStructure = null ) : unknown_type
$callback Callback
$params
$paramStructure
return unknown_type

code() public static method

public static code ( $type, $code ) : string
$type
$code
return string

createDocumentWrapper() protected static method

..
protected static createDocumentWrapper ( unknown_type $html, $contentType = null, $documentID = null ) : unknown
$html unknown_type
return unknown New DOM ID

data() public static method

public static data ( $node, $name, $data, $documentID = null )

dataRemoveNode() protected static method

protected static dataRemoveNode ( $node, $documentID )

dataSetupNode() protected static method

protected static dataSetupNode ( $node, $documentID )

debug() public static method

public static debug ( $text )

each() public static method

public static each ( $object, $callback, $param1 = null, $param2 = null, $param3 = null ) : unknown_type
$object
$callback
return unknown_type

extend() public static method

Extend class namespace.
public static extend ( string | array $target, array $source ) : unknown_type
$target string | array
$source array
return unknown_type

get() public static method

public static get ( $url, $data = null, $callback = null, $type = null )

getDOMDocument() public static method

Returns null if such document doesn't exist.
public static getDOMDocument ( $source ) : string
$source DOMNode|phpQueryObject|string
return string

getDocument() public static method

$id can be retrived via getDocumentID() or getDocumentIDRef(). Chainable.
See also: phpQuery::selectDocument()
public static getDocument ( unknown_type $id = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$id unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

getDocumentID() public static method

Returns source's document ID.
public static getDocumentID ( $source ) : string
$source DOMNode|phpQueryObject
return string

getJSON() public static method

public static getJSON ( $url, $data = null, $callback = null )

grep() public static method

public static grep ( $array, $callback, $invert = false ) : unknown_type
$array
$callback
$invert
return unknown_type

httpData() protected static method

protected static httpData ( $data, $type, $options )

inArray() public static method

public static inArray ( $value, $array )

isFunction() public static method

public static isFunction ( $function ) : unknown_type
$function
return unknown_type

isMarkup() public static method

Checks if $input is HTML string, which has to start with '<'.
Deprecation:
public static isMarkup ( string $input ) : boolean
$input string
return boolean

loadDocument() public static method

Chainable.
public static loadDocument ( $document ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$document DOMDocument
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

makeArray() public static method

public static makeArray ( $obj ) : unknown_type
return unknown_type

map() public static method

public static map ( $array, $callback, $param1 = null, $param2 = null, $param3 = null )

markupToPHP() public static method

Converts document markup containing PHP code generated by phpQuery::php() into valid (executable) PHP code syntax.
public static markupToPHP ( string | phpQueryObject $content ) : string
$content string | phpQueryObject
return string PHP code.

merge() public static method

Merge 2 phpQuery objects.
public static merge ( array $one, array $two )
$one array
$two array

newDocument() public static method

Chainable.
public static newDocument ( unknown_type $markup = null, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentFile() public static method

Chainable.
public static newDocumentFile ( string $file, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$file string URLs allowed. See File wrapper page at php.net for more supported sources.
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentFileHTML() public static method

Chainable.
public static newDocumentFileHTML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentFilePHP() public static method

Chainable.
public static newDocumentFilePHP ( $file, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentFileXHTML() public static method

Chainable.
public static newDocumentFileXHTML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentFileXML() public static method

Chainable.
public static newDocumentFileXML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentHTML() public static method

Chainable.
public static newDocumentHTML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentPHP() public static method

Chainable.
public static newDocumentPHP ( unknown_type $markup = null, $contentType = 'text/html' ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentXHTML() public static method

Chainable.
public static newDocumentXHTML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

newDocumentXML() public static method

Chainable.
public static newDocumentXML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery

param() public static method

..
public static param ( array | phpQuery $data )
$data array | phpQuery

parseJSON() public static method

Parses JSON into proper PHP type.
public static parseJSON ( string $json ) : mixed
$json string
return mixed

php() public static method

public static php ( $code ) : string
$code
return string

phpToMarkup() public static method

public static phpToMarkup ( $php, $charset = 'utf-8' )

plugin() public static method

Extend phpQuery with $class from $file.
public static plugin ( string $class, string $file = null )
$class string Extending class name. Real class name can be prepended phpQuery_.
$file string Filename to include. Defaults to "{$class}.php".

post() public static method

public static post ( $url, $data = null, $callback = null, $type = null )

pq() public static method

public static pq ( $arg1, $context = null )

removeData() public static method

public static removeData ( $node, $name, $documentID )

selectDocument() public static method

$id can be retrived via getDocumentID() or getDocumentIDRef().
public static selectDocument ( unknown_type $id )
$id unknown_type

toJSON() public static method

Returns JSON representation of $data.
public static toJSON ( mixed $data ) : string
$data mixed
return string

trim() public static method

public static trim ( $str )

unique() public static method

public static unique ( $array )

unloadDocuments() public static method

Unloades all or specified document from memory.
public static unloadDocuments ( $id = null )

unsafePHPTags() public static method

Parses phpQuery object or HTML result against PHP tags and makes them active.
Deprecation:
public static unsafePHPTags ( phpQuery | string $content ) : string
$content phpQuery | string
return string

Property Details

$active public_oe static_oe property

public static $active

$ajaxAllowedHosts public_oe static_oe property

Dot '.' means $_SERVER['HTTP_HOST'] (if any).
public static array $ajaxAllowedHosts
return array

$ajaxSettings public_oe static_oe property

AJAX settings.
public static array $ajaxSettings
return array

$debug public_oe static_oe property

public static $debug

$defaultCharset public_oe static_oe property

public static $defaultCharset

$defaultDoctype public_oe static_oe property

Applies only to HTML.
public static unknown_type $defaultDoctype
return unknown_type

$defaultDocumentID public_oe static_oe property

public static $defaultDocumentID

$documents public_oe static_oe property

public static $documents

$dumpCount public_oe static_oe property

public static $dumpCount

$extendMethods public_oe static_oe property

public static $extendMethods

$extendStaticMethods public_oe static_oe property

public static $extendStaticMethods

$lastModified public_oe static_oe property

public static $lastModified

$mbstringSupport public_oe static_oe property

XXX: Workaround for mbstring problems.
public static bool $mbstringSupport
return boolean

$plugins public_oe static_oe property

Static namespace for plugins.
public static object $plugins
return object

$pluginsLoaded public_oe static_oe property

List of loaded plugins.
public static unknown_type $pluginsLoaded
return unknown_type

$pluginsMethods public_oe static_oe property

public static $pluginsMethods

$pluginsStaticMethods public_oe static_oe property

public static $pluginsStaticMethods