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