v1.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * The modulePicker 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 Gang Liu <liugang@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. class modulePicker extends wg
  13. {
  14. /**
  15. * @var mixed[]
  16. */
  17. protected static $defineProps = array(
  18. 'id?: string', // 控件 ID。
  19. 'name?: string="module"', // 控件名称。
  20. 'value?: string', // 控件默认值。
  21. 'required?: bool=true', // 是否必填。
  22. 'items?: array', // picker 列表项或列表项获取方法。
  23. 'manageLink?: string' // 维护模块链接
  24. );
  25. public static function getPageJS()
  26. {
  27. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  28. }
  29. protected function build()
  30. {
  31. global $app, $lang;
  32. $app->loadLang('tree');
  33. $items = $this->prop('items', array());
  34. $items = array_filter($this->prop('items'),function($key, $value){return !empty($key) && !empty($value);}, ARRAY_FILTER_USE_BOTH);
  35. return inputGroup
  36. (
  37. setID('moduleBox'),
  38. $this->prop('label', null),
  39. picker(set($this->props->pick(array('id', 'name', 'value', 'required', 'items')))),
  40. $items || empty($this->prop('manageLink')) || !common::hasPriv('tree', 'browse') ? null : span
  41. (
  42. setClass('input-group-btn'),
  43. a
  44. (
  45. setID('manageModule'),
  46. setClass('btn'),
  47. setData(array('toggle' => 'modal', 'size' => 'lg')),
  48. set('href', $this->prop('manageLink')),
  49. set('title', $lang->tree->manage),
  50. icon('treemap')
  51. )
  52. )
  53. );
  54. }
  55. }