BxBaseRss.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentCore Trident Core
  7. * @{
  8. */
  9. /**
  10. * Privacy representation.
  11. * @see BxDolPrivacy
  12. */
  13. class BxBaseRss extends BxDolRss
  14. {
  15. protected $_oTemplate;
  16. public function __construct ($aOptions, $oTemplate)
  17. {
  18. parent::__construct ($aOptions);
  19. if ($oTemplate)
  20. $this->_oTemplate = $oTemplate;
  21. else
  22. $this->_oTemplate = BxDolTemplate::getInstance();
  23. }
  24. public function getFeed($mixedId, $iUserId = 0)
  25. {
  26. $sUrl = $this->getUrl($mixedId);
  27. $aMarkers = array('SiteUrl' => BX_DOL_URL_ROOT);
  28. if($iUserId) {
  29. $oProfile = BxDolProfile::getInstance($iUserId);
  30. if(!$oProfile)
  31. $oProfile = BxDolProfileUndefined::getInstance();
  32. $aMarkers['NickName'] = $oProfile->getDisplayName();
  33. }
  34. $sUrl = bx_replace_markers($sUrl, $aMarkers);
  35. header('Content-Type: text/xml; charset=utf-8');
  36. return bx_file_get_contents($sUrl . (defined('BX_PROFILER') && BX_PROFILER && 0 === strncmp(BX_DOL_URL_ROOT, $sUrl, strlen(BX_DOL_URL_ROOT)) ? '&bx_profiler_disable=1' : ''));
  37. }
  38. /**
  39. * Outputs holder html for dynamically loaded RSS.
  40. * It automatically adds necessary js, css files and make injection into HTML HEAD section.
  41. * @param $mixedRssId - system rss name, or current block id (if inserted into builder page)
  42. * @param $iRssNum - numbr of rss items to disolay
  43. * @param $iMemberId - optional member id
  44. */
  45. public function getHolder($mixedRssId, $iRssNum, $iMemberId = 0, $bInit = true)
  46. {
  47. if($bInit && !self::$bInitialized) {
  48. $this->_addJsCss();
  49. $this->_addInjection();
  50. self::$bInitialized = true;
  51. }
  52. return $this->_oTemplate->parseHtmlByName('rss_holder.html', array (
  53. 'rss_object' => $this->_sObject,
  54. 'rss_id' => $mixedRssId,
  55. 'rss_num' => $iRssNum,
  56. 'member_id' => $iMemberId,
  57. ));
  58. }
  59. protected function _addJsCss()
  60. {
  61. $this->_oTemplate->addCss(array('rss.css'));
  62. $this->_oTemplate->addJs(array(
  63. 'jquery.jfeed.pack.js',
  64. 'jquery.dolRSSFeed.js',
  65. ));
  66. }
  67. protected function _addInjection()
  68. {
  69. $sContent = $this->_oTemplate->_wrapInTagJsCode('$(document).ready(function() {$("div.RSSAggrCont").dolRSSFeed();});');
  70. $this->_oTemplate->addInjection ('injection_head', 'text', $sContent);
  71. }
  72. }
  73. /** @} */