modrssparser.class.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * modRSSParser
  4. *
  5. * @package modx
  6. * @subpackage xmlrss
  7. */
  8. /**
  9. * RSS Parser for MODX, implementing MagpieRSS
  10. *
  11. * @package modx
  12. * @subpackage xmlrss
  13. */
  14. class modRSSParser {
  15. /**
  16. * Constructor for modRSSParser
  17. *
  18. * @param modX &$modx A reference to the modx object.
  19. * @param array $config A configuration array of properties
  20. */
  21. function __construct(&$modx,array $config = array()) {
  22. $this->modx =& $modx;
  23. if (!defined('MAGPIE_CACHE_DIR')) {
  24. define('MAGPIE_CACHE_DIR',$this->modx->getOption('core_path').'cache/rss/');
  25. }
  26. if (!defined('MAGPIE_USER_AGENT')) {
  27. $this->modx->getVersionData();
  28. define('MAGPIE_USER_AGENT','RevoRSS/'.$this->modx->version['full_version']);
  29. }
  30. $this->modx->loadClass('xmlrss.rssfetch','',false,true);
  31. }
  32. /**
  33. * Parses and interprets an RSS or Atom URL
  34. *
  35. * @param string $url The URL of the RSS/Atom feed.
  36. * @return array The parsed RSS/Atom feed. $rss->items gets you the items parsed.
  37. */
  38. public function parse($url) {
  39. $rss = call_user_func('fetch_rss',$url);
  40. return $rss;
  41. }
  42. }