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