BxBaseStudioPermissions.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioPermissions extends BxDolStudioPermissions
  11. {
  12. protected $sSubpageUrl;
  13. function __construct($sPage = '')
  14. {
  15. parent::__construct($sPage);
  16. $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_permissions.php?page=';
  17. }
  18. function getPageCss()
  19. {
  20. return array_merge(parent::getPageCss(), array('forms.css', 'paginate.css', 'permissions.css'));
  21. }
  22. function getPageJs()
  23. {
  24. return array_merge(parent::getPageJs(), array('permissions.js'));
  25. }
  26. function getPageJsObject()
  27. {
  28. return 'oBxDolStudioPermissions';
  29. }
  30. function getPageMenu($aMenu = array(), $aMarkers = array())
  31. {
  32. $sJsObject = $this->getPageJsObject();
  33. $aMenu = array();
  34. $aMenuItems = array(
  35. BX_DOL_STUDIO_PRM_TYPE_LEVELS => array('icon' => 'sliders-h'),
  36. BX_DOL_STUDIO_PRM_TYPE_ACTIONS => array('icon' => 'exchange-alt')
  37. );
  38. foreach($aMenuItems as $sMenuItem => $aItem)
  39. $aMenu[] = array(
  40. 'name' => $sMenuItem,
  41. 'icon' => $aItem['icon'],
  42. 'link' => $this->sSubpageUrl . $sMenuItem,
  43. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  44. 'selected' => $sMenuItem == $this->sPage
  45. );
  46. return parent::getPageMenu($aMenu);
  47. }
  48. function getPageCode($sPage = '', $bWrap = true)
  49. {
  50. $sResult = parent::getPageCode($sPage, $bWrap);
  51. if($sResult === false)
  52. return false;
  53. $sMethod = 'get' . ucfirst($this->sPage);
  54. if(!method_exists($this, $sMethod))
  55. return '';
  56. return $sResult . $this->$sMethod();
  57. }
  58. protected function getLevels()
  59. {
  60. return $this->getGrid('sys_studio_acl');
  61. }
  62. protected function getActions()
  63. {
  64. return $this->getGrid('sys_studio_acl_actions');
  65. }
  66. protected function getPrices()
  67. {
  68. return $this->getGrid('sys_studio_acl_prices');
  69. }
  70. protected function getGrid($sObjectName)
  71. {
  72. $oGrid = BxDolGrid::getObjectInstance($sObjectName);
  73. if(!$oGrid)
  74. return '';
  75. return BxDolStudioTemplate::getInstance()->parseHtmlByName('permissions.html', array(
  76. 'js_object' => $this->getPageJsObject(),
  77. 'content' => $this->getBlockCode(array(
  78. 'items' => $oGrid->getCode()
  79. ))
  80. ));
  81. }
  82. }
  83. /** @} */