1
+ <?php
2
+ require_once ('./phpQuery/phpQuery.php ' );
3
+ //phpQuery::$debug = true;
4
+ //die(file_get_contents('http://google.com/search?hl=pl&q=phpQuery&btnG=Szukaj+w+Google&lr='));
5
+ //phpQuery::extend('WebBrowser');
6
+ //phpQuery::$ajaxAllowedHosts[] = 'http://jquery-api-browser.googlecode.com';
7
+ //
8
+ //phpQuery::$plugins->browserGet('http://jquery-api-browser.googlecode.com/svn/trunk/api-docs.xml', 'success');
9
+ phpQuery::browserGet ('http://jquery-api-browser.googlecode.com/svn/trunk/api-docs.xml ' , 'success ' );
10
+ /**
11
+ * @param phpQueryObject $pq
12
+ */
13
+ function success ($ pq ) {
14
+ switch ($ _GET ['page ' ]) {
15
+ case 'selectors ' :
16
+ case 1 :
17
+ $ categories = $ pq ->find ('cat[value=Selectors] subcat ' );
18
+ $ content = array ();
19
+ // $content[] = "==Selectors==";
20
+ $ content [] = "In *phpQuery*, as in *jQuery*, supported are following *CSS3* selectors. " ;
21
+ foreach ($ categories as $ subcat ) {
22
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
23
+ foreach (pq ($ subcat )->find ('selector ' ) as $ selector )
24
+ $ content [] = ' * *` ' .pq ('sample ' , $ selector )->text ().'`* ' .pq ('> desc ' , $ selector )->text ();
25
+ }
26
+ $ content [] = '' ;
27
+ $ content [] = "Read more at [http://docs.jquery.com/Selectors Selectors section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
28
+ break ;
29
+ case 'Attribues ' :
30
+ case 2 :
31
+ $ categories = $ pq ->find ('cat[value=Attributes] subcat ' );
32
+ $ content = array ();
33
+ // $content[] = "==Attributes==";
34
+ $ content [] = "Attributes related methods. " ;
35
+ foreach ($ categories as $ subcat ) {
36
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
37
+ foreach (pq ($ subcat )->find ('function ' ) as $ function ) {
38
+ $ tmp = ' * *` ' .pq ($ function )->attr ('name ' ).'( ' ;
39
+ foreach (pq ($ function )->find ('params ' ) as $ params ) {
40
+ $ tmp .= '$ ' .pq ($ params )->attr ('name ' );
41
+ if (pq ($ params )->nextAll ('params ' )->length )
42
+ $ tmp .= ', ' ;
43
+ }
44
+ $ tmp .= ')`* ' .pq ('> desc ' , $ function )->text ();
45
+ $ content [] = $ tmp ;
46
+ }
47
+ }
48
+ $ content [] = '' ;
49
+ $ content [] = "Read more at [http://docs.jquery.com/Attributes Attributes section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
50
+ break ;
51
+ case 'Traversing ' :
52
+ case 3 :
53
+ $ categories = $ pq ->find ('cat[value=Traversing] subcat ' );
54
+ $ content = array ();
55
+ // $content[] = "==Attributes==";
56
+ $ content [] = "Traversing related methods. " ;
57
+ foreach ($ categories as $ subcat ) {
58
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
59
+ foreach (pq ($ subcat )->find ('function ' ) as $ function ) {
60
+ $ tmp = ' * *` ' .pq ($ function )->attr ('name ' ).'( ' ;
61
+ foreach (pq ($ function )->find ('params ' ) as $ params ) {
62
+ $ tmp .= '$ ' .pq ($ params )->attr ('name ' );
63
+ if (pq ($ params )->nextAll ('params ' )->length )
64
+ $ tmp .= ', ' ;
65
+ }
66
+ $ tmp .= ')`* ' .pq ('> desc ' , $ function )->text ();
67
+ $ content [] = $ tmp ;
68
+ }
69
+ }
70
+ $ content [] = '' ;
71
+ $ content [] = "Read more at [http://docs.jquery.com/Traversing Traversing section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
72
+ break ;
73
+ case 'Manipulation ' :
74
+ case 4 :
75
+ $ categories = $ pq ->find ('cat[value=Manipulation] subcat ' );
76
+ $ content = array ();
77
+ // $content[] = "==Attributes==";
78
+ $ content [] = "Manipulatin related methods. " ;
79
+ foreach ($ categories as $ subcat ) {
80
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
81
+ foreach (pq ($ subcat )->find ('function ' ) as $ function ) {
82
+ $ tmp = ' * *` ' .pq ($ function )->attr ('name ' ).'( ' ;
83
+ foreach (pq ($ function )->find ('params ' ) as $ params ) {
84
+ $ tmp .= '$ ' .pq ($ params )->attr ('name ' );
85
+ if (pq ($ params )->nextAll ('params ' )->length )
86
+ $ tmp .= ', ' ;
87
+ }
88
+ $ tmp .= ')`* ' .pq ('> desc ' , $ function )->text ();
89
+ $ content [] = $ tmp ;
90
+ }
91
+ }
92
+ $ content [] = '' ;
93
+ $ content [] = "Read more at [http://docs.jquery.com/Manipulation Manipulation section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
94
+ break ;
95
+ case 'Events ' :
96
+ case 5 :
97
+ $ categories = $ pq ->find ('cat[value=Events] subcat ' );
98
+ $ content = array ();
99
+ // $content[] = "==Attributes==";
100
+ $ content [] = "Events related methods. " ;
101
+ foreach ($ categories as $ subcat ) {
102
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
103
+ foreach (pq ($ subcat )->find ('function ' ) as $ function ) {
104
+ $ tmp = ' * *` ' .pq ($ function )->attr ('name ' ).'( ' ;
105
+ foreach (pq ($ function )->find ('params ' ) as $ params ) {
106
+ $ tmp .= '$ ' .pq ($ params )->attr ('name ' );
107
+ if (pq ($ params )->nextAll ('params ' )->length )
108
+ $ tmp .= ', ' ;
109
+ }
110
+ $ tmp .= ')`* ' .pq ('> desc ' , $ function )->text ();
111
+ $ content [] = $ tmp ;
112
+ }
113
+ }
114
+ $ content [] = '' ;
115
+ $ content [] = "Read more at [http://docs.jquery.com/Events Events section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
116
+ break ;
117
+ case 'Ajax ' :
118
+ case 6 :
119
+ $ categories = $ pq ->find ('cat[value=Ajax] subcat ' );
120
+ $ content = array ();
121
+ // $content[] = "==Attributes==";
122
+ $ content [] = "Ajax related methods. " ;
123
+ foreach ($ categories as $ subcat ) {
124
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
125
+ foreach (pq ($ subcat )->find ('function ' ) as $ function ) {
126
+ $ tmp = ' * *` ' .str_replace ('jQuery. ' , 'phpQuery:: ' , pq ($ function )->attr ('name ' )).'( ' ;
127
+ foreach (pq ($ function )->find ('params ' ) as $ params ) {
128
+ $ tmp .= '$ ' .pq ($ params )->attr ('name ' );
129
+ if (pq ($ params )->nextAll ('params ' )->length )
130
+ $ tmp .= ', ' ;
131
+ }
132
+ $ tmp .= ')`* ' .pq ('> desc ' , $ function )->text ();
133
+ $ content [] = $ tmp ;
134
+ }
135
+ }
136
+ $ content [] = '====Options==== ' ;
137
+ foreach ($ pq ->find ('cat[value=Ajax] subcat:first function:first option ' ) as $ option ) {
138
+ $ content [] = ' * *` ' .pq ($ option )->attr ('name ' ).'`* ` ' .pq ($ option )->attr ('type ' ).'` ' ;
139
+ }
140
+ $ content [] = '' ;
141
+ $ content [] = "Read more at [http://docs.jquery.com/Ajax Ajax section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
142
+ break ;
143
+ case 'Utilities ' :
144
+ case 7 :
145
+ $ categories = $ pq ->find ('cat[value=Utilities] subcat ' );
146
+ $ content = array ();
147
+ // $content[] = "==Attributes==";
148
+ $ content [] = "Some handy functions. " ;
149
+ foreach ($ categories as $ subcat ) {
150
+ $ content [] = '==== ' .pq ($ subcat )->attr ('value ' )."==== " ;
151
+ foreach (pq ($ subcat )->find ('function ' ) as $ function ) {
152
+ $ tmp = ' * *` ' .str_replace ('jQuery. ' , 'phpQuery:: ' , pq ($ function )->attr ('name ' )).'( ' ;
153
+ foreach (pq ($ function )->find ('params ' ) as $ params ) {
154
+ $ tmp .= '$ ' .pq ($ params )->attr ('name ' );
155
+ if (pq ($ params )->nextAll ('params ' )->length )
156
+ $ tmp .= ', ' ;
157
+ }
158
+ $ tmp .= ')`* ' .pq ('> desc ' , $ function )->text ();
159
+ $ content [] = $ tmp ;
160
+ }
161
+ }
162
+ $ content [] = '' ;
163
+ $ content [] = "Read more at [http://docs.jquery.com/Utilities Utilities section] on [http://docs.jquery.com/ jQuery Documentation Site]. " ;
164
+ break ;
165
+ }
166
+ print implode ("<br /> \n" , $ content );
167
+ }
168
+ ?>
0 commit comments