Skip to content

Commit

Permalink
task 97: phpQuery::getJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasz.cudnik committed Feb 18, 2009
1 parent a6f168c commit df0b4ed
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 103 deletions.
6 changes: 3 additions & 3 deletions demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
// save it anywhere in the chain
->toReference($li);

// SELECT IT
// SELECT DOCUMENT
// pq(); is using selected document as default
phpQuery::selectDocument($doc);
// documents are selected when created, iterated or by above method
// documents are selected when created or by above method
// query all unordered lists in last selected document
$ul = pq('ul')->insertAfter('div');

// INTERATE IT
// ITERATE IT
// all direct LIs from $ul
foreach($ul['> li'] as $li) {
// iteration returns PLAIN dom nodes, NOT phpQuery objects
Expand Down
25 changes: 16 additions & 9 deletions phpQuery/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* Callback class implementing ParamStructures, pattern similar to Currying.
*
* @link http://code.google.com/p/phpquery/wiki/Callbacks#Param_Structures
* @author Tobiasz Cudnik
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
*/
class Callback
implements ICallbackNamed {
public $callback = null;
public $params = null;
protected $name;
public function __construct($callback, $param1 = null, $param2 = null, $param3 = null) {
$params = func_get_args();
$params = array_slice($params, 1);
Expand All @@ -29,12 +30,17 @@ public function setName($name) {
$this->name = $name;
return $this;
}
// TODO test me !!!
// TODO test me
// public function addParams() {
// $params = func_get_args();
// return new Callback($this->callback, $this->params+$params);
// }
}
/**
* Callback type which on execution returns reference passed during creation.
*
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
*/
class CallbackReturnReference extends Callback
implements ICallbackNamed {
protected $reference;
Expand All @@ -52,6 +58,11 @@ public function hasName() {
return isset($this->name) && $this->name;
}
}
/**
* Callback type which on execution returns value passed during creation.
*
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
*/
class CallbackReturnValue extends Callback
implements ICallbackNamed {
protected $value;
Expand Down Expand Up @@ -80,22 +91,18 @@ function getName();
}
/**
* CallbackParameterToReference 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*.
* only parameter passed to it. CallbackParameterToReference takes first
* parameter's value and passes it to reference.
*
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
*
*/
class CallbackParameterToReference extends Callback {
/**
*
* @param $reference
* @param $paramIndex
* @TODO implement $paramIndex;
* param index choose which callback param will be passed to reference
*/
public function __construct(&$reference, $paramIndex = null){
public function __construct(&$reference){
$this->callback =& $reference;
}
}
Expand Down
4 changes: 2 additions & 2 deletions phpQuery/DOMDocumentWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ protected function documentFragmentToMarkup($fragment) {
return $markup;
}
/**
* Return document markup, starting with optional $node as root.
* Return document markup, starting with optional $nodes as root.
*
* @param $node DOMNode|DOMNodeList
* @param $nodes DOMNode|DOMNodeList
* @return string
*/
public function markup($nodes = null, $innerMarkup = false) {
Expand Down
Loading

0 comments on commit df0b4ed

Please sign in to comment.