v1.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * The colorInput widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Mengyi Liu
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. require_once dirname(__DIR__) . DS . 'input' . DS . 'v1.php';
  13. require_once dirname(__DIR__) . DS . 'inputcontrol' . DS . 'v1.php';
  14. require_once dirname(__DIR__) . DS . 'colorpicker' . DS . 'v1.php';
  15. /**
  16. * 带颜色选择器的输入框(colorInput)部件类
  17. * The colorInput widget class
  18. */
  19. class colorInput extends inputControl
  20. {
  21. /**
  22. * Define widget properties.
  23. *
  24. * @var array
  25. * @access protected
  26. */
  27. protected static $defineProps = array
  28. (
  29. 'id?: string', // 组件根元素的 ID。
  30. 'name?: string', // 作为表单项的名称。
  31. 'value?: string=""', // 默认值。
  32. 'inputClass?: string=""', // input 组件样式类名。
  33. 'colorName?: string="color"', // 颜色表单项名称。
  34. 'colorValue?: string=""', // 颜色默认值。
  35. 'hint?: string', // 提示文本。
  36. 'readonly?: bool', // 是否只读。
  37. 'syncColor?: string|bool=true' // 是否同步颜色
  38. );
  39. /**
  40. * Build widget.
  41. *
  42. * @access protected
  43. */
  44. protected function build()
  45. {
  46. list($id, $name, $value, $readonly, $inputClass, $colorName, $colorValue, $syncColor, $hint) = $this->prop(array('id', 'name', 'value', 'readonly', 'inputClass', 'colorName', 'colorValue', 'syncColor', 'hint'));
  47. if($syncColor === true)
  48. {
  49. if($id == null) $id = $this->gid;
  50. $syncColor = "#$id";
  51. }
  52. return inputControl
  53. (
  54. input(setClass($inputClass), set::id($id), set::name($name), set::readonly($readonly), set::value($value)),
  55. set::suffixWidth('icon'),
  56. to::suffix
  57. (
  58. colorPicker
  59. (
  60. set::name($colorName),
  61. set::value($colorValue),
  62. set::syncColor($syncColor),
  63. set::popPlacement('bottom-end'),
  64. set::heading($hint),
  65. set($this->getRestProps())
  66. )
  67. )
  68. );
  69. }
  70. }