functions.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <php>
  2. if (!function_exists('_parse_plugin_config')) {
  3. function _parse_plugin_config($pluginConfig){
  4. </php>
  5. <foreach name="pluginConfig" item="form">
  6. <switch name="form.type">
  7. <case value="explain">
  8. <div class="form-group">
  9. <label class="col-sm-2 control-label" for="{$key}">
  10. {$form.title|default=''}
  11. <notempty name="form.rule.require">
  12. <span class="form-required">*</span>
  13. </notempty>
  14. </label>
  15. <div class="col-md-6 col-sm-10">
  16. <p class="form-control-static">{$form.value}</p>
  17. <present name="form.tip">
  18. <p class="help-block">{$form.tip}</p>
  19. </present>
  20. </div>
  21. </div>
  22. </case>
  23. <case value="text">
  24. <div class="form-group">
  25. <label class="col-sm-2 control-label" for="{$key}">
  26. {$form.title|default=''}
  27. <notempty name="form.rule.require">
  28. <span class="form-required">*</span>
  29. </notempty>
  30. </label>
  31. <div class="col-md-6 col-sm-10">
  32. <input type="text" name="config[{$key}]" class="form-control" {$form.disabled?'disabled':''} value="{$form.value}" id="{$key}">
  33. <present name="form.tip">
  34. <p class="help-block">{$form.tip}</p>
  35. </present>
  36. </div>
  37. </div>
  38. </case>
  39. <case value="password">
  40. <div class="form-group">
  41. <label class="col-sm-2 control-label" for="{$key}">
  42. {$form.title|default=''}
  43. <notempty name="form.rule.require">
  44. <span class="form-required">*</span>
  45. </notempty>
  46. </label>
  47. <div class="col-md-6 col-sm-10">
  48. <input type="password" name="config[{$key}]" class="form-control" value="{$form.value}"
  49. id="{$key}">
  50. <present name="form.tip">
  51. <p class="help-block">{$form.tip}</p>
  52. </present>
  53. </div>
  54. </div>
  55. </case>
  56. <case value="number">
  57. <div class="form-group">
  58. <label class="col-sm-2 control-label" for="{$key}">
  59. {$form.title|default=''}
  60. <notempty name="form.rule.require">
  61. <span class="form-required">*</span>
  62. </notempty>
  63. </label>
  64. <div class="col-md-6 col-sm-10">
  65. <input type="number" name="config[{$key}]" class="form-control" {$form.disabled?'disabled':''} value="{$form.value}"
  66. id="{$key}">
  67. <present name="form.tip">
  68. <p class="help-block">{$form.tip}</p>
  69. </present>
  70. </div>
  71. </div>
  72. </case>
  73. <case value="hidden">
  74. <input type="hidden" name="config[{$key}]" value="{$form.value}">
  75. </case>
  76. <case value="radio">
  77. <div class="form-group">
  78. <label class="col-sm-2 control-label" for="{$key}">
  79. {$form.title|default=''}
  80. <notempty name="form.rule.require">
  81. <span class="form-required">*</span>
  82. </notempty>
  83. </label>
  84. <div class="col-md-6 col-sm-10">
  85. <foreach name="form.options" item="opt" key="opt_k">
  86. <label class="radio-inline">
  87. <php>$radio_checked=$opt_k==$form['value']?"checked":"";</php>
  88. <input type="radio" name="config[{$key}]" value="{$opt_k}" {$radio_checked}>{$opt}
  89. </label>
  90. </foreach>
  91. <present name="form.tip">
  92. <p class="help-block">{$form.tip}</p>
  93. </present>
  94. </div>
  95. </div>
  96. </case>
  97. <case value="checkbox">
  98. <div class="form-group">
  99. <label class="col-sm-2 control-label" for="{$key}">
  100. {$form.title|default=''}
  101. <notempty name="form.rule.require">
  102. <span class="form-required">*</span>
  103. </notempty>
  104. </label>
  105. <div class="col-md-6 col-sm-10">
  106. <foreach name="form.options" item="opt" key="opt_k">
  107. <label class="checkbox-inline">
  108. <php>
  109. is_null($form["value"]) && $form["value"] = array();
  110. </php>
  111. <input type="checkbox" name="config[{$key}][]" value="{$opt_k}"
  112. <in name="opt_k" value="$form.value"> checked</in>
  113. >{$opt}
  114. </label>
  115. </foreach>
  116. <present name="form.tip">
  117. <p class="help-block">{$form.tip}</p>
  118. </present>
  119. </div>
  120. </div>
  121. </case>
  122. <case value="select">
  123. <div class="form-group">
  124. <label class="col-sm-2 control-label" for="{$key}">
  125. {$form.title|default=''}
  126. <notempty name="form.rule.require">
  127. <span class="form-required">*</span>
  128. </notempty>
  129. </label>
  130. <div class="col-md-6 col-sm-10">
  131. <select class="form-control" name="config[{$key}]" id="{$key}">
  132. <foreach name="form.options" item="opt" key="opt_k">
  133. <option value="{$opt_k}"
  134. <eq name="form.value" value="$opt_k"> selected</eq>
  135. >{$opt}</option>
  136. </foreach>
  137. </select>
  138. <present name="form.tip">
  139. <p class="help-block">{$form.tip}</p>
  140. </present>
  141. </div>
  142. </div>
  143. </case>
  144. <case value="textarea">
  145. <div class="form-group">
  146. <label class="col-sm-2 control-label" for="{$key}">
  147. {$form.title|default=''}
  148. <notempty name="form.rule.require">
  149. <span class="form-required">*</span>
  150. </notempty>
  151. </label>
  152. <div class="col-md-6 col-sm-10">
  153. <textarea class="form-control" name="config[{$key}]" {$form.disabled?'disabled':''} id="{$key}">{$form.value}</textarea>
  154. <present name="form.tip">
  155. <p class="help-block">{$form.tip}</p>
  156. </present>
  157. </div>
  158. </div>
  159. </case>
  160. <case value="group">
  161. <div>
  162. <ul class="nav nav-tabs" role="tablist">
  163. <foreach name="form.options" item="groupItem" key="groupKey" index="groupIndex">
  164. <li role="presentation" class="{$groupIndex==1?'active':''}">
  165. <a href="#tab-{$groupKey}" role="tab" data-toggle="tab" aria-controls="home"
  166. aria-expanded="true">{$groupItem.title|default=''}</a>
  167. </li>
  168. </foreach>
  169. </ul>
  170. <div class="tab-content margin-top-20">
  171. <foreach name="form.options" item="groupItem" key="groupKey" index="groupIndex">
  172. <div role="tabpanel" class="tab-pane fade in {$groupIndex==1?'active':''}" id="tab-{$groupKey}"
  173. aria-labelledby="home-tab">
  174. {:_parse_plugin_config($groupItem.options)}
  175. </div>
  176. </foreach>
  177. </div>
  178. </div>
  179. </case>
  180. <case value="date">
  181. <div class="form-group">
  182. <label class="col-sm-2 control-label" for="{$key}">
  183. {$form.title|default=''}
  184. <notempty name="form.rule.require">
  185. <span class="form-required">*</span>
  186. </notempty>
  187. </label>
  188. <div class="col-md-6 col-sm-10">
  189. <input class="form-control js-bootstrap-date" name="config[{$key}]" id="{$key}"
  190. value="{$form.value}">
  191. <present name="form.tip">
  192. <p class="help-block">{$form.tip}</p>
  193. </present>
  194. </div>
  195. </div>
  196. </case>
  197. <case value="datetime">
  198. <div class="form-group">
  199. <label class="col-sm-2 control-label" for="{$key}">
  200. {$form.title|default=''}
  201. <notempty name="form.rule.require">
  202. <span class="form-required">*</span>
  203. </notempty>
  204. </label>
  205. <div class="col-md-6 col-sm-10">
  206. <input class="form-control js-bootstrap-datetime" name="config[{$key}]" id="{$key}"
  207. value="{$form.value}">
  208. <present name="form.tip">
  209. <p class="help-block">{$form.tip}</p>
  210. </present>
  211. </div>
  212. </div>
  213. </case>
  214. <case value="color">
  215. <div class="form-group">
  216. <label class="col-sm-2 control-label" for="{$key}">
  217. {$form.title|default=''}
  218. <notempty name="form.rule.require">
  219. <span class="form-required">*</span>
  220. </notempty>
  221. </label>
  222. <div class="col-md-6 col-sm-10">
  223. <input class="form-control js-color" name="config[{$key}]" id="{$key}"
  224. value="{$form.value}">
  225. <present name="form.tip">
  226. <p class="help-block">{$form.tip}</p>
  227. </present>
  228. </div>
  229. </div>
  230. </case>
  231. <case value="image">
  232. <div class="form-group">
  233. <label class="col-sm-2 control-label" for="{$key}">
  234. {$form.title|default=''}
  235. <notempty name="form.rule.require">
  236. <span class="form-required">*</span>
  237. </notempty>
  238. </label>
  239. <div class="col-md-6 col-sm-10">
  240. <input type="hidden" name="config[{$key}]" class="form-control"
  241. value="{$form.value}" id="js-{$key}-input">
  242. <div>
  243. <a href="javascript:uploadOneImage('图片上传','#js-{$key}-input');">
  244. <if condition="empty($form['value'])">
  245. <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  246. id="js-{$key}-input-preview"
  247. width="135" style="cursor: pointer"/>
  248. <else/>
  249. <img src="{:cmf_get_image_preview_url($form['value'])}"
  250. id="js-{$key}-input-preview"
  251. width="135" style="cursor: pointer"/>
  252. </if>
  253. </a>
  254. </div>
  255. <present name="form.tip">
  256. <p class="help-block">{$form.tip}</p>
  257. </present>
  258. </div>
  259. </div>
  260. </case>
  261. <case value="file">
  262. <div class="form-group">
  263. <label class="col-sm-2 control-label" for="{$key}">
  264. {$form.title|default=''}
  265. <notempty name="form.rule.require">
  266. <span class="form-required">*</span>
  267. </notempty>
  268. </label>
  269. <div class="col-md-6 col-sm-10">
  270. <div>
  271. <input class="form-control" id="js-{$key}-input" type="text" name="config[{$key}]" value="{$form['value']}"
  272. style="width: 300px;display: inline-block;" title="文件名称">
  273. <a href="javascript:uploadOne('文件上传','#js-{$key}-input','file');">上传文件</a>
  274. </div>
  275. <present name="form.tip">
  276. <p class="help-block">{$form.tip}</p>
  277. </present>
  278. </div>
  279. </div>
  280. </case>
  281. <case value="location">
  282. <div class="form-group">
  283. <label class="col-sm-2 control-label" for="{$key}">
  284. {$form.title|default=''}
  285. <notempty name="form.rule.require">
  286. <span class="form-required">*</span>
  287. </notempty>
  288. </label>
  289. <div class="col-md-6 col-sm-10">
  290. <input class="form-control" name="config[{$key}]" id="{$key}" value="{$form.value}"
  291. onclick="doSelectLocation(this)"
  292. data-title="请选择{$form.title|default=''}">
  293. <present name="form.tip">
  294. <p class="help-block">{$form.tip}</p>
  295. </present>
  296. </div>
  297. </div>
  298. </case>
  299. </switch>
  300. </foreach>
  301. <php>
  302. }
  303. }
  304. </php>