Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
/**
4
 * SimplePie
5
 *
6
 * A PHP-Based RSS and Atom Feed Framework.
7
 * Takes the hard work out of managing a complete RSS/Atom solution.
8
 *
9
 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
10
 * All rights reserved.
11
 *
12
 * Redistribution and use in source and binary forms, with or without modification, are
13
 * permitted provided that the following conditions are met:
14
 *
15
 * 	* Redistributions of source code must retain the above copyright notice, this list of
16
 * 	  conditions and the following disclaimer.
17
 *
18
 * 	* Redistributions in binary form must reproduce the above copyright notice, this list
19
 * 	  of conditions and the following disclaimer in the documentation and/or other materials
20
 * 	  provided with the distribution.
21
 *
22
 * 	* Neither the name of the SimplePie Team nor the names of its contributors may be used
23
 * 	  to endorse or promote products derived from this software without specific prior
24
 * 	  written permission.
25
 *
26
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
27
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
28
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
29
 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
 * POSSIBILITY OF SUCH DAMAGE.
35
 *
36
 * @package SimplePie
37
 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
38
 * @author Ryan Parman
39
 * @author Sam Sneddon
40
 * @author Ryan McCue
41
 * @link http://simplepie.org/ SimplePie
42
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
43
 */
44
 
45
namespace SimplePie;
46
 
47
use SimplePie\Cache\Base;
48
 
49
/**
50
 * Used to create cache objects
51
 *
52
 * This class can be overloaded with {@see SimplePie::set_cache_class()},
53
 * although the preferred way is to create your own handler
54
 * via {@see register()}
55
 *
56
 * @package SimplePie
57
 * @subpackage Caching
58
 * @deprecated since SimplePie 1.8.0, use "SimplePie\SimplePie::set_cache()" instead
59
 */
60
class Cache
61
{
62
    /**
63
     * Cache handler classes
64
     *
65
     * These receive 3 parameters to their constructor, as documented in
66
     * {@see register()}
67
     * @var array
68
     */
69
    protected static $handlers = [
70
        'mysql'     => 'SimplePie\Cache\MySQL',
71
        'memcache'  => 'SimplePie\Cache\Memcache',
72
        'memcached' => 'SimplePie\Cache\Memcached',
73
        'redis'     => 'SimplePie\Cache\Redis'
74
    ];
75
 
76
    /**
77
     * Don't call the constructor. Please.
78
     */
79
    private function __construct()
80
    {
81
    }
82
 
83
    /**
84
     * Create a new SimplePie\Cache object
85
     *
86
     * @param string $location URL location (scheme is used to determine handler)
87
     * @param string $filename Unique identifier for cache object
88
     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $extension 'spi' or 'spc'
89
     * @return Base Type of object depends on scheme of `$location`
90
     */
91
    public static function get_handler($location, $filename, $extension)
92
    {
93
        $type = explode(':', $location, 2);
94
        $type = $type[0];
95
        if (!empty(self::$handlers[$type])) {
96
            $class = self::$handlers[$type];
97
            return new $class($location, $filename, $extension);
98
        }
99
 
100
        return new \SimplePie\Cache\File($location, $filename, $extension);
101
    }
102
 
103
    /**
104
     * Create a new SimplePie\Cache object
105
     *
106
     * @deprecated since SimplePie 1.3.1, use {@see get_handler()} instead
107
     */
108
    public function create($location, $filename, $extension)
109
    {
110
        trigger_error('Cache::create() has been replaced with Cache::get_handler() since SimplePie 1.3.1, use the registry system instead.', \E_USER_DEPRECATED);
111
 
112
        return self::get_handler($location, $filename, $extension);
113
    }
114
 
115
    /**
116
     * Register a handler
117
     *
118
     * @param string $type DSN type to register for
119
     * @param class-string<Base> $class Name of handler class. Must implement Base
120
     */
121
    public static function register($type, $class)
122
    {
123
        self::$handlers[$type] = $class;
124
    }
125
 
126
    /**
127
     * Parse a URL into an array
128
     *
129
     * @param string $url
130
     * @return array
131
     */
132
    public static function parse_URL($url)
133
    {
134
        $params = parse_url($url);
135
        $params['extras'] = [];
136
        if (isset($params['query'])) {
137
            parse_str($params['query'], $params['extras']);
138
        }
139
        return $params;
140
    }
141
}
142
 
143
class_alias('SimplePie\Cache', 'SimplePie_Cache');