當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。