BxDolStudioFormsPreLists.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 UnaStudio UNA Studio
  7. * @{
  8. */
  9. class BxDolStudioFormsPreLists extends BxTemplStudioGrid
  10. {
  11. public function __construct ($aOptions, $oTemplate = false)
  12. {
  13. parent::__construct ($aOptions, $oTemplate);
  14. $this->oDb = new BxDolStudioFormsQuery();
  15. }
  16. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  17. {
  18. $sModule = '';
  19. if(strpos($sFilter, $this->sParamsDivider) !== false)
  20. list($sModule, $sFilter) = explode($this->sParamsDivider, $sFilter);
  21. if($sModule != '')
  22. $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `module`=?", $sModule);
  23. $aResults = parent::_getDataSql($sFilter, !empty($sOrderField) ? $sOrderField : 'title', $sOrderDir, $iStart, $iPerPage);
  24. $aLists = array();
  25. $this->oDb->getLists(array('type' => 'pairs_list_values'), $aLists, false);
  26. foreach($aResults as $iKey => $aResult)
  27. if(isset($aLists[$aResult['key']]))
  28. $aResults[$iKey]['values_count'] = (int)$aLists[$aResult['key']];
  29. return $aResults;
  30. }
  31. }
  32. /** @} */