test_manual.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  2. <?php
  3. require_once('../phpQuery/phpQuery.php');
  4. //phpQuery::$debug = 2;
  5. phpQuery::plugin('Scripts');
  6. //$doc = phpQuery::newDocumentXML('<article><someMarkupStuff/><p>p</p></article>');
  7. //print $doc['article']->children(':empty')->get(0)->tagName;
  8. //$doc = phpQuery::newDocumentFile('test.html');
  9. //setlocale(LC_ALL, 'pl_PL.UTF-8');
  10. //$string = strftime('%B %Y', time());
  11. //$doc['p:first']->append($string)->dump();
  12. /*
  13. *
  14. $doc1 = phpQuery::newDocumentFileXHTML('doc1.html');
  15. $doc2 = phpQuery::newDocumentFileXHTML('doc2.html');
  16. $doc3 = phpQuery::newDocumentFileXHTML('doc3.html');
  17. $doc4 = phpQuery::newDocumentFileXHTML('doc4.html');
  18. $doc2['body']
  19. ->append($doc3['body >*'])
  20. ->append($doc4['body >*']);
  21. $doc1['body']
  22. ->append($doc2['body >*']);
  23. print $doc1->plugin('Scripts')->script('safe_print');
  24. */
  25. //$doc = phpQuery::newDocument('<p> p1 <b> b1 </b> <b> b2 </b> </p><p> p2 </p>');
  26. //print $doc['p']->contents()->not('[nodeType=1]');
  27. //print phpQuery::newDocumentFileXML('tmp.xml');
  28. //$doc = phpQuery::newDocumentXML('text<node>node</node>test');
  29. //pq('<p/>', $doc)->insertBefore(pq('node'))->append(pq('node'));
  30. //$doc->contents()->wrap('<p/>');
  31. //$doc['node']->wrapAll('<p/>');
  32. // ->contents()
  33. // ->wrap('<p></p>');
  34. //print $doc;
  35. // http://code.google.com/p/phpquery/issues/detail?id=66
  36. //$doc = phpQuery::newDocumentXML('<p>123<span/>123</p>');
  37. //$doc->dump();
  38. //$doc->children()->wrapAll('<div/>')->dump();
  39. // http://code.google.com/p/phpquery/issues/detail?id=69
  40. //$doc = phpQuery::newDocumentXML('<p class="test">123<span/>123</p>');
  41. //$doc['[class^="test"]']->dump();
  42. // http://code.google.com/p/phpquery/issues/detail?id=71
  43. // $doc = phpQuery::newDocument('<input value=""/>');
  44. // print $doc['input']->val('new')->val();
  45. // http://code.google.com/p/phpquery/issues/detail?id=71
  46. // $doc = phpQuery::newDocument('<select><option value="10">10</option><option value="10">20</option></select>');
  47. // $doc['select']->val('20')->dump();
  48. // http://code.google.com/p/phpquery/issues/detail?id=73
  49. // $doc = phpQuery::newDocument('<input value=""/>');
  50. // var_dump($doc['input']->val(0)->val());
  51. // $a = null;
  52. // new CallbackReference($a);
  53. // phpQuery::callbackRun(new CallbackReference($a), array('new $a value'));
  54. // var_dump($a);
  55. // check next() inside (also, but separatly)
  56. // $inputs->dump();
  57. // foreach($inputs as $node) {
  58. // }
  59. // $inputs->dump();
  60. // http://code.google.com/p/phpquery/issues/detail?id=74
  61. // http://code.google.com/p/phpquery/issues/detail?id=31
  62. //$doc = phpQuery::newDocument('<div class="class1 class2"/><div class="class1"/><div class="class2"/>');
  63. //$doc['div']->filter('.class1, .class2')->dump()->dumpWhois();
  64. // http://code.google.com/p/phpquery/issues/detail?id=76
  65. // mb_internal_encoding("UTF-8");
  66. // mb_regex_encoding("UTF-8");
  67. // $xml = phpQuery::newDocumentXML('<документа/>');
  68. //
  69. // $xml['документа']->append('<список></список>');
  70. // $xml['документа список'] = '<эл>1</эл><эл>2</эл><эл>3</эл>';
  71. // print "<xmp>$xml</xmp>";
  72. // zeromski 0.9.5 vs 0.9.1
  73. // phpQuery::newDocumentXML('<xml><b></xml>')->dump();
  74. // http://code.google.com/p/phpquery/issues/detail?id=77
  75. // phpQuery::newDocumentFile('http://google.com/')
  76. // ->find('body > *')->dumpWhois();
  77. /*$XHTML = <<<EOF
  78. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  79. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  80. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  81. <head>
  82. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  83. <meta http-equiv="Content-Language" content="fr" />
  84. </head>
  85. <body>
  86. <div id="contenu_volets">
  87. <div id="contenu_voletGauche">
  88. <div id="contenu_navigation" class="bloc_arrondi blanc_10_10 administrable">
  89. <div class="bloc_arrondi_haut">
  90. <div class="bloc_arrondi_haut_gauche"></div>
  91. <div class="bloc_arrondi_haut_droit"></div>
  92. </div>
  93. <div class="bloc_arrondi_centre">
  94. <div class="bloc_arrondi_centre1">
  95. <div class="bloc_arrondi_centre2 bloc_contenu administrable_contenu"></div>
  96. </div>
  97. </div>
  98. <div class="bloc_arrondi_bas">
  99. <div class="bloc_arrondi_bas_gauche"></div>
  100. <div class="bloc_arrondi_bas_droit"></div>
  101. </div>
  102. </div>
  103. </div>
  104. <div id="contenu_voletDroit">
  105. <div id="contenu_article" class="bloc_arrondi grisDegrade_10_10_341 administrable
  106. redimensionnable">
  107. <div class="bloc_arrondi_haut">
  108. <div class="bloc_arrondi_haut_gauche"></div>
  109. <div class="bloc_arrondi_haut_droit"></div>
  110. </div>
  111. <div class="bloc_arrondi_centre">
  112. <div class="bloc_arrondi_centre1">
  113. <div class="bloc_arrondi_centre2 bloc_contenu administrable_contenu
  114. WAI_element-40-WAI_principal-30 WAI_contenu">
  115. <p class="contenu_filAriane justifier_non">
  116. Vous êtes ici : <span class="filAriane_contenu"></span>
  117. </p>
  118. <h1 id="IDcmsRef-page-titre">Editorial</h1>
  119. <div id="IDcmsTag_article"></div>
  120. <div class="nettoyeur"></div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="bloc_arrondi_bas">
  125. <div class="bloc_arrondi_bas_gauche"></div>
  126. <div class="bloc_arrondi_bas_droit"></div>
  127. </div>
  128. </div>
  129. </div>
  130. <div id="contenu_voletPied"></div>
  131. </div>
  132. </body>
  133. </html>
  134. EOF;
  135. phpQuery::newDocumentXHTML($XHTML)
  136. ->find('body:first > *')->dumpWhois();*/
  137. // http://code.google.com/p/phpquery/issues/detail?id=83
  138. //$doc = phpQuery::newDocument('<select
  139. //name="toto"><option></option><option value="1">1</option></select><div><input
  140. //type="hidden" name="toto"/></div>');
  141. //print $doc['[name=toto]']->val('1');
  142. //$doc = phpQuery::newDocumentFile('http://www.google.pl/search?hl=en&q=test&btnG=Google+Search');
  143. //print $doc;
  144. // http://code.google.com/p/phpquery/issues/detail?id=88
  145. //$doc = phpQuery::newDocumentXML('<foo><bar/></foo>');
  146. //$doc['foo']->find('bar')->andSelf()->addClass('test');
  147. //$doc->dump();
  148. // http://code.google.com/p/phpquery/issues/detail?id=90
  149. //print phpQuery::newDocument('<html><body></body></html>')
  150. // ->find('body')
  151. // ->load('http://localhost/phpinfo.php');
  152. // http://code.google.com/p/phpquery/issues/detail?id=91
  153. // phpQuery::newDocumentXML('<foo bar="abc"/><foo bar="bca"/>');
  154. // print pq('foo')->filter('[bar$=c]');
  155. // FIXME http://code.google.com/p/phpquery/issues/detail?id=93
  156. //$doc = '<head><title>SomeTitle</title>
  157. //</head>
  158. //<body bgcolor="#ffffff" text="#000000" topmargin="1" leftmargin="0">blah
  159. //</body>';
  160. //$pq = phpQuery::newDocument($doc);
  161. //echo $pq;
  162. # http://code.google.com/p/phpquery/issues/detail?id=94#makechanges
  163. //$doc = phpQuery::newDocument();
  164. //$test = pq(
  165. //'
  166. //<li>
  167. // <label>Fichier : </label>
  168. // <input type="file" name="pjModification_fichier[0]"/>
  169. // <br/>
  170. // <label>Titre : </label>
  171. // <input type="text" name="pjModification_titre[0]" class="pieceJointe_titre"/>
  172. //</li>
  173. //'
  174. //);
  175. // http://code.google.com/p/phpquery/issues/detail?id=96
  176. //$doc = phpQuery::newDocument('<select name="section"><option
  177. //value="-1">Niveau</option><option value="1">6°</option><option
  178. //value="2">5°</option><option
  179. //value="3">4°</option><option value="4">3°</option></select>');
  180. //$doc = phpQuery::newDocument('<select name="section"><option
  181. //value="-1">Niveau</option><option value="1">6°</option><option
  182. //value="2">5°</option><option
  183. //value="3">4°</option><option value="4">3&deg;</option></select>');
  184. //print $doc['select']->val(3)->end()->script('print_source');
  185. //(16:27:56) jomofcw: $option_element =
  186. //(16:27:56) jomofcw: pq('<option/>')
  187. //(16:27:56) jomofcw: ->attr('value',$section['id'])
  188. //(16:27:56) jomofcw: ->html($section['libelle'])
  189. //(16:27:56) jomofcw: ;
  190. //(16:29:27) jomofcw: where $section['libelle'] is from a database UTF-8
  191. //16:30
  192. //(16:30:20) jomofcw: the value of $section['libelle'] is exactly "3&deg;" in database...
  193. # http://code.google.com/p/phpquery/issues/detail?id=98
  194. //$doc = phpQuery::newDocument('<select id="test"><option value="0">a</option><option
  195. //value="10">b</option><option value="20">c</option></select>');
  196. //print $doc['select']->val(0)->end()->script('print_source');
  197. // http://groups.google.com/group/phpquery/browse_thread/thread/1c78f7e41fc5808c?hl=en
  198. //$doc = phpQuery::newDocumentXML("
  199. //<s:Schema id='RowsetSchema'>
  200. // <s:ElementType name='row' content='eltOnly'>
  201. // <s:AttributeType name='ComparteElementoComun_ID' rs:number='1'
  202. //rs:maydefer='true' rs:writeunknown='true'>
  203. // <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
  204. //rs:fixedlength='true'/>
  205. // </s:AttributeType>
  206. // <s:AttributeType name='ComparteElementoComun' rs:number='2'
  207. //rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
  208. // <s:datatype dt:type='string' dt:maxLength='100'/>
  209. // </s:AttributeType>
  210. // <s:extends type='rs:rowbase'/>
  211. // </s:ElementType>
  212. //</s:Schema>");
  213. //foreach($doc['Schema ElementType AttributeType'] as $campo){
  214. // if( count(pq($campo)->find('datatype'))==1 ){
  215. // var_dump(pq($campo)->find('datatype')->attr('dt:type')); // Should print "string" but prints ""
  216. // }
  217. //}
  218. // http://code.google.com/p/phpquery/issues/detail?id=97
  219. //function jsonSuccess($data) {
  220. // var_dump($data);
  221. //}
  222. //$url = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json';
  223. //phpQuery::ajaxAllowHost('api.flickr.com');
  224. //phpQuery::getJSON($url, array('jsoncallback' => '?'), 'jsonSuccess');
  225. //var_dump(json_decode($json));
  226. //require_once('../phpQuery/Zend/Json/Decoder.php');
  227. //var_dump(Zend_Json_Decoder::decode($json));
  228. #var_dump(''.phpQuery::newDocumentFile("http://www.chefkoch.de/magazin/artikel/943,0/AEG-Electrolux/Frischer-Saft-aus-dem-Dampfgarer.html"));
  229. // var_dump(phpQuery::newDocument(
  230. // str_replace('<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
  231. // ', '',
  232. // file_get_contents("http://www.chefkoch.de/magazin/artikel/943,0/AEG-Electrolux/Frischer-Saft-aus-dem-Dampfgarer.html"
  233. // ))));
  234. // http://code.google.com/p/phpquery/issues/detail?id=102
  235. // $doc = phpQuery::newDocumentFileHTML('http://www.google.de');
  236. // //$doc = phpQuery::newDocument('');
  237. // $images = $doc['img']->dump();
  238. //
  239. // $foo = 'aaa';
  240. // var_dump(mb_ereg_match('^[\w|\||-]+$', $foo) || $foo == '*');
  241. // var_dump(preg_match('@^[\w|\||-]+$@', $foo) || $foo == '*');
  242. // http://code.google.com/p/phpquery/issues/detail?id=67
  243. //$doc = phpQuery::newDocumentXML("<node1/><node2/>");
  244. //$doc['node1']->data('foo', 'bar');
  245. //var_dump($doc['node1']->data('foo'));
  246. //$doc['node1']->removeData('foo');
  247. //var_dump($doc['node1']->data('foo'));
  248. //$doc['node1']->data('foo.bar', 'bar');
  249. //var_dump($doc['node1']->data('foo.bar'));
  250. //var_dump(phpQuery::$documents[$doc->getDocumentID()]->data);
  251. // xhtml fragments
  252. //$doc = phpQuery::newDocumentXHTML("<p><br/></p>");
  253. //print $doc;
  254. $doc = phpQuery::newDocument('<div id="content"></div><div id="content"></div>');
  255. //$content_string = str_repeat('a', 99988);
  256. $content_string = str_repeat(str_repeat('a', 350)."\n", 350);
  257. //var_dump(strlen($content_string));
  258. ?><pre class='1'><?php
  259. //print $content_string;
  260. ?></pre><?php
  261. pq('#content')->php('echo $content_string;');
  262. //pq('#content')->php('echo '.var_export($content_string, true));
  263. $doc->dumpTree();
  264. ?><pre class='2'><?php
  265. var_dump($doc->php());
  266. ?></pre><?php
  267. eval('?>'.$doc->php());