author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 17:46:52 -0800 | |
changeset 204 | 09a1c134465b |
parent 194 | 32102edaa81b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2 |
if ( ! class_exists( 'SimplePie' ) ) : |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
4 |
// Load classes we will need. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
5 |
require ABSPATH . WPINC . '/SimplePie/Misc.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
6 |
require ABSPATH . WPINC . '/SimplePie/Cache.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
7 |
require ABSPATH . WPINC . '/SimplePie/File.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
8 |
require ABSPATH . WPINC . '/SimplePie/Sanitize.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
9 |
require ABSPATH . WPINC . '/SimplePie/Registry.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
10 |
require ABSPATH . WPINC . '/SimplePie/IRI.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
11 |
require ABSPATH . WPINC . '/SimplePie/Locator.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
12 |
require ABSPATH . WPINC . '/SimplePie/Content/Type/Sniffer.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
13 |
require ABSPATH . WPINC . '/SimplePie/XML/Declaration/Parser.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
14 |
require ABSPATH . WPINC . '/SimplePie/Parser.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
15 |
require ABSPATH . WPINC . '/SimplePie/Item.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
16 |
require ABSPATH . WPINC . '/SimplePie/Parse/Date.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
17 |
require ABSPATH . WPINC . '/SimplePie/Author.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
18 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
19 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
20 |
* WordPress autoloader for SimplePie. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
21 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
22 |
* @since 3.5.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
23 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
24 |
function wp_simplepie_autoload( $class ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
25 |
if ( 0 !== strpos( $class, 'SimplePie_' ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
26 |
return; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
27 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
28 |
$file = ABSPATH . WPINC . '/' . str_replace( '_', '/', $class ) . '.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
29 |
include $file; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
30 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
31 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
32 |
if ( function_exists( 'spl_autoload_register' ) ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
33 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
34 |
* We autoload classes we may not need. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
35 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
36 |
* If SPL is disabled, we load all of SimplePie manually. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
37 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
38 |
* Core.php is not loaded manually, because SimplePie_Core (a deprecated class) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
39 |
* was never included in WordPress core. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
40 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
41 |
spl_autoload_register( 'wp_simplepie_autoload' ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
42 |
} else { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
43 |
require ABSPATH . WPINC . '/SimplePie/Cache/Base.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
44 |
require ABSPATH . WPINC . '/SimplePie/Cache/DB.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
45 |
require ABSPATH . WPINC . '/SimplePie/Cache/File.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
46 |
require ABSPATH . WPINC . '/SimplePie/Cache/Memcache.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
47 |
require ABSPATH . WPINC . '/SimplePie/Cache/MySQL.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
48 |
require ABSPATH . WPINC . '/SimplePie/Caption.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
49 |
require ABSPATH . WPINC . '/SimplePie/Category.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
50 |
require ABSPATH . WPINC . '/SimplePie/Copyright.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
51 |
require ABSPATH . WPINC . '/SimplePie/Credit.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
52 |
require ABSPATH . WPINC . '/SimplePie/Decode/HTML/Entities.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
53 |
require ABSPATH . WPINC . '/SimplePie/Enclosure.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
54 |
require ABSPATH . WPINC . '/SimplePie/gzdecode.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
55 |
require ABSPATH . WPINC . '/SimplePie/HTTP/Parser.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
56 |
require ABSPATH . WPINC . '/SimplePie/Net/IPv6.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
57 |
require ABSPATH . WPINC . '/SimplePie/Rating.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
58 |
require ABSPATH . WPINC . '/SimplePie/Restriction.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
59 |
require ABSPATH . WPINC . '/SimplePie/Source.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
60 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
61 |
|
136 | 62 |
/** |
63 |
* SimplePie |
|
64 |
* |
|
65 |
* A PHP-Based RSS and Atom Feed Framework. |
|
66 |
* Takes the hard work out of managing a complete RSS/Atom solution. |
|
67 |
* |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
68 |
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors |
136 | 69 |
* All rights reserved. |
70 |
* |
|
71 |
* Redistribution and use in source and binary forms, with or without modification, are |
|
72 |
* permitted provided that the following conditions are met: |
|
73 |
* |
|
74 |
* * Redistributions of source code must retain the above copyright notice, this list of |
|
75 |
* conditions and the following disclaimer. |
|
76 |
* |
|
77 |
* * Redistributions in binary form must reproduce the above copyright notice, this list |
|
78 |
* of conditions and the following disclaimer in the documentation and/or other materials |
|
79 |
* provided with the distribution. |
|
80 |
* |
|
81 |
* * Neither the name of the SimplePie Team nor the names of its contributors may be used |
|
82 |
* to endorse or promote products derived from this software without specific prior |
|
83 |
* written permission. |
|
84 |
* |
|
85 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS |
|
86 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
87 |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS |
|
88 |
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
89 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
90 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
91 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
92 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
93 |
* POSSIBILITY OF SUCH DAMAGE. |
|
94 |
* |
|
95 |
* @package SimplePie |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
96 |
* @version 1.3.1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
97 |
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue |
136 | 98 |
* @author Ryan Parman |
99 |
* @author Geoffrey Sneddon |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
100 |
* @author Ryan McCue |
136 | 101 |
* @link http://simplepie.org/ SimplePie |
102 |
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
103 |
*/ |
|
104 |
||
105 |
/** |
|
106 |
* SimplePie Name |
|
107 |
*/ |
|
108 |
define('SIMPLEPIE_NAME', 'SimplePie'); |
|
109 |
||
110 |
/** |
|
111 |
* SimplePie Version |
|
112 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
113 |
define('SIMPLEPIE_VERSION', '1.3.1'); |
136 | 114 |
|
115 |
/** |
|
116 |
* SimplePie Build |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
117 |
* @todo Hardcode for release (there's no need to have to call SimplePie_Misc::get_build() only every load of simplepie.inc) |
136 | 118 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
119 |
define('SIMPLEPIE_BUILD', gmdate('YmdHis', SimplePie_Misc::get_build())); |
136 | 120 |
|
121 |
/** |
|
122 |
* SimplePie Website URL |
|
123 |
*/ |
|
124 |
define('SIMPLEPIE_URL', 'http://simplepie.org'); |
|
125 |
||
126 |
/** |
|
127 |
* SimplePie Useragent |
|
128 |
* @see SimplePie::set_useragent() |
|
129 |
*/ |
|
130 |
define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD); |
|
131 |
||
132 |
/** |
|
133 |
* SimplePie Linkback |
|
134 |
*/ |
|
135 |
define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>'); |
|
136 |
||
137 |
/** |
|
138 |
* No Autodiscovery |
|
139 |
* @see SimplePie::set_autodiscovery_level() |
|
140 |
*/ |
|
141 |
define('SIMPLEPIE_LOCATOR_NONE', 0); |
|
142 |
||
143 |
/** |
|
144 |
* Feed Link Element Autodiscovery |
|
145 |
* @see SimplePie::set_autodiscovery_level() |
|
146 |
*/ |
|
147 |
define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1); |
|
148 |
||
149 |
/** |
|
150 |
* Local Feed Extension Autodiscovery |
|
151 |
* @see SimplePie::set_autodiscovery_level() |
|
152 |
*/ |
|
153 |
define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2); |
|
154 |
||
155 |
/** |
|
156 |
* Local Feed Body Autodiscovery |
|
157 |
* @see SimplePie::set_autodiscovery_level() |
|
158 |
*/ |
|
159 |
define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4); |
|
160 |
||
161 |
/** |
|
162 |
* Remote Feed Extension Autodiscovery |
|
163 |
* @see SimplePie::set_autodiscovery_level() |
|
164 |
*/ |
|
165 |
define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8); |
|
166 |
||
167 |
/** |
|
168 |
* Remote Feed Body Autodiscovery |
|
169 |
* @see SimplePie::set_autodiscovery_level() |
|
170 |
*/ |
|
171 |
define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16); |
|
172 |
||
173 |
/** |
|
174 |
* All Feed Autodiscovery |
|
175 |
* @see SimplePie::set_autodiscovery_level() |
|
176 |
*/ |
|
177 |
define('SIMPLEPIE_LOCATOR_ALL', 31); |
|
178 |
||
179 |
/** |
|
180 |
* No known feed type |
|
181 |
*/ |
|
182 |
define('SIMPLEPIE_TYPE_NONE', 0); |
|
183 |
||
184 |
/** |
|
185 |
* RSS 0.90 |
|
186 |
*/ |
|
187 |
define('SIMPLEPIE_TYPE_RSS_090', 1); |
|
188 |
||
189 |
/** |
|
190 |
* RSS 0.91 (Netscape) |
|
191 |
*/ |
|
192 |
define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2); |
|
193 |
||
194 |
/** |
|
195 |
* RSS 0.91 (Userland) |
|
196 |
*/ |
|
197 |
define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4); |
|
198 |
||
199 |
/** |
|
200 |
* RSS 0.91 (both Netscape and Userland) |
|
201 |
*/ |
|
202 |
define('SIMPLEPIE_TYPE_RSS_091', 6); |
|
203 |
||
204 |
/** |
|
205 |
* RSS 0.92 |
|
206 |
*/ |
|
207 |
define('SIMPLEPIE_TYPE_RSS_092', 8); |
|
208 |
||
209 |
/** |
|
210 |
* RSS 0.93 |
|
211 |
*/ |
|
212 |
define('SIMPLEPIE_TYPE_RSS_093', 16); |
|
213 |
||
214 |
/** |
|
215 |
* RSS 0.94 |
|
216 |
*/ |
|
217 |
define('SIMPLEPIE_TYPE_RSS_094', 32); |
|
218 |
||
219 |
/** |
|
220 |
* RSS 1.0 |
|
221 |
*/ |
|
222 |
define('SIMPLEPIE_TYPE_RSS_10', 64); |
|
223 |
||
224 |
/** |
|
225 |
* RSS 2.0 |
|
226 |
*/ |
|
227 |
define('SIMPLEPIE_TYPE_RSS_20', 128); |
|
228 |
||
229 |
/** |
|
230 |
* RDF-based RSS |
|
231 |
*/ |
|
232 |
define('SIMPLEPIE_TYPE_RSS_RDF', 65); |
|
233 |
||
234 |
/** |
|
235 |
* Non-RDF-based RSS (truly intended as syndication format) |
|
236 |
*/ |
|
237 |
define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190); |
|
238 |
||
239 |
/** |
|
240 |
* All RSS |
|
241 |
*/ |
|
242 |
define('SIMPLEPIE_TYPE_RSS_ALL', 255); |
|
243 |
||
244 |
/** |
|
245 |
* Atom 0.3 |
|
246 |
*/ |
|
247 |
define('SIMPLEPIE_TYPE_ATOM_03', 256); |
|
248 |
||
249 |
/** |
|
250 |
* Atom 1.0 |
|
251 |
*/ |
|
252 |
define('SIMPLEPIE_TYPE_ATOM_10', 512); |
|
253 |
||
254 |
/** |
|
255 |
* All Atom |
|
256 |
*/ |
|
257 |
define('SIMPLEPIE_TYPE_ATOM_ALL', 768); |
|
258 |
||
259 |
/** |
|
260 |
* All feed types |
|
261 |
*/ |
|
262 |
define('SIMPLEPIE_TYPE_ALL', 1023); |
|
263 |
||
264 |
/** |
|
265 |
* No construct |
|
266 |
*/ |
|
267 |
define('SIMPLEPIE_CONSTRUCT_NONE', 0); |
|
268 |
||
269 |
/** |
|
270 |
* Text construct |
|
271 |
*/ |
|
272 |
define('SIMPLEPIE_CONSTRUCT_TEXT', 1); |
|
273 |
||
274 |
/** |
|
275 |
* HTML construct |
|
276 |
*/ |
|
277 |
define('SIMPLEPIE_CONSTRUCT_HTML', 2); |
|
278 |
||
279 |
/** |
|
280 |
* XHTML construct |
|
281 |
*/ |
|
282 |
define('SIMPLEPIE_CONSTRUCT_XHTML', 4); |
|
283 |
||
284 |
/** |
|
285 |
* base64-encoded construct |
|
286 |
*/ |
|
287 |
define('SIMPLEPIE_CONSTRUCT_BASE64', 8); |
|
288 |
||
289 |
/** |
|
290 |
* IRI construct |
|
291 |
*/ |
|
292 |
define('SIMPLEPIE_CONSTRUCT_IRI', 16); |
|
293 |
||
294 |
/** |
|
295 |
* A construct that might be HTML |
|
296 |
*/ |
|
297 |
define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); |
|
298 |
||
299 |
/** |
|
300 |
* All constructs |
|
301 |
*/ |
|
302 |
define('SIMPLEPIE_CONSTRUCT_ALL', 63); |
|
303 |
||
304 |
/** |
|
305 |
* Don't change case |
|
306 |
*/ |
|
307 |
define('SIMPLEPIE_SAME_CASE', 1); |
|
308 |
||
309 |
/** |
|
310 |
* Change to lowercase |
|
311 |
*/ |
|
312 |
define('SIMPLEPIE_LOWERCASE', 2); |
|
313 |
||
314 |
/** |
|
315 |
* Change to uppercase |
|
316 |
*/ |
|
317 |
define('SIMPLEPIE_UPPERCASE', 4); |
|
318 |
||
319 |
/** |
|
320 |
* PCRE for HTML attributes |
|
321 |
*/ |
|
322 |
define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*'); |
|
323 |
||
324 |
/** |
|
325 |
* PCRE for XML attributes |
|
326 |
*/ |
|
327 |
define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*'); |
|
328 |
||
329 |
/** |
|
330 |
* XML Namespace |
|
331 |
*/ |
|
332 |
define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace'); |
|
333 |
||
334 |
/** |
|
335 |
* Atom 1.0 Namespace |
|
336 |
*/ |
|
337 |
define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom'); |
|
338 |
||
339 |
/** |
|
340 |
* Atom 0.3 Namespace |
|
341 |
*/ |
|
342 |
define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#'); |
|
343 |
||
344 |
/** |
|
345 |
* RDF Namespace |
|
346 |
*/ |
|
347 |
define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); |
|
348 |
||
349 |
/** |
|
350 |
* RSS 0.90 Namespace |
|
351 |
*/ |
|
352 |
define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/'); |
|
353 |
||
354 |
/** |
|
355 |
* RSS 1.0 Namespace |
|
356 |
*/ |
|
357 |
define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); |
|
358 |
||
359 |
/** |
|
360 |
* RSS 1.0 Content Module Namespace |
|
361 |
*/ |
|
362 |
define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); |
|
363 |
||
364 |
/** |
|
365 |
* RSS 2.0 Namespace |
|
366 |
* (Stupid, I know, but I'm certain it will confuse people less with support.) |
|
367 |
*/ |
|
368 |
define('SIMPLEPIE_NAMESPACE_RSS_20', ''); |
|
369 |
||
370 |
/** |
|
371 |
* DC 1.0 Namespace |
|
372 |
*/ |
|
373 |
define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/'); |
|
374 |
||
375 |
/** |
|
376 |
* DC 1.1 Namespace |
|
377 |
*/ |
|
378 |
define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/'); |
|
379 |
||
380 |
/** |
|
381 |
* W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace |
|
382 |
*/ |
|
383 |
define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); |
|
384 |
||
385 |
/** |
|
386 |
* GeoRSS Namespace |
|
387 |
*/ |
|
388 |
define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); |
|
389 |
||
390 |
/** |
|
391 |
* Media RSS Namespace |
|
392 |
*/ |
|
393 |
define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); |
|
394 |
||
395 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
396 |
* Wrong Media RSS Namespace. Caused by a long-standing typo in the spec. |
136 | 397 |
*/ |
398 |
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss'); |
|
399 |
||
400 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
401 |
* Wrong Media RSS Namespace #2. New namespace introduced in Media RSS 1.5. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
402 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
403 |
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2', 'http://video.search.yahoo.com/mrss'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
404 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
405 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
406 |
* Wrong Media RSS Namespace #3. A possible typo of the Media RSS 1.5 namespace. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
407 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
408 |
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3', 'http://video.search.yahoo.com/mrss/'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
409 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
410 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
411 |
* Wrong Media RSS Namespace #4. New spec location after the RSS Advisory Board takes it over, but not a valid namespace. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
412 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
413 |
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4', 'http://www.rssboard.org/media-rss'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
414 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
415 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
416 |
* Wrong Media RSS Namespace #5. A possible typo of the RSS Advisory Board URL. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
417 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
418 |
define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5', 'http://www.rssboard.org/media-rss/'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
419 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
420 |
/** |
136 | 421 |
* iTunes RSS Namespace |
422 |
*/ |
|
423 |
define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); |
|
424 |
||
425 |
/** |
|
426 |
* XHTML Namespace |
|
427 |
*/ |
|
428 |
define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml'); |
|
429 |
||
430 |
/** |
|
431 |
* IANA Link Relations Registry |
|
432 |
*/ |
|
433 |
define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/'); |
|
434 |
||
435 |
/** |
|
436 |
* No file source |
|
437 |
*/ |
|
438 |
define('SIMPLEPIE_FILE_SOURCE_NONE', 0); |
|
439 |
||
440 |
/** |
|
441 |
* Remote file source |
|
442 |
*/ |
|
443 |
define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1); |
|
444 |
||
445 |
/** |
|
446 |
* Local file source |
|
447 |
*/ |
|
448 |
define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2); |
|
449 |
||
450 |
/** |
|
451 |
* fsockopen() file source |
|
452 |
*/ |
|
453 |
define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4); |
|
454 |
||
455 |
/** |
|
456 |
* cURL file source |
|
457 |
*/ |
|
458 |
define('SIMPLEPIE_FILE_SOURCE_CURL', 8); |
|
459 |
||
460 |
/** |
|
461 |
* file_get_contents() file source |
|
462 |
*/ |
|
463 |
define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); |
|
464 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
465 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
466 |
|
136 | 467 |
/** |
468 |
* SimplePie |
|
469 |
* |
|
470 |
* @package SimplePie |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
471 |
* @subpackage API |
136 | 472 |
*/ |
473 |
class SimplePie |
|
474 |
{ |
|
475 |
/** |
|
476 |
* @var array Raw data |
|
477 |
* @access private |
|
478 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
479 |
public $data = array(); |
136 | 480 |
|
481 |
/** |
|
482 |
* @var mixed Error string |
|
483 |
* @access private |
|
484 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
485 |
public $error; |
136 | 486 |
|
487 |
/** |
|
488 |
* @var object Instance of SimplePie_Sanitize (or other class) |
|
489 |
* @see SimplePie::set_sanitize_class() |
|
490 |
* @access private |
|
491 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
492 |
public $sanitize; |
136 | 493 |
|
494 |
/** |
|
495 |
* @var string SimplePie Useragent |
|
496 |
* @see SimplePie::set_useragent() |
|
497 |
* @access private |
|
498 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
499 |
public $useragent = SIMPLEPIE_USERAGENT; |
136 | 500 |
|
501 |
/** |
|
502 |
* @var string Feed URL |
|
503 |
* @see SimplePie::set_feed_url() |
|
504 |
* @access private |
|
505 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
506 |
public $feed_url; |
136 | 507 |
|
508 |
/** |
|
509 |
* @var object Instance of SimplePie_File to use as a feed |
|
510 |
* @see SimplePie::set_file() |
|
511 |
* @access private |
|
512 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
513 |
public $file; |
136 | 514 |
|
515 |
/** |
|
516 |
* @var string Raw feed data |
|
517 |
* @see SimplePie::set_raw_data() |
|
518 |
* @access private |
|
519 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
520 |
public $raw_data; |
136 | 521 |
|
522 |
/** |
|
523 |
* @var int Timeout for fetching remote files |
|
524 |
* @see SimplePie::set_timeout() |
|
525 |
* @access private |
|
526 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
527 |
public $timeout = 10; |
136 | 528 |
|
529 |
/** |
|
530 |
* @var bool Forces fsockopen() to be used for remote files instead |
|
531 |
* of cURL, even if a new enough version is installed |
|
532 |
* @see SimplePie::force_fsockopen() |
|
533 |
* @access private |
|
534 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
535 |
public $force_fsockopen = false; |
136 | 536 |
|
537 |
/** |
|
538 |
* @var bool Force the given data/URL to be treated as a feed no matter what |
|
539 |
* it appears like |
|
540 |
* @see SimplePie::force_feed() |
|
541 |
* @access private |
|
542 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
543 |
public $force_feed = false; |
136 | 544 |
|
545 |
/** |
|
546 |
* @var bool Enable/Disable Caching |
|
547 |
* @see SimplePie::enable_cache() |
|
548 |
* @access private |
|
549 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
550 |
public $cache = true; |
136 | 551 |
|
552 |
/** |
|
553 |
* @var int Cache duration (in seconds) |
|
554 |
* @see SimplePie::set_cache_duration() |
|
555 |
* @access private |
|
556 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
557 |
public $cache_duration = 3600; |
136 | 558 |
|
559 |
/** |
|
560 |
* @var int Auto-discovery cache duration (in seconds) |
|
561 |
* @see SimplePie::set_autodiscovery_cache_duration() |
|
562 |
* @access private |
|
563 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
564 |
public $autodiscovery_cache_duration = 604800; // 7 Days. |
136 | 565 |
|
566 |
/** |
|
567 |
* @var string Cache location (relative to executing script) |
|
568 |
* @see SimplePie::set_cache_location() |
|
569 |
* @access private |
|
570 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
571 |
public $cache_location = './cache'; |
136 | 572 |
|
573 |
/** |
|
574 |
* @var string Function that creates the cache filename |
|
575 |
* @see SimplePie::set_cache_name_function() |
|
576 |
* @access private |
|
577 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
578 |
public $cache_name_function = 'md5'; |
136 | 579 |
|
580 |
/** |
|
581 |
* @var bool Reorder feed by date descending |
|
582 |
* @see SimplePie::enable_order_by_date() |
|
583 |
* @access private |
|
584 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
585 |
public $order_by_date = true; |
136 | 586 |
|
587 |
/** |
|
588 |
* @var mixed Force input encoding to be set to the follow value |
|
589 |
* (false, or anything type-cast to false, disables this feature) |
|
590 |
* @see SimplePie::set_input_encoding() |
|
591 |
* @access private |
|
592 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
593 |
public $input_encoding = false; |
136 | 594 |
|
595 |
/** |
|
596 |
* @var int Feed Autodiscovery Level |
|
597 |
* @see SimplePie::set_autodiscovery_level() |
|
598 |
* @access private |
|
599 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
600 |
public $autodiscovery = SIMPLEPIE_LOCATOR_ALL; |
136 | 601 |
|
602 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
603 |
* Class registry object |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
604 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
605 |
* @var SimplePie_Registry |
136 | 606 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
607 |
public $registry; |
136 | 608 |
|
609 |
/** |
|
610 |
* @var int Maximum number of feeds to check with autodiscovery |
|
611 |
* @see SimplePie::set_max_checked_feeds() |
|
612 |
* @access private |
|
613 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
614 |
public $max_checked_feeds = 10; |
136 | 615 |
|
616 |
/** |
|
617 |
* @var array All the feeds found during the autodiscovery process |
|
618 |
* @see SimplePie::get_all_discovered_feeds() |
|
619 |
* @access private |
|
620 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
621 |
public $all_discovered_feeds = array(); |
136 | 622 |
|
623 |
/** |
|
624 |
* @var string Web-accessible path to the handler_image.php file. |
|
625 |
* @see SimplePie::set_image_handler() |
|
626 |
* @access private |
|
627 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
628 |
public $image_handler = ''; |
136 | 629 |
|
630 |
/** |
|
631 |
* @var array Stores the URLs when multiple feeds are being initialized. |
|
632 |
* @see SimplePie::set_feed_url() |
|
633 |
* @access private |
|
634 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
635 |
public $multifeed_url = array(); |
136 | 636 |
|
637 |
/** |
|
638 |
* @var array Stores SimplePie objects when multiple feeds initialized. |
|
639 |
* @access private |
|
640 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
641 |
public $multifeed_objects = array(); |
136 | 642 |
|
643 |
/** |
|
644 |
* @var array Stores the get_object_vars() array for use with multifeeds. |
|
645 |
* @see SimplePie::set_feed_url() |
|
646 |
* @access private |
|
647 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
648 |
public $config_settings = null; |
136 | 649 |
|
650 |
/** |
|
651 |
* @var integer Stores the number of items to return per-feed with multifeeds. |
|
652 |
* @see SimplePie::set_item_limit() |
|
653 |
* @access private |
|
654 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
655 |
public $item_limit = 0; |
136 | 656 |
|
657 |
/** |
|
658 |
* @var array Stores the default attributes to be stripped by strip_attributes(). |
|
659 |
* @see SimplePie::strip_attributes() |
|
660 |
* @access private |
|
661 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
662 |
public $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); |
136 | 663 |
|
664 |
/** |
|
665 |
* @var array Stores the default tags to be stripped by strip_htmltags(). |
|
666 |
* @see SimplePie::strip_htmltags() |
|
667 |
* @access private |
|
668 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
669 |
public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); |
136 | 670 |
|
671 |
/** |
|
672 |
* The SimplePie class contains feed level data and options |
|
673 |
* |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
674 |
* To use SimplePie, create the SimplePie object with no parameters. You can |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
675 |
* then set configuration options using the provided methods. After setting |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
676 |
* them, you must initialise the feed using $feed->init(). At that point the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
677 |
* object's methods and properties will be available to you. |
136 | 678 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
679 |
* Previously, it was possible to pass in the feed URL along with cache |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
680 |
* options directly into the constructor. This has been removed as of 1.3 as |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
681 |
* it caused a lot of confusion. |
136 | 682 |
* |
683 |
* @since 1.0 Preview Release |
|
684 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
685 |
public function __construct() |
136 | 686 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
687 |
if (version_compare(PHP_VERSION, '5.2', '<')) |
136 | 688 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
689 |
trigger_error('PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
690 |
die(); |
136 | 691 |
} |
692 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
693 |
// Other objects, instances created here so we can set options on them |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
694 |
$this->sanitize = new SimplePie_Sanitize(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
695 |
$this->registry = new SimplePie_Registry(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
696 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
697 |
if (func_num_args() > 0) |
136 | 698 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
699 |
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
700 |
trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.', $level); |
136 | 701 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
702 |
$args = func_get_args(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
703 |
switch (count($args)) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
704 |
case 3: |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
705 |
$this->set_cache_duration($args[2]); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
706 |
case 2: |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
707 |
$this->set_cache_location($args[1]); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
708 |
case 1: |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
709 |
$this->set_feed_url($args[0]); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
710 |
$this->init(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
711 |
} |
136 | 712 |
} |
713 |
} |
|
714 |
||
715 |
/** |
|
716 |
* Used for converting object to a string |
|
717 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
718 |
public function __toString() |
136 | 719 |
{ |
720 |
return md5(serialize($this->data)); |
|
721 |
} |
|
722 |
||
723 |
/** |
|
724 |
* Remove items that link back to this before destroying this object |
|
725 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
726 |
public function __destruct() |
136 | 727 |
{ |
728 |
if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) |
|
729 |
{ |
|
730 |
if (!empty($this->data['items'])) |
|
731 |
{ |
|
732 |
foreach ($this->data['items'] as $item) |
|
733 |
{ |
|
734 |
$item->__destruct(); |
|
735 |
} |
|
736 |
unset($item, $this->data['items']); |
|
737 |
} |
|
738 |
if (!empty($this->data['ordered_items'])) |
|
739 |
{ |
|
740 |
foreach ($this->data['ordered_items'] as $item) |
|
741 |
{ |
|
742 |
$item->__destruct(); |
|
743 |
} |
|
744 |
unset($item, $this->data['ordered_items']); |
|
745 |
} |
|
746 |
} |
|
747 |
} |
|
748 |
||
749 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
750 |
* Force the given data/URL to be treated as a feed |
136 | 751 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
752 |
* This tells SimplePie to ignore the content-type provided by the server. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
753 |
* Be careful when using this option, as it will also disable autodiscovery. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
754 |
* |
136 | 755 |
* @since 1.1 |
756 |
* @param bool $enable Force the given data/URL to be treated as a feed |
|
757 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
758 |
public function force_feed($enable = false) |
136 | 759 |
{ |
760 |
$this->force_feed = (bool) $enable; |
|
761 |
} |
|
762 |
||
763 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
764 |
* Set the URL of the feed you want to parse |
136 | 765 |
* |
766 |
* This allows you to enter the URL of the feed you want to parse, or the |
|
767 |
* website you want to try to use auto-discovery on. This takes priority |
|
768 |
* over any set raw data. |
|
769 |
* |
|
770 |
* You can set multiple feeds to mash together by passing an array instead |
|
771 |
* of a string for the $url. Remember that with each additional feed comes |
|
772 |
* additional processing and resources. |
|
773 |
* |
|
774 |
* @since 1.0 Preview Release |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
775 |
* @see set_raw_data() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
776 |
* @param string|array $url This is the URL (or array of URLs) that you want to parse. |
136 | 777 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
778 |
public function set_feed_url($url) |
136 | 779 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
780 |
$this->multifeed_url = array(); |
136 | 781 |
if (is_array($url)) |
782 |
{ |
|
783 |
foreach ($url as $value) |
|
784 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
785 |
$this->multifeed_url[] = $this->registry->call('Misc', 'fix_protocol', array($value, 1)); |
136 | 786 |
} |
787 |
} |
|
788 |
else |
|
789 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
790 |
$this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1)); |
136 | 791 |
} |
792 |
} |
|
793 |
||
794 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
795 |
* Set an instance of {@see SimplePie_File} to use as a feed |
136 | 796 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
797 |
* @param SimplePie_File &$file |
136 | 798 |
* @return bool True on success, false on failure |
799 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
800 |
public function set_file(&$file) |
136 | 801 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
802 |
if ($file instanceof SimplePie_File) |
136 | 803 |
{ |
804 |
$this->feed_url = $file->url; |
|
805 |
$this->file =& $file; |
|
806 |
return true; |
|
807 |
} |
|
808 |
return false; |
|
809 |
} |
|
810 |
||
811 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
812 |
* Set the raw XML data to parse |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
813 |
* |
136 | 814 |
* Allows you to use a string of RSS/Atom data instead of a remote feed. |
815 |
* |
|
816 |
* If you have a feed available as a string in PHP, you can tell SimplePie |
|
817 |
* to parse that data string instead of a remote feed. Any set feed URL |
|
818 |
* takes precedence. |
|
819 |
* |
|
820 |
* @since 1.0 Beta 3 |
|
821 |
* @param string $data RSS or Atom data as a string. |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
822 |
* @see set_feed_url() |
136 | 823 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
824 |
public function set_raw_data($data) |
136 | 825 |
{ |
826 |
$this->raw_data = $data; |
|
827 |
} |
|
828 |
||
829 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
830 |
* Set the the default timeout for fetching remote feeds |
136 | 831 |
* |
832 |
* This allows you to change the maximum time the feed's server to respond |
|
833 |
* and send the feed back. |
|
834 |
* |
|
835 |
* @since 1.0 Beta 3 |
|
836 |
* @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed. |
|
837 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
838 |
public function set_timeout($timeout = 10) |
136 | 839 |
{ |
840 |
$this->timeout = (int) $timeout; |
|
841 |
} |
|
842 |
||
843 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
844 |
* Force SimplePie to use fsockopen() instead of cURL |
136 | 845 |
* |
846 |
* @since 1.0 Beta 3 |
|
847 |
* @param bool $enable Force fsockopen() to be used |
|
848 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
849 |
public function force_fsockopen($enable = false) |
136 | 850 |
{ |
851 |
$this->force_fsockopen = (bool) $enable; |
|
852 |
} |
|
853 |
||
854 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
855 |
* Enable/disable caching in SimplePie. |
136 | 856 |
* |
857 |
* This option allows you to disable caching all-together in SimplePie. |
|
858 |
* However, disabling the cache can lead to longer load times. |
|
859 |
* |
|
860 |
* @since 1.0 Preview Release |
|
861 |
* @param bool $enable Enable caching |
|
862 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
863 |
public function enable_cache($enable = true) |
136 | 864 |
{ |
865 |
$this->cache = (bool) $enable; |
|
866 |
} |
|
867 |
||
868 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
869 |
* Set the length of time (in seconds) that the contents of a feed will be |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
870 |
* cached |
136 | 871 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
872 |
* @param int $seconds The feed content cache duration |
136 | 873 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
874 |
public function set_cache_duration($seconds = 3600) |
136 | 875 |
{ |
876 |
$this->cache_duration = (int) $seconds; |
|
877 |
} |
|
878 |
||
879 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
880 |
* Set the length of time (in seconds) that the autodiscovered feed URL will |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
881 |
* be cached |
136 | 882 |
* |
883 |
* @param int $seconds The autodiscovered feed URL cache duration. |
|
884 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
885 |
public function set_autodiscovery_cache_duration($seconds = 604800) |
136 | 886 |
{ |
887 |
$this->autodiscovery_cache_duration = (int) $seconds; |
|
888 |
} |
|
889 |
||
890 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
891 |
* Set the file system location where the cached files should be stored |
136 | 892 |
* |
893 |
* @param string $location The file system location. |
|
894 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
895 |
public function set_cache_location($location = './cache') |
136 | 896 |
{ |
897 |
$this->cache_location = (string) $location; |
|
898 |
} |
|
899 |
||
900 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
901 |
* Set whether feed items should be sorted into reverse chronological order |
136 | 902 |
* |
903 |
* @param bool $enable Sort as reverse chronological order. |
|
904 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
905 |
public function enable_order_by_date($enable = true) |
136 | 906 |
{ |
907 |
$this->order_by_date = (bool) $enable; |
|
908 |
} |
|
909 |
||
910 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
911 |
* Set the character encoding used to parse the feed |
136 | 912 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
913 |
* This overrides the encoding reported by the feed, however it will fall |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
914 |
* back to the normal encoding detection if the override fails |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
915 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
916 |
* @param string $encoding Character encoding |
136 | 917 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
918 |
public function set_input_encoding($encoding = false) |
136 | 919 |
{ |
920 |
if ($encoding) |
|
921 |
{ |
|
922 |
$this->input_encoding = (string) $encoding; |
|
923 |
} |
|
924 |
else |
|
925 |
{ |
|
926 |
$this->input_encoding = false; |
|
927 |
} |
|
928 |
} |
|
929 |
||
930 |
/** |
|
931 |
* Set how much feed autodiscovery to do |
|
932 |
* |
|
933 |
* @see SIMPLEPIE_LOCATOR_NONE |
|
934 |
* @see SIMPLEPIE_LOCATOR_AUTODISCOVERY |
|
935 |
* @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION |
|
936 |
* @see SIMPLEPIE_LOCATOR_LOCAL_BODY |
|
937 |
* @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION |
|
938 |
* @see SIMPLEPIE_LOCATOR_REMOTE_BODY |
|
939 |
* @see SIMPLEPIE_LOCATOR_ALL |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
940 |
* @param int $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator) |
136 | 941 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
942 |
public function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL) |
136 | 943 |
{ |
944 |
$this->autodiscovery = (int) $level; |
|
945 |
} |
|
946 |
||
947 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
948 |
* Get the class registry |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
949 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
950 |
* Use this to override SimplePie's default classes |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
951 |
* @see SimplePie_Registry |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
952 |
* @return SimplePie_Registry |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
953 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
954 |
public function &get_registry() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
955 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
956 |
return $this->registry; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
957 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
958 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
959 |
/**#@+ |
136 | 960 |
* Useful when you are overloading or extending SimplePie's default classes. |
961 |
* |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
962 |
* @deprecated Use {@see get_registry()} instead |
136 | 963 |
* @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
964 |
* @param string $class Name of custom class |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
965 |
* @return boolean True on success, false otherwise |
136 | 966 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
967 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
968 |
* Set which class SimplePie uses for caching |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
969 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
970 |
public function set_cache_class($class = 'SimplePie_Cache') |
136 | 971 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
972 |
return $this->registry->register('Cache', $class, true); |
136 | 973 |
} |
974 |
||
975 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
976 |
* Set which class SimplePie uses for auto-discovery |
136 | 977 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
978 |
public function set_locator_class($class = 'SimplePie_Locator') |
136 | 979 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
980 |
return $this->registry->register('Locator', $class, true); |
136 | 981 |
} |
982 |
||
983 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
984 |
* Set which class SimplePie uses for XML parsing |
136 | 985 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
986 |
public function set_parser_class($class = 'SimplePie_Parser') |
136 | 987 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
988 |
return $this->registry->register('Parser', $class, true); |
136 | 989 |
} |
990 |
||
991 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
992 |
* Set which class SimplePie uses for remote file fetching |
136 | 993 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
994 |
public function set_file_class($class = 'SimplePie_File') |
136 | 995 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
996 |
return $this->registry->register('File', $class, true); |
136 | 997 |
} |
998 |
||
999 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1000 |
* Set which class SimplePie uses for data sanitization |
136 | 1001 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1002 |
public function set_sanitize_class($class = 'SimplePie_Sanitize') |
136 | 1003 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1004 |
return $this->registry->register('Sanitize', $class, true); |
136 | 1005 |
} |
1006 |
||
1007 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1008 |
* Set which class SimplePie uses for handling feed items |
136 | 1009 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1010 |
public function set_item_class($class = 'SimplePie_Item') |
136 | 1011 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1012 |
return $this->registry->register('Item', $class, true); |
136 | 1013 |
} |
1014 |
||
1015 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1016 |
* Set which class SimplePie uses for handling author data |
136 | 1017 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1018 |
public function set_author_class($class = 'SimplePie_Author') |
136 | 1019 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1020 |
return $this->registry->register('Author', $class, true); |
136 | 1021 |
} |
1022 |
||
1023 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1024 |
* Set which class SimplePie uses for handling category data |
136 | 1025 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1026 |
public function set_category_class($class = 'SimplePie_Category') |
136 | 1027 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1028 |
return $this->registry->register('Category', $class, true); |
136 | 1029 |
} |
1030 |
||
1031 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1032 |
* Set which class SimplePie uses for feed enclosures |
136 | 1033 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1034 |
public function set_enclosure_class($class = 'SimplePie_Enclosure') |
136 | 1035 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1036 |
return $this->registry->register('Enclosure', $class, true); |
136 | 1037 |
} |
1038 |
||
1039 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1040 |
* Set which class SimplePie uses for `<media:text>` captions |
136 | 1041 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1042 |
public function set_caption_class($class = 'SimplePie_Caption') |
136 | 1043 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1044 |
return $this->registry->register('Caption', $class, true); |
136 | 1045 |
} |
1046 |
||
1047 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1048 |
* Set which class SimplePie uses for `<media:copyright>` |
136 | 1049 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1050 |
public function set_copyright_class($class = 'SimplePie_Copyright') |
136 | 1051 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1052 |
return $this->registry->register('Copyright', $class, true); |
136 | 1053 |
} |
1054 |
||
1055 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1056 |
* Set which class SimplePie uses for `<media:credit>` |
136 | 1057 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1058 |
public function set_credit_class($class = 'SimplePie_Credit') |
136 | 1059 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1060 |
return $this->registry->register('Credit', $class, true); |
136 | 1061 |
} |
1062 |
||
1063 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1064 |
* Set which class SimplePie uses for `<media:rating>` |
136 | 1065 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1066 |
public function set_rating_class($class = 'SimplePie_Rating') |
136 | 1067 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1068 |
return $this->registry->register('Rating', $class, true); |
136 | 1069 |
} |
1070 |
||
1071 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1072 |
* Set which class SimplePie uses for `<media:restriction>` |
136 | 1073 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1074 |
public function set_restriction_class($class = 'SimplePie_Restriction') |
136 | 1075 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1076 |
return $this->registry->register('Restriction', $class, true); |
136 | 1077 |
} |
1078 |
||
1079 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1080 |
* Set which class SimplePie uses for content-type sniffing |
136 | 1081 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1082 |
public function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') |
136 | 1083 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1084 |
return $this->registry->register('Content_Type_Sniffer', $class, true); |
136 | 1085 |
} |
1086 |
||
1087 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1088 |
* Set which class SimplePie uses item sources |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1089 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1090 |
public function set_source_class($class = 'SimplePie_Source') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1091 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1092 |
return $this->registry->register('Source', $class, true); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1093 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1094 |
/**#@-*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1095 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1096 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1097 |
* Set the user agent string |
136 | 1098 |
* |
1099 |
* @param string $ua New user agent string. |
|
1100 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1101 |
public function set_useragent($ua = SIMPLEPIE_USERAGENT) |
136 | 1102 |
{ |
1103 |
$this->useragent = (string) $ua; |
|
1104 |
} |
|
1105 |
||
1106 |
/** |
|
1107 |
* Set callback function to create cache filename with |
|
1108 |
* |
|
1109 |
* @param mixed $function Callback function |
|
1110 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1111 |
public function set_cache_name_function($function = 'md5') |
136 | 1112 |
{ |
1113 |
if (is_callable($function)) |
|
1114 |
{ |
|
1115 |
$this->cache_name_function = $function; |
|
1116 |
} |
|
1117 |
} |
|
1118 |
||
1119 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1120 |
* Set options to make SP as fast as possible |
136 | 1121 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1122 |
* Forgoes a substantial amount of data sanitization in favor of speed. This |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1123 |
* turns SimplePie into a dumb parser of feeds. |
136 | 1124 |
* |
1125 |
* @param bool $set Whether to set them or not |
|
1126 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1127 |
public function set_stupidly_fast($set = false) |
136 | 1128 |
{ |
1129 |
if ($set) |
|
1130 |
{ |
|
1131 |
$this->enable_order_by_date(false); |
|
1132 |
$this->remove_div(false); |
|
1133 |
$this->strip_comments(false); |
|
1134 |
$this->strip_htmltags(false); |
|
1135 |
$this->strip_attributes(false); |
|
1136 |
$this->set_image_handler(false); |
|
1137 |
} |
|
1138 |
} |
|
1139 |
||
1140 |
/** |
|
1141 |
* Set maximum number of feeds to check with autodiscovery |
|
1142 |
* |
|
1143 |
* @param int $max Maximum number of feeds to check |
|
1144 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1145 |
public function set_max_checked_feeds($max = 10) |
136 | 1146 |
{ |
1147 |
$this->max_checked_feeds = (int) $max; |
|
1148 |
} |
|
1149 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1150 |
public function remove_div($enable = true) |
136 | 1151 |
{ |
1152 |
$this->sanitize->remove_div($enable); |
|
1153 |
} |
|
1154 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1155 |
public function strip_htmltags($tags = '', $encode = null) |
136 | 1156 |
{ |
1157 |
if ($tags === '') |
|
1158 |
{ |
|
1159 |
$tags = $this->strip_htmltags; |
|
1160 |
} |
|
1161 |
$this->sanitize->strip_htmltags($tags); |
|
1162 |
if ($encode !== null) |
|
1163 |
{ |
|
1164 |
$this->sanitize->encode_instead_of_strip($tags); |
|
1165 |
} |
|
1166 |
} |
|
1167 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1168 |
public function encode_instead_of_strip($enable = true) |
136 | 1169 |
{ |
1170 |
$this->sanitize->encode_instead_of_strip($enable); |
|
1171 |
} |
|
1172 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1173 |
public function strip_attributes($attribs = '') |
136 | 1174 |
{ |
1175 |
if ($attribs === '') |
|
1176 |
{ |
|
1177 |
$attribs = $this->strip_attributes; |
|
1178 |
} |
|
1179 |
$this->sanitize->strip_attributes($attribs); |
|
1180 |
} |
|
1181 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1182 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1183 |
* Set the output encoding |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1184 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1185 |
* Allows you to override SimplePie's output to match that of your webpage. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1186 |
* This is useful for times when your webpages are not being served as |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1187 |
* UTF-8. This setting will be obeyed by {@see handle_content_type()}, and |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1188 |
* is similar to {@see set_input_encoding()}. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1189 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1190 |
* It should be noted, however, that not all character encodings can support |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1191 |
* all characters. If your page is being served as ISO-8859-1 and you try |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1192 |
* to display a Japanese feed, you'll likely see garbled characters. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1193 |
* Because of this, it is highly recommended to ensure that your webpages |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1194 |
* are served as UTF-8. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1195 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1196 |
* The number of supported character encodings depends on whether your web |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1197 |
* host supports {@link http://php.net/mbstring mbstring}, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1198 |
* {@link http://php.net/iconv iconv}, or both. See |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1199 |
* {@link http://simplepie.org/wiki/faq/Supported_Character_Encodings} for |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1200 |
* more information. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1201 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1202 |
* @param string $encoding |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1203 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1204 |
public function set_output_encoding($encoding = 'UTF-8') |
136 | 1205 |
{ |
1206 |
$this->sanitize->set_output_encoding($encoding); |
|
1207 |
} |
|
1208 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1209 |
public function strip_comments($strip = false) |
136 | 1210 |
{ |
1211 |
$this->sanitize->strip_comments($strip); |
|
1212 |
} |
|
1213 |
||
1214 |
/** |
|
1215 |
* Set element/attribute key/value pairs of HTML attributes |
|
1216 |
* containing URLs that need to be resolved relative to the feed |
|
1217 |
* |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1218 |
* Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1219 |
* |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1220 |
* |q|@cite |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1221 |
* |
136 | 1222 |
* @since 1.0 |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1223 |
* @param array|null $element_attribute Element/attribute key/value pairs, null for default |
136 | 1224 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1225 |
public function set_url_replacements($element_attribute = null) |
136 | 1226 |
{ |
1227 |
$this->sanitize->set_url_replacements($element_attribute); |
|
1228 |
} |
|
1229 |
||
1230 |
/** |
|
1231 |
* Set the handler to enable the display of cached images. |
|
1232 |
* |
|
1233 |
* @param str $page Web-accessible path to the handler_image.php file. |
|
1234 |
* @param str $qs The query string that the value should be passed to. |
|
1235 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1236 |
public function set_image_handler($page = false, $qs = 'i') |
136 | 1237 |
{ |
1238 |
if ($page !== false) |
|
1239 |
{ |
|
1240 |
$this->sanitize->set_image_handler($page . '?' . $qs . '='); |
|
1241 |
} |
|
1242 |
else |
|
1243 |
{ |
|
1244 |
$this->image_handler = ''; |
|
1245 |
} |
|
1246 |
} |
|
1247 |
||
1248 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1249 |
* Set the limit for items returned per-feed with multifeeds |
136 | 1250 |
* |
1251 |
* @param integer $limit The maximum number of items to return. |
|
1252 |
*/ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1253 |
public function set_item_limit($limit = 0) |
136 | 1254 |
{ |
1255 |
$this->item_limit = (int) $limit; |
|
1256 |
} |
|
1257 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1258 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1259 |
* Initialize the feed object |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1260 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1261 |
* This is what makes everything happen. Period. This is where all of the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1262 |
* configuration options get processed, feeds are fetched, cached, and |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1263 |
* parsed, and all of that other good stuff. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1264 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1265 |
* @return boolean True if successful, false otherwise |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1266 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1267 |
public function init() |
136 | 1268 |
{ |
1269 |
// Check absolute bare minimum requirements. |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1270 |
if (!extension_loaded('xml') || !extension_loaded('pcre')) |
136 | 1271 |
{ |
1272 |
return false; |
|
1273 |
} |
|
1274 |
// Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. |
|
1275 |
elseif (!extension_loaded('xmlreader')) |
|
1276 |
{ |
|
1277 |
static $xml_is_sane = null; |
|
1278 |
if ($xml_is_sane === null) |
|
1279 |
{ |
|
1280 |
$parser_check = xml_parser_create(); |
|
1281 |
xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); |
|
1282 |
xml_parser_free($parser_check); |
|
1283 |
$xml_is_sane = isset($values[0]['value']); |
|
1284 |
} |
|
1285 |
if (!$xml_is_sane) |
|
1286 |
{ |
|
1287 |
return false; |
|
1288 |
} |
|
1289 |
} |
|
1290 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1291 |
if (method_exists($this->sanitize, 'set_registry')) |
136 | 1292 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1293 |
$this->sanitize->set_registry($this->registry); |
136 | 1294 |
} |
1295 |
||
1296 |
// Pass whatever was set with config options over to the sanitizer. |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1297 |
// Pass the classes in for legacy support; new classes should use the registry instead |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1298 |
$this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->registry->get_class('Cache')); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1299 |
$this->sanitize->pass_file_data($this->registry->get_class('File'), $this->timeout, $this->useragent, $this->force_fsockopen); |
136 | 1300 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1301 |
if (!empty($this->multifeed_url)) |
136 | 1302 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1303 |
$i = 0; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1304 |
$success = 0; |
136 | 1305 |
$this->multifeed_objects = array(); |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1306 |
$this->error = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1307 |
foreach ($this->multifeed_url as $url) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1308 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1309 |
$this->multifeed_objects[$i] = clone $this; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1310 |
$this->multifeed_objects[$i]->set_feed_url($url); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1311 |
$single_success = $this->multifeed_objects[$i]->init(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1312 |
$success |= $single_success; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1313 |
if (!$single_success) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1314 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1315 |
$this->error[$i] = $this->multifeed_objects[$i]->error(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1316 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1317 |
$i++; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1318 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1319 |
return (bool) $success; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1320 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1321 |
elseif ($this->feed_url === null && $this->raw_data === null) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1322 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1323 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1324 |
} |
136 | 1325 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1326 |
$this->error = null; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1327 |
$this->data = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1328 |
$this->multifeed_objects = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1329 |
$cache = false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1330 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1331 |
if ($this->feed_url !== null) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1332 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1333 |
$parsed_feed_url = $this->registry->call('Misc', 'parse_url', array($this->feed_url)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1334 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1335 |
// Decide whether to enable caching |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1336 |
if ($this->cache && $parsed_feed_url['scheme'] !== '') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1337 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1338 |
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc')); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1339 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1340 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1341 |
// Fetch the data via SimplePie_File into $this->raw_data |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1342 |
if (($fetched = $this->fetch_data($cache)) === true) |
136 | 1343 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1344 |
return true; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1345 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1346 |
elseif ($fetched === false) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1347 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1348 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1349 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1350 |
list($headers, $sniffed) = $fetched; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1351 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1352 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1353 |
// Set up array of possible encodings |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1354 |
$encodings = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1355 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1356 |
// First check to see if input has been overridden. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1357 |
if ($this->input_encoding !== false) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1358 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1359 |
$encodings[] = $this->input_encoding; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1360 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1361 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1362 |
$application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1363 |
$text_types = array('text/xml', 'text/xml-external-parsed-entity'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1364 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1365 |
// RFC 3023 (only applies to sniffed content) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1366 |
if (isset($sniffed)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1367 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1368 |
if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1369 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1370 |
if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) |
136 | 1371 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1372 |
$encodings[] = strtoupper($charset[1]); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1373 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1374 |
$encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1375 |
$encodings[] = 'UTF-8'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1376 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1377 |
elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1378 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1379 |
if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1380 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1381 |
$encodings[] = $charset[1]; |
136 | 1382 |
} |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1383 |
$encodings[] = 'US-ASCII'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1384 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1385 |
// Text MIME-type default |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1386 |
elseif (substr($sniffed, 0, 5) === 'text/') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1387 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1388 |
$encodings[] = 'US-ASCII'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1389 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1390 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1391 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1392 |
// Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1393 |
$encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1394 |
$encodings[] = 'UTF-8'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1395 |
$encodings[] = 'ISO-8859-1'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1396 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1397 |
// There's no point in trying an encoding twice |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1398 |
$encodings = array_unique($encodings); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1399 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1400 |
// Loop through each possible encoding, till we return something, or run out of possibilities |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1401 |
foreach ($encodings as $encoding) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1402 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1403 |
// Change the encoding to UTF-8 (as we always use UTF-8 internally) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1404 |
if ($utf8_data = $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8'))) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1405 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1406 |
// Create new parser |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1407 |
$parser = $this->registry->create('Parser'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1408 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1409 |
// If it's parsed fine |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1410 |
if ($parser->parse($utf8_data, 'UTF-8')) |
136 | 1411 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1412 |
$this->data = $parser->get_data(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1413 |
if (!($this->get_type() & ~SIMPLEPIE_TYPE_NONE)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1414 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1415 |
$this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1416 |
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1417 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1418 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1419 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1420 |
if (isset($headers)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1421 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1422 |
$this->data['headers'] = $headers; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1423 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1424 |
$this->data['build'] = SIMPLEPIE_BUILD; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1425 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1426 |
// Cache the file if caching is enabled |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1427 |
if ($cache && !$cache->save($this)) |
136 | 1428 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1429 |
trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1430 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1431 |
return true; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1432 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1433 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1434 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1435 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1436 |
if (isset($parser)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1437 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1438 |
// We have an error, just set SimplePie_Misc::error to it and quit |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1439 |
$this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1440 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1441 |
else |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1442 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1443 |
$this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1444 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1445 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1446 |
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1447 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1448 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1449 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1450 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1451 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1452 |
* Fetch the data via SimplePie_File |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1453 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1454 |
* If the data is already cached, attempt to fetch it from there instead |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1455 |
* @param SimplePie_Cache|false $cache Cache handler, or false to not load from the cache |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1456 |
* @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1457 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1458 |
protected function fetch_data(&$cache) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1459 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1460 |
// If it's enabled, use the cache |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1461 |
if ($cache) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1462 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1463 |
// Load the Cache |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1464 |
$this->data = $cache->load(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1465 |
if (!empty($this->data)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1466 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1467 |
// If the cache is for an outdated build of SimplePie |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1468 |
if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1469 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1470 |
$cache->unlink(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1471 |
$this->data = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1472 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1473 |
// If we've hit a collision just rerun it with caching disabled |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1474 |
elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1475 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1476 |
$cache = false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1477 |
$this->data = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1478 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1479 |
// If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1480 |
elseif (isset($this->data['feed_url'])) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1481 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1482 |
// If the autodiscovery cache is still valid use it. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1483 |
if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1484 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1485 |
// Do not need to do feed autodiscovery yet. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1486 |
if ($this->data['feed_url'] !== $this->data['url']) |
136 | 1487 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1488 |
$this->set_feed_url($this->data['feed_url']); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1489 |
return $this->init(); |
136 | 1490 |
} |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1491 |
|
136 | 1492 |
$cache->unlink(); |
1493 |
$this->data = array(); |
|
1494 |
} |
|
1495 |
} |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1496 |
// Check if the cache has been updated |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1497 |
elseif ($cache->mtime() + $this->cache_duration < time()) |
136 | 1498 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1499 |
// If we have last-modified and/or etag set |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1500 |
if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) |
136 | 1501 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1502 |
$headers = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1503 |
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1504 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1505 |
if (isset($this->data['headers']['last-modified'])) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1506 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1507 |
$headers['if-modified-since'] = $this->data['headers']['last-modified']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1508 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1509 |
if (isset($this->data['headers']['etag'])) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1510 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1511 |
$headers['if-none-match'] = $this->data['headers']['etag']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1512 |
} |
136 | 1513 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1514 |
$file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1515 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1516 |
if ($file->success) |
136 | 1517 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1518 |
if ($file->status_code === 304) |
136 | 1519 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1520 |
$cache->touch(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1521 |
return true; |
136 | 1522 |
} |
1523 |
} |
|
1524 |
else |
|
1525 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1526 |
unset($file); |
136 | 1527 |
} |
1528 |
} |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1529 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1530 |
// If the cache is still valid, just return true |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1531 |
else |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1532 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1533 |
$this->raw_data = false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1534 |
return true; |
136 | 1535 |
} |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1536 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1537 |
// If the cache is empty, delete it |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1538 |
else |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1539 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1540 |
$cache->unlink(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1541 |
$this->data = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1542 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1543 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1544 |
// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1545 |
if (!isset($file)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1546 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1547 |
if ($this->file instanceof SimplePie_File && $this->file->url === $this->feed_url) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1548 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1549 |
$file =& $this->file; |
136 | 1550 |
} |
1551 |
else |
|
1552 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1553 |
$headers = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1554 |
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1555 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1556 |
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen)); |
136 | 1557 |
} |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1558 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1559 |
// If the file connection has an error, set SimplePie::error to that and quit |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1560 |
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1561 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1562 |
$this->error = $file->error; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1563 |
return !empty($this->data); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1564 |
} |
136 | 1565 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1566 |
if (!$this->force_feed) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1567 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1568 |
// Check if the supplied URL is a feed, if it isn't, look for it. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1569 |
$locate = $this->registry->create('Locator', array(&$file, $this->timeout, $this->useragent, $this->max_checked_feeds)); |
136 | 1570 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1571 |
if (!$locate->is_feed($file)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1572 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1573 |
// We need to unset this so that if SimplePie::set_file() has been called that object is untouched |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1574 |
unset($file); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1575 |
try |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1576 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1577 |
if (!($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))) |
136 | 1578 |
{ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1579 |
$this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1580 |
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1581 |
return false; |
136 | 1582 |
} |
1583 |
} |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1584 |
catch (SimplePie_Exception $e) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1585 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1586 |
// This is usually because DOMDocument doesn't exist |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1587 |
$this->error = $e->getMessage(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1588 |
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, $e->getFile(), $e->getLine())); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1589 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1590 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1591 |
if ($cache) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1592 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1593 |
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1594 |
if (!$cache->save($this)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1595 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1596 |
trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1597 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1598 |
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc')); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1599 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1600 |
$this->feed_url = $file->url; |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1601 |
} |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1602 |
$locate = null; |
136 | 1603 |
} |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1604 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1605 |
$this->raw_data = $file->body; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1606 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1607 |
$headers = $file->headers; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1608 |
$sniffer = $this->registry->create('Content_Type_Sniffer', array(&$file)); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1609 |
$sniffed = $sniffer->get_type(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1610 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1611 |
return array($headers, $sniffed); |
136 | 1612 |
} |
1613 |
||
1614 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1615 |
* Get the error message for the occured error |
136 | 1616 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1617 |
* @return string|array Error message, or array of messages for multifeeds |
136 | 1618 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1619 |
public function error() |
136 | 1620 |
{ |
1621 |
return $this->error; |
|
1622 |
} |
|
1623 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1624 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1625 |
* Get the raw XML |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1626 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1627 |
* This is the same as the old `$feed->enable_xml_dump(true)`, but returns |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1628 |
* the data instead of printing it. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1629 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1630 |
* @return string|boolean Raw XML data, false if the cache is used |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1631 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1632 |
public function get_raw_data() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1633 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1634 |
return $this->raw_data; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1635 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1636 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1637 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1638 |
* Get the character encoding used for output |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1639 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1640 |
* @since Preview Release |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1641 |
* @return string |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1642 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1643 |
public function get_encoding() |
136 | 1644 |
{ |
1645 |
return $this->sanitize->output_encoding; |
|
1646 |
} |
|
1647 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1648 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1649 |
* Send the content-type header with correct encoding |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1650 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1651 |
* This method ensures that the SimplePie-enabled page is being served with |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1652 |
* the correct {@link http://www.iana.org/assignments/media-types/ mime-type} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1653 |
* and character encoding HTTP headers (character encoding determined by the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1654 |
* {@see set_output_encoding} config option). |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1655 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1656 |
* This won't work properly if any content or whitespace has already been |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1657 |
* sent to the browser, because it relies on PHP's |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1658 |
* {@link http://php.net/header header()} function, and these are the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1659 |
* circumstances under which the function works. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1660 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1661 |
* Because it's setting these settings for the entire page (as is the nature |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1662 |
* of HTTP headers), this should only be used once per page (again, at the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1663 |
* top). |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1664 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1665 |
* @param string $mime MIME type to serve the page as |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1666 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1667 |
public function handle_content_type($mime = 'text/html') |
136 | 1668 |
{ |
1669 |
if (!headers_sent()) |
|
1670 |
{ |
|
1671 |
$header = "Content-type: $mime;"; |
|
1672 |
if ($this->get_encoding()) |
|
1673 |
{ |
|
1674 |
$header .= ' charset=' . $this->get_encoding(); |
|
1675 |
} |
|
1676 |
else |
|
1677 |
{ |
|
1678 |
$header .= ' charset=UTF-8'; |
|
1679 |
} |
|
1680 |
header($header); |
|
1681 |
} |
|
1682 |
} |
|
1683 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1684 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1685 |
* Get the type of the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1686 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1687 |
* This returns a SIMPLEPIE_TYPE_* constant, which can be tested against |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1688 |
* using {@link http://php.net/language.operators.bitwise bitwise operators} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1689 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1690 |
* @since 0.8 (usage changed to using constants in 1.0) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1691 |
* @see SIMPLEPIE_TYPE_NONE Unknown. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1692 |
* @see SIMPLEPIE_TYPE_RSS_090 RSS 0.90. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1693 |
* @see SIMPLEPIE_TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape). |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1694 |
* @see SIMPLEPIE_TYPE_RSS_091_USERLAND RSS 0.91 (Userland). |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1695 |
* @see SIMPLEPIE_TYPE_RSS_091 RSS 0.91. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1696 |
* @see SIMPLEPIE_TYPE_RSS_092 RSS 0.92. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1697 |
* @see SIMPLEPIE_TYPE_RSS_093 RSS 0.93. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1698 |
* @see SIMPLEPIE_TYPE_RSS_094 RSS 0.94. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1699 |
* @see SIMPLEPIE_TYPE_RSS_10 RSS 1.0. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1700 |
* @see SIMPLEPIE_TYPE_RSS_20 RSS 2.0.x. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1701 |
* @see SIMPLEPIE_TYPE_RSS_RDF RDF-based RSS. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1702 |
* @see SIMPLEPIE_TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format). |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1703 |
* @see SIMPLEPIE_TYPE_RSS_ALL Any version of RSS. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1704 |
* @see SIMPLEPIE_TYPE_ATOM_03 Atom 0.3. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1705 |
* @see SIMPLEPIE_TYPE_ATOM_10 Atom 1.0. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1706 |
* @see SIMPLEPIE_TYPE_ATOM_ALL Any version of Atom. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1707 |
* @see SIMPLEPIE_TYPE_ALL Any known/supported feed type. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1708 |
* @return int SIMPLEPIE_TYPE_* constant |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1709 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1710 |
public function get_type() |
136 | 1711 |
{ |
1712 |
if (!isset($this->data['type'])) |
|
1713 |
{ |
|
1714 |
$this->data['type'] = SIMPLEPIE_TYPE_ALL; |
|
1715 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) |
|
1716 |
{ |
|
1717 |
$this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10; |
|
1718 |
} |
|
1719 |
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) |
|
1720 |
{ |
|
1721 |
$this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03; |
|
1722 |
} |
|
1723 |
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) |
|
1724 |
{ |
|
1725 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) |
|
1726 |
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) |
|
1727 |
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) |
|
1728 |
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) |
|
1729 |
{ |
|
1730 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; |
|
1731 |
} |
|
1732 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) |
|
1733 |
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) |
|
1734 |
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) |
|
1735 |
|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) |
|
1736 |
{ |
|
1737 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; |
|
1738 |
} |
|
1739 |
} |
|
1740 |
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) |
|
1741 |
{ |
|
1742 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; |
|
1743 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) |
|
1744 |
{ |
|
1745 |
switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) |
|
1746 |
{ |
|
1747 |
case '0.91': |
|
1748 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; |
|
1749 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) |
|
1750 |
{ |
|
1751 |
switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) |
|
1752 |
{ |
|
1753 |
case '0': |
|
1754 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; |
|
1755 |
break; |
|
1756 |
||
1757 |
case '24': |
|
1758 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; |
|
1759 |
break; |
|
1760 |
} |
|
1761 |
} |
|
1762 |
break; |
|
1763 |
||
1764 |
case '0.92': |
|
1765 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; |
|
1766 |
break; |
|
1767 |
||
1768 |
case '0.93': |
|
1769 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; |
|
1770 |
break; |
|
1771 |
||
1772 |
case '0.94': |
|
1773 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; |
|
1774 |
break; |
|
1775 |
||
1776 |
case '2.0': |
|
1777 |
$this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; |
|
1778 |
break; |
|
1779 |
} |
|
1780 |
} |
|
1781 |
} |
|
1782 |
else |
|
1783 |
{ |
|
1784 |
$this->data['type'] = SIMPLEPIE_TYPE_NONE; |
|
1785 |
} |
|
1786 |
} |
|
1787 |
return $this->data['type']; |
|
1788 |
} |
|
1789 |
||
1790 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1791 |
* Get the URL for the feed |
136 | 1792 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1793 |
* May or may not be different from the URL passed to {@see set_feed_url()}, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1794 |
* depending on whether auto-discovery was used. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1795 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1796 |
* @since Preview Release (previously called `get_feed_url()` since SimplePie 0.8.) |
136 | 1797 |
* @todo If we have a perm redirect we should return the new URL |
1798 |
* @todo When we make the above change, let's support <itunes:new-feed-url> as well |
|
1799 |
* @todo Also, |atom:link|@rel=self |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1800 |
* @return string|null |
136 | 1801 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1802 |
public function subscribe_url() |
136 | 1803 |
{ |
1804 |
if ($this->feed_url !== null) |
|
1805 |
{ |
|
1806 |
return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI); |
|
1807 |
} |
|
1808 |
else |
|
1809 |
{ |
|
1810 |
return null; |
|
1811 |
} |
|
1812 |
} |
|
1813 |
||
1814 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1815 |
* Get data for an feed-level element |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1816 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1817 |
* This method allows you to get access to ANY element/attribute that is a |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1818 |
* sub-element of the opening feed tag. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1819 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1820 |
* The return value is an indexed array of elements matching the given |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1821 |
* namespace and tag name. Each element has `attribs`, `data` and `child` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1822 |
* subkeys. For `attribs` and `child`, these contain namespace subkeys. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1823 |
* `attribs` then has one level of associative name => value data (where |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1824 |
* `value` is a string) after the namespace. `child` has tag-indexed keys |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1825 |
* after the namespace, each member of which is an indexed array matching |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1826 |
* this same format. |
136 | 1827 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1828 |
* For example: |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1829 |
* <pre> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1830 |
* // This is probably a bad example because we already support |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1831 |
* // <media:content> natively, but it shows you how to parse through |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1832 |
* // the nodes. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1833 |
* $group = $item->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group'); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1834 |
* $content = $group[0]['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1835 |
* $file = $content[0]['attribs']['']['url']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1836 |
* echo $file; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1837 |
* </pre> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1838 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1839 |
* @since 1.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1840 |
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1841 |
* @param string $namespace The URL of the XML namespace of the elements you're trying to access |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1842 |
* @param string $tag Tag name |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1843 |
* @return array |
136 | 1844 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1845 |
public function get_feed_tags($namespace, $tag) |
136 | 1846 |
{ |
1847 |
$type = $this->get_type(); |
|
1848 |
if ($type & SIMPLEPIE_TYPE_ATOM_10) |
|
1849 |
{ |
|
1850 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) |
|
1851 |
{ |
|
1852 |
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]; |
|
1853 |
} |
|
1854 |
} |
|
1855 |
if ($type & SIMPLEPIE_TYPE_ATOM_03) |
|
1856 |
{ |
|
1857 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) |
|
1858 |
{ |
|
1859 |
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]; |
|
1860 |
} |
|
1861 |
} |
|
1862 |
if ($type & SIMPLEPIE_TYPE_RSS_RDF) |
|
1863 |
{ |
|
1864 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) |
|
1865 |
{ |
|
1866 |
return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]; |
|
1867 |
} |
|
1868 |
} |
|
1869 |
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) |
|
1870 |
{ |
|
1871 |
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) |
|
1872 |
{ |
|
1873 |
return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; |
|
1874 |
} |
|
1875 |
} |
|
1876 |
return null; |
|
1877 |
} |
|
1878 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1879 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1880 |
* Get data for an channel-level element |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1881 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1882 |
* This method allows you to get access to ANY element/attribute in the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1883 |
* channel/header section of the feed. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1884 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1885 |
* See {@see SimplePie::get_feed_tags()} for a description of the return value |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1886 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1887 |
* @since 1.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1888 |
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1889 |
* @param string $namespace The URL of the XML namespace of the elements you're trying to access |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1890 |
* @param string $tag Tag name |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1891 |
* @return array |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1892 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1893 |
public function get_channel_tags($namespace, $tag) |
136 | 1894 |
{ |
1895 |
$type = $this->get_type(); |
|
1896 |
if ($type & SIMPLEPIE_TYPE_ATOM_ALL) |
|
1897 |
{ |
|
1898 |
if ($return = $this->get_feed_tags($namespace, $tag)) |
|
1899 |
{ |
|
1900 |
return $return; |
|
1901 |
} |
|
1902 |
} |
|
1903 |
if ($type & SIMPLEPIE_TYPE_RSS_10) |
|
1904 |
{ |
|
1905 |
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) |
|
1906 |
{ |
|
1907 |
if (isset($channel[0]['child'][$namespace][$tag])) |
|
1908 |
{ |
|
1909 |
return $channel[0]['child'][$namespace][$tag]; |
|
1910 |
} |
|
1911 |
} |
|
1912 |
} |
|
1913 |
if ($type & SIMPLEPIE_TYPE_RSS_090) |
|
1914 |
{ |
|
1915 |
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) |
|
1916 |
{ |
|
1917 |
if (isset($channel[0]['child'][$namespace][$tag])) |
|
1918 |
{ |
|
1919 |
return $channel[0]['child'][$namespace][$tag]; |
|
1920 |
} |
|
1921 |
} |
|
1922 |
} |
|
1923 |
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) |
|
1924 |
{ |
|
1925 |
if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) |
|
1926 |
{ |
|
1927 |
if (isset($channel[0]['child'][$namespace][$tag])) |
|
1928 |
{ |
|
1929 |
return $channel[0]['child'][$namespace][$tag]; |
|
1930 |
} |
|
1931 |
} |
|
1932 |
} |
|
1933 |
return null; |
|
1934 |
} |
|
1935 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1936 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1937 |
* Get data for an channel-level element |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1938 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1939 |
* This method allows you to get access to ANY element/attribute in the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1940 |
* image/logo section of the feed. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1941 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1942 |
* See {@see SimplePie::get_feed_tags()} for a description of the return value |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1943 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1944 |
* @since 1.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1945 |
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1946 |
* @param string $namespace The URL of the XML namespace of the elements you're trying to access |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1947 |
* @param string $tag Tag name |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1948 |
* @return array |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1949 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1950 |
public function get_image_tags($namespace, $tag) |
136 | 1951 |
{ |
1952 |
$type = $this->get_type(); |
|
1953 |
if ($type & SIMPLEPIE_TYPE_RSS_10) |
|
1954 |
{ |
|
1955 |
if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) |
|
1956 |
{ |
|
1957 |
if (isset($image[0]['child'][$namespace][$tag])) |
|
1958 |
{ |
|
1959 |
return $image[0]['child'][$namespace][$tag]; |
|
1960 |
} |
|
1961 |
} |
|
1962 |
} |
|
1963 |
if ($type & SIMPLEPIE_TYPE_RSS_090) |
|
1964 |
{ |
|
1965 |
if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) |
|
1966 |
{ |
|
1967 |
if (isset($image[0]['child'][$namespace][$tag])) |
|
1968 |
{ |
|
1969 |
return $image[0]['child'][$namespace][$tag]; |
|
1970 |
} |
|
1971 |
} |
|
1972 |
} |
|
1973 |
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) |
|
1974 |
{ |
|
1975 |
if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) |
|
1976 |
{ |
|
1977 |
if (isset($image[0]['child'][$namespace][$tag])) |
|
1978 |
{ |
|
1979 |
return $image[0]['child'][$namespace][$tag]; |
|
1980 |
} |
|
1981 |
} |
|
1982 |
} |
|
1983 |
return null; |
|
1984 |
} |
|
1985 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1986 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1987 |
* Get the base URL value from the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1988 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1989 |
* Uses `<xml:base>` if available, otherwise uses the first link in the |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1990 |
* feed, or failing that, the URL of the feed itself. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1991 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1992 |
* @see get_link |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1993 |
* @see subscribe_url |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1994 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1995 |
* @param array $element |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1996 |
* @return string |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1997 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1998 |
public function get_base($element = array()) |
136 | 1999 |
{ |
2000 |
if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) |
|
2001 |
{ |
|
2002 |
return $element['xml_base']; |
|
2003 |
} |
|
2004 |
elseif ($this->get_link() !== null) |
|
2005 |
{ |
|
2006 |
return $this->get_link(); |
|
2007 |
} |
|
2008 |
else |
|
2009 |
{ |
|
2010 |
return $this->subscribe_url(); |
|
2011 |
} |
|
2012 |
} |
|
2013 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2014 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2015 |
* Sanitize feed data |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2016 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2017 |
* @access private |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2018 |
* @see SimplePie_Sanitize::sanitize() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2019 |
* @param string $data Data to sanitize |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2020 |
* @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2021 |
* @param string $base Base URL to resolve URLs against |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2022 |
* @return string Sanitized data |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2023 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2024 |
public function sanitize($data, $type, $base = '') |
136 | 2025 |
{ |
2026 |
return $this->sanitize->sanitize($data, $type, $base); |
|
2027 |
} |
|
2028 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2029 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2030 |
* Get the title of the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2031 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2032 |
* Uses `<atom:title>`, `<title>` or `<dc:title>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2033 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2034 |
* @since 1.0 (previously called `get_feed_title` since 0.8) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2035 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2036 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2037 |
public function get_title() |
136 | 2038 |
{ |
2039 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) |
|
2040 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2041 |
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
136 | 2042 |
} |
2043 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) |
|
2044 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2045 |
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
136 | 2046 |
} |
2047 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
2048 |
{ |
|
2049 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
2050 |
} |
|
2051 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
2052 |
{ |
|
2053 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
2054 |
} |
|
2055 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
2056 |
{ |
|
2057 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
2058 |
} |
|
2059 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
2060 |
{ |
|
2061 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2062 |
} |
|
2063 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
2064 |
{ |
|
2065 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2066 |
} |
|
2067 |
else |
|
2068 |
{ |
|
2069 |
return null; |
|
2070 |
} |
|
2071 |
} |
|
2072 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2073 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2074 |
* Get a category for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2075 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2076 |
* @since Unknown |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2077 |
* @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2078 |
* @return SimplePie_Category|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2079 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2080 |
public function get_category($key = 0) |
136 | 2081 |
{ |
2082 |
$categories = $this->get_categories(); |
|
2083 |
if (isset($categories[$key])) |
|
2084 |
{ |
|
2085 |
return $categories[$key]; |
|
2086 |
} |
|
2087 |
else |
|
2088 |
{ |
|
2089 |
return null; |
|
2090 |
} |
|
2091 |
} |
|
2092 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2093 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2094 |
* Get all categories for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2095 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2096 |
* Uses `<atom:category>`, `<category>` or `<dc:subject>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2097 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2098 |
* @since Unknown |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2099 |
* @return array|null List of {@see SimplePie_Category} objects |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2100 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2101 |
public function get_categories() |
136 | 2102 |
{ |
2103 |
$categories = array(); |
|
2104 |
||
2105 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) |
|
2106 |
{ |
|
2107 |
$term = null; |
|
2108 |
$scheme = null; |
|
2109 |
$label = null; |
|
2110 |
if (isset($category['attribs']['']['term'])) |
|
2111 |
{ |
|
2112 |
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2113 |
} |
|
2114 |
if (isset($category['attribs']['']['scheme'])) |
|
2115 |
{ |
|
2116 |
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2117 |
} |
|
2118 |
if (isset($category['attribs']['']['label'])) |
|
2119 |
{ |
|
2120 |
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2121 |
} |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2122 |
$categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
136 | 2123 |
} |
2124 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) |
|
2125 |
{ |
|
2126 |
// This is really the label, but keep this as the term also for BC. |
|
2127 |
// Label will also work on retrieving because that falls back to term. |
|
2128 |
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2129 |
if (isset($category['attribs']['']['domain'])) |
|
2130 |
{ |
|
2131 |
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2132 |
} |
|
2133 |
else |
|
2134 |
{ |
|
2135 |
$scheme = null; |
|
2136 |
} |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2137 |
$categories[] = $this->registry->create('Category', array($term, $scheme, null)); |
136 | 2138 |
} |
2139 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) |
|
2140 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2141 |
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
136 | 2142 |
} |
2143 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) |
|
2144 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2145 |
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
136 | 2146 |
} |
2147 |
||
2148 |
if (!empty($categories)) |
|
2149 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2150 |
return array_unique($categories); |
136 | 2151 |
} |
2152 |
else |
|
2153 |
{ |
|
2154 |
return null; |
|
2155 |
} |
|
2156 |
} |
|
2157 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2158 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2159 |
* Get an author for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2160 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2161 |
* @since 1.1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2162 |
* @param int $key The author that you want to return. Remember that arrays begin with 0, not 1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2163 |
* @return SimplePie_Author|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2164 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2165 |
public function get_author($key = 0) |
136 | 2166 |
{ |
2167 |
$authors = $this->get_authors(); |
|
2168 |
if (isset($authors[$key])) |
|
2169 |
{ |
|
2170 |
return $authors[$key]; |
|
2171 |
} |
|
2172 |
else |
|
2173 |
{ |
|
2174 |
return null; |
|
2175 |
} |
|
2176 |
} |
|
2177 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2178 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2179 |
* Get all authors for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2180 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2181 |
* Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2182 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2183 |
* @since 1.1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2184 |
* @return array|null List of {@see SimplePie_Author} objects |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2185 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2186 |
public function get_authors() |
136 | 2187 |
{ |
2188 |
$authors = array(); |
|
2189 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) |
|
2190 |
{ |
|
2191 |
$name = null; |
|
2192 |
$uri = null; |
|
2193 |
$email = null; |
|
2194 |
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
2195 |
{ |
|
2196 |
$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2197 |
} |
|
2198 |
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
2199 |
{ |
|
2200 |
$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); |
|
2201 |
} |
|
2202 |
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
2203 |
{ |
|
2204 |
$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2205 |
} |
|
2206 |
if ($name !== null || $email !== null || $uri !== null) |
|
2207 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2208 |
$authors[] = $this->registry->create('Author', array($name, $uri, $email)); |
136 | 2209 |
} |
2210 |
} |
|
2211 |
if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) |
|
2212 |
{ |
|
2213 |
$name = null; |
|
2214 |
$url = null; |
|
2215 |
$email = null; |
|
2216 |
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
2217 |
{ |
|
2218 |
$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2219 |
} |
|
2220 |
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
2221 |
{ |
|
2222 |
$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); |
|
2223 |
} |
|
2224 |
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
2225 |
{ |
|
2226 |
$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2227 |
} |
|
2228 |
if ($name !== null || $email !== null || $url !== null) |
|
2229 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2230 |
$authors[] = $this->registry->create('Author', array($name, $url, $email)); |
136 | 2231 |
} |
2232 |
} |
|
2233 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) |
|
2234 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2235 |
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
136 | 2236 |
} |
2237 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) |
|
2238 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2239 |
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
136 | 2240 |
} |
2241 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) |
|
2242 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2243 |
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); |
136 | 2244 |
} |
2245 |
||
2246 |
if (!empty($authors)) |
|
2247 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2248 |
return array_unique($authors); |
136 | 2249 |
} |
2250 |
else |
|
2251 |
{ |
|
2252 |
return null; |
|
2253 |
} |
|
2254 |
} |
|
2255 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2256 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2257 |
* Get a contributor for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2258 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2259 |
* @since 1.1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2260 |
* @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2261 |
* @return SimplePie_Author|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2262 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2263 |
public function get_contributor($key = 0) |
136 | 2264 |
{ |
2265 |
$contributors = $this->get_contributors(); |
|
2266 |
if (isset($contributors[$key])) |
|
2267 |
{ |
|
2268 |
return $contributors[$key]; |
|
2269 |
} |
|
2270 |
else |
|
2271 |
{ |
|
2272 |
return null; |
|
2273 |
} |
|
2274 |
} |
|
2275 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2276 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2277 |
* Get all contributors for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2278 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2279 |
* Uses `<atom:contributor>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2280 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2281 |
* @since 1.1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2282 |
* @return array|null List of {@see SimplePie_Author} objects |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2283 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2284 |
public function get_contributors() |
136 | 2285 |
{ |
2286 |
$contributors = array(); |
|
2287 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) |
|
2288 |
{ |
|
2289 |
$name = null; |
|
2290 |
$uri = null; |
|
2291 |
$email = null; |
|
2292 |
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) |
|
2293 |
{ |
|
2294 |
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2295 |
} |
|
2296 |
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) |
|
2297 |
{ |
|
2298 |
$uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); |
|
2299 |
} |
|
2300 |
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) |
|
2301 |
{ |
|
2302 |
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2303 |
} |
|
2304 |
if ($name !== null || $email !== null || $uri !== null) |
|
2305 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2306 |
$contributors[] = $this->registry->create('Author', array($name, $uri, $email)); |
136 | 2307 |
} |
2308 |
} |
|
2309 |
foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) |
|
2310 |
{ |
|
2311 |
$name = null; |
|
2312 |
$url = null; |
|
2313 |
$email = null; |
|
2314 |
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) |
|
2315 |
{ |
|
2316 |
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2317 |
} |
|
2318 |
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) |
|
2319 |
{ |
|
2320 |
$url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); |
|
2321 |
} |
|
2322 |
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) |
|
2323 |
{ |
|
2324 |
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2325 |
} |
|
2326 |
if ($name !== null || $email !== null || $url !== null) |
|
2327 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2328 |
$contributors[] = $this->registry->create('Author', array($name, $url, $email)); |
136 | 2329 |
} |
2330 |
} |
|
2331 |
||
2332 |
if (!empty($contributors)) |
|
2333 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2334 |
return array_unique($contributors); |
136 | 2335 |
} |
2336 |
else |
|
2337 |
{ |
|
2338 |
return null; |
|
2339 |
} |
|
2340 |
} |
|
2341 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2342 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2343 |
* Get a single link for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2344 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2345 |
* @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2346 |
* @param int $key The link that you want to return. Remember that arrays begin with 0, not 1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2347 |
* @param string $rel The relationship of the link to return |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2348 |
* @return string|null Link URL |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2349 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2350 |
public function get_link($key = 0, $rel = 'alternate') |
136 | 2351 |
{ |
2352 |
$links = $this->get_links($rel); |
|
2353 |
if (isset($links[$key])) |
|
2354 |
{ |
|
2355 |
return $links[$key]; |
|
2356 |
} |
|
2357 |
else |
|
2358 |
{ |
|
2359 |
return null; |
|
2360 |
} |
|
2361 |
} |
|
2362 |
||
2363 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2364 |
* Get the permalink for the item |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2365 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2366 |
* Returns the first link available with a relationship of "alternate". |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2367 |
* Identical to {@see get_link()} with key 0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2368 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2369 |
* @see get_link |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2370 |
* @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2371 |
* @internal Added for parity between the parent-level and the item/entry-level. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2372 |
* @return string|null Link URL |
136 | 2373 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2374 |
public function get_permalink() |
136 | 2375 |
{ |
2376 |
return $this->get_link(0); |
|
2377 |
} |
|
2378 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2379 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2380 |
* Get all links for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2381 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2382 |
* Uses `<atom:link>` or `<link>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2383 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2384 |
* @since Beta 2 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2385 |
* @param string $rel The relationship of links to return |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2386 |
* @return array|null Links found for the feed (strings) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2387 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2388 |
public function get_links($rel = 'alternate') |
136 | 2389 |
{ |
2390 |
if (!isset($this->data['links'])) |
|
2391 |
{ |
|
2392 |
$this->data['links'] = array(); |
|
2393 |
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) |
|
2394 |
{ |
|
2395 |
foreach ($links as $link) |
|
2396 |
{ |
|
2397 |
if (isset($link['attribs']['']['href'])) |
|
2398 |
{ |
|
2399 |
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
2400 |
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
2401 |
} |
|
2402 |
} |
|
2403 |
} |
|
2404 |
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) |
|
2405 |
{ |
|
2406 |
foreach ($links as $link) |
|
2407 |
{ |
|
2408 |
if (isset($link['attribs']['']['href'])) |
|
2409 |
{ |
|
2410 |
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; |
|
2411 |
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
|
2412 |
||
2413 |
} |
|
2414 |
} |
|
2415 |
} |
|
2416 |
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) |
|
2417 |
{ |
|
2418 |
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
2419 |
} |
|
2420 |
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) |
|
2421 |
{ |
|
2422 |
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
2423 |
} |
|
2424 |
if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) |
|
2425 |
{ |
|
2426 |
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); |
|
2427 |
} |
|
2428 |
||
2429 |
$keys = array_keys($this->data['links']); |
|
2430 |
foreach ($keys as $key) |
|
2431 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2432 |
if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) |
136 | 2433 |
{ |
2434 |
if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) |
|
2435 |
{ |
|
2436 |
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); |
|
2437 |
$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; |
|
2438 |
} |
|
2439 |
else |
|
2440 |
{ |
|
2441 |
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; |
|
2442 |
} |
|
2443 |
} |
|
2444 |
elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) |
|
2445 |
{ |
|
2446 |
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; |
|
2447 |
} |
|
2448 |
$this->data['links'][$key] = array_unique($this->data['links'][$key]); |
|
2449 |
} |
|
2450 |
} |
|
2451 |
||
2452 |
if (isset($this->data['links'][$rel])) |
|
2453 |
{ |
|
2454 |
return $this->data['links'][$rel]; |
|
2455 |
} |
|
2456 |
else |
|
2457 |
{ |
|
2458 |
return null; |
|
2459 |
} |
|
2460 |
} |
|
2461 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2462 |
public function get_all_discovered_feeds() |
136 | 2463 |
{ |
2464 |
return $this->all_discovered_feeds; |
|
2465 |
} |
|
2466 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2467 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2468 |
* Get the content for the item |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2469 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2470 |
* Uses `<atom:subtitle>`, `<atom:tagline>`, `<description>`, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2471 |
* `<dc:description>`, `<itunes:summary>` or `<itunes:subtitle>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2472 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2473 |
* @since 1.0 (previously called `get_feed_description()` since 0.8) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2474 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2475 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2476 |
public function get_description() |
136 | 2477 |
{ |
2478 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) |
|
2479 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2480 |
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
136 | 2481 |
} |
2482 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) |
|
2483 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2484 |
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
136 | 2485 |
} |
2486 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) |
|
2487 |
{ |
|
2488 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
2489 |
} |
|
2490 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) |
|
2491 |
{ |
|
2492 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); |
|
2493 |
} |
|
2494 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) |
|
2495 |
{ |
|
2496 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
2497 |
} |
|
2498 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) |
|
2499 |
{ |
|
2500 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2501 |
} |
|
2502 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) |
|
2503 |
{ |
|
2504 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2505 |
} |
|
2506 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) |
|
2507 |
{ |
|
2508 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
2509 |
} |
|
2510 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
|
2511 |
{ |
|
2512 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
|
2513 |
} |
|
2514 |
else |
|
2515 |
{ |
|
2516 |
return null; |
|
2517 |
} |
|
2518 |
} |
|
2519 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2520 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2521 |
* Get the copyright info for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2522 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2523 |
* Uses `<atom:rights>`, `<atom:copyright>` or `<dc:rights>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2524 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2525 |
* @since 1.0 (previously called `get_feed_copyright()` since 0.8) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2526 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2527 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2528 |
public function get_copyright() |
136 | 2529 |
{ |
2530 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
|
2531 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2532 |
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
136 | 2533 |
} |
2534 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) |
|
2535 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2536 |
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); |
136 | 2537 |
} |
2538 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) |
|
2539 |
{ |
|
2540 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2541 |
} |
|
2542 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) |
|
2543 |
{ |
|
2544 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2545 |
} |
|
2546 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
|
2547 |
{ |
|
2548 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2549 |
} |
|
2550 |
else |
|
2551 |
{ |
|
2552 |
return null; |
|
2553 |
} |
|
2554 |
} |
|
2555 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2556 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2557 |
* Get the language for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2558 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2559 |
* Uses `<language>`, `<dc:language>`, or @xml_lang |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2560 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2561 |
* @since 1.0 (previously called `get_feed_language()` since 0.8) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2562 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2563 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2564 |
public function get_language() |
136 | 2565 |
{ |
2566 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) |
|
2567 |
{ |
|
2568 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2569 |
} |
|
2570 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) |
|
2571 |
{ |
|
2572 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2573 |
} |
|
2574 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) |
|
2575 |
{ |
|
2576 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2577 |
} |
|
2578 |
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) |
|
2579 |
{ |
|
2580 |
return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2581 |
} |
|
2582 |
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) |
|
2583 |
{ |
|
2584 |
return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2585 |
} |
|
2586 |
elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) |
|
2587 |
{ |
|
2588 |
return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2589 |
} |
|
2590 |
elseif (isset($this->data['headers']['content-language'])) |
|
2591 |
{ |
|
2592 |
return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2593 |
} |
|
2594 |
else |
|
2595 |
{ |
|
2596 |
return null; |
|
2597 |
} |
|
2598 |
} |
|
2599 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2600 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2601 |
* Get the latitude coordinates for the item |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2602 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2603 |
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2604 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2605 |
* Uses `<geo:lat>` or `<georss:point>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2606 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2607 |
* @since 1.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2608 |
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2609 |
* @link http://www.georss.org/ GeoRSS |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2610 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2611 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2612 |
public function get_latitude() |
136 | 2613 |
{ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2614 |
|
136 | 2615 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
2616 |
{ |
|
2617 |
return (float) $return[0]['data']; |
|
2618 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2619 |
elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
136 | 2620 |
{ |
2621 |
return (float) $match[1]; |
|
2622 |
} |
|
2623 |
else |
|
2624 |
{ |
|
2625 |
return null; |
|
2626 |
} |
|
2627 |
} |
|
2628 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2629 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2630 |
* Get the longitude coordinates for the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2631 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2632 |
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2633 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2634 |
* Uses `<geo:long>`, `<geo:lon>` or `<georss:point>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2635 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2636 |
* @since 1.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2637 |
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2638 |
* @link http://www.georss.org/ GeoRSS |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2639 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2640 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2641 |
public function get_longitude() |
136 | 2642 |
{ |
2643 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
|
2644 |
{ |
|
2645 |
return (float) $return[0]['data']; |
|
2646 |
} |
|
2647 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) |
|
2648 |
{ |
|
2649 |
return (float) $return[0]['data']; |
|
2650 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2651 |
elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
136 | 2652 |
{ |
2653 |
return (float) $match[2]; |
|
2654 |
} |
|
2655 |
else |
|
2656 |
{ |
|
2657 |
return null; |
|
2658 |
} |
|
2659 |
} |
|
2660 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2661 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2662 |
* Get the feed logo's title |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2663 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2664 |
* RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" title. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2665 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2666 |
* Uses `<image><title>` or `<image><dc:title>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2667 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2668 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2669 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2670 |
public function get_image_title() |
136 | 2671 |
{ |
2672 |
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) |
|
2673 |
{ |
|
2674 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2675 |
} |
|
2676 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) |
|
2677 |
{ |
|
2678 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2679 |
} |
|
2680 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) |
|
2681 |
{ |
|
2682 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2683 |
} |
|
2684 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) |
|
2685 |
{ |
|
2686 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2687 |
} |
|
2688 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
|
2689 |
{ |
|
2690 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
|
2691 |
} |
|
2692 |
else |
|
2693 |
{ |
|
2694 |
return null; |
|
2695 |
} |
|
2696 |
} |
|
2697 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2698 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2699 |
* Get the feed logo's URL |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2700 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2701 |
* RSS 0.9.0, 2.0, Atom 1.0, and feeds with iTunes RSS tags are allowed to |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2702 |
* have a "feed logo" URL. This points directly to the image itself. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2703 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2704 |
* Uses `<itunes:image>`, `<atom:logo>`, `<atom:icon>`, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2705 |
* `<image><title>` or `<image><dc:title>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2706 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2707 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2708 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2709 |
public function get_image_url() |
136 | 2710 |
{ |
2711 |
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) |
|
2712 |
{ |
|
2713 |
return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); |
|
2714 |
} |
|
2715 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) |
|
2716 |
{ |
|
2717 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2718 |
} |
|
2719 |
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
|
2720 |
{ |
|
2721 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2722 |
} |
|
2723 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) |
|
2724 |
{ |
|
2725 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2726 |
} |
|
2727 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) |
|
2728 |
{ |
|
2729 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2730 |
} |
|
2731 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) |
|
2732 |
{ |
|
2733 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2734 |
} |
|
2735 |
else |
|
2736 |
{ |
|
2737 |
return null; |
|
2738 |
} |
|
2739 |
} |
|
2740 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2741 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2742 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2743 |
* Get the feed logo's link |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2744 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2745 |
* RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" link. This |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2746 |
* points to a human-readable page that the image should link to. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2747 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2748 |
* Uses `<itunes:image>`, `<atom:logo>`, `<atom:icon>`, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2749 |
* `<image><title>` or `<image><dc:title>` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2750 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2751 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2752 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2753 |
public function get_image_link() |
136 | 2754 |
{ |
2755 |
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) |
|
2756 |
{ |
|
2757 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2758 |
} |
|
2759 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) |
|
2760 |
{ |
|
2761 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2762 |
} |
|
2763 |
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) |
|
2764 |
{ |
|
2765 |
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
|
2766 |
} |
|
2767 |
else |
|
2768 |
{ |
|
2769 |
return null; |
|
2770 |
} |
|
2771 |
} |
|
2772 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2773 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2774 |
* Get the feed logo's link |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2775 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2776 |
* RSS 2.0 feeds are allowed to have a "feed logo" width. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2777 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2778 |
* Uses `<image><width>` or defaults to 88.0 if no width is specified and |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2779 |
* the feed is an RSS 2.0 feed. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2780 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2781 |
* @return int|float|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2782 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2783 |
public function get_image_width() |
136 | 2784 |
{ |
2785 |
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) |
|
2786 |
{ |
|
2787 |
return round($return[0]['data']); |
|
2788 |
} |
|
2789 |
elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) |
|
2790 |
{ |
|
2791 |
return 88.0; |
|
2792 |
} |
|
2793 |
else |
|
2794 |
{ |
|
2795 |
return null; |
|
2796 |
} |
|
2797 |
} |
|
2798 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2799 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2800 |
* Get the feed logo's height |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2801 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2802 |
* RSS 2.0 feeds are allowed to have a "feed logo" height. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2803 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2804 |
* Uses `<image><height>` or defaults to 31.0 if no height is specified and |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2805 |
* the feed is an RSS 2.0 feed. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2806 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2807 |
* @return int|float|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2808 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2809 |
public function get_image_height() |
136 | 2810 |
{ |
2811 |
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) |
|
2812 |
{ |
|
2813 |
return round($return[0]['data']); |
|
2814 |
} |
|
2815 |
elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) |
|
2816 |
{ |
|
2817 |
return 31.0; |
|
2818 |
} |
|
2819 |
else |
|
2820 |
{ |
|
2821 |
return null; |
|
2822 |
} |
|
2823 |
} |
|
2824 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2825 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2826 |
* Get the number of items in the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2827 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2828 |
* This is well-suited for {@link http://php.net/for for()} loops with |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2829 |
* {@see get_item()} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2830 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2831 |
* @param int $max Maximum value to return. 0 for no limit |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2832 |
* @return int Number of items in the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2833 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2834 |
public function get_item_quantity($max = 0) |
136 | 2835 |
{ |
2836 |
$max = (int) $max; |
|
2837 |
$qty = count($this->get_items()); |
|
2838 |
if ($max === 0) |
|
2839 |
{ |
|
2840 |
return $qty; |
|
2841 |
} |
|
2842 |
else |
|
2843 |
{ |
|
2844 |
return ($qty > $max) ? $max : $qty; |
|
2845 |
} |
|
2846 |
} |
|
2847 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2848 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2849 |
* Get a single item from the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2850 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2851 |
* This is better suited for {@link http://php.net/for for()} loops, whereas |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2852 |
* {@see get_items()} is better suited for |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2853 |
* {@link http://php.net/foreach foreach()} loops. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2854 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2855 |
* @see get_item_quantity() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2856 |
* @since Beta 2 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2857 |
* @param int $key The item that you want to return. Remember that arrays begin with 0, not 1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2858 |
* @return SimplePie_Item|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2859 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2860 |
public function get_item($key = 0) |
136 | 2861 |
{ |
2862 |
$items = $this->get_items(); |
|
2863 |
if (isset($items[$key])) |
|
2864 |
{ |
|
2865 |
return $items[$key]; |
|
2866 |
} |
|
2867 |
else |
|
2868 |
{ |
|
2869 |
return null; |
|
2870 |
} |
|
2871 |
} |
|
2872 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2873 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2874 |
* Get all items from the feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2875 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2876 |
* This is better suited for {@link http://php.net/for for()} loops, whereas |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2877 |
* {@see get_items()} is better suited for |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2878 |
* {@link http://php.net/foreach foreach()} loops. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2879 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2880 |
* @see get_item_quantity |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2881 |
* @since Beta 2 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2882 |
* @param int $start Index to start at |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2883 |
* @param int $end Number of items to return. 0 for all items after `$start` |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2884 |
* @return array|null List of {@see SimplePie_Item} objects |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2885 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2886 |
public function get_items($start = 0, $end = 0) |
136 | 2887 |
{ |
2888 |
if (!isset($this->data['items'])) |
|
2889 |
{ |
|
2890 |
if (!empty($this->multifeed_objects)) |
|
2891 |
{ |
|
2892 |
$this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); |
|
2893 |
} |
|
2894 |
else |
|
2895 |
{ |
|
2896 |
$this->data['items'] = array(); |
|
2897 |
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) |
|
2898 |
{ |
|
2899 |
$keys = array_keys($items); |
|
2900 |
foreach ($keys as $key) |
|
2901 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2902 |
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
136 | 2903 |
} |
2904 |
} |
|
2905 |
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) |
|
2906 |
{ |
|
2907 |
$keys = array_keys($items); |
|
2908 |
foreach ($keys as $key) |
|
2909 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2910 |
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
136 | 2911 |
} |
2912 |
} |
|
2913 |
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) |
|
2914 |
{ |
|
2915 |
$keys = array_keys($items); |
|
2916 |
foreach ($keys as $key) |
|
2917 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2918 |
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
136 | 2919 |
} |
2920 |
} |
|
2921 |
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) |
|
2922 |
{ |
|
2923 |
$keys = array_keys($items); |
|
2924 |
foreach ($keys as $key) |
|
2925 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2926 |
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
136 | 2927 |
} |
2928 |
} |
|
2929 |
if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) |
|
2930 |
{ |
|
2931 |
$keys = array_keys($items); |
|
2932 |
foreach ($keys as $key) |
|
2933 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2934 |
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); |
136 | 2935 |
} |
2936 |
} |
|
2937 |
} |
|
2938 |
} |
|
2939 |
||
2940 |
if (!empty($this->data['items'])) |
|
2941 |
{ |
|
2942 |
// If we want to order it by date, check if all items have a date, and then sort it |
|
2943 |
if ($this->order_by_date && empty($this->multifeed_objects)) |
|
2944 |
{ |
|
2945 |
if (!isset($this->data['ordered_items'])) |
|
2946 |
{ |
|
2947 |
$do_sort = true; |
|
2948 |
foreach ($this->data['items'] as $item) |
|
2949 |
{ |
|
2950 |
if (!$item->get_date('U')) |
|
2951 |
{ |
|
2952 |
$do_sort = false; |
|
2953 |
break; |
|
2954 |
} |
|
2955 |
} |
|
2956 |
$item = null; |
|
2957 |
$this->data['ordered_items'] = $this->data['items']; |
|
2958 |
if ($do_sort) |
|
2959 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2960 |
usort($this->data['ordered_items'], array(get_class($this), 'sort_items')); |
136 | 2961 |
} |
2962 |
} |
|
2963 |
$items = $this->data['ordered_items']; |
|
2964 |
} |
|
2965 |
else |
|
2966 |
{ |
|
2967 |
$items = $this->data['items']; |
|
2968 |
} |
|
2969 |
||
2970 |
// Slice the data as desired |
|
2971 |
if ($end === 0) |
|
2972 |
{ |
|
2973 |
return array_slice($items, $start); |
|
2974 |
} |
|
2975 |
else |
|
2976 |
{ |
|
2977 |
return array_slice($items, $start, $end); |
|
2978 |
} |
|
2979 |
} |
|
2980 |
else |
|
2981 |
{ |
|
2982 |
return array(); |
|
2983 |
} |
|
2984 |
} |
|
2985 |
||
2986 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2987 |
* Set the favicon handler |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2988 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2989 |
* @deprecated Use your own favicon handling instead |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2990 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2991 |
public function set_favicon_handler($page = false, $qs = 'i') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2992 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2993 |
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2994 |
trigger_error('Favicon handling has been removed, please use your own handling', $level); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2995 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2996 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2997 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2998 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2999 |
* Get the favicon for the current feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3000 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3001 |
* @deprecated Use your own favicon handling instead |
136 | 3002 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3003 |
public function get_favicon() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3004 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3005 |
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3006 |
trigger_error('Favicon handling has been removed, please use your own handling', $level); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3007 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3008 |
if (($url = $this->get_link()) !== null) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3009 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3010 |
return 'http://g.etfv.co/' . urlencode($url); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3011 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3012 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3013 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3014 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3015 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3016 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3017 |
* Magic method handler |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3018 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3019 |
* @param string $method Method name |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3020 |
* @param array $args Arguments to the method |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3021 |
* @return mixed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3022 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3023 |
public function __call($method, $args) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3024 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3025 |
if (strpos($method, 'subscribe_') === 0) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3026 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3027 |
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3028 |
trigger_error('subscribe_*() has been deprecated, implement the callback yourself', $level); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3029 |
return ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3030 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3031 |
if ($method === 'enable_xml_dump') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3032 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3033 |
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3034 |
trigger_error('enable_xml_dump() has been deprecated, use get_raw_data() instead', $level); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3035 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3036 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3037 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3038 |
$class = get_class($this); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3039 |
$trace = debug_backtrace(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3040 |
$file = $trace[0]['file']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3041 |
$line = $trace[0]['line']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3042 |
trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3043 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3044 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3045 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3046 |
* Sorting callback for items |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3047 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3048 |
* @access private |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3049 |
* @param SimplePie $a |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3050 |
* @param SimplePie $b |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3051 |
* @return boolean |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3052 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3053 |
public static function sort_items($a, $b) |
136 | 3054 |
{ |
3055 |
return $a->get_date('U') <= $b->get_date('U'); |
|
3056 |
} |
|
3057 |
||
3058 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3059 |
* Merge items from several feeds into one |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3060 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3061 |
* If you're merging multiple feeds together, they need to all have dates |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3062 |
* for the items or else SimplePie will refuse to sort them. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3063 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3064 |
* @link http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3065 |
* @param array $urls List of SimplePie feed objects to merge |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3066 |
* @param int $start Starting item |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3067 |
* @param int $end Number of items to return |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3068 |
* @param int $limit Maximum number of items per feed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3069 |
* @return array |
136 | 3070 |
*/ |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3071 |
public static function merge_items($urls, $start = 0, $end = 0, $limit = 0) |
136 | 3072 |
{ |
3073 |
if (is_array($urls) && sizeof($urls) > 0) |
|
3074 |
{ |
|
3075 |
$items = array(); |
|
3076 |
foreach ($urls as $arg) |
|
3077 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3078 |
if ($arg instanceof SimplePie) |
136 | 3079 |
{ |
3080 |
$items = array_merge($items, $arg->get_items(0, $limit)); |
|
3081 |
} |
|
3082 |
else |
|
3083 |
{ |
|
3084 |
trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); |
|
3085 |
} |
|
3086 |
} |
|
3087 |
||
3088 |
$do_sort = true; |
|
3089 |
foreach ($items as $item) |
|
3090 |
{ |
|
3091 |
if (!$item->get_date('U')) |
|
3092 |
{ |
|
3093 |
$do_sort = false; |
|
3094 |
break; |
|
3095 |
} |
|
3096 |
} |
|
3097 |
$item = null; |
|
3098 |
if ($do_sort) |
|
3099 |
{ |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3100 |
usort($items, array(get_class($urls[0]), 'sort_items')); |
136 | 3101 |
} |
3102 |
||
3103 |
if ($end === 0) |
|
3104 |
{ |
|
3105 |
return array_slice($items, $start); |
|
3106 |
} |
|
3107 |
else |
|
3108 |
{ |
|
3109 |
return array_slice($items, $start, $end); |
|
3110 |
} |
|
3111 |
} |
|
3112 |
else |
|
3113 |
{ |
|
3114 |
trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING); |
|
3115 |
return array(); |
|
3116 |
} |
|
3117 |
} |
|
3118 |
} |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
3119 |
endif; |