factory.php
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @package Joomla.Legacy
* @subpackage Simplepie
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_PLATFORM') or die;
jimport('simplepie.simplepie');
/**
* Class to maintain a pathway.
*
* The user's navigated path within the application.
*
* @since 3.0
* @deprecated 3.0 Use JFeed or supply your own methods
*/
class JSimplepieFactory
{
/**
* Get a parsed XML Feed Source
*
* @param string $url URL for feed source.
* @param integer $cache_time Time to cache feed for (using internal cache mechanism).
*
* @return SimplePie|boolean SimplePie parsed object on success, false on failure.
*
* @since 3.0
* @deprecated 3.0 Use JFeedFactory($url) instead.
*/
public static function getFeedParser($url, $cache_time = 0)
{
JLog::add(__METHOD__ . ' is deprecated. Use JFeedFactory() or supply Simple Pie instead.', JLog::WARNING, 'deprecated');
$cache = JFactory::getCache('feed_parser', 'callback');
if ($cache_time > 0)
{
$cache->setLifeTime($cache_time);
}
$simplepie = new SimplePie(null, null, 0);
$simplepie->enable_cache(false);
$simplepie->set_feed_url($url);
$simplepie->force_feed(true);
$contents = $cache->get(array($simplepie, 'init'), null, false, false);
if ($contents)
{
return $simplepie;
}
JLog::add(JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'), JLog::WARNING, 'jerror');
return false;
}
}