menu.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '开启',
  6. 2 => '关闭',
  7. );
  8. $menu = function()
  9. {
  10. $array = array(-1 => array('name' => '父级菜单'));
  11. $data = Dever::load('weixin/menu-main');
  12. if($data)
  13. {
  14. $array += $data;
  15. }
  16. return $array;
  17. };
  18. $message = function()
  19. {
  20. $array = array(-1 => array('name' => '不选择消息'));
  21. $data = Dever::load('weixin/content-get_2');
  22. if($data)
  23. {
  24. $array += $data;
  25. }
  26. return $array;
  27. };
  28. # 菜单类型
  29. $type = array
  30. (
  31. 'click' => '点击推事件',
  32. 'view' => '跳转url',
  33. 'scancode_push' => '扫码推事件',
  34. 'scancode_waitmsg' => '扫码推事件且弹出“消息接收中”提示框',
  35. 'pic_sysphoto' => '弹出系统拍照发图',
  36. 'pic_photo_or_album' => '弹出拍照或者相册发图',
  37. 'pic_weixin' => '弹出微信相册发图器',
  38. 'location_select' => '弹出地理位置选择器',
  39. //'media_id' => '下发消息(除文本消息)',
  40. //'view_limited' => '跳转图文消息URL',
  41. );
  42. return array
  43. (
  44. # 表名
  45. 'name' => 'menu',
  46. # 显示给用户看的名称
  47. 'lang' => '自定义菜单',
  48. 'order' => 17,
  49. # 数据结构
  50. 'struct' => array
  51. (
  52. 'id' => array
  53. (
  54. 'type' => 'int-11',
  55. 'name' => 'ID',
  56. 'default' => '',
  57. 'desc' => '',
  58. 'match' => 'is_numeric',
  59. 'search' => 'order',
  60. //'list' => true,
  61. ),
  62. 'site' => array
  63. (
  64. 'type' => 'int-11',
  65. 'name' => '站点',
  66. 'default' => '',
  67. 'desc' => '请输入站点',
  68. 'match' => 'is_numeric',
  69. //'search' => 'order,fulltext',
  70. //'update' => 'text',
  71. //'list' => true,
  72. ),
  73. 'name' => array
  74. (
  75. 'type' => 'varchar-24',
  76. 'name' => '菜单名称',
  77. 'default' => '',
  78. 'desc' => '请输入菜单名称',
  79. 'match' => 'is_string',
  80. 'update' => 'text',
  81. 'search' => 'order,fulltext',
  82. 'list' => true,
  83. ),
  84. 'menu_id' => array
  85. (
  86. 'type' => 'int-11',
  87. 'name' => '上级菜单',
  88. 'default' => '-1',
  89. 'desc' => '请选择上级菜单',
  90. 'match' => 'is_numeric',
  91. 'update' => 'select',
  92. 'search' => 'order,select',
  93. 'list' => '{menu_id} > 0 ? Dever::load("weixin/menu-one#name", {menu_id}) : "父级菜单"',
  94. 'option' => $menu,
  95. ),
  96. 'type' => array
  97. (
  98. 'type' => 'varchar-10',
  99. 'name' => '菜单类型',
  100. 'default' => 'click',
  101. 'desc' => '请选择菜单类型',
  102. 'match' => 'is_string',
  103. 'option' => $type,
  104. 'update' => 'radio',
  105. 'list' => true,
  106. # 开启显示控制,可以控制下边的表单
  107. 'show' => 'type',
  108. ),
  109. 'message' => array
  110. (
  111. 'type' => 'int-11',
  112. 'name' => '回复消息',
  113. 'default' => '',
  114. 'desc' => '回复消息',
  115. 'match' => 'is_numeric',
  116. 'update' => 'select',
  117. 'list' => '{message} > 0 ? Dever::load("weixin/content-one#keywords", {message}) : "未选择消息"',
  118. 'option' => $message,
  119. 'show' => array('type_click'),
  120. ),
  121. 'url' => array
  122. (
  123. 'type' => 'varchar-100',
  124. 'name' => '网页链接',
  125. 'default' => '',
  126. 'desc' => '请输入网页链接',
  127. 'match' => 'option',
  128. 'update' => 'text',
  129. 'show' => array('type_view'),
  130. ),
  131. 'reorder' => array
  132. (
  133. 'type' => 'int-11',
  134. 'name' => '排序(数值越大越靠前)',
  135. 'default' => '1',
  136. 'desc' => '请输入排序',
  137. 'match' => 'option',
  138. 'update' => 'text',
  139. 'search' => 'order',
  140. 'list' => true,
  141. 'order' => 'desc',
  142. ),
  143. 'state' => array
  144. (
  145. 'type' => 'tinyint-1',
  146. 'name' => '状态',
  147. 'default' => '1',
  148. 'desc' => '请选择状态',
  149. 'match' => 'is_numeric',
  150. 'option' => $option,
  151. 'update' => 'radio',
  152. ),
  153. 'cdate' => array
  154. (
  155. 'type' => 'int-11',
  156. 'name' => '录入时间',
  157. 'match' => array('is_numeric', time()),
  158. 'desc' => '',
  159. # 只有insert时才生效
  160. 'insert' => true,
  161. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  162. ),
  163. ),
  164. # 更新表结构
  165. 'alter' => array
  166. (
  167. 1 => array
  168. (
  169. array('update', 'url', 'url', 'text-255 头部菜单'),
  170. ),
  171. 'version' => 1,
  172. ),
  173. 'manage' => array
  174. (
  175. # 不允许编辑
  176. //'edit' => false,
  177. //
  178. //# 列表页的类型
  179. 'list_type' => 'parent',
  180. # 按钮
  181. 'button' => array
  182. (
  183. '发布菜单' => 'weixin/menu.create',
  184. '删除菜单' => 'weixin/data.menu_del',
  185. ),
  186. # 可以删除
  187. //1 => array('同步', '"javascript:load(\'".Dever::url("weixin/menu.test?id={id}")."\')"')
  188. 'list_button' => array(6 => '删除'),
  189. 'desc' => '注意:除了点击推事件和跳转URL,其他类型的菜单,仅支持微信iPhone5.4.1以上版本,和Android5.4以上版本的微信用户,旧版本微信用户点击后将没有回应,开发者也不能正常接收到事件推送。',
  190. ),
  191. 'auth' => 'site',
  192. # request 请求接口定义
  193. 'request' => array
  194. (
  195. # main 取所有主栏目
  196. 'main' => array
  197. (
  198. 'where' => array
  199. (
  200. 'menu_id' => -1,
  201. 'state' => 1,
  202. 'site' => 'yes',
  203. ),
  204. 'type' => 'all',
  205. 'order' => array('reorder` desc,`id', 'desc'),
  206. 'col' => '*|id',
  207. ),
  208. # 取所有下级栏目
  209. 'child' => array
  210. (
  211. 'where' => array
  212. (
  213. 'menu_id' => array('1', '>='),
  214. 'state' => 1,
  215. 'site' => 'yes',
  216. ),
  217. 'type' => 'all',
  218. 'order' => array('reorder` desc,`id', 'desc'),
  219. 'col' => '*|menu_id|id|',
  220. ),
  221. # 取所有菜单
  222. 'all' => array
  223. (
  224. 'where' => array
  225. (
  226. 'state' => 1,
  227. 'site' => 'yes',
  228. ),
  229. 'type' => 'all',
  230. 'order' => array('reorder` desc,`id', 'desc'),
  231. 'col' => '*|menu_id|id|',
  232. ),
  233. ),
  234. );