author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 17:46:52 -0800 | |
changeset 204 | 09a1c134465b |
permissions | -rw-r--r-- |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
2 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
3 |
* SimplePie |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
4 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
5 |
* A PHP-Based RSS and Atom Feed Framework. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
6 |
* Takes the hard work out of managing a complete RSS/Atom solution. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
7 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
8 |
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
9 |
* All rights reserved. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
10 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
11 |
* Redistribution and use in source and binary forms, with or without modification, are |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
12 |
* permitted provided that the following conditions are met: |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
13 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
14 |
* * Redistributions of source code must retain the above copyright notice, this list of |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
15 |
* conditions and the following disclaimer. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
16 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
17 |
* * Redistributions in binary form must reproduce the above copyright notice, this list |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
18 |
* of conditions and the following disclaimer in the documentation and/or other materials |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
19 |
* provided with the distribution. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
20 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
21 |
* * Neither the name of the SimplePie Team nor the names of its contributors may be used |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
22 |
* to endorse or promote products derived from this software without specific prior |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
23 |
* written permission. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
24 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
25 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
26 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
27 |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
28 |
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
29 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
30 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
31 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
32 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
33 |
* POSSIBILITY OF SUCH DAMAGE. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
34 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
35 |
* @package SimplePie |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
36 |
* @version 1.3.1 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
37 |
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
38 |
* @author Ryan Parman |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
39 |
* @author Geoffrey Sneddon |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
40 |
* @author Ryan McCue |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
41 |
* @link http://simplepie.org/ SimplePie |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
42 |
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
43 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
44 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
45 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
46 |
* Handles creating objects and calling methods |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
47 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
48 |
* Access this via {@see SimplePie::get_registry()} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
49 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
50 |
* @package SimplePie |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
51 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
52 |
class SimplePie_Registry |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
53 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
54 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
55 |
* Default class mapping |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
56 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
57 |
* Overriding classes *must* subclass these. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
58 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
59 |
* @var array |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
60 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
61 |
protected $default = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
62 |
'Cache' => 'SimplePie_Cache', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
63 |
'Locator' => 'SimplePie_Locator', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
64 |
'Parser' => 'SimplePie_Parser', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
65 |
'File' => 'SimplePie_File', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
66 |
'Sanitize' => 'SimplePie_Sanitize', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
67 |
'Item' => 'SimplePie_Item', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
68 |
'Author' => 'SimplePie_Author', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
69 |
'Category' => 'SimplePie_Category', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
70 |
'Enclosure' => 'SimplePie_Enclosure', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
71 |
'Caption' => 'SimplePie_Caption', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
72 |
'Copyright' => 'SimplePie_Copyright', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
73 |
'Credit' => 'SimplePie_Credit', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
74 |
'Rating' => 'SimplePie_Rating', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
75 |
'Restriction' => 'SimplePie_Restriction', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
76 |
'Content_Type_Sniffer' => 'SimplePie_Content_Type_Sniffer', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
77 |
'Source' => 'SimplePie_Source', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
78 |
'Misc' => 'SimplePie_Misc', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
79 |
'XML_Declaration_Parser' => 'SimplePie_XML_Declaration_Parser', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
80 |
'Parse_Date' => 'SimplePie_Parse_Date', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
81 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
82 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
83 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
84 |
* Class mapping |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
85 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
86 |
* @see register() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
87 |
* @var array |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
88 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
89 |
protected $classes = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
90 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
91 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
92 |
* Legacy classes |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
93 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
94 |
* @see register() |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
95 |
* @var array |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
96 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
97 |
protected $legacy = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
98 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
99 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
100 |
* Constructor |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
101 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
102 |
* No-op |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
103 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
104 |
public function __construct() { } |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
105 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
106 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
107 |
* Register a class |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
108 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
109 |
* @param string $type See {@see $default} for names |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
110 |
* @param string $class Class name, must subclass the corresponding default |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
111 |
* @param bool $legacy Whether to enable legacy support for this class |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
112 |
* @return bool Successfulness |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
113 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
114 |
public function register($type, $class, $legacy = false) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
115 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
116 |
if (!is_subclass_of($class, $this->default[$type])) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
117 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
118 |
return false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
119 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
120 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
121 |
$this->classes[$type] = $class; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
122 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
123 |
if ($legacy) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
124 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
125 |
$this->legacy[] = $class; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
126 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
127 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
128 |
return true; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
129 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
130 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
131 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
132 |
* Get the class registered for a type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
133 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
134 |
* Where possible, use {@see create()} or {@see call()} instead |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
135 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
136 |
* @param string $type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
137 |
* @return string|null |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
138 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
139 |
public function get_class($type) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
140 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
141 |
if (!empty($this->classes[$type])) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
142 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
143 |
return $this->classes[$type]; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
144 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
145 |
if (!empty($this->default[$type])) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
146 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
147 |
return $this->default[$type]; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
148 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
149 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
150 |
return null; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
151 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
152 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
153 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
154 |
* Create a new instance of a given type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
155 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
156 |
* @param string $type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
157 |
* @param array $parameters Parameters to pass to the constructor |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
158 |
* @return object Instance of class |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
159 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
160 |
public function &create($type, $parameters = array()) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
161 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
162 |
$class = $this->get_class($type); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
163 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
164 |
if (in_array($class, $this->legacy)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
165 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
166 |
switch ($type) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
167 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
168 |
case 'locator': |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
169 |
// Legacy: file, timeout, useragent, file_class, max_checked_feeds, content_type_sniffer_class |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
170 |
// Specified: file, timeout, useragent, max_checked_feeds |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
171 |
$replacement = array($this->get_class('file'), $parameters[3], $this->get_class('content_type_sniffer')); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
172 |
array_splice($parameters, 3, 1, $replacement); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
173 |
break; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
174 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
175 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
176 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
177 |
if (!method_exists($class, '__construct')) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
178 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
179 |
$instance = new $class; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
180 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
181 |
else |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
182 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
183 |
$reflector = new ReflectionClass($class); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
184 |
$instance = $reflector->newInstanceArgs($parameters); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
185 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
186 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
187 |
if (method_exists($instance, 'set_registry')) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
188 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
189 |
$instance->set_registry($this); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
190 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
191 |
return $instance; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
192 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
193 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
194 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
195 |
* Call a static method for a type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
196 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
197 |
* @param string $type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
198 |
* @param string $method |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
199 |
* @param array $parameters |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
200 |
* @return mixed |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
201 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
202 |
public function &call($type, $method, $parameters = array()) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
203 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
204 |
$class = $this->get_class($type); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
205 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
206 |
if (in_array($class, $this->legacy)) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
207 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
208 |
switch ($type) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
209 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
210 |
case 'Cache': |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
211 |
// For backwards compatibility with old non-static |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
212 |
// Cache::create() methods |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
213 |
if ($method === 'get_handler') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
214 |
{ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
215 |
$result = @call_user_func_array(array($class, 'create'), $parameters); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
216 |
return $result; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
217 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
218 |
break; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
219 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
220 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
221 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
222 |
$result = call_user_func_array(array($class, $method), $parameters); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
223 |
return $result; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
224 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff
changeset
|
225 |
} |