1
0

BxBaseMenuWiki.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Wiki block menu
  11. */
  12. class BxBaseMenuWiki extends BxTemplMenu
  13. {
  14. protected $_oWikiObject;
  15. protected $_iBlockId;
  16. public function __construct ($aObject, $oTemplate)
  17. {
  18. parent::__construct ($aObject, $oTemplate);
  19. if ($sWikiObj = bx_get('wiki_obj')) {
  20. $oWiki = BxDolWiki::getObjectInstance($sWikiObj);
  21. if ($oWiki) {
  22. $this->_oWikiObject = $oWiki;
  23. $this->_iBlockId = (int)bx_get('block_id');
  24. }
  25. }
  26. }
  27. public function getCode ()
  28. {
  29. $s = parent::getCode ();
  30. $s .= '<script>window.glBxDolWiki' . $this->_iBlockId . '.bindEvents();</script>';
  31. return $s;
  32. }
  33. /**
  34. * Check if menu items is visible with extended checking for friends notifications
  35. * @param $a menu item array
  36. * @return boolean
  37. */
  38. protected function _isVisible ($a)
  39. {
  40. if(!$this->_oWikiObject || !parent::_isVisible($a))
  41. return false;
  42. return $this->_oWikiObject->isAllowed($a['name']);
  43. }
  44. }
  45. /** @} */