create.html.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * The create view file of webhook module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Yidong Wang <yidong@easycorp.ltd>
  7. * @package webhook
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $fields = $config->webhook->form->create;
  12. $defaultWidth = '1/2';
  13. $formItems = array();
  14. foreach($fields as $field => $attr)
  15. {
  16. $width = zget($attr, 'width', $defaultWidth);
  17. $fieldName = $field;
  18. $notice = '';
  19. $required = zget($attr, 'required', false);
  20. $rowID = '';
  21. $rowClass = '';
  22. $title = $field;
  23. $control = array();
  24. if($field == 'domain') $attr['default'] = common::getSysURL();
  25. if($field == 'products') $attr['options'] = $products;
  26. if($field == 'executions') $attr['options'] = $executions;
  27. $control['type'] = $attr['control'];
  28. if($attr['control'] == 'picker') $control['items'] = array();
  29. if(!empty($attr['options'])) $control['items'] = $attr['options'];
  30. if(!empty($attr['inline'])) $control['inline'] = $attr['inline'];
  31. if($attr['control'] == 'checkList') $fieldName = $field . '[]';
  32. if(!empty($attr['multiple']))
  33. {
  34. $control['multiple'] = true;
  35. $fieldName = $field . '[]';
  36. }
  37. if(isset($lang->webhook->{$field})) $title = $lang->webhook->{$field};
  38. if($field == 'appKey') $title = $lang->webhook->dingAppKey;
  39. if($field == 'appSecret') $title = $lang->webhook->dingAppSecret;
  40. if($field == 'agentId') $title = $lang->webhook->dingAgentId;
  41. if($field == 'products') $title = $lang->webhook->product;
  42. if($field == 'executions') $title = $lang->webhook->execution;
  43. if($field == 'secret') $rowID = 'secretTR';
  44. if($field == 'url') $rowID = 'urlTR';
  45. if($field == 'sendType') $rowID = 'sendTypeTR';
  46. if($field == 'wechatCorpId') $notice = $lang->webhook->note->wechatHelp;
  47. if($field == 'url') $notice = $lang->webhook->note->typeList['default'];
  48. if($field == 'agentId') $notice = $lang->webhook->note->dingHelp;
  49. if($field == 'sendType') $notice = $lang->webhook->note->async;
  50. if($field == 'products') $notice = $lang->webhook->note->product;
  51. if($field == 'executions') $notice = $lang->webhook->note->execution;
  52. if($field == 'agentId' || $field == 'appKey' || $field == 'appSecret') $rowClass = 'dinguserTR';
  53. if($field == 'feishuAppId' || $field == 'feishuAppSecret') $rowClass = 'feishuTR';
  54. if($field == 'wechatCorpId' || $field == 'wechatCorpSecret' || $field == 'wechatAgentId') $rowClass = 'wechatTR';
  55. if($field == 'agentId' || $field == 'appKey' || $field == 'appSecret') $required = true;
  56. if($field == 'feishuAppId' || $field == 'feishuAppSecret') $required = true;
  57. if($field == 'wechatCorpId' || $field == 'wechatCorpSecret' || $field == 'wechatAgentId') $required = true;
  58. if($field == 'type') $required = true;
  59. $formItems[] = formRow
  60. (
  61. $rowID ? setID($rowID) : null,
  62. $rowClass ? setClass($rowClass) : null,
  63. formGroup
  64. (
  65. set::width($width),
  66. set::name($fieldName),
  67. set::label($title),
  68. set::control($control),
  69. set::value($attr['default']),
  70. set::required($required)
  71. ),
  72. $notice ? formGroup
  73. (
  74. $field == 'url' ? setID('urlNote') : null,
  75. set::style(array('align-items' => 'center')),
  76. html($notice)
  77. ) : null
  78. );
  79. }
  80. jsVar('urlNote', $lang->webhook->note->typeList);
  81. formPanel
  82. (
  83. on::change('[name=type]', 'changeType'),
  84. $formItems
  85. );
  86. render();