本文整理汇总了PHP中phpQuery::importMarkup方法的典型用法代码示例。如果您正苦于以下问题:PHP phpQuery::importMarkup方法的具体用法?PHP phpQuery::importMarkup怎么用?PHP phpQuery::importMarkup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpQuery
的用法示例。
在下文中一共展示了phpQuery::importMarkup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pq
/**
* Enter description here...
*
* @return false|phpQuery|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
*/
public static function pq($arg1, $context = null)
{
// TODO support DOMNodes as $context, find out ownerDocument, search loaded DOMs
if (!$context) {
$domId = self::$lastDomId;
} else {
if ($context instanceof self) {
$domId = $context->domId;
} else {
if ($context instanceof DOMDOCUMENT) {
foreach (phpQuery::$documents as $id => $document) {
if ($context->isSameNode($document['document'])) {
$domId = $id;
}
}
if (!$domId) {
throw new Exception('Orphaned DOMNode');
// $domId = self::newDocument($context);
}
} else {
if ($context instanceof DOMNODE) {
foreach (phpQuery::$documents as $id => $document) {
if ($context->ownerDocument->isSameNode($document['document'])) {
$domId = $id;
}
}
if (!$domId) {
throw new Exception('Orphaned DOMNode');
// $domId = self::newDocument($context->ownerDocument);
}
} else {
$domId = $context;
}
}
}
}
if ($arg1 instanceof self) {
/**
* Return $arg1 or import $arg1 stack if document differs:
* pq(pq('<div/>'))
*/
if ($arg1->domId == $domId) {
return $arg1;
}
$phpQuery = new phpQuery($domId);
$phpQuery->elements = array();
foreach ($arg1->elements as $node) {
$phpQuery->elements[] = $phpQuery->DOM->importNode($node, true);
}
return $phpQuery;
} else {
if ($arg1 instanceof DOMNODE || is_array($arg1) && isset($arg1[0]) && $arg[0] instanceof DOMNODE) {
/**
* Wrap DOM nodes with phpQuery object, import into document when needed:
* pq(array($domNode1, $domNode2))
*/
$phpQuery = new phpQuery($domId);
if (!$arg1 instanceof DOMNODELIST && !is_array($arg1)) {
$arg1 = array($arg1);
}
$phpQuery->elements = array();
foreach ($arg1 as $node) {
$phpQuery->elements[] = !$node->ownerDocument->isSameNode($phpQuery->DOM) ? $phpQuery->DOM->importNode($node, true) : $node;
}
return $phpQuery;
} else {
if (self::isMarkup($arg1)) {
/**
* Import HTML:
* pq('<div/>')
*/
$phpQuery = new phpQuery($domId);
$phpQuery->importMarkup($arg1);
return $phpQuery;
} else {
/**
* Run CSS query:
* pq('div.myClass')
*/
$phpQuery = new phpQuery($domId);
if ($context && $context instanceof self) {
$phpQuery->elements = $context->elements;
} else {
if ($context && $context instanceof DOMNODELIST) {
$phpQuery->elements = array();
foreach ($context as $node) {
$phpQuery->elements[] = $node;
}
} else {
if ($context && $context instanceof DOMNODE) {
$phpQuery->elements = array(DOMNODE);
}
}
}
return $phpQuery->find($arg1);
//.........这里部分代码省略.........