当前位置: 首页>>代码示例>>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;未经允许,请勿转载。