當前位置: 首頁>>代碼示例>>PHP>>正文


PHP phpQuery::newDocumentXHTML方法代碼示例

本文整理匯總了PHP中phpQuery::newDocumentXHTML方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpQuery::newDocumentXHTML方法的具體用法?PHP phpQuery::newDocumentXHTML怎麽用?PHP phpQuery::newDocumentXHTML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在phpQuery的用法示例。


在下文中一共展示了phpQuery::newDocumentXHTML方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_defaults

 /**
  * checks that an empty form is initialized correctly
  */
 function test_defaults()
 {
     global $INPUT;
     global $ID;
     $ID = 'some:test';
     $INPUT->get->set('id', $ID);
     $INPUT->get->set('foo', 'bar');
     $form = new Form\Form();
     $html = $form->toHTML();
     $pq = phpQuery::newDocumentXHTML($html);
     $this->assertTrue($pq->find('form')->hasClass('doku_form'));
     $this->assertEquals(wl($ID, array('foo' => 'bar'), false, '&'), $pq->find('form')->attr('action'));
     $this->assertEquals('post', $pq->find('form')->attr('method'));
     $this->assertTrue($pq->find('input[name=sectok]')->length == 1);
 }
開發者ID:richmahn,項目名稱:Door43,代碼行數:18,代碼來源:form.test.php

示例2: test_prefill

 /**
  * check that posted values overwrite preset default
  */
 function test_prefill()
 {
     global $INPUT;
     $INPUT->post->set('foo', 'second');
     $form = new Form\Form();
     $form->addRadioButton('foo', 'label text first')->val('first')->attr('checked', 'checked');
     $form->addRadioButton('foo', 'label text second')->val('second');
     $html = $form->toHTML();
     $pq = phpQuery::newDocumentXHTML($html);
     $inputs = $pq->find('input[name=foo]');
     $this->assertEquals('first', pq($inputs->elements[0])->val());
     $this->assertEquals('second', pq($inputs->elements[1])->val());
     $this->assertEquals('', pq($inputs->elements[0])->attr('checked'));
     $this->assertEquals('checked', pq($inputs->elements[1])->attr('checked'));
 }
開發者ID:richmahn,項目名稱:Door43,代碼行數:18,代碼來源:checkableelement.test.php

示例3: PqDocument

 /**
  * Creates phpQuery document from string or file.
  * Options: 
  * FixHtml (True|False): Clean content by HtmlFormatter
  * phpQuery is a server-side, chainable, CSS3 selector driven Document Object Model (DOM),
  * API based on jQuery JavaScript Library. 
  * More information: http://code.google.com/p/phpquery/
  * 
  * @param mixed $Document, string, file or url.
  * @return PhpQueryDocument object.
  */
 function PqDocument($Document, $Options = False)
 {
     if (!function_exists('Pq')) {
         require_once USEFULFUNCTIONS_VENDORS . '/phpQuery.php';
     }
     $Cache = GetValue('Cache', $Options);
     if ($Cache) {
         $Name = Crc32Value($Options);
         if ($Cache === True) {
             $Name = Crc32Value($Document, $Name);
         }
         $CacheDirectory = PATH_CACHE . '/PqDocument';
         if (!is_dir($CacheDirectory)) {
             mkdir($CacheDirectory, 0777, True);
         }
         $CacheFile = $CacheDirectory . DS . $Name . '.php';
         if (file_exists($CacheFile)) {
             $IncludeCache = True;
             if (is_numeric($Cache)) {
                 $Created = filemtime($CacheFile);
                 $LifeTime = time() - $Created;
                 if ($LifeTime > $Cache) {
                     // Cache expired.
                     $IncludeCache = False;
                 }
             }
             if ($IncludeCache) {
                 $Document = (include $CacheFile);
                 return phpQuery::newDocumentXHTML($Document);
             }
         }
     }
     if (strpos($Document, '<') === False) {
         if (is_file($Document) || substr($Document, 0, 7) == 'http://') {
             $Document = file_get_contents($Document);
         }
     }
     if (ArrayValue('ConvertEncoding', $Options)) {
         $Document = ConvertEncoding($Document);
     }
     if (ArrayValue('FixHtml', $Options, True)) {
         $HtmlFormatter = Gdn::Factory('HtmlFormatter');
         if ($HtmlFormatter) {
             $Document = $HtmlFormatter->Format($Document);
         }
     } elseif (ArrayValue('Body', $Options, False)) {
         $BodyPos1 = strpos($Document, '<body');
         $EndTag = '</body>';
         $BodyPos2 = strrpos($Document, $EndTag);
         if ($BodyPos1 !== False) {
             if ($BodyPos2 === False) {
                 $Document = substr($Document, $BodyPos1);
             } else {
                 $Document = substr($Document, $BodyPos1, strlen($Document) - $BodyPos1 - strlen($EndTag));
             }
         }
     }
     if ($Cache) {
         $Contents = "<?php if(!defined('APPLICATION')) exit(); \nreturn " . var_export($Document, True) . ';';
         file_put_contents($CacheFile, $Contents);
     }
     return phpQuery::newDocumentXHTML($Document);
 }
開發者ID:unlight,項目名稱:UsefulFunctions,代碼行數:74,代碼來源:functions.text.php

示例4: PqDocument

 /**
  * Creates phpQuery document from string or file.
  * Options: 
  * FixHtml (True|False): Clean content by HtmlFormatter
  * phpQuery is a server-side, chainable, CSS3 selector driven Document Object Model (DOM),
  * API based on jQuery JavaScript Library. 
  * More information: http://code.google.com/p/phpquery/
  * 
  * @param mixed $Document, string, file or url.
  * @return PhpQueryDocument object.
  */
 function PqDocument($Document, $Options = False)
 {
     if (!function_exists('Pq')) {
         require_once USEFULFUNCTIONS_VENDORS . '/phpQuery.php';
     }
     if (strpos($Document, '<') === False) {
         if (is_file($Document) || substr($Document, 0, 7) == 'http://') {
             $Document = file_get_contents($Document);
         }
     }
     if (ArrayValue('ConvertEncoding', $Options)) {
         $Document = ConvertEncoding($Document);
     }
     if (ArrayValue('FixHtml', $Options, True)) {
         $HtmlFormatter = Gdn::Factory('HtmlFormatter');
         if ($HtmlFormatter) {
             $Document = $HtmlFormatter->Format($Document);
         }
     }
     return phpQuery::newDocumentXHTML($Document);
 }
開發者ID:ru4,項目名稱:arabbnota,代碼行數:32,代碼來源:functions.text.php


注:本文中的phpQuery::newDocumentXHTML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。