BxBaseStudioGrid.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 DolphinView Dolphin Studio Representation classes
  7. * @ingroup DolphinStudio
  8. * @{
  9. */
  10. bx_import('BxDolStudioGrid');
  11. class BxBaseStudioGrid extends BxDolStudioGrid {
  12. function __construct($aOptions, $oTemplate = false) {
  13. parent::__construct($aOptions, $oTemplate);
  14. }
  15. function getJsObject() {
  16. return '';
  17. }
  18. public function getModulesSelectOne($sGetItemsMethod, $bShowCustom = true, $bShowSystem = true)
  19. {
  20. if(empty($sGetItemsMethod))
  21. return '';
  22. bx_import('BxTemplStudioFormView');
  23. $oForm = new BxTemplStudioFormView(array());
  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. $aInputModules['values'] = array_merge(array('' => _t('_adm_txt_select_module')), $aInputModules['values']);
  39. return $oForm->genRow($aInputModules);
  40. }
  41. protected function _getItem($sDbMethod = '')
  42. {
  43. $aIds = bx_get('ids');
  44. if(!$aIds || !is_array($aIds)) {
  45. $iId = (int)bx_get('id');
  46. if(!$iId)
  47. return false;
  48. $aIds = array($iId);
  49. }
  50. $iId = $aIds[0];
  51. $aItem = array();
  52. $this->oDb->$sDbMethod(array('type' => 'by_id', 'value' => $iId), $aItem, false);
  53. if(!is_array($aItem) || empty($aItem))
  54. return false;
  55. return $aItem;
  56. }
  57. }
  58. /** @} */