Skip to content

Commit 96b806d

Browse files
author
tobiasz.cudnik
committed
task 97: phpQuery::getJSON
http://code.google.com/p/phpquery/issues/detail?id=97 git-svn-id: http://phpquery.googlecode.com/svn/branches/dev@355 afc5ee8f-4a33-0410-9214-8715c29b7d85
1 parent 5f055cf commit 96b806d

9 files changed

Lines changed: 203 additions & 103 deletions

File tree

demo.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
// save it anywhere in the chain
2727
->toReference($li);
2828

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

36-
// INTERATE IT
36+
// ITERATE IT
3737
// all direct LIs from $ul
3838
foreach($ul['> li'] as $li) {
3939
// iteration returns PLAIN dom nodes, NOT phpQuery objects

phpQuery/Callback.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* Callback class implementing ParamStructures, pattern similar to Currying.
44
*
55
* @link http://code.google.com/p/phpquery/wiki/Callbacks#Param_Structures
6-
* @author Tobiasz Cudnik
6+
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
77
*/
88
class Callback
99
implements ICallbackNamed {
1010
public $callback = null;
1111
public $params = null;
12+
protected $name;
1213
public function __construct($callback, $param1 = null, $param2 = null, $param3 = null) {
1314
$params = func_get_args();
1415
$params = array_slice($params, 1);
@@ -29,12 +30,17 @@ public function setName($name) {
2930
$this->name = $name;
3031
return $this;
3132
}
32-
// TODO test me !!!
33+
// TODO test me
3334
// public function addParams() {
3435
// $params = func_get_args();
3536
// return new Callback($this->callback, $this->params+$params);
3637
// }
3738
}
39+
/**
40+
* Callback type which on execution returns reference passed during creation.
41+
*
42+
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
43+
*/
3844
class CallbackReturnReference extends Callback
3945
implements ICallbackNamed {
4046
protected $reference;
@@ -52,6 +58,11 @@ public function hasName() {
5258
return isset($this->name) && $this->name;
5359
}
5460
}
61+
/**
62+
* Callback type which on execution returns value passed during creation.
63+
*
64+
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
65+
*/
5566
class CallbackReturnValue extends Callback
5667
implements ICallbackNamed {
5768
protected $value;
@@ -80,22 +91,18 @@ function getName();
8091
}
8192
/**
8293
* CallbackParameterToReference can be used when we don't really want a callback,
83-
* only parameter passed to it. CallbackReference takes first parameter's value
84-
* and passes it to reference. Thanks to that, we can use *if statement* instead
85-
* of *callback function*.
94+
* only parameter passed to it. CallbackParameterToReference takes first
95+
* parameter's value and passes it to reference.
8696
*
8797
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
88-
*
8998
*/
9099
class CallbackParameterToReference extends Callback {
91100
/**
92-
*
93101
* @param $reference
94-
* @param $paramIndex
95102
* @TODO implement $paramIndex;
96103
* param index choose which callback param will be passed to reference
97104
*/
98-
public function __construct(&$reference, $paramIndex = null){
105+
public function __construct(&$reference){
99106
$this->callback =& $reference;
100107
}
101108
}

phpQuery/DOMDocumentWrapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ protected function documentFragmentToMarkup($fragment) {
501501
return $markup;
502502
}
503503
/**
504-
* Return document markup, starting with optional $node as root.
504+
* Return document markup, starting with optional $nodes as root.
505505
*
506-
* @param $node DOMNode|DOMNodeList
506+
* @param $nodes DOMNode|DOMNodeList
507507
* @return string
508508
*/
509509
public function markup($nodes = null, $innerMarkup = false) {

0 commit comments

Comments
 (0)