当前位置: 首页>>代码示例>>PHP>>正文


PHP phpQuery::isMarkup方法代码示例

本文整理汇总了PHP中phpQuery::isMarkup方法的典型用法代码示例。如果您正苦于以下问题:PHP phpQuery::isMarkup方法的具体用法?PHP phpQuery::isMarkup怎么用?PHP phpQuery::isMarkup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpQuery的用法示例。


在下文中一共展示了phpQuery::isMarkup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

 /**
  * Internal insert method. Don't use it.
  *
  * @param unknown_type $target
  * @param unknown_type $type
  * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  * @access private
  */
 public function insert($target, $type)
 {
     $this->debug("Inserting data with '{$type}'");
     $to = false;
     switch ($type) {
         case 'appendTo':
         case 'prependTo':
         case 'insertBefore':
         case 'insertAfter':
             $to = true;
     }
     switch (gettype($target)) {
         case 'string':
             $insertFrom = $insertTo = array();
             if ($to) {
                 // INSERT TO
                 $insertFrom = $this->elements;
                 if (phpQuery::isMarkup($target)) {
                     // $target is new markup, import it
                     $insertTo = $this->documentWrapper->import($target);
                     // insert into selected element
                 } else {
                     // $tagret is a selector
                     $thisStack = $this->elements;
                     $this->toRoot();
                     $insertTo = $this->find($target)->elements;
                     $this->elements = $thisStack;
                 }
             } else {
                 // INSERT FROM
                 $insertTo = $this->elements;
                 $insertFrom = $this->documentWrapper->import($target);
             }
             break;
         case 'object':
             $insertFrom = $insertTo = array();
             // phpQuery
             if ($target instanceof self) {
                 if ($to) {
                     $insertTo = $target->elements;
                     if ($this->documentFragment && $this->stackIsRoot()) {
                         // get all body children
                         //							$loop = $this->find('body > *')->elements;
                         // TODO test it, test it hard...
                         //							$loop = $this->newInstance($this->root)->find('> *')->elements;
                         $loop = $this->root->childNodes;
                     } else {
                         $loop = $this->elements;
                     }
                     // import nodes if needed
                     $insertFrom = $this->getDocumentID() == $target->getDocumentID() ? $loop : $target->documentWrapper->import($loop);
                 } else {
                     $insertTo = $this->elements;
                     if ($target->documentFragment && $target->stackIsRoot()) {
                         // get all body children
                         //							$loop = $target->find('body > *')->elements;
                         $loop = $target->root->childNodes;
                     } else {
                         $loop = $target->elements;
                     }
                     // import nodes if needed
                     $insertFrom = $this->getDocumentID() == $target->getDocumentID() ? $loop : $this->documentWrapper->import($loop);
                 }
                 // DOMNODE
             } elseif ($target instanceof DOMNODE) {
                 // import node if needed
                 //					if ( $target->ownerDocument != $this->DOM )
                 //						$target = $this->DOM->importNode($target, true);
                 if ($to) {
                     $insertTo = array($target);
                     if ($this->documentFragment && $this->stackIsRoot()) {
                         // get all body children
                         $loop = $this->root->childNodes;
                     } else {
                         $loop = $this->elements;
                     }
                     foreach ($loop as $fromNode) {
                         // import nodes if needed
                         $insertFrom[] = !$fromNode->ownerDocument->isSameNode($target->ownerDocument) ? $target->ownerDocument->importNode($fromNode, true) : $fromNode;
                     }
                 } else {
                     // import node if needed
                     if (!$target->ownerDocument->isSameNode($this->document)) {
                         $target = $this->document->importNode($target, true);
                     }
                     $insertTo = $this->elements;
                     $insertFrom[] = $target;
                 }
             }
             break;
     }
     phpQuery::debug("From " . count($insertFrom) . "; To " . count($insertTo) . " nodes");
//.........这里部分代码省略.........
开发者ID:limi58,项目名称:fetchJD,代码行数:101,代码来源:phpQueryObject.php


注:本文中的phpQuery::isMarkup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。