BxBaseStudioGrid.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 BxBaseStudioGrid extends BxDolStudioGrid
  11. {
  12. function __construct($aOptions, $oTemplate = false)
  13. {
  14. parent::__construct($aOptions, $oTemplate);
  15. }
  16. function getJsObject()
  17. {
  18. return '';
  19. }
  20. public function getModulesSelectOneArray($sGetItemsMethod, $bShowCustom = true, $bShowSystem = true)
  21. {
  22. if(empty($sGetItemsMethod))
  23. return '';
  24. $aInputModules = array(
  25. 'type' => 'select',
  26. 'name' => 'module',
  27. 'attrs' => array(
  28. 'id' => 'bx-grid-module-' . $this->_sObject,
  29. 'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
  30. ),
  31. 'value' => $this->sModule,
  32. 'values' => $this->getModules($bShowCustom, $bShowSystem)
  33. );
  34. $aCounter = array();
  35. $this->oDb->$sGetItemsMethod(array('type' => 'counter_by_modules'), $aCounter, false);
  36. foreach($aInputModules['values'] as $sKey => $sValue)
  37. $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
  38. return $aInputModules;
  39. }
  40. public function getModulesSelectOne($sGetItemsMethod, $bShowCustom = true, $bShowSystem = true)
  41. {
  42. $aInputModules = $this->getModulesSelectOneArray($sGetItemsMethod, $bShowCustom, $bShowSystem);
  43. $aInputModules['values'] = array_merge(array('' => _t('_adm_txt_select_module')), $aInputModules['values']);
  44. $oForm = new BxTemplStudioFormView(array());
  45. return $oForm->genRow($aInputModules);
  46. }
  47. protected function _getItem($sDbMethod = '')
  48. {
  49. $aIds = bx_get('ids');
  50. if(!$aIds || !is_array($aIds)) {
  51. $iId = (int)bx_get('id');
  52. if(!$iId)
  53. return false;
  54. $aIds = array($iId);
  55. }
  56. $iId = $aIds[0];
  57. $aItem = array();
  58. $this->oDb->$sDbMethod(array('type' => 'by_id', 'value' => $iId), $aItem, false);
  59. if(!is_array($aItem) || empty($aItem))
  60. return false;
  61. return $aItem;
  62. }
  63. }
  64. /** @} */