BxBaseLabelForm.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. class BxBaseLabelForm extends BxTemplFormView
  10. {
  11. protected $_oObject;
  12. public function __construct($aInfo, $oTemplate)
  13. {
  14. parent::__construct($aInfo, $oTemplate);
  15. $this->_oObject = BxDolLabel::getInstance();
  16. switch($this->aParams['display']) {
  17. case 'sys_labels_select':
  18. $this->aInputs['action']['value'] = 'select_labels';
  19. break;
  20. }
  21. }
  22. public function initChecker($aValues = array(), $aSpecificValues = array())
  23. {
  24. return parent::initChecker($aValues, $aSpecificValues);
  25. }
  26. public function getElementLabels($aInput = array())
  27. {
  28. $sName = !empty($aInput['name']) ? $aInput['name'] : 'labels';
  29. $sHtmlId = !empty($aInput['attrs']['id']) ? $aInput['attrs']['id'] : 'bx-form-element-labels';
  30. $sValue = '';
  31. if(!empty($aInput['value']) && is_array($aInput['value']))
  32. foreach($aInput['value'] as $sLabel)
  33. $sValue .= $this->_oObject->getLabel($sName, $sLabel);
  34. $aInputLabels = array(
  35. 'type' => 'custom',
  36. 'name' => $sName,
  37. 'caption' => '',
  38. 'value' => $sValue,
  39. 'ajax_get_suggestions' => BX_DOL_URL_ROOT . bx_append_url_params('label.php', array(
  40. 'action' => 'labels_list',
  41. )),
  42. 'attrs' => array(
  43. 'disabled' => 'disabled'
  44. )
  45. );
  46. return $this->oTemplate->parseHtmlByName('label_select_field.html', array(
  47. 'js_object' => $this->_oObject->getJsObjectName(),
  48. 'js_code' => $this->_oObject->getJsCodeForm(),
  49. 'html_id' => $sHtmlId,
  50. 'input_labels' => $this->genCustomInputUsernamesSuggestions($aInputLabels)
  51. ));
  52. }
  53. protected function genCustomInputSearch($aInput)
  54. {
  55. $aInput = array_merge($aInput, array(
  56. 'custom' => array(
  57. 'b_img' => false
  58. ),
  59. 'ajax_get_suggestions' => BX_DOL_URL_ROOT . bx_append_url_params('label.php', array(
  60. 'action' => 'labels_list',
  61. ))
  62. ));
  63. return $this->genCustomInputUsernamesSuggestions($aInput);
  64. }
  65. protected function genCustomInputList($aInput)
  66. {
  67. return $this->_oObject->getLabelsList($aInput, $this);
  68. }
  69. }
  70. /** @} */