BxCoursesFormContentNode.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 Courses Courses
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxCoursesFormContentNode extends BxTemplFormView
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_iParentId;
  16. protected $_iLevel;
  17. protected $_iLevelMax;
  18. protected $_aLevelMaxInputs;
  19. public function __construct($aInfo, $oTemplate = false)
  20. {
  21. $this->_sModule = 'bx_courses';
  22. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  23. parent::__construct($aInfo, $oTemplate);
  24. $this->_iParentId = 0;
  25. $this->_iLevel = 0;
  26. $this->_iLevelMax = $this->_oModule->_oConfig->getContentLevelMax();
  27. $this->_aLevelMaxInputs = ['text', 'passing'];
  28. if(isset($this->aInputs['passing']))
  29. $this->aInputs['passing']['values'] = [
  30. ['key' => BX_COURSES_CND_PASSING_ALL, 'value' => _t('_bx_courses_form_content_node_input_passing_all')],
  31. ['key' => BX_COURSES_CND_PASSING_ALTERNATE, 'value' => _t('_bx_courses_form_content_node_input_passing_alternate')]
  32. ];
  33. }
  34. public function setData($iParentId, $iLevel = 0)
  35. {
  36. $this->_iParentId = $iParentId;
  37. if(!$iLevel) {
  38. $aParent = $this->_oModule->_oDb->getContentStructure([
  39. 'sample' => 'node_id',
  40. 'node_id' => $this->_iParentId
  41. ]);
  42. $iLevel = $this->_oModule->getNodeLevelByParent($aParent);
  43. }
  44. $this->_iLevel = $iLevel;
  45. }
  46. public function initChecker($aValues = [], $aSpecificValues = [])
  47. {
  48. if($this->_iLevel != $this->_iLevelMax)
  49. $this->aInputs = array_diff_key($this->aInputs, array_flip($this->_aLevelMaxInputs));
  50. parent::initChecker ($aValues, $aSpecificValues);
  51. }
  52. }
  53. /** @} */