BxDolStudioFormsLabels.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 BxDolStudioFormsLabels extends BxTemplStudioGrid
  10. {
  11. protected $_oLabel;
  12. protected $_iParent;
  13. protected $_aParent;
  14. public function __construct ($aOptions, $oTemplate = false)
  15. {
  16. parent::__construct ($aOptions, $oTemplate);
  17. $this->oDb = new BxDolStudioFormsQuery();
  18. $this->_oLabel = BxDolLabel::getInstance();
  19. $this->_iParent = bx_get('parent') !== false ? (int)bx_get('parent') : 0;
  20. $this->_aQueryAppend['parent'] = $this->_iParent;
  21. $this->_aParent = array();
  22. if(!empty($this->_iParent))
  23. $this->_aParent = $this->_oLabel->getLabels(array('type' => 'id', 'id' => $this->_iParent));
  24. }
  25. protected function _delete ($mixedId)
  26. {
  27. $aChildren = $this->_oLabel->getLabels(['type' => 'parent', 'parent' => $mixedId]);
  28. if(!empty($aChildren) && is_array($aChildren))
  29. foreach($aChildren as $aChild)
  30. $this->_delete($aChild['id']);
  31. $this->_oLabel->onDelete($mixedId);
  32. return parent::_delete($mixedId);
  33. }
  34. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  35. {
  36. $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `parent`=?", $this->_iParent);
  37. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  38. }
  39. }
  40. /** @} */