v1.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace zin;
  3. class aclBox extends wg
  4. {
  5. /**
  6. * Define widget properties.
  7. *
  8. * @var array
  9. * @access protected
  10. */
  11. protected static $defineProps = array(
  12. 'aclItems?: array', // 访问控制可选项。
  13. 'aclValue?: string="open"', // 访问控制默认选中值。
  14. 'whitelistLabel?: string=""', // 白名单标签。
  15. 'userName?: string="whitelist[]"', // 用户组名称。
  16. 'userValue?: string=""', // 用户组默认选中值。
  17. );
  18. public static function getPageCSS()
  19. {
  20. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  21. }
  22. protected function build()
  23. {
  24. list($aclItems, $aclValue, $whitelistLabel, $groupLabel, $userLabel, $groupName, $userName, $groupItems, $groupValue, $userValue) = $this->prop(array('aclItems', 'aclValue', 'whitelistLabel', 'groupLabel', 'userLabel', 'groupName', 'userName', 'groupItems', 'groupValue', 'userValue'));
  25. return div
  26. (
  27. div
  28. (
  29. setClass('aclBox'),
  30. radiolist
  31. (
  32. set(array('items' => $aclItems, 'value' => $aclValue, 'name' => 'acl')),
  33. on::change()->toggleClass('.whitelistBox', 'hidden', "\$element.find('[name=acl]:checked').val() === 'open'")
  34. )
  35. ),
  36. formGroup
  37. (
  38. setClass('whitelistBox'),
  39. $aclValue == 'open' ? setClass('hidden') : null,
  40. set(array('label' => $whitelistLabel, 'required' => false)),
  41. whitelist
  42. (
  43. set(array('inputGroupClass' => 'w-full', 'name' => $userName, 'value' => $userValue))
  44. )
  45. )
  46. );
  47. }
  48. }