v1.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * The thinkOptions 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 Zemei Wang<wangzemei@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. require_once dirname(__DIR__) . DS . 'input' . DS . 'v1.php';
  13. /**
  14. * 思引师选项部件类
  15. * The thinkOptions widget class
  16. */
  17. class thinkOptions extends wg
  18. {
  19. /**
  20. * Define widget properties.
  21. *
  22. * @var array
  23. * @access protected
  24. */
  25. protected static $defineProps = array
  26. (
  27. 'id?: string="$GID"', // 组件根元素的 ID。
  28. 'name?: string="fields"', // 步骤输入框作为表单项的名称。
  29. 'data?: array', // 默认值。
  30. 'stepText?: string', // 步骤文本。
  31. 'sameLevelText?: string', // 同级文本。
  32. 'deleteStepTip?: string', // 有子层级禁用删除提示。
  33. 'showOther?: bool=true', // 是否展示启用其他。
  34. 'enableOther?: bool=false', // 是否启用其他。
  35. 'otherName?: string="enableOther"', // 启用其他的 name。
  36. );
  37. public static function getPageJS()
  38. {
  39. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  40. }
  41. public static function getPageCSS()
  42. {
  43. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  44. }
  45. /**
  46. * Build the widget.
  47. *
  48. * @access protected
  49. * @return mixed
  50. */
  51. protected function build()
  52. {
  53. global $lang, $app;
  54. $app->loadLang('thinkstep');
  55. $id = $this->prop('id') ? $this->prop('id') : $this->gid;
  56. $deleteStepTip = $this->prop('deleteStepTip', $lang->thinkstep->deleteOptionTip);
  57. list($enableOther, $otherName, $showOther) = $this->prop(array('enableOther', 'otherName', 'showOther'));
  58. return div
  59. (
  60. setID($id),
  61. setClass('think-options w-full'),
  62. div(setClass('think-options-body')),
  63. zui::thinkOptions
  64. (
  65. set::_to("#$id"),
  66. set::deleteStepTip($deleteStepTip),
  67. set::enterPlaceholder($lang->thinkstep->placeholder->pleaseInput),
  68. set($this->props->pick(array('name', 'data')))
  69. ),
  70. $showOther ? div
  71. (
  72. setClass('w-full flex justify-between items-center h-8 rounded mt-1 ring-opacity-70 ring-gray-300'),
  73. setStyle(array('box-shadow' => 'var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color)')),
  74. div(setClass('h-full flex items-center flex-1'), div
  75. (
  76. setClass('h-full flex items-center pl-2.5 opacity-80'),
  77. setStyle(array('width' => '48px', 'background' => 'rgba(var(--color-gray-200-rgb), .6)')),
  78. $lang->other
  79. ), div(setClass('h-full w-full flex items-center text-gray-400 pl-2.5'), setStyle('background', 'rgba(244, 245, 247, .7)'), $lang->thinkstep->placeholder->pleaseInput)),
  80. div(setClass('h-full flex items-center pr-2.5'), setStyle(array('min-width' => '60px', 'background' => 'rgba(244, 245, 247, .7)')), checkbox
  81. (
  82. set::name($otherName),
  83. set::checked($enableOther),
  84. set::text($lang->thinkstep->enable)
  85. ))
  86. ) : null
  87. );
  88. }
  89. }