diff --git a/Ajax.md b/Ajax.md new file mode 100644 index 0000000..10160d5 --- /dev/null +++ b/Ajax.md @@ -0,0 +1,70 @@ +## Example ## +``` +pq('#element')->load('http://somesite.com/page .inline-selector')->... +``` +# Table of Contents # + * [Server Side Ajax](#Server_Side_Ajax.md) + * [Cross Domain Ajax](#Cross_Domain_Ajax.md) + * [Ajax Requests](#Ajax_Requests.md) + * [Ajax Events](#Ajax_Events.md) + * [Misc](#Misc.md) +## Server Side Ajax ## +Ajax, standing for _Asynchronous JavaScript and XML_ is combination of HTTP Client and XML parser which doesn't lock program's thread (doing request in asynchronous way). + +**phpQuery** also offers such functionality, making use of solid quality [Zend\_Http\_Client](http://framework.zend.com/manual/en/zend.http.html). Unfortunately requests aren't asynchronous, but nothing is impossible. For today, instead of [XMLHttpRequest](http://en.wikipedia.org/wiki/XMLHttpRequest) you always get Zend\_Http\_Client instance. API unification is [planned](http://code.google.com/p/phpquery/issues/detail?id=44). +## Cross Domain Ajax ## +For security reasons, by default **phpQuery** doesn't allow connections to hosts other than actual `$_SERVER['HTTP_HOST']`. Developer needs to grant rights to other hosts before making an [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) request. + +There are 2 methods for allowing other hosts + * phpQuery::**ajaxAllowURL**($url) + * phpQuery::**ajaxAllowHost**($host) + +``` +// connect to google.com +phpQuery::ajaxAllowHost('google.com'); +phpQuery::get('http://google.com/ig'); +// or using same string +$url = 'http://google.com/ig'; +phpQuery::ajaxAllowURL($url); +phpQuery::get($url); +``` +## Ajax Requests ## + * **[phpQuery::ajax](http://docs.jquery.com/Ajax/jQuery.ajax)**[($options)](http://docs.jquery.com/Ajax/jQuery.ajax) Load a remote page using an HTTP request. + * **[load](http://docs.jquery.com/Ajax/load)**[($url, $data, $callback)](http://docs.jquery.com/Ajax/load) Load HTML from a remote file and inject it into the DOM. + * **[phpQuery::get](http://docs.jquery.com/Ajax/jQuery.get)**[($url, $data, $callback)](http://docs.jquery.com/Ajax/jQuery.get) Load a remote page using an HTTP GET request. + * **[phpQuery::getJSON](http://docs.jquery.com/Ajax/jQuery.getJSON)**[($url, $data, $callback)](http://docs.jquery.com/Ajax/jQuery.getJSON) Load JSON data using an HTTP GET request. + * **[phpQuery::getScript](http://docs.jquery.com/Ajax/jQuery.getScript)**[($url, $callback)](http://docs.jquery.com/Ajax/jQuery.getScript) Loads, and executes, a local JavaScript file using an HTTP GET request. + * **[phpQuery::post](http://docs.jquery.com/Ajax/jQuery.post)**[($url, $data, $callback, $type)](http://docs.jquery.com/Ajax/jQuery.post) Load a remote page using an HTTP POST request. +## Ajax Events ## + * **[ajaxComplete](http://docs.jquery.com/Ajax/ajaxComplete)**[($callback)](http://docs.jquery.com/Ajax/ajaxComplete) Attach a function to be executed whenever an AJAX request completes. This is an Ajax Event. + * **[ajaxError](http://docs.jquery.com/Ajax/ajaxError)**[($callback)](http://docs.jquery.com/Ajax/ajaxError) Attach a function to be executed whenever an AJAX request fails. This is an Ajax Event. + * **[ajaxSend](http://docs.jquery.com/Ajax/ajaxSend)**[($callback)](http://docs.jquery.com/Ajax/ajaxSend) Attach a function to be executed before an AJAX request is sent. This is an Ajax Event. + * **[ajaxStart](http://docs.jquery.com/Ajax/ajaxStart)**[($callback)](http://docs.jquery.com/Ajax/ajaxStart) Attach a function to be executed whenever an AJAX request begins and there is none already active. This is an Ajax Event. + * **[ajaxStop](http://docs.jquery.com/Ajax/ajaxStop)**[($callback)](http://docs.jquery.com/Ajax/ajaxStop) Attach a function to be executed whenever all AJAX requests have ended. This is an Ajax Event. + * **[ajaxSuccess](http://docs.jquery.com/Ajax/ajaxSuccess)**[($callback)](http://docs.jquery.com/Ajax/ajaxSuccess) Attach a function to be executed whenever an AJAX request completes successfully. This is an Ajax Event. +## Misc ## + * **[phpQuery::ajaxSetup](http://docs.jquery.com/Ajax/jQuery.ajaxSetup)**[($options)](http://docs.jquery.com/Ajax/jQuery.ajaxSetup) Setup global settings for AJAX requests. + * **[serialize](http://docs.jquery.com/Ajax/serialize)**[()](http://docs.jquery.com/Ajax/serialize) Serializes a set of input elements into a string of data. This will serialize all given elements. + * **[serializeArray](http://docs.jquery.com/Ajax/serializeArray)**[()](http://docs.jquery.com/Ajax/serializeArray) Serializes all forms and form elements (like the .serialize() method) but returns a JSON data structure for you to work with. +## Options ## +Detailed options description in available at [jQuery Documentation Site](http://docs.jquery.com/Ajax/jQuery.ajax#toptions). + * **`async`** `Boolean` + * **`beforeSend`** `Function` + * **`cache`** `Boolean` + * **`complete`** `Function` + * **`contentType`** `String` + * **`data`** `Object, String` + * **`dataType`** `String` + * **`error`** `Function` + * **`global`** `Boolean` + * **`ifModified`** `Boolean` + * **`jsonp`** `String` + * **`password`** `String` + * **`processData`** `Boolean` + * **`success`** `Function` + * **`timeout`** `Number` + * **`type`** `String` + * **`url`** `String` + * **`username`** `String` + +Read more at [Ajax](http://docs.jquery.com/Ajax) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/Attributes.md b/Attributes.md new file mode 100644 index 0000000..1381d91 --- /dev/null +++ b/Attributes.md @@ -0,0 +1,33 @@ +## Example ## +``` +pq('a')->attr('href', 'newVal')->removeClass('className')->html('newHtml')->... +``` +# Table of Contents # + * [Attr](#Attr.md) + * [Class](#Class.md) + * [HTML](#HTML.md) + * [Text](#Text.md) + * [Value](#Value.md) +## Attr ## + * **[attr](http://docs.jquery.com/Attributes/attr)**[($name)](http://docs.jquery.com/Attributes/attr) Access a property on the first matched element. This method makes it easy to retrieve a property value from the first matched element. If the element does not have an attribute with such a name, undefined is returned. + * **[attr](http://docs.jquery.com/Attributes/attr)**[($properties)](http://docs.jquery.com/Attributes/attr) Set a key/value object as properties to all matched elements. + * **[attr](http://docs.jquery.com/Attributes/attr)**[($key, $value)](http://docs.jquery.com/Attributes/attr) Set a single property to a value, on all matched elements. + * **[attr](http://docs.jquery.com/Attributes/attr)**[($key, $fn)](http://docs.jquery.com/Attributes/attr) Set a single property to a computed value, on all matched elements. + * **[removeAttr](http://docs.jquery.com/Attributes/removeAttr)**[($name)](http://docs.jquery.com/Attributes/removeAttr) Remove an attribute from each of the matched elements. +## Class ## + * **[addClass](http://docs.jquery.com/Attributes/addClass)**[($class)](http://docs.jquery.com/Attributes/addClass) Adds the specified class(es) to each of the set of matched elements. + * **[hasClass](http://docs.jquery.com/Attributes/hasClass)**[($class)](http://docs.jquery.com/Attributes/hasClass) Returns true if the specified class is present on at least one of the set of matched elements. + * **[removeClass](http://docs.jquery.com/Attributes/removeClass)**[($class)](http://docs.jquery.com/Attributes/removeClass) Removes all or the specified class(es) from the set of matched elements. + * **[toggleClass](http://docs.jquery.com/Attributes/toggleClass)**[($class)](http://docs.jquery.com/Attributes/toggleClass) Adds the specified class if it is not present, removes the specified class if it is present. +## HTML ## + * **[html](http://docs.jquery.com/Attributes/html)**[()](http://docs.jquery.com/Attributes/html) Get the html contents (innerHTML) of the first matched element. This property is not available on XML documents (although it will work for XHTML documents). + * **[html](http://docs.jquery.com/Attributes/html)**[($val)](http://docs.jquery.com/Attributes/html) Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents). +## Text ## + * **[text](http://docs.jquery.com/Attributes/text)**[()](http://docs.jquery.com/Attributes/text) Get the combined text contents of all matched elements. + * **[text](http://docs.jquery.com/Attributes/text)**[($val)](http://docs.jquery.com/Attributes/text) Set the text contents of all matched elements. +## Value ## + * **[val](http://docs.jquery.com/Attributes/val)**[()](http://docs.jquery.com/Attributes/val) Get the content of the value attribute of the first matched element. + * **[val](http://docs.jquery.com/Attributes/val)**[($val)](http://docs.jquery.com/Attributes/val) Set the value attribute of every matched element. + * **[val](http://docs.jquery.com/Attributes/val)**[($val)](http://docs.jquery.com/Attributes/val) Checks, or selects, all the radio buttons, checkboxes, and select options that match the set of values. + +Read more at [Attributes](http://docs.jquery.com/Attributes) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/Basics.md b/Basics.md new file mode 100644 index 0000000..309a8b1 --- /dev/null +++ b/Basics.md @@ -0,0 +1,54 @@ +## Example ## +``` +phpQuery::newDocumentFileXHTML('my-xhtml.html')->find('p'); +$ul = pq('ul'); +``` +# Table of Contents # + * [Loading documents](#Loading_documents.md) + * [pq() function](#pq_function.md) + +## Loading documents ## + * phpQuery::**newDocument**($html, $contentType = null) Creates new document from markup. If no $contentType, autodetection is made (based on markup). If it fails, text/html in utf-8 is used. + * phpQuery::**newDocumentFile**($file, $contentType = null) Creates new document from file. Works like newDocument() + * phpQuery::**newDocumentHTML**($html, $charset = 'utf-8') + * phpQuery::**newDocumentXHTML**($html, $charset = 'utf-8') + * phpQuery::**newDocumentXML**($html, $charset = 'utf-8') + * phpQuery::**newDocumentPHP**($html, $contentType = null) Read more about it on [PHPSupport page](http://code.google.com/p/phpquery/wiki/PHPSupport) + * phpQuery::**newDocumentFileHTML**($file, $charset = 'utf-8') + * phpQuery::**newDocumentFileXHTML**($file, $charset = 'utf-8') + * phpQuery::**newDocumentFileXML**($file, $charset = 'utf-8') + * phpQuery::**newDocumentFilePHP**($file, $contentType) Read more about it on [PHPSupport page](http://code.google.com/p/phpquery/wiki/PHPSupport) +## pq function ## +**`pq($param, $context = null);`** + +**pq();** function is equivalent of jQuery's **$();**. It's used for 3 type of things: + 1. Importing markup +``` +// Import into selected document: +// doesn't accept text nodes at beginning of input string +pq('
') +// Import into document with ID from $pq->getDocumentID(): +pq('
', $pq->getDocumentID()) +// Import into same document as DOMNode belongs to: +pq('
', DOMNode) +// Import into document from phpQuery object: +pq('
', $pq) +``` + 1. Running queries +``` +// Run query on last selected document: +pq('div.myClass') +// Run query on document with ID from $pq->getDocumentID(): +pq('div.myClass', $pq->getDocumentID()) +// Run query on same document as DOMNode belongs to and use node(s)as root for query: +pq('div.myClass', DOMNode) +// Run query on document from phpQuery object +// and use object's stack as root node(s) for query: +pq('div.myClass', $pq) +``` + 1. Wrapping DOMNodes with phpQuery objects +``` +foreach(pq('li') as $li) + // $li is pure DOMNode, change it to phpQuery object + pq($li); +``` \ No newline at end of file diff --git a/CSS.md b/CSS.md new file mode 100644 index 0000000..e1a913a --- /dev/null +++ b/CSS.md @@ -0,0 +1 @@ +Work in progress. Scheduled before 1.0. \ No newline at end of file diff --git a/Callbacks.md b/Callbacks.md new file mode 100644 index 0000000..e47a904 --- /dev/null +++ b/Callbacks.md @@ -0,0 +1,91 @@ +# Table of Contents # + * [What are callbacks](#What_are_callbacks.md) + * [phpQuery callback system](#phpQuery_callbacks.md) + * [Callback class](#Callback.md) + * [CallbackParam class](#CallbackParam.md) + * [CallbackReference class](#CallbackReference.md) + * [Scope Pseudo-Inheritance](#Scope_Pseudo_Inheritance.md) +## What are callbacks ## +Callbacks are functions _called back_ by other functions in proper moment (eg on [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) request error). + +In **JavaScript** this pattern can be very flexible due to [Closures](http://en.wikipedia.org/wiki/Closure_(computer_science)) support, which can be inline (no code break) and inherits scope (no need to passing params). + +**PHP** has only simple [support for callbacks](http://pl2.php.net/manual/en/function.call-user-func-array.php) so the case is more complicated. That's why phpQuery extends callback support by it's own. +## phpQuery callback system ## +phpQuery uses it's own approach to callbacks. This task is achieved thou **Callback**, **CallbackParam** and **CallbackReference** classes. +### Callback ### +Callback class is used for wrapping valid callbacks with params. +#### Example 1 #### +``` +function myCallback($param1, $param2) { + var_dump($param1); + var_dump($param2); +} +phpQuery::get($url, + new Callback('myCallback', 'myParam1', new CallbackParam) +); +// now $param1 in myCallback will have value 'myParam1' +// and $param2 will be parameter passed by function calling callback +// which in this example would be ajax request result +``` +### CallbackParam ### +As we can see in [last example](#Example_1.md), new instance of CallbackParam class is used for defining places, where original callback parameter(s) will be placed. Such pattern can be used also without Callback class for some methods. +#### Example 2 #### +``` +phpQuery::each( + // first param is array which will be iterated + array(1,2,3), + // second param is callback (string or array to call objects method) + 'myCallback', + // rest of params are ParamStructure + // CallbackParam objects will be changed to $i and $v by phpQuery::each method + 'param1', new CallbackParam, new CallbackParam, 'param4' +); +function myCallback($param1, $i, $v, $param4) { + print "Index: $i; Value: $v"; +} +``` +Methods supporting CallbackParam **without** using Callback class: + * `phpQuery::each()` + * `phpQuery::map()` + * `pq()->each()` + * `pq()->map()` +### CallbackReference ### +Finally, CallbackReference can be used when we don't really want a callback, only parameter passed to it. CallbackReference takes first parameter's value and passes it to reference. Thanks to that, we can use **if statement** instead of **callback function**. +#### Example 3 #### +``` +$html; +phpQuery::get($url, new CallbackReference($html)); +if ($html) { + // callback triggered, value non-false + phpQuery::get($url, new CallbackReference($html)); + if ($html) { + // we just skipped 2 function declarations + } +} +``` +## Scope Pseudo Inheritance ## +There is an easy way to pseudo inherit scope in PHP. [Scope](http://en.wikipedia.org/wiki/Scope_(programming)) means _variables accessible in specified point of code_ (which in other words means _any variable you can use_). It's achieved using [compact()](http://php.net/compact) and [extract()](http://php.net/extract) functions. +#### Example 4 #### +Look at this modified [example 2](#Example_2.md). Previous comments were removed. +``` +$a = 'foo'; +$b = 'bar'; +phpQuery::each( + array(1,2,3), + 'myCallback', + // notice that 'param1' changed to compact('a', 'b') + // where 'a' and 'b' are variable names accessible in actual scope + compact('a', 'b'), new CallbackParam, new CallbackParam, 'param4' +); +function myCallback($scope, $i, $v, $param4) { + // this is the place where variables from $scope array + // are forwarded to actual function's scope + extract($scope); + print "Var a: $a"; // will print 'Var a: foo' + print "Var b: $b"; // will print 'Var a: bar' + print "Index: $i; Value: $v"; +} +``` +## Future ## +In the future this functionality will be extended and more methods will support it. Check [Issue Tracker entry #48](http://code.google.com/p/phpquery/issues/detail?id=48) if you're interested in any way. \ No newline at end of file diff --git a/Chains.md b/Chains.md new file mode 100644 index 0000000..2ff4028 --- /dev/null +++ b/Chains.md @@ -0,0 +1 @@ +TODO ;) \ No newline at end of file diff --git a/CommandLineInterface.md b/CommandLineInterface.md new file mode 100644 index 0000000..92dd774 --- /dev/null +++ b/CommandLineInterface.md @@ -0,0 +1,14 @@ +phpQuery features CommandLineInterface aka CLI. +``` +Usage: phpquery URL --method1 arg1 arg2 argN --method2 arg1 arg2 argN ... +Example: phpquery 'http://localhost' --find 'div > p' --contents +Pipe: cat index.html | phpquery --find 'div > p' --contents +Docs: http://code.google.com/p/phpquery/wiki/ +``` +## Example ## +Fetch number of downloads of all release packages. +``` +phpquery 'http://code.google.com/p/phpquery/downloads/list?can=1' \ + --find '.vt.col_4 a' --contents \ + --getString null array_sum +``` \ No newline at end of file diff --git a/Debugging.md b/Debugging.md new file mode 100644 index 0000000..f290347 --- /dev/null +++ b/Debugging.md @@ -0,0 +1,16 @@ +## Enabling debugging ## +``` +// enable debugging messages +phpQuery::$debug = 1; +// enable extensive debugging messages +// used to debug document loading errors from phpQuery::newDocument() +phpQuery::$debug = 2; +``` +## Debugging methods ## +``` +// debug inside chain +pq('.foo')->dump()->...; +pq('.foo')->dumpWhois()->...; +pq('.foo')->dumpTree()->...; +pq('.foo')->dumpDie()->...; +``` \ No newline at end of file diff --git a/Dependencies.md b/Dependencies.md new file mode 100644 index 0000000..67bcba3 --- /dev/null +++ b/Dependencies.md @@ -0,0 +1,14 @@ +**phpQuery** depends on following code parts: + * [PHP5](#PHP5.md) + * [PHP5 DOM extension](#DOM_extension.md) + * [Zend Framework](#Zend_Framework.md) + +## PHP5 ## +Required version of PHP is [PHP5](http://www.php.net/), **5.2** recommended. + +## DOM extension ## +PHP5's build-in [DOM extension](http://php.net/manual/en/book.dom.php) is required. Users of +[windows XAMPP](http://www.apachefriends.org/en/xampp-windows.html) (and maybe other unofficial PHP distributions) need to disable depracated [DOM XML](http://php.net/manual/en/ref.domxml.php) extension. More information can be found in [this post on mrclay.org](http://mrclay.org/index.php/2008/10/08/getting-phpquery-running-under-xampp-for-windows/) + +## Zend Framework ## +[Zend Framework](http://framework.zend.com/) is used as HTTP Client and JSON encoder. Those who already have Zend Framework in their applications, can remove directory **/phpQuery/Zend**. Only condition is having proper include path set for own copy of the library. \ No newline at end of file diff --git a/Events.md b/Events.md new file mode 100644 index 0000000..c1c8079 --- /dev/null +++ b/Events.md @@ -0,0 +1,47 @@ +# Table of Contents # + * [Example](#Example.md) + * [Server Side Events](#Server_Side_Events.md) + * [Page Load](#Page_Load.md) + * [Event Handling](#Event_Handling.md) + * [Interaction Helpers](#Interaction_Helpers.md) + * [Event Helpers](#Event_Helpers.md) + +## Example ## +``` +pq('form')->bind('submit', 'submitHandler')->trigger('submit')->... +function submitHandler($e) { + print 'Target: '.$e->target->tagName; + print 'Bubbling ? '.$e->currentTarget->tagName; +} +``` + +## Server Side Events ## +phpQuery support **server-side** events, same as jQuery handle client-side ones. On server there isn't, of course, events such as _mouseover_ (but they can be triggered). + +By default, phpQuery automatically fires up only **change** event for form elements. If you load WebBrowser plugin, **submit** and **click** will be handled properly - eg submitting form with inputs' data to action URL via new [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) request. + +$this (`this` in JS) context for handler scope **isn't available**. You have to use one of following manually: + * $event->**target** + * $event->**currentTarget** + * $event->**relatedTarget** + +## Page Load ## +_none_ + +## Event Handling ## + * **[bind](http://docs.jquery.com/Events/bind)**[($type, $data, $fn)](http://docs.jquery.com/Events/bind) Binds a handler to one or more events (like click) for each matched element. Can also bind custom events. + * **[one](http://docs.jquery.com/Events/one)**[($type, $data, $fn)](http://docs.jquery.com/Events/one) Binds a handler to one or more events to be executed once for each matched element. + * **[trigger](http://docs.jquery.com/Events/trigger)**[($type , $data )](http://docs.jquery.com/Events/trigger) Trigger a type of event on every matched element. + * **[triggerHandler](http://docs.jquery.com/Events/triggerHandler)**[($type , $data )](http://docs.jquery.com/Events/triggerHandler) This particular method triggers all bound event handlers on an element (for a specific event type) WITHOUT executing the browsers default actions. + * **[unbind](http://docs.jquery.com/Events/unbind)**[($type , $data )](http://docs.jquery.com/Events/unbind) This does the opposite of bind, it removes bound events from each of the matched elements. + +## Interaction Helpers ## +_none_ + +## Event Helpers ## + * **[change](http://docs.jquery.com/Events/change)**[()](http://docs.jquery.com/Events/change) Triggers the change event of each matched element. + * **[change](http://docs.jquery.com/Events/change)**[($fn)](http://docs.jquery.com/Events/change) Binds a function to the change event of each matched element. + * **[submit](http://docs.jquery.com/Events/submit)**[()](http://docs.jquery.com/Events/submit) Trigger the submit event of each matched element. + * **[submit](http://docs.jquery.com/Events/submit)**[($fn)](http://docs.jquery.com/Events/submit) Bind a function to the submit event of each matched element. + +Read more at [Events](http://docs.jquery.com/Events) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/LibrarySections.md b/LibrarySections.md new file mode 100644 index 0000000..d6a3885 --- /dev/null +++ b/LibrarySections.md @@ -0,0 +1 @@ +Renamed to [Manual](http://code.google.com/p/phpquery/wiki/Manual). \ No newline at end of file diff --git a/Manipulation.md b/Manipulation.md new file mode 100644 index 0000000..8d96a8d --- /dev/null +++ b/Manipulation.md @@ -0,0 +1,45 @@ +## Example ## +``` +pq('div.old')->replaceWith( pq('div.new')->clone() )->appendTo('.trash')->prepend('Deleted')->... +``` +# Table of Contents # + * [Changing Contents](#Changing_Contents.md) + * [Inserting Inside](#Inserting_Inside.md) + * [Inserting Outside](#Inserting_Outside.md) + * [Inserting Around](#Inserting_Around.md) + * [Replacing](#Replacing.md) + * [Removing](#Removing.md) + * [Copying](#Copying.md) +## Changing Contents ## + * **[html](http://docs.jquery.com/Manipulation/html)**[()](http://docs.jquery.com/Manipulation/html) Get the html contents (innerHTML) of the first matched element. This property is not available on XML documents (although it will work for XHTML documents). + * **[html](http://docs.jquery.com/Manipulation/html)**[($val)](http://docs.jquery.com/Manipulation/html) Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents). + * **[text](http://docs.jquery.com/Manipulation/text)**[()](http://docs.jquery.com/Manipulation/text) Get the combined text contents of all matched elements. + * **[text](http://docs.jquery.com/Manipulation/text)**[($val)](http://docs.jquery.com/Manipulation/text) Set the text contents of all matched elements. +## Inserting Inside ## + * **[append](http://docs.jquery.com/Manipulation/append)**[($content)](http://docs.jquery.com/Manipulation/append) Append content to the inside of every matched element. + * **[appendTo](http://docs.jquery.com/Manipulation/appendTo)**[($content)](http://docs.jquery.com/Manipulation/appendTo) Append all of the matched elements to another, specified, set of elements. + * **[prepend](http://docs.jquery.com/Manipulation/prepend)**[($content)](http://docs.jquery.com/Manipulation/prepend) Prepend content to the inside of every matched element. + * **[prependTo](http://docs.jquery.com/Manipulation/prependTo)**[($content)](http://docs.jquery.com/Manipulation/prependTo) Prepend all of the matched elements to another, specified, set of elements. +## Inserting Outside ## + * **[after](http://docs.jquery.com/Manipulation/after)**[($content)](http://docs.jquery.com/Manipulation/after) Insert content after each of the matched elements. + * **[before](http://docs.jquery.com/Manipulation/before)**[($content)](http://docs.jquery.com/Manipulation/before) Insert content before each of the matched elements. + * **[insertAfter](http://docs.jquery.com/Manipulation/insertAfter)**[($content)](http://docs.jquery.com/Manipulation/insertAfter) Insert all of the matched elements after another, specified, set of elements. + * **[insertBefore](http://docs.jquery.com/Manipulation/insertBefore)**[($content)](http://docs.jquery.com/Manipulation/insertBefore) Insert all of the matched elements before another, specified, set of elements. +## Inserting Around ## + * **[wrap](http://docs.jquery.com/Manipulation/wrap)**[($html)](http://docs.jquery.com/Manipulation/wrap) Wrap each matched element with the specified HTML content. + * **[wrap](http://docs.jquery.com/Manipulation/wrap)**[($elem)](http://docs.jquery.com/Manipulation/wrap) Wrap each matched element with the specified element. + * **[wrapAll](http://docs.jquery.com/Manipulation/wrapAll)**[($html)](http://docs.jquery.com/Manipulation/wrapAll) Wrap all the elements in the matched set into a single wrapper element. + * **[wrapAll](http://docs.jquery.com/Manipulation/wrapAll)**[($elem)](http://docs.jquery.com/Manipulation/wrapAll) Wrap all the elements in the matched set into a single wrapper element. + * **[wrapInner](http://docs.jquery.com/Manipulation/wrapInner)**[($html)](http://docs.jquery.com/Manipulation/wrapInner) Wrap the inner child contents of each matched element (including text nodes) with an HTML structure. + * **[wrapInner](http://docs.jquery.com/Manipulation/wrapInner)**[($elem)](http://docs.jquery.com/Manipulation/wrapInner) Wrap the inner child contents of each matched element (including text nodes) with a DOM element. +## Replacing ## + * **[replaceWith](http://docs.jquery.com/Manipulation/replaceWith)**[($content)](http://docs.jquery.com/Manipulation/replaceWith) Replaces all matched elements with the specified HTML or DOM elements. + * **[replaceAll](http://docs.jquery.com/Manipulation/replaceAll)**[($selector)](http://docs.jquery.com/Manipulation/replaceAll) Replaces the elements matched by the specified selector with the matched elements. +## Removing ## + * **[empty](http://docs.jquery.com/Manipulation/empty)**[()](http://docs.jquery.com/Manipulation/empty) Remove all child nodes from the set of matched elements. + * **[remove](http://docs.jquery.com/Manipulation/remove)**[($expr)](http://docs.jquery.com/Manipulation/remove) Removes all matched elements from the DOM. +## Copying ## + * **[clone](http://docs.jquery.com/Manipulation/clone)**[()](http://docs.jquery.com/Manipulation/clone) Clone matched DOM Elements and select the clones. + * **[clone](http://docs.jquery.com/Manipulation/clone)**[($true)](http://docs.jquery.com/Manipulation/clone) Clone matched DOM Elements, and all their event handlers, and select the clones. + +Read more at [Manipulation](http://docs.jquery.com/Manipulation) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/Manual.md b/Manual.md new file mode 100644 index 0000000..8eb8868 --- /dev/null +++ b/Manual.md @@ -0,0 +1,21 @@ + 1. [Basics](http://code.google.com/p/phpquery/wiki/Basics) + 1. [Ported jQuery sections](http://code.google.com/p/phpquery/wiki/jQueryPortingState) + 1. [Selectors](http://code.google.com/p/phpquery/wiki/Selectors) + 1. [Attributes](http://code.google.com/p/phpquery/wiki/Attributes) + 1. [Traversing](http://code.google.com/p/phpquery/wiki/Traversing) + 1. [Manipulation](http://code.google.com/p/phpquery/wiki/Manipulation) + 1. [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) + 1. [Events](http://code.google.com/p/phpquery/wiki/Events) + 1. [Utilities](http://code.google.com/p/phpquery/wiki/Utilities) + 1. [Plugin ports](http://code.google.com/p/phpquery/wiki/PluginsClientSidePorts) + 1. [PHP Support](http://code.google.com/p/phpquery/wiki/PHPSupport) + 1. [Command Line Interface](http://code.google.com/p/phpquery/wiki/CommandLineInterface) + 1. [Multi document support](http://code.google.com/p/phpquery/wiki/MultiDocumentSupport) + 1. [Plugins](http://code.google.com/p/phpquery/wiki/PluginsServerSide) + 1. [WebBrowser](http://code.google.com/p/phpquery/wiki/WebBrowser) + 1. [Scripts](http://code.google.com/p/phpquery/wiki/ScriptsPlugin) + 1. [jQueryServer](http://code.google.com/p/phpquery/wiki/jQueryServer) + 1. [Debugging](http://code.google.com/p/phpquery/wiki/Debugging) + 1. Bootstrap file + +**[API Reference](http://meta20.net/phpquery-api/)** is also available. \ No newline at end of file diff --git a/MultiDocumentSupport.md b/MultiDocumentSupport.md new file mode 100644 index 0000000..07691a0 --- /dev/null +++ b/MultiDocumentSupport.md @@ -0,0 +1,53 @@ +## What MultiDocumentSupport is ## + * support for working on several documents in same time + * easy importing of nodes from one document to another + * pointing document thought + * phpQuery object + * [DOMNode](http://www.php.net/manual/en/class.domnode.php) object + * [DOMDocument](http://www.php.net/manual/en/class.domdocument.php) object + * internal document ID + * last created (or selected) document is assumed to be default in pq(); +## What MultiDocumentSupport is NOT ## + * it's **not possible** to fetch nodes from several document in one query + * it's **not possible** to operate on nodes from several document in one phpQuery object + +## Example ## +``` +// first three documents are wrapped inside phpQuery +$doc1 = phpQuery::newDocumentFile('my-file.html'); +$doc2 = phpQuery::newDocumentFile('my-file.html'); +$doc3 = phpQuery::newDocumentFile('my-other-file.html'); +// $doc4 is plain DOMDocument +$doc4 = new DOMDocument; +$doc4->loadHTMLFile('my-file.html'); +// find first UL list in $doc1 +$doc1->find('ul:first') + // append all LIs from $doc2 (node import) + ->append( $doc2->find('li') ) + // append UL (with new LIs) into $doc3 BODY (node import) + ->appendTo( $doc3->find('body') ); +// this will find all LIs from $doc3 +// thats because it was created as last one +pq('li'); +// this will find all LIs inside first UL in $doc2 (context query) +pq('li', $doc2->find('ul:first')->get()); +// this will find all LIs in whole $doc2 (not a context query) +pq('li', $doc2->find('ul:first')->getDocumentID()); +// this will transparently load $doc4 into phpQuery::$documents +// and then all LIs will be found +// TODO this example must be verified +pq('li', $doc4); +``` +## Static Methods ## + * phpQuery::**newDocument**($html) Creates new document from markup + * phpQuery::**newDocumentFile**($file) Creates new document from file + * phpQuery::**getDocument**($id = null) Returns phpQueryObject containing document with id $id or default document (last created/selected) + * phpQuery::**selectDocument**($id) Sets default document to $id + * phpQuery::**unloadDocuments**($id = null) Unloades all or specified document from memory + * phpQuery::**getDocumentID**($source) Returns $source's document ID + * phpQuery::**getDOMDocument**($source) Get DOMDocument object related to $source +## Object Methods ## + * $pq->**getDocument**() Returns object with stack set to document root + * $pq->**getDocumentID**() Get object's Document ID + * $pq->**getDocumentIDRef**(&$documentID) Saves object's DocumentID to $var by reference + * $pq->**unloadDocument**() Unloads whole document from memory \ No newline at end of file diff --git a/PHPSupport.md b/PHPSupport.md new file mode 100644 index 0000000..f51ce39 --- /dev/null +++ b/PHPSupport.md @@ -0,0 +1,78 @@ +Although **phpQuery** is a [jQuery port](http://code.google.com/p/phpquery/wiki/jQueryPortingState), there is extensive PHP-specific support. + +# Table of Contents # + * [Class Interfaces](#Class_Interfaces.md) + * [Iterator Interface](#Iterator.md) + * [ArrayAccess](#Array_Access.md) + * [Countable Interface](#Countable.md) + * [Callbacks](http://code.google.com/p/phpquery/wiki/Callbacks) + * [PHP Code Support](#PHP_Code_Support.md) + * [Opening PHP files as DOM](#Opening_PHP_files_as_DOM.md) + * [Inputting PHP code](#Inputting_PHP_code.md) + * [Outputting PHP code](#Outputting_PHP_code.md) + +## Class Interfaces ## +phpQuery implements some of [Standard PHP Library (SPL)](http://pl.php.net/spl) interfaces. +#### Iterator #### +Iterator interface allows looping objects thou native PHP **foreach loop**. Example: +``` +// get all direct LI elements from UL list of class 'im-the-list' +$LIs = pq('ul.im-the-list > li'); +foreach($LIs as $li) { + pq($li)->addClass('foreached'); +} +``` +Now there is a catch above. Foreach loop **doesn't return phpQuery object**. Instead it returns pure DOMNode. That's how jQuery does, because not always you need **phpQuery** when you found interesting nodes. +#### Array Access #### +If you like writing arrays, with phpQuery you can still do it, thanks to the ArrayAccess interface. +``` +$pq = phpQuery::newDocumentFile('somefile.html'); +// print first list outer HTML +print $pq['ul:first']; +// change INNER HTML of second LI directly in first UL +$pq['ul:first > li:eq(1)'] = 'new inner html of second LI directly in first UL'; +// now look at the difference (outer vs inner) +print $pq['ul:first > li:eq(1)']; +// will print
  • new inner html of second LI directly in first UL
  • +``` +#### Countable #### +If used to do `count($something)` you can still do this that way, instead of eg `pq('p')->size()`. +``` +// count all direct LIs in first list +print count(pq('ul:first > li')); +``` +## Callbacks ## +There is a special [Callbacks](http://code.google.com/p/phpquery/wiki/Callbacks) wiki section, to which you should refer to. +## PHP Code Support ## +#### Opening PHP files as DOM #### +PHP files can be opened using **phpQuery::newDocumentPHP($markup)** or **phpQuery::newDocumentFilePHP($file)**. Such files are visible as DOM, where: + * PHP tags beetween DOM elements are available (queryable) as ` ...code... ` + * PHP tags inside attributes are HTML entities + * PHP tags between DOM element's attributes are **not yet supported** +#### Inputting PHP code #### +Additional methods allows placing PHP code inside DOM. Below each method visible is it's logic equivalent. + * **attrPHP**($attr, $code) + * [attr](http://docs.jquery.com/Attributes/attr)($attr, "") + * **addClassPHP**($code) + * [addClass](http://docs.jquery.com/Attributes/addClass)("") + * **beforePHP**($code) + * [before](http://docs.jquery.com/Manipulation/before)("") + * **afterPHP**($code) + * [after](http://docs.jquery.com/Manipulation/after)("") + * **prependPHP**($code) + * [prepend](http://docs.jquery.com/Manipulation/prepend)("") + * **appendPHP**($code) + * [append](http://docs.jquery.com/Manipulation/append)("") + * **php**($code) + * [html](http://docs.jquery.com/Manipulation/html)("") + * **wrapAllPHP**($codeBefore, $codeAfter) + * [wrapAll](http://docs.jquery.com/Manipulation/wrapAll)("") + * **wrapPHP**($codeBefore, $codeAfter) + * [wrap](http://docs.jquery.com/Manipulation/wrap)("") + * **wrapInnerPHP**($codeBefore, $codeAfter) + * [wrapInner](http://docs.jquery.com/Manipulation/wrapInner)("") + * **replaceWithPHP**($code) + * [replaceWith](http://docs.jquery.com/Manipulation/replaceWith)("") +#### Outputting PHP code #### +Code inserted with methods above won't be returned as valid (runnable) using classic output methods such as **html()**. To make it work, **php()** method without parameter have to be used. Optionaly **phpQuery::markupToPHP($markup)** can activate tags in string outputed before. +**REMEMBER** Outputing runnable code and placing it on webserver is always dangerous ! \ No newline at end of file diff --git a/PluginsClientSidePorts.md b/PluginsClientSidePorts.md new file mode 100644 index 0000000..90763da --- /dev/null +++ b/PluginsClientSidePorts.md @@ -0,0 +1,7 @@ +In [Issue Tracker](http://code.google.com/p/phpquery/issues/list) there is a list of [plugins which are planned to be ported](http://code.google.com/p/phpquery/issues/list?can=2&q=label%3APort). +## JSON ## +Port of [JSON](http://jollytoad.googlepages.com/json.js) plugin. +``` +$jsonString = phpQuery::toJSON( pq('form')->serializeArray() ); +$array = phpQuery::parseJSON('{"foo": "bar"}'); +``` \ No newline at end of file diff --git a/phpQuery/phpQuery/plugins/example.php b/PluginsServerSide.md similarity index 66% rename from phpQuery/phpQuery/plugins/example.php rename to PluginsServerSide.md index 732f05c..21f111e 100644 --- a/phpQuery/phpQuery/plugins/example.php +++ b/PluginsServerSide.md @@ -1,19 +1,19 @@ -plugin('example') - * pq('ul')->plugin('example', 'example.php') - * - * Plugin classes are never intialized, just method calls are forwarded - * in static way from phpQuery. - * - * Have fun writing plugins :) - */ +If you need to write plugin only for simple task, write a **script** using ScriptsPlugin. + +## Using plugins ## +Plugins are loaded using **plugin** method from phpQueryObject or phpQuery static namespace. +``` +// all calls to plugin below are equal +phpQuery::plugin('example') +phpQuery::plugin('example', 'example.php') +pq('ul')->plugin('example') +pq('ul')->plugin('example', 'example.php') +``` +## Writing plugins ## +Plugin consist from 2 classes - first extending **phpQueryObjects** (result of pq(); function) and second, extending static **phpQuery::$plugins** namespace. Plugin classes are never intialized, just method calls are forwarded in static way from phpQuery. +#### Extending phpQueryObject #### +``` /** * phpQuery plugin class extending phpQuery object. * Methods from this class are callable on every phpQuery object. @@ -49,7 +49,9 @@ protected static function helperFunction() { // because it isn't publicly callable } } - +``` +#### Extending phpQuery #### +``` /** * phpQuery plugin class extending phpQuery static namespace. * Methods from this class are callable as follows: @@ -72,4 +74,4 @@ public static function staticMethod() { // phpQuery::$plugins->staticMethod() } } -?> \ No newline at end of file +``` \ No newline at end of file diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..ede8766 --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,147 @@ +# phpQuery - pq(); # +**phpQuery** is a server-side, chainable, CSS3 selector driven Document Object Model (DOM) API [based on](http://code.google.com/p/phpquery/wiki/jQueryPortingState) [jQuery JavaScript Library](http://jquery.com/). + +Library is written in [PHP5](http://code.google.com/p/phpquery/wiki/Dependencies) and provides additional [Command Line Interface](http://code.google.com/p/phpquery/wiki/CommandLineInterface) (CLI). + +## PEAR installation ## +``` +pear channel-discover phpquery-pear.appspot.com +pear install phpquery/phpQuery +``` + +## `GitHub` ## +Fork & pull request: [github.com/TobiaszCudnik/phpquery](https://github.com/TobiaszCudnik/phpquery). + +## [Download](http://code.google.com/p/phpquery/downloads/list) ## + * [Available packages](http://code.google.com/p/phpquery/downloads/list) ([rss](http://code.google.com/feeds/p/phpquery/downloads/basic)) + * [Release notes](http://phpquery-library.blogspot.com/search/label/release) + * Bugs: [active](http://code.google.com/p/phpquery/issues/list?can=2&q=label%3AType-Defect) / [fixed](http://code.google.com/p/phpquery/issues/list?can=1&q=label%3AType-Defect%20status%3AFixed) + * [Dependencies](http://code.google.com/p/phpquery/wiki/Dependencies) + * [SVN checkout](http://code.google.com/p/phpquery/wiki/SVNCheckout) + +## [Manual](http://code.google.com/p/phpquery/wiki/Manual) ## + 1. [Basics](http://code.google.com/p/phpquery/wiki/Basics) + 1. [Ported jQuery sections](http://code.google.com/p/phpquery/wiki/jQueryPortingState) + 1. [Selectors](http://code.google.com/p/phpquery/wiki/Selectors) + 1. [Attributes](http://code.google.com/p/phpquery/wiki/Attributes) + 1. [Traversing](http://code.google.com/p/phpquery/wiki/Traversing) + 1. [Manipulation](http://code.google.com/p/phpquery/wiki/Manipulation) + 1. [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) + 1. [Events](http://code.google.com/p/phpquery/wiki/Events) + 1. [Utilities](http://code.google.com/p/phpquery/wiki/Utilities) + 1. [Plugin ports](http://code.google.com/p/phpquery/wiki/PluginsClientSidePorts) + 1. [PHP Support](http://code.google.com/p/phpquery/wiki/PHPSupport) + 1. [Command Line Interface](http://code.google.com/p/phpquery/wiki/CommandLineInterface) + 1. [Multi document support](http://code.google.com/p/phpquery/wiki/MultiDocumentSupport) + 1. [Plugins](http://code.google.com/p/phpquery/wiki/PluginsServerSide) + 1. [WebBrowser](http://code.google.com/p/phpquery/wiki/WebBrowser) + 1. [Scripts](http://code.google.com/p/phpquery/wiki/ScriptsPlugin) + 1. [jQueryServer](http://code.google.com/p/phpquery/wiki/jQueryServer) + 1. [Debugging](http://code.google.com/p/phpquery/wiki/Debugging) + 1. Bootstrap file + +## Documentation ## + * **[Wiki](http://code.google.com/p/phpquery/w/list)** + * [Manual](http://code.google.com/p/phpquery/wiki/Manual) + * [API reference](http://meta20.net/phpquery-api/) + * [jQuery documentation wiki](http://docs.jquery.com/Main_Page) + * [CHM version](http://www.box.net/index.php?rm=box_download_shared_file&file_id=f_196697302&shared_name=p5gk0bnk94) + * [CheatSheet](http://colorcharge.com/wp-content/uploads/2007/12/jquery12_colorcharge.png) + +## Publications ## + * **[Official blog](http://phpquery-library.blogspot.com/)** with latest [release notes](http://phpquery-library.blogspot.com/search/label/release) + * [Author's blog](http://tobiasz123.wordpress.com/) with [examples and new feature sneak peaks](http://tobiasz123.wordpress.com/tag/phpquery/) + * Follow **[phpQuery on Twitter](http://twitter.com/phpQuery)** + * Roadmap: [Planned](http://code.google.com/p/phpquery/issues/list?q=label%3AEnhancement&can=2&sort=milestone) / [Completed](http://code.google.com/p/phpquery/issues/list?can=1&q=label%3AEnhancement%20status%3AFixed&sort=milestone) + +## Feedback ## + * **[Issue/Bug Tracker](http://code.google.com/p/phpquery/issues/list?sort=milestone)** ([new issue](http://code.google.com/p/phpquery/issues/entry)) + * **[Google Group](http://groups.google.com/group/phpquery/topics?gvc=2)** + * **IRC** #phpquery at [freenode.net](http://freenode.net/) + * **ohloh.net** has [phpQuery project](https://www.ohloh.net/projects/phpquery) + +--- + +# Examples # +## [CLI](CommandLineInterface.md) ## +Fetch number of downloads of all release packages +``` +phpquery 'http://code.google.com/p/phpquery/downloads/list?can=1' \ + --find '.vt.col_4 a' --contents \ + --getString null array_sum +``` +## PHP ## +Examples from [demo.php](http://code.google.com/p/phpquery/source/browse/branches/dev/demo.php) +``` +require('phpQuery/phpQuery.php'); +// for PEAR installation use this +// require('phpQuery.php'); +``` + +#### INITIALIZE IT #### +``` +// $doc = phpQuery::newDocumentHTML($markup); +// $doc = phpQuery::newDocumentXML(); +// $doc = phpQuery::newDocumentFileXHTML('test.html'); +// $doc = phpQuery::newDocumentFilePHP('test.php'); +// $doc = phpQuery::newDocument('test.xml', 'application/rss+xml'); +// this one defaults to text/html in utf8 +$doc = phpQuery::newDocument('
    '); +``` + +#### FILL IT #### +``` +// array syntax works like ->find() here +$doc['div']->append('
      '); +// array set changes inner html +$doc['div ul'] = '
    • 1
    • 2
    • 3
    • '; +``` + +#### MANIPULATE IT #### +``` +// almost everything can be a chain +$li = null; +$doc['ul > li'] + ->addClass('my-new-class') + ->filter(':last') + ->addClass('last-li') +// save it anywhere in the chain + ->toReference($li); +``` + +#### SELECT DOCUMENT #### +``` +// pq(); is using selected document as default +phpQuery::selectDocument($doc); +// documents are selected when created or by above method +// query all unordered lists in last selected document +pq('ul')->insertAfter('div'); +``` + +#### ITERATE IT #### +``` +// all LIs from last selected DOM +foreach(pq('li') as $li) { + // iteration returns PLAIN dom nodes, NOT phpQuery objects + $tagName = $li->tagName; + $childNodes = $li->childNodes; + // so you NEED to wrap it within phpQuery, using pq(); + pq($li)->addClass('my-second-new-class'); +} +``` + +#### PRINT OUTPUT #### +``` +// 1st way +print phpQuery::getDocument($doc->getDocumentID()); +// 2nd way +print phpQuery::getDocument(pq('div')->getDocumentID()); +// 3rd way +print pq('div')->getDocument(); +// 4th way +print $doc->htmlOuter(); +// 5th way +print $doc; +// another... +print $doc['ul']; +``` \ No newline at end of file diff --git a/ReleasePackages.md b/ReleasePackages.md new file mode 100644 index 0000000..13b8767 --- /dev/null +++ b/ReleasePackages.md @@ -0,0 +1,11 @@ +# This page is TODO # + +## Formats ## + * RPM + * ZIP + +## Forms ## + * Standard + * OneFile + * Broken plugins support ? + * ZendFramework not included \ No newline at end of file diff --git a/SVNCheckout.md b/SVNCheckout.md new file mode 100644 index 0000000..0258eb1 --- /dev/null +++ b/SVNCheckout.md @@ -0,0 +1,14 @@ +#### Checkout latest release #### +``` +svn checkout http://phpquery.googlecode.com/svn/trunk/ phpQuery +``` +#### Checkout developer branch #### +``` +svn checkout http://phpquery.googlecode.com/svn/branches/dev/ phpQuery-dev +``` + +You can directly [browse the code](http://code.google.com/p/phpquery/source/browse/) using web interface. + +SVN changelog is also available thou [web interface](http://code.google.com/p/phpquery/source/list) and also as [RSS](http://code.google.com/feeds/p/phpquery/svnchanges/basic). + +Get SVN for Windows from [TortoiseSVN](http://tortoisesvn.tigris.org/). \ No newline at end of file diff --git a/ScriptsPlugin.md b/ScriptsPlugin.md new file mode 100644 index 0000000..70780b2 --- /dev/null +++ b/ScriptsPlugin.md @@ -0,0 +1,24 @@ +ScriptsPlugin simplifies writing short code scripts which can be easily reused (chained). It removes plugin overhead allowing script to be one-line command. + +## Using scripts ## +Before using any script, you need to load **Scripts** plugin, like so: +``` +phpQuery::plugin('Scripts'); +// or inside a chain +pq('li')->plugin('Scripts'); +``` +After that, any available script can be used thou **script** method. +``` +print pq('div')->script('safe_print'); +``` +## Writing scripts ## +Scripts are placed in **/phpQuery/plugins/Scripts**. Each script has it's own file. Each file has access to 4 variables: + * **$self** Represents $this + * **$params** Represents parameters passed to script() method (without script name) + * **$return** If not null, will be used as method result + * **$config** Content of config.php file +By default each script returns $self aka $this. +##### Example script ##### +``` +$return = $self->find($params[0]); +``` \ No newline at end of file diff --git a/Selectors.md b/Selectors.md new file mode 100644 index 0000000..b696c47 --- /dev/null +++ b/Selectors.md @@ -0,0 +1,76 @@ +Selectors are the heart of jQuery-like interface. Most of [CSS Level 3](http://www.w3.org/TR/2005/WD-css3-selectors-20051215/) syntax is implemented (in state same as in jQuery). +## Example ## +``` +pq(".class ul > li[rel='foo']:first:has(a)")->appendTo('.append-target-wrapper div')->... +``` +# Table of Contents # + * [Basics](#Basics.md) + * [Hierarchy](#Hierarchy.md) + * [Basic Filters](#Basic_Filters.md) + * [Content Filters](#Content_Filters.md) + * [Visibility Filters](#Visibility_Filters.md) + * [Attribute Filters](#Attribute_Filters.md) + * [Child Filters](#Child_Filters.md) + * [Forms](#Forms.md) + * [Form Filters](#Form_Filters.md) +## Basics ## + * **[#id](http://docs.jquery.com/Selectors/id)** Matches a single element with the given id attribute. + * **[element](http://docs.jquery.com/Selectors/element)** Matches all elements with the given name. + * **[.class](http://docs.jquery.com/Selectors/class)** Matches all elements with the given class. + * **[\*](http://docs.jquery.com/Selectors/all)** Matches all elements. + * **[selector1, selector2, selectorN](http://docs.jquery.com/Selectors/multiple)** Matches the combined results of all the specified selectors. +## Hierarchy ## + * **[ancestor descendant](http://docs.jquery.com/Selectors/descendant)** Matches all descendant elements specified by "descendant" of elements specified by "ancestor". + * **[parent > child](http://docs.jquery.com/Selectors/child)** Matches all child elements specified by "child" of elements specified by "parent". + * **[prev + next](http://docs.jquery.com/Selectors/next)** Matches all next elements specified by "next" that are next to elements specified by "prev". + * **[prev ~ siblings](http://docs.jquery.com/Selectors/siblings)** Matches all sibling elements after the "prev" element that match the filtering "siblings" selector. +## Basic Filters ## + * **[:first](http://docs.jquery.com/Selectors/first)** Matches the first selected element. + * **[:last](http://docs.jquery.com/Selectors/last)** Matches the last selected element. + * **[:not(selector)](http://docs.jquery.com/Selectors/not)** Filters out all elements matching the given selector. + * **[:even](http://docs.jquery.com/Selectors/even)** Matches even elements, zero-indexed. + * **[:odd](http://docs.jquery.com/Selectors/odd)** Matches odd elements, zero-indexed. + * **[:eq(index)](http://docs.jquery.com/Selectors/eq)** Matches a single element by its index. + * **[:gt(index)](http://docs.jquery.com/Selectors/gt)** Matches all elements with an index above the given one. + * **[:lt(index)](http://docs.jquery.com/Selectors/lt)** Matches all elements with an index below the given one. + * **[:header](http://docs.jquery.com/Selectors/header)** Matches all elements that are headers, like h1, h2, h3 and so on. + * **[:animated](http://docs.jquery.com/Selectors/animated)** Matches all elements that are currently being animated. +## Content Filters ## + * **[:contains(text)](http://docs.jquery.com/Selectors/contains)** Matches elements which contain the given text. + * **[:empty](http://docs.jquery.com/Selectors/empty)** Matches all elements that have no children (including text nodes). + * **[:has(selector)](http://docs.jquery.com/Selectors/has)** Matches elements which contain at least one element that matches the specified selector. + * **[:parent](http://docs.jquery.com/Selectors/parent)** Matches all elements that are parents - they have child elements, including text. +## Visibility Filters ## +_none_ +## Attribute Filters ## + * **[[attribute](http://docs.jquery.com/Selectors/attributeHas)]** Matches elements that have the specified attribute. + * **[[attribute=value](http://docs.jquery.com/Selectors/attributeEquals)]** Matches elements that have the specified attribute with a certain value. + * **[[attribute!=value](http://docs.jquery.com/Selectors/attributeNotEqual)]** Matches elements that don't have the specified attribute with a certain value. + * **[[attribute^=value](http://docs.jquery.com/Selectors/attributeStartsWith)]** Matches elements that have the specified attribute and it starts with a certain value. + * **[[attribute$=value](http://docs.jquery.com/Selectors/attributeEndsWith)]** Matches elements that have the specified attribute and it ends with a certain value. + * **[[attribute\*=value](http://docs.jquery.com/Selectors/attributeContains)]** Matches elements that have the specified attribute and it contains a certain value. + * **[[selector1](http://docs.jquery.com/Selectors/attributeMultiple)[selector2](selector2.md)[selectorN](selectorN.md)]** Matches elements that have the specified attribute and it contains a certain value. +## Child Filters ## + * **[:nth-child(index/even/odd/equation)](http://docs.jquery.com/Selectors/nthChild)** Matches all elements that are the nth-child of their parent or that are the parent's even or odd children. + * **[:first-child](http://docs.jquery.com/Selectors/firstChild)** Matches all elements that are the first child of their parent. + * **[:last-child](http://docs.jquery.com/Selectors/lastChild)** Matches all elements that are the last child of their parent. + * **[:only-child](http://docs.jquery.com/Selectors/onlyChild)** Matches all elements that are the only child of their parent. +## Forms ## + * **[:input](http://docs.jquery.com/Selectors/input)** Matches all input, textarea, select and button elements. + * **[:text](http://docs.jquery.com/Selectors/text)** Matches all input elements of type text. + * **[:password](http://docs.jquery.com/Selectors/password)** Matches all input elements of type password. + * **[:radio](http://docs.jquery.com/Selectors/radio)** Matches all input elements of type radio. + * **[:checkbox](http://docs.jquery.com/Selectors/checkbox)** Matches all input elements of type checkbox. + * **[:submit](http://docs.jquery.com/Selectors/submit)** Matches all input elements of type submit. + * **[:image](http://docs.jquery.com/Selectors/image)** Matches all input elements of type image. + * **[:reset](http://docs.jquery.com/Selectors/reset)** Matches all input elements of type reset. + * **[:button](http://docs.jquery.com/Selectors/button)** Matches all button elements and input elements of type button. + * **[:file](http://docs.jquery.com/Selectors/file)** Matches all input elements of type file. + * **[:hidden](http://docs.jquery.com/Selectors/hidden)** Matches all elements that are hidden, or input elements of type "hidden". +## Form Filters ## + * **[:enabled](http://docs.jquery.com/Selectors/enabled)** Matches all elements that are enabled. + * **[:disabled](http://docs.jquery.com/Selectors/disabled)** Matches all elements that are disabled. + * **[:checked](http://docs.jquery.com/Selectors/checked)** Matches all elements that are checked. + * **[:selected](http://docs.jquery.com/Selectors/selected)** Matches all elements that are selected. + +Read more at [Selectors](http://docs.jquery.com/Selectors) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/Traversing.md b/Traversing.md new file mode 100644 index 0000000..9c0b600 --- /dev/null +++ b/Traversing.md @@ -0,0 +1,34 @@ +## Example ## +``` +pq('div > p')->add('div > ul')->filter(':has(a)')->find('p:first')->nextAll()->andSelf()->... +``` +# Table of Contents # + * [Filtering](#Filtering.md) + * [Finding](#Finding.md) + * [Chaining](#Chaining.md) +## Filtering ## + * **[eq](http://docs.jquery.com/Traversing/eq)**[($index)](http://docs.jquery.com/Traversing/eq) Reduce the set of matched elements to a single element. + * **[hasClass](http://docs.jquery.com/Traversing/hasClass)**[($class)](http://docs.jquery.com/Traversing/hasClass) Checks the current selection against a class and returns true, if at least one element of the selection has the given class. + * **[filter](http://docs.jquery.com/Traversing/filter)**[($expr)](http://docs.jquery.com/Traversing/filter) Removes all elements from the set of matched elements that do not match the specified expression(s). + * **[filter](http://docs.jquery.com/Traversing/filter)**[($fn)](http://docs.jquery.com/Traversing/filter) Removes all elements from the set of matched elements that does not match the specified function. + * **[is](http://docs.jquery.com/Traversing/is)**[($expr)](http://docs.jquery.com/Traversing/is) Checks the current selection against an expression and returns true, if at least one element of the selection fits the given expression. + * **[map](http://docs.jquery.com/Traversing/map)**[($callback)](http://docs.jquery.com/Traversing/map) Translate a set of elements in the jQuery object into another set of values in an array (which may, or may not, be elements). + * **[not](http://docs.jquery.com/Traversing/not)**[($expr)](http://docs.jquery.com/Traversing/not) Removes elements matching the specified expression from the set of matched elements. + * **[slice](http://docs.jquery.com/Traversing/slice)**[($start, $end)](http://docs.jquery.com/Traversing/slice) Selects a subset of the matched elements. +## Finding ## + * **[add](http://docs.jquery.com/Traversing/add)**[($expr)](http://docs.jquery.com/Traversing/add) Adds more elements, matched by the given expression, to the set of matched elements. + * **[children](http://docs.jquery.com/Traversing/children)**[($expr)](http://docs.jquery.com/Traversing/children) Get a set of elements containing all of the unique immediate children of each of the matched set of elements. + * **[contents](http://docs.jquery.com/Traversing/contents)**[()](http://docs.jquery.com/Traversing/contents) Find all the child nodes inside the matched elements (including text nodes), or the content document, if the element is an iframe. + * **[find](http://docs.jquery.com/Traversing/find)**[($expr)](http://docs.jquery.com/Traversing/find) Searches for all elements that match the specified expression. This method is a good way to find additional descendant elements with which to process. + * **[next](http://docs.jquery.com/Traversing/next)**[($expr)](http://docs.jquery.com/Traversing/next) Get a set of elements containing the unique next siblings of each of the given set of elements. + * **[nextAll](http://docs.jquery.com/Traversing/nextAll)**[($expr)](http://docs.jquery.com/Traversing/nextAll) Find all sibling elements after the current element. + * **[parent](http://docs.jquery.com/Traversing/parent)**[($expr)](http://docs.jquery.com/Traversing/parent) Get a set of elements containing the unique parents of the matched set of elements. + * **[parents](http://docs.jquery.com/Traversing/parents)**[($expr)](http://docs.jquery.com/Traversing/parents) Get a set of elements containing the unique ancestors of the matched set of elements (except for the root element). The matched elements can be filtered with an optional expression. + * **[prev](http://docs.jquery.com/Traversing/prev)**[($expr)](http://docs.jquery.com/Traversing/prev) Get a set of elements containing the unique previous siblings of each of the matched set of elements. + * **[prevAll](http://docs.jquery.com/Traversing/prevAll)**[($expr)](http://docs.jquery.com/Traversing/prevAll) Find all sibling elements before the current element. + * **[siblings](http://docs.jquery.com/Traversing/siblings)**[($expr)](http://docs.jquery.com/Traversing/siblings) Get a set of elements containing all of the unique siblings of each of the matched set of elements. Can be filtered with an optional expressions. +## Chaining ## + * **[andSelf](http://docs.jquery.com/Traversing/andSelf)**[()](http://docs.jquery.com/Traversing/andSelf) Add the previous selection to the current selection. + * **[end](http://docs.jquery.com/Traversing/end)**[()](http://docs.jquery.com/Traversing/end) Revert the most recent 'destructive' operation, changing the set of matched elements to its previous state (right before the destructive operation). + +Read more at [Traversing](http://docs.jquery.com/Traversing) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/Utilities.md b/Utilities.md new file mode 100644 index 0000000..c1c5421 --- /dev/null +++ b/Utilities.md @@ -0,0 +1,20 @@ +# Table of Contents # + * [User Agent](#User_Agent.md) + * [Array and Object operations](#Array_and_Object_operations.md) + * [Test operations](#Test_operations.md) + * [String operations](#String_operations.md) +## User Agent ## +_none_ +## Array and Object operations ## + * **[phpQuery::each](http://docs.jquery.com/Utilities/jQuery.each)**[($object, $callback)](http://docs.jquery.com/Utilities/jQuery.each) A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. + * **[phpQuery::grep](http://docs.jquery.com/Utilities/jQuery.grep)**[($array, $callback, $invert)](http://docs.jquery.com/Utilities/jQuery.grep) Filter items out of an array, by using a filter function. + * **[phpQuery::makeArray](http://docs.jquery.com/Utilities/jQuery.makeArray)**[($obj)](http://docs.jquery.com/Utilities/jQuery.makeArray) Turns an array-like object into a true array. + * **[phpQuery::map](http://docs.jquery.com/Utilities/jQuery.map)**[($array, $callback)](http://docs.jquery.com/Utilities/jQuery.map) Translate all items in an array to another array of items. + * **[phpQuery::inArray](http://docs.jquery.com/Utilities/jQuery.inArray)**[($value, $array)](http://docs.jquery.com/Utilities/jQuery.inArray) Determine the index of the first parameter in the Array (-1 if not found). + * **[phpQuery::unique](http://docs.jquery.com/Utilities/jQuery.unique)**[($array)](http://docs.jquery.com/Utilities/jQuery.unique) Remove all duplicate elements from an array of elements. +## Test operations ## + * **[phpQuery::isFunction](http://docs.jquery.com/Utilities/jQuery.isFunction)**[($obj)](http://docs.jquery.com/Utilities/jQuery.isFunction) Determine if the parameter passed is a function. +## String operations ## + * **[phpQuery::trim](http://docs.jquery.com/Utilities/jQuery.trim)**[($str)](http://docs.jquery.com/Utilities/jQuery.trim) Remove the whitespace from the beginning and end of a string. + +Read more at [Utilities](http://docs.jquery.com/Utilities) section on [jQuery Documentation Site](http://docs.jquery.com/). \ No newline at end of file diff --git a/WebBrowser.md b/WebBrowser.md new file mode 100644 index 0000000..2ffe7d3 --- /dev/null +++ b/WebBrowser.md @@ -0,0 +1,37 @@ +**WebBrowser** is a phpQuery [plugin](http://code.google.com/p/phpquery/wiki/PluginsServerSide) that mimics behaviors of web browser. Thanks to that developer can simulate user's behavior inside a PHP script. + +## Supported ## + * Link navigation (click event) + * Form navigation (submit event) + * Cookies (thought [Zend\_Http\_CookieJar](http://framework.zend.com/manual/en/zend.http.cookies.html)) + * Relative links + * document.location (not an object, yet) + +## Use cases ## + * Fill forms and submit them easly + * Login to secure pages and collect content + * Write test cases reproducing browsing proccess + +## Example 1 ## +Adding web browser functionality to existing phpQuery object and submiting the form. +``` +->WebBrowser('callback')->find('form')->submit()->... +``` + +## Example 2 ## +Querying Google against "search phrase": +``` +require_once('phpQuery/phpQuery.php'); +phpQuery::browserGet('http://www.google.com/', 'success1'); +function success1($browser) { + $browser + ->WebBrowser('success2') + ->find('input[name=q]') + ->val('search phrase') + ->parents('form') + ->submit(); +} +function success2($browser) { + print $browser; +} +``` \ No newline at end of file diff --git a/cli/phpquery b/cli/phpquery deleted file mode 100755 index 10dccf5..0000000 --- a/cli/phpquery +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env php - p' --contents -Pipe: - cat index.html | phpquery --find 'div > p' --contents -Docs: - http://code.google.com/p/phpquery/wiki/\n"); -/* ALL-IN-ONE-SECTION-START */ -set_include_path(get_include_path() - .':'.'/usr/lib/phpquery' - .':'.realpath(dirname(__FILE__).'/../phpQuery') -); -require_once('phpQuery.php'); -/* ALL-IN-ONE-SECTION-END */ -//phpQuery::$debug = true; -//var_dump($argv); -if (isset($argv[1]) && parse_url($argv[1], PHP_URL_HOST)) { - if (@include_once('Zend/Http/Client.php')) { - // use Ajax if possible - phpQuery::ajaxAllowURL($argv[1]); - // TODO support contentType passing (from response headers) - phpQuery::get($argv[1], - new Callback('phpQueryCli', new CallbackParam, array_slice($argv, 2)) - ); - } else { - // use file wrapper when no Ajax - phpQueryCli(file_get_contents($argv[1]), array_slice($argv, 2)); - } -} else if (feof(STDIN) === false) { - $markup = ''; - while(!feof(STDIN)) - $markup .= fgets(STDIN, 4096); - phpQueryCli($markup, array_slice($argv, 1)); -} else { - phpQueryCli($argv[1], array_slice($argv, 2)); -} -function phpQueryCli($markup, $callQueue) { - $pq = phpQuery::newDocument($markup); - $method = null; - $params = array(); - foreach($callQueue as $param) { - if (strpos($param, '--') === 0) { - if ($method) { - $pq = call_user_func_array(array($pq, $method), $params); - } - $method = substr($param, 2); // delete -- - $params = array(); - } else { - $param = str_replace('\n', "\n", $param); - $params[] = strtolower($param) == 'null' - ? null - : $param; - } - } - if ($method) - $pq = call_user_func_array(array($pq, $method), $params); - if (is_array($pq)) - foreach($pq as $v) - print $v; - else - print $pq."\n"; - //var_dump($pq); -} -?> \ No newline at end of file diff --git a/demo.php b/demo.php deleted file mode 100644 index 63dacea..0000000 --- a/demo.php +++ /dev/null @@ -1,58 +0,0 @@ -'); - -// FILL IT -// array syntax works like ->find() here -$doc['div']->append('
        '); -// array set changes inner html -$doc['div ul'] = '
      • 1
      • 2
      • 3
      • '; - -// MANIPULATE IT -$li = null; -// almost everything can be a chain -$doc['ul > li'] - ->addClass('my-new-class') - ->filter(':last') - ->addClass('last-li') -// save it anywhere in the chain - ->toReference($li); - -// SELECT DOCUMENT -// pq(); is using selected document as default -phpQuery::selectDocument($doc); -// documents are selected when created or by above method -// query all unordered lists in last selected document -$ul = pq('ul')->insertAfter('div'); - -// ITERATE IT -// all direct LIs from $ul -foreach($ul['> li'] as $li) { - // iteration returns PLAIN dom nodes, NOT phpQuery objects - $tagName = $li->tagName; - $childNodes = $li->childNodes; - // so you NEED to wrap it within phpQuery, using pq(); - pq($li)->addClass('my-second-new-class'); -} - -// PRINT OUTPUT -// 1st way -print phpQuery::getDocument($doc->getDocumentID()); -// 2nd way -print phpQuery::getDocument(pq('div')->getDocumentID()); -// 3rd way -print pq('div')->getDocument(); -// 4th way -print $doc->htmlOuter(); -// 5th way -print $doc; -// another... -print $doc['ul']; \ No newline at end of file diff --git a/jQueryDifferences.md b/jQueryDifferences.md new file mode 100644 index 0000000..4cc32f2 --- /dev/null +++ b/jQueryDifferences.md @@ -0,0 +1 @@ +Renamed to [jQueryPortingState](http://code.google.com/p/phpquery/wiki/jQueryPortingState). \ No newline at end of file diff --git a/jQueryHelpers.md b/jQueryHelpers.md new file mode 100644 index 0000000..2df052a --- /dev/null +++ b/jQueryHelpers.md @@ -0,0 +1,3 @@ +jQuery helper libraries written in PHP + * [jquery-php](http://code.google.com/p/jquery-php/) + * [PQuery](http://www.ngcoders.com/php/pquery-php-and-jquery) \ No newline at end of file diff --git a/jQueryPortingState.md b/jQueryPortingState.md new file mode 100644 index 0000000..8162797 --- /dev/null +++ b/jQueryPortingState.md @@ -0,0 +1,29 @@ +phpQuery is almost a full port of the [jQuery JavaScript Library](http://jquery.com/). + +## Ported Sections ## + 1. [Selectors](http://code.google.com/p/phpquery/wiki/Selectors) + 1. [Attributes](http://code.google.com/p/phpquery/wiki/Attributes) + 1. [Traversing](http://code.google.com/p/phpquery/wiki/Traversing) + 1. [Manipulation](http://code.google.com/p/phpquery/wiki/Manipulation) + 1. [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) + 1. [Events](http://code.google.com/p/phpquery/wiki/Events) + 1. [Utilities](http://code.google.com/p/phpquery/wiki/Utilities) + 1. [Plugin ports](http://code.google.com/p/phpquery/wiki/PluginsClientSidePorts) + +## Additional methods ## +phpQuery features many additional methods comparing to jQuery: + * htmlOuter() + * xml() + * xmlOuter() + * markup() + * markupOuter() + * getString() + * reverse() + * contentsUnwrap() + * switchWith() + * all from [PHPSupport](http://code.google.com/p/phpquery/wiki/PHPSupport) + * all from [Basic](http://code.google.com/p/phpquery/wiki/Basic) + * all from [MultiDocumentSupport](http://code.google.com/p/phpquery/wiki/MultiDocumentSupport) + +## Other Differences ## + * [Server Side Events](http://code.google.com/p/phpquery/wiki/Events?ts=1225458859&updated=Events#Server_Side_Events) \ No newline at end of file diff --git a/jQueryServer.md b/jQueryServer.md new file mode 100644 index 0000000..7a221a0 --- /dev/null +++ b/jQueryServer.md @@ -0,0 +1,16 @@ +**jQueryServer** is a jQuery plugin giving unobstrusive, client-side bindings to server-side implementation of jQuery. + +## Example scenario ## + 1. Connect to server and make an [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) request to somewhere ([crossdomain allowed](http://code.google.com/p/phpquery/wiki/CrossDomainAjax)) + 1. Do some manipulations, you can even trigger a [server-side event](http://code.google.com/p/phpquery/wiki/Events#Server_Side_Events) + 1. Get processed date back to the browser + +## Example code ## +``` +$.server({url: 'http://somesite.com'}) + .find('.my-class') + .client(function(response){ + $('.destination').html(response); +}); +``` +Since version **0.5.1** (this is **not** phpQuery release version number) there is a support for config file which **authorizes** [Ajax](http://code.google.com/p/phpquery/wiki/Ajax) hosts and referers. \ No newline at end of file diff --git a/jQueryServer/demo/demo.htm b/jQueryServer/demo/demo.htm deleted file mode 100644 index 2f854dd..0000000 --- a/jQueryServer/demo/demo.htm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - jQuery Server Plugin - - - - - -
        jQuery Server Plugin demo...
        -
          -
        • test1
        • -
        • test2
        • -
        • test3
        • -
        - - diff --git a/jQueryServer/demo/jquery.js b/jQueryServer/demo/jquery.js deleted file mode 100755 index c7ced10..0000000 --- a/jQueryServer/demo/jquery.js +++ /dev/null @@ -1,2991 +0,0 @@ -(function(){ -/* - * jQuery 1.2.1 - New Wave Javascript - * - * Copyright (c) 2007 John Resig (jquery.com) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $ - * $Rev: 3353 $ - */ - -// Map over jQuery in case of overwrite -if ( typeof jQuery != "undefined" ) - var _jQuery = jQuery; - -var jQuery = window.jQuery = function(selector, context) { - // If the context is a namespace object, return a new object - return this instanceof jQuery ? - this.init(selector, context) : - new jQuery(selector, context); -}; - -// Map over the $ in case of overwrite -if ( typeof $ != "undefined" ) - var _$ = $; - -// Map the jQuery namespace to the '$' one -window.$ = jQuery; - -var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; - -jQuery.fn = jQuery.prototype = { - init: function(selector, context) { - // Make sure that a selection was provided - selector = selector || document; - - // Handle HTML strings - if ( typeof selector == "string" ) { - var m = quickExpr.exec(selector); - if ( m && (m[1] || !context) ) { - // HANDLE: $(html) -> $(array) - if ( m[1] ) - selector = jQuery.clean( [ m[1] ], context ); - - // HANDLE: $("#id") - else { - var tmp = document.getElementById( m[3] ); - if ( tmp ) - // Handle the case where IE and Opera return items - // by name instead of ID - if ( tmp.id != m[3] ) - return jQuery().find( selector ); - else { - this[0] = tmp; - this.length = 1; - return this; - } - else - selector = []; - } - - // HANDLE: $(expr) - } else - return new jQuery( context ).find( selector ); - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction(selector) ) - return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( selector ); - - return this.setArray( - // HANDLE: $(array) - selector.constructor == Array && selector || - - // HANDLE: $(arraylike) - // Watch for when an array-like object is passed as the selector - (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || - - // HANDLE: $(*) - [ selector ] ); - }, - - jquery: "1.2.1", - - size: function() { - return this.length; - }, - - length: 0, - - get: function( num ) { - return num == undefined ? - - // Return a 'clean' array - jQuery.makeArray( this ) : - - // Return just the object - this[num]; - }, - - pushStack: function( a ) { - var ret = jQuery(a); - ret.prevObject = this; - return ret; - }, - - setArray: function( a ) { - this.length = 0; - Array.prototype.push.apply( this, a ); - return this; - }, - - each: function( fn, args ) { - return jQuery.each( this, fn, args ); - }, - - index: function( obj ) { - var pos = -1; - this.each(function(i){ - if ( this == obj ) pos = i; - }); - return pos; - }, - - attr: function( key, value, type ) { - var obj = key; - - // Look for the case where we're accessing a style value - if ( key.constructor == String ) - if ( value == undefined ) - return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined; - else { - obj = {}; - obj[ key ] = value; - } - - // Check to see if we're setting style values - return this.each(function(index){ - // Set all the styles - for ( var prop in obj ) - jQuery.attr( - type ? this.style : this, - prop, jQuery.prop(this, obj[prop], type, index, prop) - ); - }); - }, - - css: function( key, value ) { - return this.attr( key, value, "curCSS" ); - }, - - text: function(e) { - if ( typeof e != "object" && e != null ) - return this.empty().append( document.createTextNode( e ) ); - - var t = ""; - jQuery.each( e || this, function(){ - jQuery.each( this.childNodes, function(){ - if ( this.nodeType != 8 ) - t += this.nodeType != 1 ? - this.nodeValue : jQuery.fn.text([ this ]); - }); - }); - return t; - }, - - wrapAll: function(html) { - if ( this[0] ) - // The elements to wrap the target around - jQuery(html, this[0].ownerDocument) - .clone() - .insertBefore(this[0]) - .map(function(){ - var elem = this; - while ( elem.firstChild ) - elem = elem.firstChild; - return elem; - }) - .append(this); - - return this; - }, - - wrapInner: function(html) { - return this.each(function(){ - jQuery(this).contents().wrapAll(html); - }); - }, - - wrap: function(html) { - return this.each(function(){ - jQuery(this).wrapAll(html); - }); - }, - - append: function() { - return this.domManip(arguments, true, 1, function(a){ - this.appendChild( a ); - }); - }, - - prepend: function() { - return this.domManip(arguments, true, -1, function(a){ - this.insertBefore( a, this.firstChild ); - }); - }, - - before: function() { - return this.domManip(arguments, false, 1, function(a){ - this.parentNode.insertBefore( a, this ); - }); - }, - - after: function() { - return this.domManip(arguments, false, -1, function(a){ - this.parentNode.insertBefore( a, this.nextSibling ); - }); - }, - - end: function() { - return this.prevObject || jQuery([]); - }, - - find: function(t) { - var data = jQuery.map(this, function(a){ return jQuery.find(t,a); }); - return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ? - jQuery.unique( data ) : data ); - }, - - clone: function(events) { - // Do the clone - var ret = this.map(function(){ - return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true); - }); - - // Need to set the expando to null on the cloned set if it exists - // removeData doesn't work here, IE removes it from the original as well - // this is primarily for IE but the data expando shouldn't be copied over in any browser - var clone = ret.find("*").andSelf().each(function(){ - if ( this[ expando ] != undefined ) - this[ expando ] = null; - }); - - // Copy the events from the original to the clone - if (events === true) - this.find("*").andSelf().each(function(i) { - var events = jQuery.data(this, "events"); - for ( var type in events ) - for ( var handler in events[type] ) - jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data); - }); - - // Return the cloned set - return ret; - }, - - filter: function(t) { - return this.pushStack( - jQuery.isFunction( t ) && - jQuery.grep(this, function(el, index){ - return t.apply(el, [index]); - }) || - - jQuery.multiFilter(t,this) ); - }, - - not: function(t) { - return this.pushStack( - t.constructor == String && - jQuery.multiFilter(t, this, true) || - - jQuery.grep(this, function(a) { - return ( t.constructor == Array || t.jquery ) - ? jQuery.inArray( a, t ) < 0 - : a != t; - }) - ); - }, - - add: function(t) { - return this.pushStack( jQuery.merge( - this.get(), - t.constructor == String ? - jQuery(t).get() : - t.length != undefined && (!t.nodeName || jQuery.nodeName(t, "form")) ? - t : [t] ) - ); - }, - - is: function(expr) { - return expr ? jQuery.multiFilter(expr,this).length > 0 : false; - }, - - hasClass: function(expr) { - return this.is("." + expr); - }, - - val: function( val ) { - if ( val == undefined ) { - if ( this.length ) { - var elem = this[0]; - - // We need to handle select boxes special - if ( jQuery.nodeName(elem, "select") ) { - var index = elem.selectedIndex, - a = [], - options = elem.options, - one = elem.type == "select-one"; - - // Nothing was selected - if ( index < 0 ) - return null; - - // Loop through all the selected options - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { - var option = options[i]; - if ( option.selected ) { - // Get the specifc value for the option - var val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value; - - // We don't need an array for one selects - if ( one ) - return val; - - // Multi-Selects return an array - a.push(val); - } - } - - return a; - - // Everything else, we just grab the value - } else - return this[0].value.replace(/\r/g, ""); - } - } else - return this.each(function(){ - if ( val.constructor == Array && /radio|checkbox/.test(this.type) ) - this.checked = (jQuery.inArray(this.value, val) >= 0 || - jQuery.inArray(this.name, val) >= 0); - else if ( jQuery.nodeName(this, "select") ) { - var tmp = val.constructor == Array ? val : [val]; - - jQuery("option", this).each(function(){ - this.selected = (jQuery.inArray(this.value, tmp) >= 0 || - jQuery.inArray(this.text, tmp) >= 0); - }); - - if ( !tmp.length ) - this.selectedIndex = -1; - } else - this.value = val; - }); - }, - - html: function( val ) { - return val == undefined ? - ( this.length ? this[0].innerHTML : null ) : - this.empty().append( val ); - }, - - replaceWith: function( val ) { - return this.after( val ).remove(); - }, - - eq: function(i){ - return this.slice(i, i+1); - }, - - slice: function() { - return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); - }, - - map: function(fn) { - return this.pushStack(jQuery.map( this, function(elem,i){ - return fn.call( elem, i, elem ); - })); - }, - - andSelf: function() { - return this.add( this.prevObject ); - }, - - domManip: function(args, table, dir, fn) { - var clone = this.length > 1, a; - - return this.each(function(){ - if ( !a ) { - a = jQuery.clean(args, this.ownerDocument); - if ( dir < 0 ) - a.reverse(); - } - - var obj = this; - - if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") ) - obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody")); - - jQuery.each( a, function(){ - var elem = clone ? this.cloneNode(true) : this; - if ( !evalScript(0, elem) ) - fn.call( obj, elem ); - }); - }); - } -}; - -function evalScript(i, elem){ - var script = jQuery.nodeName(elem, "script"); - - if ( script ) { - if ( elem.src ) - jQuery.ajax({ url: elem.src, async: false, dataType: "script" }); - else - jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); - - if ( elem.parentNode ) - elem.parentNode.removeChild(elem); - - } else if ( elem.nodeType == 1 ) - jQuery("script", elem).each(evalScript); - - return script; -} - -jQuery.extend = jQuery.fn.extend = function() { - // copy reference to target object - var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false; - - // Handle a deep copy situation - if ( target.constructor == Boolean ) { - deep = target; - target = arguments[1] || {}; - } - - // extend jQuery itself if only one argument is passed - if ( al == 1 ) { - target = this; - a = 0; - } - - var prop; - - for ( ; a < al; a++ ) - // Only deal with non-null/undefined values - if ( (prop = arguments[a]) != null ) - // Extend the base object - for ( var i in prop ) { - // Prevent never-ending loop - if ( target == prop[i] ) - continue; - - // Recurse if we're merging object values - if ( deep && typeof prop[i] == 'object' && target[i] ) - jQuery.extend( target[i], prop[i] ); - - // Don't bring in undefined values - else if ( prop[i] != undefined ) - target[i] = prop[i]; - } - - // Return the modified object - return target; -}; - -var expando = "jQuery" + (new Date()).getTime(), uuid = 0, win = {}; - -jQuery.extend({ - noConflict: function(deep) { - window.$ = _$; - if ( deep ) - window.jQuery = _jQuery; - return jQuery; - }, - - // This may seem like some crazy code, but trust me when I say that this - // is the only cross-browser way to do this. --John - isFunction: function( fn ) { - return !!fn && typeof fn != "string" && !fn.nodeName && - fn.constructor != Array && /function/i.test( fn + "" ); - }, - - // check if an element is in a XML document - isXMLDoc: function(elem) { - return elem.documentElement && !elem.body || - elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; - }, - - // Evalulates a script in a global context - // Evaluates Async. in Safari 2 :-( - globalEval: function( data ) { - data = jQuery.trim( data ); - if ( data ) { - if ( window.execScript ) - window.execScript( data ); - else if ( jQuery.browser.safari ) - // safari doesn't provide a synchronous global eval - window.setTimeout( data, 0 ); - else - eval.call( window, data ); - } - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); - }, - - cache: {}, - - data: function( elem, name, data ) { - elem = elem == window ? win : elem; - - var id = elem[ expando ]; - - // Compute a unique ID for the element - if ( !id ) - id = elem[ expando ] = ++uuid; - - // Only generate the data cache if we're - // trying to access or manipulate it - if ( name && !jQuery.cache[ id ] ) - jQuery.cache[ id ] = {}; - - // Prevent overriding the named cache with undefined values - if ( data != undefined ) - jQuery.cache[ id ][ name ] = data; - - // Return the named cache data, or the ID for the element - return name ? jQuery.cache[ id ][ name ] : id; - }, - - removeData: function( elem, name ) { - elem = elem == window ? win : elem; - - var id = elem[ expando ]; - - // If we want to remove a specific section of the element's data - if ( name ) { - if ( jQuery.cache[ id ] ) { - // Remove the section of cache data - delete jQuery.cache[ id ][ name ]; - - // If we've removed all the data, remove the element's cache - name = ""; - for ( name in jQuery.cache[ id ] ) break; - if ( !name ) - jQuery.removeData( elem ); - } - - // Otherwise, we want to remove all of the element's data - } else { - // Clean up the element expando - try { - delete elem[ expando ]; - } catch(e){ - // IE has trouble directly removing the expando - // but it's ok with using removeAttribute - if ( elem.removeAttribute ) - elem.removeAttribute( expando ); - } - - // Completely remove the data cache - delete jQuery.cache[ id ]; - } - }, - - // args is for internal usage only - each: function( obj, fn, args ) { - if ( args ) { - if ( obj.length == undefined ) - for ( var i in obj ) - fn.apply( obj[i], args ); - else - for ( var i = 0, ol = obj.length; i < ol; i++ ) - if ( fn.apply( obj[i], args ) === false ) break; - - // A special, fast, case for the most common use of each - } else { - if ( obj.length == undefined ) - for ( var i in obj ) - fn.call( obj[i], i, obj[i] ); - else - for ( var i = 0, ol = obj.length, val = obj[0]; - i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){} - } - - return obj; - }, - - prop: function(elem, value, type, index, prop){ - // Handle executable functions - if ( jQuery.isFunction( value ) ) - value = value.call( elem, [index] ); - - // exclude the following css properties to add px - var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; - - // Handle passing in a number to a CSS property - return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ? - value + "px" : - value; - }, - - className: { - // internal only, use addClass("class") - add: function( elem, c ){ - jQuery.each( (c || "").split(/\s+/), function(i, cur){ - if ( !jQuery.className.has( elem.className, cur ) ) - elem.className += ( elem.className ? " " : "" ) + cur; - }); - }, - - // internal only, use removeClass("class") - remove: function( elem, c ){ - elem.className = c != undefined ? - jQuery.grep( elem.className.split(/\s+/), function(cur){ - return !jQuery.className.has( c, cur ); - }).join(" ") : ""; - }, - - // internal only, use is(".class") - has: function( t, c ) { - return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1; - } - }, - - swap: function(e,o,f) { - for ( var i in o ) { - e.style["old"+i] = e.style[i]; - e.style[i] = o[i]; - } - f.apply( e, [] ); - for ( var i in o ) - e.style[i] = e.style["old"+i]; - }, - - css: function(e,p) { - if ( p == "height" || p == "width" ) { - var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"]; - - jQuery.each( d, function(){ - old["padding" + this] = 0; - old["border" + this + "Width"] = 0; - }); - - jQuery.swap( e, old, function() { - if ( jQuery(e).is(':visible') ) { - oHeight = e.offsetHeight; - oWidth = e.offsetWidth; - } else { - e = jQuery(e.cloneNode(true)) - .find(":radio").removeAttr("checked").end() - .css({ - visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0" - }).appendTo(e.parentNode)[0]; - - var parPos = jQuery.css(e.parentNode,"position") || "static"; - if ( parPos == "static" ) - e.parentNode.style.position = "relative"; - - oHeight = e.clientHeight; - oWidth = e.clientWidth; - - if ( parPos == "static" ) - e.parentNode.style.position = "static"; - - e.parentNode.removeChild(e); - } - }); - - return p == "height" ? oHeight : oWidth; - } - - return jQuery.curCSS( e, p ); - }, - - curCSS: function(elem, prop, force) { - var ret, stack = [], swap = []; - - // A helper method for determining if an element's values are broken - function color(a){ - if ( !jQuery.browser.safari ) - return false; - - var ret = document.defaultView.getComputedStyle(a,null); - return !ret || ret.getPropertyValue("color") == ""; - } - - if (prop == "opacity" && jQuery.browser.msie) { - ret = jQuery.attr(elem.style, "opacity"); - return ret == "" ? "1" : ret; - } - - if (prop.match(/float/i)) - prop = styleFloat; - - if (!force && elem.style[prop]) - ret = elem.style[prop]; - - else if (document.defaultView && document.defaultView.getComputedStyle) { - - if (prop.match(/float/i)) - prop = "float"; - - prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase(); - var cur = document.defaultView.getComputedStyle(elem, null); - - if ( cur && !color(elem) ) - ret = cur.getPropertyValue(prop); - - // If the element isn't reporting its values properly in Safari - // then some display: none elements are involved - else { - // Locate all of the parent display: none elements - for ( var a = elem; a && color(a); a = a.parentNode ) - stack.unshift(a); - - // Go through and make them visible, but in reverse - // (It would be better if we knew the exact display type that they had) - for ( a = 0; a < stack.length; a++ ) - if ( color(stack[a]) ) { - swap[a] = stack[a].style.display; - stack[a].style.display = "block"; - } - - // Since we flip the display style, we have to handle that - // one special, otherwise get the value - ret = prop == "display" && swap[stack.length-1] != null ? - "none" : - document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || ""; - - // Finally, revert the display styles back - for ( a = 0; a < swap.length; a++ ) - if ( swap[a] != null ) - stack[a].style.display = swap[a]; - } - - if ( prop == "opacity" && ret == "" ) - ret = "1"; - - } else if (elem.currentStyle) { - var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();}); - ret = elem.currentStyle[prop] || elem.currentStyle[newProp]; - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) { - var style = elem.style.left; - var runtimeStyle = elem.runtimeStyle.left; - elem.runtimeStyle.left = elem.currentStyle.left; - elem.style.left = ret || 0; - ret = elem.style.pixelLeft + "px"; - elem.style.left = style; - elem.runtimeStyle.left = runtimeStyle; - } - } - - return ret; - }, - - clean: function(a, doc) { - var r = []; - doc = doc || document; - - jQuery.each( a, function(i,arg){ - if ( !arg ) return; - - if ( arg.constructor == Number ) - arg = arg.toString(); - - // Convert html string into DOM nodes - if ( typeof arg == "string" ) { - // Fix "XHTML"-style tags in all browsers - arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){ - return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+">"; - }); - - // Trim whitespace, otherwise indexOf won't work as expected - var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = []; - - var wrap = - // option or optgroup - !s.indexOf("", ""] || - - !s.indexOf("", ""] || - - s.match(/^<(thead|tbody|tfoot|colg|cap)/) && - [1, "", "
        "] || - - !s.indexOf("", ""] || - - // matched above - (!s.indexOf("", ""] || - - !s.indexOf("", ""] || - - // IE can't serialize and - - -

        Test:  

        -

        This is an example of an - XHTML 1.0 Strict document.
        - Valid XHTML 1.0 Strict
        - - -

        - - diff --git a/test-cases/document-types/document-iso88592-nocharset.xml b/test-cases/document-types/document-iso88592-nocharset.xml deleted file mode 100644 index 2f2b426..0000000 --- a/test-cases/document-types/document-iso88592-nocharset.xml +++ /dev/null @@ -1,17 +0,0 @@ - - Basic bread - Flour - Yeast - Water - Salt - - Mix all ingredients together. - Knead thoroughly. - Cover with a cloth, and leave for one hour in warm room. - Knead again. - Place in a bread baking tin. - Cover with a cloth, and leave for one hour in warm room. - Bake in the oven at 180(degrees)C for 30 minutes. - Charset test: - - diff --git a/test-cases/document-types/document-iso88592.html b/test-cases/document-types/document-iso88592.html deleted file mode 100644 index bef1a9f..0000000 --- a/test-cases/document-types/document-iso88592.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - HTML document with ISO-8859-2 charset - - - - Hello World! - - - \ No newline at end of file diff --git a/test-cases/document-types/document-iso88592.xhtml b/test-cases/document-types/document-iso88592.xhtml deleted file mode 100644 index a32e9b5..0000000 --- a/test-cases/document-types/document-iso88592.xhtml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - XHTML 1.0 Example - - - -

        Test:  

        -

        This is an example of an - XHTML 1.0 Strict document.
        - Valid XHTML 1.0 Strict
        - - -

        - - diff --git a/test-cases/document-types/document-iso88592.xml b/test-cases/document-types/document-iso88592.xml deleted file mode 100644 index 0b85c10..0000000 --- a/test-cases/document-types/document-iso88592.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - Basic bread - Flour - Yeast - Water - Salt - - Mix all ingredients together. - Knead thoroughly. - Cover with a cloth, and leave for one hour in warm room. - Knead again. - Place in a bread baking tin. - Cover with a cloth, and leave for one hour in warm room. - Bake in the oven at 180(degrees)C for 30 minutes. - Charset test: - - diff --git a/test-cases/document-types/document-utf8-nocharset.html b/test-cases/document-types/document-utf8-nocharset.html deleted file mode 100644 index 280e634..0000000 --- a/test-cases/document-types/document-utf8-nocharset.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - HTML document without charset (encoded in UTF-8) - - - Hello World! - ąśżźć - - \ No newline at end of file diff --git a/test-cases/document-types/document-utf8-nocharset.xhtml b/test-cases/document-types/document-utf8-nocharset.xhtml deleted file mode 100644 index a12ccda..0000000 --- a/test-cases/document-types/document-utf8-nocharset.xhtml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - XHTML 1.0 Example - - - -

        Test:   żźć

        -

        This is an example of an - XHTML 1.0 Strict document.
        - Valid XHTML 1.0 Strict
        - - -

        - - diff --git a/test-cases/document-types/document-utf8-nocharset.xml b/test-cases/document-types/document-utf8-nocharset.xml deleted file mode 100644 index acc35be..0000000 --- a/test-cases/document-types/document-utf8-nocharset.xml +++ /dev/null @@ -1,17 +0,0 @@ - - Basic bread - Flour - Yeast - Water - Salt - - Mix all ingredients together. - Knead thoroughly. - Cover with a cloth, and leave for one hour in warm room. - Knead again. - Place in a bread baking tin. - Cover with a cloth, and leave for one hour in warm room. - Bake in the oven at 180(degrees)C for 30 minutes. - Charset test: ąśżźć - - diff --git a/test-cases/document-types/document-utf8.html b/test-cases/document-types/document-utf8.html deleted file mode 100644 index 0bbe914..0000000 --- a/test-cases/document-types/document-utf8.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - HTML document with UTF-8 charset ąśżźć - - - - Hello World! - ąśżźć - - \ No newline at end of file diff --git a/test-cases/document-types/document-utf8.php b/test-cases/document-types/document-utf8.php deleted file mode 100644 index 35353c7..0000000 --- a/test-cases/document-types/document-utf8.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - HTML document with UTF-8 charset - - foob\'"bar'; ?> - - - Hello World! - ąśżźć - '>Attr test - - diff --git a/test-cases/document-types/document-utf8.xhtml b/test-cases/document-types/document-utf8.xhtml deleted file mode 100644 index 90c957b..0000000 --- a/test-cases/document-types/document-utf8.xhtml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - XHTML 1.0 Example - - - - - -
        -

        Test:   żźć

        -

        This is an example of an - XHTML 1.0 Strict document.
        - Valid XHTML 1.0 Strict
        - - -

        - - diff --git a/test-cases/document-types/document-utf8.xml b/test-cases/document-types/document-utf8.xml deleted file mode 100644 index 718be8b..0000000 --- a/test-cases/document-types/document-utf8.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - Basic bread - Flour - Yeast - Water - Salt - - Mix all ingredients together. - Knead thoroughly. - Cover with a cloth, and leave for one hour in warm room. - Knead again. - Place in a bread baking tin. - Cover with a cloth, and leave for one hour in warm room. - Bake in the oven at 180(degrees)C for 30 minutes. - Charset test: ąśżźć - - diff --git a/test-cases/document_types.php b/test-cases/document_types.php deleted file mode 100644 index e094007..0000000 --- a/test-cases/document_types.php +++ /dev/null @@ -1,151 +0,0 @@ -'; -print ''; - -/* HTML */ - -//$htmlIso = new DOMDocumentWrapper( -// file_get_contents('document-types/document-iso88592.html') -//); -//$htmlIsoNoCharset = new DOMDocumentWrapper( -// file_get_contents('document-types/document-iso88592-nocharset.html'), -// 'text/html;charset=iso-8859-2' -//); -$htmlUtf = new DOMDocumentWrapper( - file_get_contents('document-types/document-utf8.html') -); -var_dump($htmlUtf->markup()); -//$htmlUtfNoCharset = new DOMDocumentWrapper( -// file_get_contents('document-types/document-utf8-nocharset.html'), -// 'text/html;charset=utf-8' -//); -//print htmlspecialchars($htmlIso->markup( -// $htmlIso->document->getElementsByTagName('span')) -//); -//print htmlspecialchars($htmlIsoNoCharset->markup( -// $htmlIsoNoCharset->document->getElementsByTagName('p')) -//); -//print htmlspecialchars($htmlUtf->markup()); -//print htmlspecialchars($htmlUtfNoCharset->markup()); - -/* XML */ - -//$xmlIso = new DOMDocumentWrapper( -// file_get_contents('document-types/document-iso88592.xml') -//); -//$xmlIsoNoCharset = new DOMDocumentWrapper( -// file_get_contents('document-types/document-iso88592-nocharset.xml'), -// 'text/xml;charset=iso-8859-2' -//); -//$xmlUtf = new DOMDocumentWrapper( -// file_get_contents('document-types/document-utf8.xml') -//); -//$xmlUtfNoCharset = new DOMDocumentWrapper( -// file_get_contents('document-types/document-utf8-nocharset.xml'), -// 'text/xml;charset=utf-8' -//); -//print var_dump($xmlIso->markup( -// $xmlIso->document->getElementsByTagName('step')->item(0) -//)); -//print htmlspecialchars($xmlIsoNoCharset->markup()); -//print htmlspecialchars($xmlUtf->markup()); -//print htmlspecialchars($xmlUtfNoCharset->markup()); - -/* XHTML */ - -//$xhtmlIso = new DOMDocumentWrapper( -// file_get_contents('document-types/document-iso88592.xhtml') -//); -//$xhtmlIsoNoCharset = new DOMDocumentWrapper( -// file_get_contents('document-types/document-iso88592-nocharset.xhtml'), -// 'application/xhtml+xml;charset=iso-8859-2' -//); -//$xhtmlUtf = new DOMDocumentWrapper( -// file_get_contents('document-types/document-utf8.xhtml') -//); -//$xhtmlUtfNoCharset = new DOMDocumentWrapper( -// file_get_contents('document-types/document-utf8-nocharset.xhtml'), -// 'application/xhtml+xml' -//); -//print htmlspecialchars($xhtmlIso->markup()); -//print var_dump($xhtmlIsoNoCharset->markup()); -//print var_dump($xhtmlIsoNoCharset->markup( -// $xhtmlIsoNoCharset->document->getElementsByTagName('p') -//)); -//print var_dump($xhtmlUtf->markup()); -//print var_dump($xhtmlUtf->markup( -// $xhtmlUtf->document->getElementsByTagName('p') -//)); -//print htmlspecialchars($xhtmlUtfNoCharset->markup()); - -/** FRAGMETNS **/ - -/* HTML fragment */ - -//$htmlFragmentUtf = new DOMDocumentWrapper( -// file_get_contents('document-types/document-fragment-utf8.html') -//); -//$htmlFragmentUtf->markup(); -//$htmlFragmentUtf->markup( -// $htmlFragmentUtf->document->getElementsByTagName('span') -//); - -/* XML fragment */ - -//$xmlFragmentUtf = new DOMDocumentWrapper( -// file_get_contents('document-types/document-fragment-utf8.xml'), -// 'text/xml'nt var_dump($xhtmlFragmentUtf->document->saveXML()); -//$xhtmlFragmentUtf->markup(); -//$xhtmlFragmentUtf->markup( -// $xhtmlFragmentUtf->document->getElementsByTagName('p') -//); -//); -//$xmlFragmentUtf->markup(); -//$xmlFragmentUtf->markup( -// $xmlFragmentUtf->document->getElementsByTagName('step') -//); - -/* XHTML fragment */ - -//$xhtmlFragmentUtf = new DOMDocumentWrapper( -// file_get_contents('document-types/document-fragment-utf8.xhtml'), -// 'application/xhtml+xml' -//); -//print var_dump($xhtmlFragmentUtf->document->saveXML()); -//$xhtmlFragmentUtf->markup(); -//$xhtmlFragmentUtf->markup( -// $xhtmlFragmentUtf->document->getElementsByTagName('p') -//); - -/* Test template */ -//$result = pq('p:eq(1)'); -//if ( $result->hasClass('newTitle') ) -// print "Test '{$testName}' PASSED :)"; -//else -// print "Test '{$testName}' FAILED !!! "; -//$result->dump(); -//print "\n"; \ No newline at end of file diff --git a/test-cases/run.php b/test-cases/run.php deleted file mode 100644 index 240fdea..0000000 --- a/test-cases/run.php +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/test-cases/test.html b/test-cases/test.html deleted file mode 100644 index 9b22f9f..0000000 --- a/test-cases/test.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - plainTemplate test - - - - - -
        - div.articles text node - < -
          -
        • -

          This is paragraph of first LI

          -

          - this is example title -

          -

          - this is example body -

          -
        • -
        • -

          This is paragraph of second LI

          -

          - this is example title 2 -

          -

          - this is example body 2 -

          -
        • -
        • -

          This is paragraph of third LI

          -

          There isnt any title

          -

          - this is example body 3 -

          -
        • -
        -

        paragraph after UL

        -
        -
          -
        • -
            -
          • -
          -
        • -
        • -
        • -
        - - diff --git a/test-cases/test_2.php b/test-cases/test_2.php deleted file mode 100644 index 4b82993..0000000 --- a/test-cases/test_2.php +++ /dev/null @@ -1,59 +0,0 @@ -find('p') - ->filter('.body:gt(1)'); -if ( $result->whois() == $testResult ) - print "Test '{$testName}' PASSED :)"; -else - print "Test '{$testName}' FAILED !!! "; -print_r($result->whois()); -print "\n"; - - -$testName = 'Filter with multiplie selectors'; -$testResult = array( - 'p.body', -); -$testDOM = phpQuery::newDocumentFile('test.html'); -$single = $testDOM->find('p')->filter('.body') - ->add( - $testDOM->find('p')->filter('.title') - ) -; -$double = $testDOM->find('p') - ->filter('.body, .title'); -if ($single->length == count($double)) - print "Test '{$testName}' PASSED :)"; -else - print "Test '{$testName}' FAILED !!! "; -print "\n"; -print_r($single->whois()); -print "\n"; -print_r($double->whois()); -print "\n"; - - -$testName = 'Attributes in HTML element'; -$validResult = 'testValue'; -$result = phpQuery::newDocumentFile('test.html')->find('html') - ->empty() - ->attr('test', $validResult); -$result = phpQuery::newDocument($result->htmlOuter())->find('html') - ->attr('test'); -//similar_text($result->htmlOuter(), $validResult, $similarity); -if ( $result == $validResult ) - print "Test '{$testName}' PASSED :)"; -else { - print "Test '{$testName}' FAILED !!! "; - print "
        ";
        -	print $result;
        -	print "
        \n"; -} \ No newline at end of file diff --git a/test-cases/test_4.php b/test-cases/test_4.php deleted file mode 100755 index a262638..0000000 --- a/test-cases/test_4.php +++ /dev/null @@ -1,106 +0,0 @@ -find('li') - ->slice(1, 2); -if ( $result->whois() == $testResult ) - print "Test 'Slice1' PASSED :)"; -else { - print "Test 'Slice1' FAILED !!! "; - print "
        ";
        -	print_r($result->whois());
        -	print "
        \n"; -} -print "\n"; - -// SLICE2 -$testResult = array( - 'li#testID', - 'li', - 'li#i_have_nested_list', - 'li.nested', -); -$result = phpQuery::newDocumentFile('test.html') - ->find('li') - ->slice(1, -1); -if ( $result->whois() == $testResult ) - print "Test 'Slice2' PASSED :)"; -else { - print "Test 'Slice2' FAILED !!! "; - print "
        ";
        -	print_r($result->whois());
        -	print "
        \n"; -} -print "\n"; - -// Multi-insert -$result = phpQuery::newDocument('
      • ') - ->find('.field1') - ->php('longlongtest'); -$validResult = '
      • longlongtestlonglongtest
      • '; -similar_text($result->htmlOuter(), $validResult, $similarity); -if ( $similarity > 80 ) - print "Test 'Multi-insert' PASSED :)"; -else { - print "Test 'Multi-insert' FAILED !!! "; - print "
        ";
        -	var_dump($result->htmlOuter());
        -	print "
        \n"; -} -print "\n"; - -// INDEX -$testResult = 1; -$result = phpQuery::newDocumentFile('test.html') - ->find('p') - ->index(pq('p.title:first')); -if ( $result == $testResult ) - print "Test 'Index' PASSED :)"; -else { - print "Test 'Index' FAILED !!! "; -} -print "\n"; - -// CLONE -$testName = 'Clone'; -$testResult = 3; -$document; -$p = phpQuery::newDocumentFile('test.html') - ->toReference($document) - ->find('p:first'); -foreach(array(0,1,2) as $i) { - $p->clone() - ->addClass("clone-test") - ->addClass("class-$i") - ->insertBefore($p); -} -if (pq('.clone-test')->size() == $testResult) - print "Test '$testName' PASSED :)"; -else { - print "Test '$testName' FAILED !!! "; -} -print "\n"; - -// SIBLINGS -$testName = 'Next'; -$testResult = 3; -$document; -$result = phpQuery::newDocumentFile('test.html') - ->find('li:first') - ->next() - ->next() - ->prev() - ->is('#testID'); -if ($result) - print "Test '$testName' PASSED :)"; -else { - print "Test '$testName' FAILED !!! "; -} -print "\n"; -?> \ No newline at end of file diff --git a/test-cases/test_5.php b/test-cases/test_5.php deleted file mode 100755 index 13a7c44..0000000 --- a/test-cases/test_5.php +++ /dev/null @@ -1,47 +0,0 @@ -addClass('newClass'); - } - function methodCallback($node) { - pq($node)->addClass('newClass'); - } -} -function functionCallback($node) { - pq($node)->addClass('newClass'); -} -$testResult = array( - 'li.newClass', - 'li#testID.newClass', - 'li.newClass', - 'li#i_have_nested_list.newClass', - 'li.nested.newClass', - 'li.second.newClass', -); -$tests = array( - 'functionCallback', - array('callbackClass', 'staticMethodCallback'), - array(new callbackClass, 'methodCallback') -); -foreach($tests as $test) { - $result = phpQuery::newDocumentFile('test.html') - ->find('li') - ->each($test); - $testName = is_array($test) - ? $test[1] - : $test; - if ( $result->whois() == $testResult ) - print "Test '$testName' PASSED :)"; - else { - print "Test '$testName' FAILED !!! "; - print "
        ";
        -		print_r($result->whois());
        -		print "
        \n"; - } - print "\n"; -} -?> \ No newline at end of file diff --git a/test-cases/test_ajax.php b/test-cases/test_ajax.php deleted file mode 100755 index 8fed6f3..0000000 --- a/test-cases/test_ajax.php +++ /dev/null @@ -1,64 +0,0 @@ - 'http://wikipedia.org/', -// 'success' => 'v87shs79d8fhs9d' -//)); -//function v87shs79d8fhs9d($html) { -// $title = phpQuery::newDocument($html)->find('title'); -// $testName = 'Simple AJAX'; -// if ( strpos(strtolower($title->html()), 'wikipedia') !== false ) -// print "Test '$testName' PASSED :)"; -// else { -// print "Test '$testName' FAILED !!! "; -// print "
        ";
        -//		print_r($title->whois());
        -//		print "
        \n"; -// } -// print "\n"; -//} - - -$testName = 'Load'; -$test = phpQuery::newDocumentFile('test.html') - ->find('div:first') - ->load('http://wikipedia.org/ div[lang]'); -if (pq('div[lang]')->size()) - print "Test '$testName' PASSED :)"; -else { - print "Test '$testName' FAILED !!! "; - print "
        ";
        -	print "
        \n"; -} -print "\n"; - - -//$testName = 'gdata plugin'; -//phpQuery::extend('gdata'); -//$xhr = phpQuery::$plugins->gdata('tobiasz.cudnik@gmail.com', 'XXX'); -//$url = 'http://code.google.com/p/phpquery/w/edit/Callbacks'; -//phpQuery::ajax(array('url' => $url, 'success' => 'ksjsdgh892jh23'), $xhr); -//function ksjsdgh892jh23($html) { -// print $html; -// print pq($html)->find('script')->remove()->end(); -// if (pq('div[lang]')->size()) -// print "Test '$testName' PASSED :)"; -// else { -// print "Test '$testName' FAILED !!! "; -// print "
        ";
        -//		print "
        \n"; -// } -// print "\n"; -//} \ No newline at end of file diff --git a/test-cases/test_arrayaccess.php b/test-cases/test_arrayaccess.php deleted file mode 100755 index fb31098..0000000 --- a/test-cases/test_arrayaccess.php +++ /dev/null @@ -1,36 +0,0 @@ -append('test'); -$testName = 'Array Access get'; -if (trim($testHtml['.just-added']->html()) == 'test') - print "Test '$testName' PASSED :)"; -else { - print "Test '$testName' FAILED !!! "; - print "
        ";
        -	print_r($testHtml['.just-added']->whois());
        -	print "
        \n"; -} -print "\n"; - -require_once('../phpQuery/phpQuery.php'); -phpQuery::$debug = true; -$testHtml = phpQuery::newDocumentFile('test.html'); -$testHtml['li:first'] = 'new inner html'; -$testName = 'Array Access set'; -if (trim($testHtml['li:first']->html()) == 'new inner html') - print "Test '$testName' PASSED :)"; -else { - print "Test '$testName' FAILED !!! "; - print "
        ";
        -	print_r($testHtml['.just-added']->whois());
        -	print "
        \n"; -} -print "\n"; diff --git a/test-cases/test_attr.php b/test-cases/test_attr.php deleted file mode 100644 index 4e808c0..0000000 --- a/test-cases/test_attr.php +++ /dev/null @@ -1,26 +0,0 @@ -find('p[rel]:first') - ->attr('rel', $expected); -if ($result->attr('rel') == $expected) - print "Test '{$testName}' passed :)"; -else - print "Test '{$testName}' FAILED !!!"; -print "\n"; - - -$testName = 'Attribute change in iteration'; -$expected = 'new attr value'; -$doc = phpQuery::newDocumentFile('test.html'); -foreach($doc['p[rel]:first'] as $p) - pq($p)->attr('rel', $expected); -if ($doc['p[rel]:first']->attr('rel') == $expected) - print "Test '{$testName}' passed :)"; -else - print "Test '{$testName}' FAILED !!!"; -print "\n"; \ No newline at end of file diff --git a/test-cases/test_callback.php b/test-cases/test_callback.php deleted file mode 100644 index a854ab5..0000000 --- a/test-cases/test_callback.php +++ /dev/null @@ -1,27 +0,0 @@ - array($this, 'callback1'), - 'newMethod2' => array($this, 'callback2'), - ); - phpQuery::extend('phpQueryObject', $newMethods); - $doc = phpQuery::newDocumentXML("
        "); - $this->assertTrue($doc->newMethod1() == $doc, - '$doc->newMethod1 == $doc'); - $this->assertTrue($doc->newMethod2() == "callback2", - '$doc->newMethod1 == "callback2"'); - } -} \ No newline at end of file diff --git a/test-cases/test_charset.php b/test-cases/test_charset.php deleted file mode 100644 index a0b4768..0000000 --- a/test-cases/test_charset.php +++ /dev/null @@ -1,94 +0,0 @@ - -find('li:first') - ->find('p:first') - ->html('żźć'); -if (trim($result->html()) == 'żźć') - print "Test '{$testName}' passed :)
        \n"; -else - print "Test '{$testName}' FAILED !!!
        \n"; -print "\n"; - -$testName = 'Text node HTML entite append'; -$result = phpQuery::newDocumentFile('test.html') - ->find('li:first') - ->find('p:first') - ->_empty() - ->append('é'); -if (trim($result->html()) == 'é') - print "Test '{$testName}' passed :)
        \n"; -else { - print "Test '{$testName}' FAILED !!!
        \n"; - print $result->html(); -} -print "\n"; - -$testName = 'DOMElement node HTML entite append'; -$result = phpQuery::newDocumentFile('test.html') - ->find('li:first') - ->find('p:first') - ->empty() - ->append('é'); -if (trim($result->html()) == 'é') - print "Test '{$testName}' passed :)
        \n"; -else { - print "Test '{$testName}' FAILED !!!
        \n"; - print $result->html(); -} -print "\n"; - -$testName = 'Append and move'; -$result = phpQuery::newDocumentFile('test.html'); -$li = $result->find('li:first'); -$result->find('div')->_empty(); -$li->html('test1-é-test1') - ->append('test2-é-test2') - ->appendTo( - $result->find('div:first') - ); -$result = $result->find('div:first li:first'); -$expected = 'test1-é-test1test2-é-test2'; -if (trim(str_replace("\n", '', $result->html())) == $expected) - print "Test '{$testName}' passed :)
        \n"; -else { - print "Test '{$testName}' FAILED !!!
        \n"; - print "'".trim($result->html())."'"; -} -print "\n"; - -$testName = 'Attr charset'; -$result = phpQuery::newDocumentFile('test.html') - ->find('li:first') - ->attr('test', 'foo é żźć bar'); -if (trim($result->attr('test')) == 'foo é żźć bar') - print "Test '{$testName}' passed :)
        \n"; -else { - print "Test '{$testName}' FAILED !!!
        \n"; - print $result->attr('test'); -} -print "\n"; - - -//$testName = 'Loading document without meta charset'; -//$result = phpQuery::newDocumentFile('test.html') -// ->_empty(); -////var_dump((string)$result->htmlOuter()); -//$result = phpQuery::newDocument($result->htmlOuter()); -//$validResult = << -// -//EOF; -//$similarity = 0; -//similar_text($result->htmlOuter(), $validResult, $similarity); -//if ( $similarity > 90 ) -// print "Test '{$testName}' passed :)
        \n"; -//else -// print "Test '{$testName}' FAILED !!! "; -//print "
        ";
        -//print $result;
        -//print "
        \n"; \ No newline at end of file diff --git a/test-cases/test_document.php b/test-cases/test_document.php deleted file mode 100644 index 24c2cc5..0000000 --- a/test-cases/test_document.php +++ /dev/null @@ -1,20 +0,0 @@ -find('li:first')->html('foo

        bar

        foo foo')->html(); -die(); -$testResult = 10; -if ($doc->script('example', 'p')->length == $testResult) - print "Test '$testName' PASSED :)"; -else { - print "Test '$testName' FAILED !!! "; - print "
        ";
        -	var_dump($doc->whois());
        -	print "
        \n"; -} -print "\n"; \ No newline at end of file diff --git a/test-cases/test_events.php b/test-cases/test_events.php deleted file mode 100755 index f4ebcd9..0000000 --- a/test-cases/test_events.php +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - -EOF; -$doc = phpQuery::newDocumentHTML($form); -$inputs = $doc['form > *']; -// creates array from input names -// $results = $inputs->get(null, -// create_function('$node', 'return $node->getAttribute("name");') -// ); -$results = array(); -foreach($inputs as $node) { - $node = pq($node); - $name = $node->attr('name'); - $results[$name] = false; - $node->change( - new CallbackReference($results[$name]) - ); -} -$inputs - ->not('select,:checkbox,:radio') - ->val('new value') - ->end() - ->filter('select') - ->val('first') - ->end() - ->filter(':checkbox') - ->val(array('foo')) - ->end() - ->filter(':radio') - ->val(array('foo')) - ->end() -; -foreach($results as $name => $result) { - print $result - ? "Test for '$name' PASSED :)
        \n" - : "Test for '$name' FAILED !!!
        \n"; -} \ No newline at end of file diff --git a/test-cases/test_insert.php b/test-cases/test_insert.php deleted file mode 100644 index ff2e7e2..0000000 --- a/test-cases/test_insert.php +++ /dev/null @@ -1,20 +0,0 @@ -find('step'); -print $doc->find('p'); -$markup = "test
        test

        test p

        "; -$doc['body > p:last']->append($markup); -if ($doc['body > p:last p']->length == 1) - print "Test '{$testName}' PASSED :)"; -else { - print "Test '{$testName}' FAILED !!! "; - print $doc->htmlOuter('htmlspecialchars'); -} -print "\n"; \ No newline at end of file diff --git a/test-cases/test_manipulation.php b/test-cases/test_manipulation.php deleted file mode 100644 index ac55307..0000000 --- a/test-cases/test_manipulation.php +++ /dev/null @@ -1,143 +0,0 @@ - - div.articles text node -
          - -
        • -

          This is paragraph of first LI

          -

          News 1 title

          -

          News 1 body

          -
        • - -
        • -

          This is paragraph of first LI

          -

          News 2 title

          -

          News 2 body

          -
        • -
        • -

          This is paragraph of first LI

          -

          News 3

          -

          News 3 body

          -
        • -
        -

        paragraph after UL

        -
        -EOF; -$rows = array( - array( - 'title' => 'News 1 title', - 'body' => 'News 1 body', - ), - array( - 'title' => 'News 2 title', - 'body' => 'News 2 body', - ), - array( - 'title' => 'News 3', - 'body' => 'News 3 body', - ), -); -phpQuery::newDocumentFile('test.html'); -$articles = pq('.articles ul'); -$rowSrc = $articles->find('li') - ->remove() - ->eq(0); -foreach( $rows as $r ) { - $row = $rowSrc->_clone(); - foreach( $r as $field => $value ) { - $row->find(".{$field}") - ->html($value); -// die($row->htmlOuter()); - } - $row->appendTo($articles); -} -$result = pq('.articles')->htmlOuter(); -//print htmlspecialchars("
        {$result}
        ").'
        '; -$similarity = 0.0; -similar_text($testResult, $result, $similarity); -if ($similarity > 90) - print "Test '{$testName}' passed :)"; -else - print "Test '{$testName}' FAILED ($similarity) !!!"; -print "\n"; - - -$testName = 'Parent && children'; -$result = phpQuery::newDocumentFile('test.html'); -$parent = $result->find('ul:first'); -$children = $parent->find('li:first'); -$e = null; -try { - $children->before('
      • test
      • '); -} catch(Exception $e) { - print "Test '{$testName}' FAILED !!! "; -} -if (! $e) { - print "Test '{$testName}' PASSED :)"; -} -print "\n"; - - -$testName = 'HTML insertion'; -$doc = phpQuery::newDocument('

        '); -$string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre 0°C et 210°C."; -$doc->find('p')->html($string); -if (pq('p')->length == 1) - print "Test '{$testName}' PASSED :)"; -else { - print "Test '{$testName}' FAILED !!! "; - print $doc->htmlOuter('htmlentities'); -} -print "\n"; - - -$testName = 'HTML insertion 2'; -$doc = phpQuery::newDocument('

        '); -$string = "
        La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre 0°C et 210°C.
        "; -$doc->find('p')->html($string); -if (pq('div')->length == 2) { - print "Test '{$testName}' PASSED :)"; -} else { - print "Test '{$testName}' FAILED !!! "; - print $doc->htmlOuter('htmlentities'); -} -print "\n"; - - -$testName = 'HTML insertion 3'; -$doc = phpQuery::newDocument('

        '); -$string = 'Hors paragraphe. - -

        Éditorial de l\'institution Saint-Pierre.

        - Hors paragraphe.'; -$doc->find('p')->html($string); -if (pq('img')->length == 1) { - print "Test '{$testName}' PASSED :)"; - print $doc->htmlOuter(); -} else { - print "Test '{$testName}' FAILED !!! "; - print $doc->htmlOuter('htmlentities'); -} -print "\n"; - - - - -$testName = 'Text insertion'; -$doc = phpQuery::newDocument('

        '); -$string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie"; -$doc->find('p')->html($string); -if (trim(pq('p:first')->html()) == $string) - print "Test '{$testName}' PASSED :)"; -else { - print "Test '{$testName}' FAILED !!! "; - print $doc->htmlOuter('htmlentities'); -} -print "\n"; -?> \ No newline at end of file diff --git a/test-cases/test_manual.php b/test-cases/test_manual.php deleted file mode 100644 index fe81cc7..0000000 --- a/test-cases/test_manual.php +++ /dev/null @@ -1,301 +0,0 @@ - -

        p

        '); -//print $doc['article']->children(':empty')->get(0)->tagName; - -//$doc = phpQuery::newDocumentFile('test.html'); -//setlocale(LC_ALL, 'pl_PL.UTF-8'); -//$string = strftime('%B %Y', time()); -//$doc['p:first']->append($string)->dump(); - -/* - * -$doc1 = phpQuery::newDocumentFileXHTML('doc1.html'); -$doc2 = phpQuery::newDocumentFileXHTML('doc2.html'); -$doc3 = phpQuery::newDocumentFileXHTML('doc3.html'); -$doc4 = phpQuery::newDocumentFileXHTML('doc4.html'); -$doc2['body'] - ->append($doc3['body >*']) - ->append($doc4['body >*']); -$doc1['body'] - ->append($doc2['body >*']); -print $doc1->plugin('Scripts')->script('safe_print'); -*/ -//$doc = phpQuery::newDocument('

        p1 b1 b2

        p2

        '); -//print $doc['p']->contents()->not('[nodeType=1]'); - -//print phpQuery::newDocumentFileXML('tmp.xml'); - - -//$doc = phpQuery::newDocumentXML('textnodetest'); -//pq('

        ', $doc)->insertBefore(pq('node'))->append(pq('node')); -//$doc->contents()->wrap('

        '); -//$doc['node']->wrapAll('

        '); -// ->contents() -// ->wrap('

        '); -//print $doc; - -// http://code.google.com/p/phpquery/issues/detail?id=66 -//$doc = phpQuery::newDocumentXML('

        123123

        '); -//$doc->dump(); -//$doc->children()->wrapAll('
        ')->dump(); - -// http://code.google.com/p/phpquery/issues/detail?id=69 -//$doc = phpQuery::newDocumentXML('

        123123

        '); -//$doc['[class^="test"]']->dump(); - -// http://code.google.com/p/phpquery/issues/detail?id=71 -// $doc = phpQuery::newDocument(''); -// print $doc['input']->val('new')->val(); - -// http://code.google.com/p/phpquery/issues/detail?id=71 -// $doc = phpQuery::newDocument(''); -// $doc['select']->val('20')->dump(); - -// http://code.google.com/p/phpquery/issues/detail?id=73 -// $doc = phpQuery::newDocument(''); -// var_dump($doc['input']->val(0)->val()); - -// $a = null; -// new CallbackReference($a); -// phpQuery::callbackRun(new CallbackReference($a), array('new $a value')); -// var_dump($a); - -// check next() inside (also, but separatly) -// $inputs->dump(); -// foreach($inputs as $node) { -// } -// $inputs->dump(); - -// http://code.google.com/p/phpquery/issues/detail?id=74 -// http://code.google.com/p/phpquery/issues/detail?id=31 -//$doc = phpQuery::newDocument('
        '); -//$doc['div']->filter('.class1, .class2')->dump()->dumpWhois(); - -// http://code.google.com/p/phpquery/issues/detail?id=76 -// mb_internal_encoding("UTF-8"); -// mb_regex_encoding("UTF-8"); -// $xml = phpQuery::newDocumentXML('<документа/>'); -// -// $xml['документа']->append('<список>'); -// $xml['документа список'] = '<эл>1<эл>2<эл>3'; -// print "$xml"; - -// zeromski 0.9.5 vs 0.9.1 -// phpQuery::newDocumentXML('')->dump(); - -// http://code.google.com/p/phpquery/issues/detail?id=77 -// phpQuery::newDocumentFile('http://google.com/') -// ->find('body > *')->dumpWhois(); -/*$XHTML = << - - - - - - -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -

        - Vous êtes ici : -

        -

        Editorial

        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        -
        - - -EOF; -phpQuery::newDocumentXHTML($XHTML) - ->find('body:first > *')->dumpWhois();*/ - -// http://code.google.com/p/phpquery/issues/detail?id=83 -//$doc = phpQuery::newDocument('
        '); -//print $doc['[name=toto]']->val('1'); - -//$doc = phpQuery::newDocumentFile('http://www.google.pl/search?hl=en&q=test&btnG=Google+Search'); -//print $doc; - -// http://code.google.com/p/phpquery/issues/detail?id=88 -//$doc = phpQuery::newDocumentXML(''); -//$doc['foo']->find('bar')->andSelf()->addClass('test'); -//$doc->dump(); - -// http://code.google.com/p/phpquery/issues/detail?id=90 -//print phpQuery::newDocument('') -// ->find('body') -// ->load('http://localhost/phpinfo.php'); - -// http://code.google.com/p/phpquery/issues/detail?id=91 -// phpQuery::newDocumentXML(''); -// print pq('foo')->filter('[bar$=c]'); - -// FIXME http://code.google.com/p/phpquery/issues/detail?id=93 -//$doc = 'SomeTitle -// -//blah -//'; -//$pq = phpQuery::newDocument($doc); -//echo $pq; - -# http://code.google.com/p/phpquery/issues/detail?id=94#makechanges -//$doc = phpQuery::newDocument(); -//$test = pq( -//' -//
      • -// -// -//
        -// -// -//
      • -//' -//); - -// http://code.google.com/p/phpquery/issues/detail?id=96 -//$doc = phpQuery::newDocument(''); -//$doc = phpQuery::newDocument(''); -//print $doc['select']->val(3)->end()->script('print_source'); -//(16:27:56) jomofcw: $option_element = -//(16:27:56) jomofcw: pq('