BxBaseCover.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * Cover representation.
  11. * @see BxDolCover
  12. */
  13. class BxBaseCover extends BxDolCover
  14. {
  15. protected $_bJsCssAdded = false;
  16. protected $_oTemplate;
  17. public function __construct ($oTemplate)
  18. {
  19. parent::__construct ();
  20. if ($oTemplate)
  21. $this->_oTemplate = $oTemplate;
  22. else
  23. $this->_oTemplate = BxDolTemplate::getInstance();
  24. }
  25. /**
  26. * Display Cover.
  27. */
  28. public function display ()
  29. {
  30. $this->_addJsCss();
  31. if (!$this->_aOptions) {
  32. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  33. $mixedOptions = $oMenuSubmenu->getParamsForCover();
  34. if (!$mixedOptions || !is_array($mixedOptions))
  35. return $this->_oTemplate->parseHtmlByName($this->_sTemplateNameEmpty, array());
  36. if (!$this->_sCoverImageUrl) {
  37. $iId = (int)getParam('sys_site_cover_common');
  38. if ($iId != 0)
  39. $this->setCoverImageUrl(array(
  40. 'id' => $iId,
  41. 'transcoder' => BX_DOL_TRANSCODER_OBJ_COVER
  42. ));
  43. }
  44. if ($this->_sCoverImageUrl)
  45. $mixedOptions['bx_if:bg'] = array (
  46. 'condition' => true,
  47. 'content' => array('image_url' => $this->_sCoverImageUrl),
  48. );
  49. return $this->_oTemplate->parseHtmlByName($this->_sTemplateName, array_merge($this->_aOptiondDefault, $mixedOptions));
  50. }
  51. return $this->_oTemplate->parseHtmlByName($this->_sTemplateName, array_merge($this->_aOptiondDefault, $this->_aOptions));
  52. }
  53. /**
  54. * Add css/js files which are needed for display and functionality.
  55. */
  56. protected function _addJsCss()
  57. {
  58. if ($this->_bJsCssAdded)
  59. return;
  60. $this->_oTemplate->addCss(array('cover.css'));
  61. $this->_bJsCssAdded = true;
  62. }
  63. }
  64. /** @} */