BxCoursesMenuContentAdd.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 Courses Courses
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxCoursesMenuContentAdd extends BxTemplMenu
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_iEntryPid;
  16. protected $_iNodeId;
  17. protected $_iUsage;
  18. public function __construct($aObject, $oTemplate = false)
  19. {
  20. $this->_sModule = 'bx_courses';
  21. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  22. parent::__construct($aObject, $oTemplate);
  23. $this->_iEntryPid = 0;
  24. if(($iEntryPid = bx_get('entry_pid')) !== false)
  25. $this->_iEntryPid = (int)$iEntryPid;
  26. $this->_iNodeId = 0;
  27. if(($iNodeId = bx_get('node_id')) !== false)
  28. $this->_iNodeId = (int)$iNodeId;
  29. $this->_iUsage = 0;
  30. if(($iUsage = bx_get('usage')) !== false)
  31. $this->_iUsage = (int)$iUsage;
  32. }
  33. protected function getMenuItemsRaw()
  34. {
  35. $aResults = [];
  36. $oPermalink = BxDolPermalinks::getInstance();
  37. $aModules = $this->_oModule->_oConfig->getContentModules($this->_iUsage);
  38. foreach($aModules as $sModule) {
  39. $oModule = BxDolModule::getInstance($sModule);
  40. if(!$oModule)
  41. continue;
  42. $CNF = &$oModule->_oConfig->CNF;
  43. if(!isset($CNF['URI_ADD_ENTRY']))
  44. continue;
  45. $sUrl = $oPermalink->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY'], [
  46. 'context_pid' => $this->_iEntryPid,
  47. 'context_nid' => $this->_iNodeId,
  48. 'context_usage' => $this->_iUsage
  49. ]);
  50. $aResults[] = [
  51. 'id' => $sModule,
  52. 'name' => $sModule,
  53. 'class' => '',
  54. 'link' => $sUrl,
  55. 'onclick' => "$(this).parents('.bx-popup-applied:visible:first').dolPopupHide()",
  56. 'target' => '_self',
  57. 'title' => _t('_' . $sModule)
  58. ];
  59. }
  60. return $aResults;
  61. }
  62. }
  63. /** @} */