cate.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '显示',
  6. 2 => '不显示',
  7. );
  8. $comment = array
  9. (
  10. 1 => '允许评论',
  11. 2 => '不允许评论',
  12. );
  13. $cate = function () {
  14. $array = array(-1 => array('name' => '父级分类'));
  15. $cate = Dever::load('doc/cate-main');
  16. if ($cate) {
  17. $array += $cate;
  18. }
  19. return $array;
  20. };
  21. return array
  22. (
  23. # 表名
  24. 'name' => 'cate',
  25. # 显示给用户看的名称
  26. 'lang' => '分类',
  27. 'order' => 10,
  28. # 数据结构
  29. 'struct' => array
  30. (
  31. 'id' => array
  32. (
  33. 'type' => 'int-11',
  34. 'name' => '分类ID',
  35. 'default' => '',
  36. 'desc' => '',
  37. 'match' => 'is_numeric',
  38. //'search' => 'order',
  39. 'order' => 'desc',
  40. 'list' => true,
  41. ),
  42. 'name' => array
  43. (
  44. 'type' => 'varchar-60',
  45. 'name' => '分类名称',
  46. 'default' => '',
  47. 'desc' => '请输入分类名称',
  48. 'match' => 'is_string',
  49. 'update' => 'text',
  50. 'search' => 'fulltext',
  51. 'list' => true,
  52. ),
  53. 'cate_id' => array
  54. (
  55. 'type' => 'int-11',
  56. 'name' => '上级分类',
  57. 'default' => Dever::input('option_cate_id', -1),
  58. 'desc' => '请选择上级分类',
  59. 'match' => 'is_numeric',
  60. 'update' => 'select',
  61. 'search' => 'order,select',
  62. 'option' => $cate,
  63. ),
  64. 'pic' => array
  65. (
  66. 'type' => 'varchar-150',
  67. 'name' => '分类图片-选填,大小为150X150px',
  68. 'default' => '',
  69. 'desc' => '请选择分类图片',
  70. 'match' => 'option',
  71. 'update' => 'image',
  72. 'key' => '1',
  73. 'place' => '150',
  74. ),
  75. 'info' => array
  76. (
  77. 'type' => 'varchar-500',
  78. 'name' => '分类介绍-选填,字数不超过500字,出现分类头部,如果想清空该介绍,请输入null。',
  79. 'default' => '',
  80. 'desc' => '请输入分类介绍',
  81. 'match' => 'option',
  82. 'update' => 'editor',
  83. ),
  84. 'link' => array
  85. (
  86. 'type' => 'varchar-150',
  87. 'name' => '分类链接-选填,如果填写了链接,则点击本分类直接跳转至本链接。',
  88. 'default' => '',
  89. 'desc' => '请输入分类链接',
  90. 'match' => 'option',
  91. 'update' => 'text',
  92. ),
  93. 'reorder' => array
  94. (
  95. 'type' => 'int-11',
  96. 'name' => '排序(数值越大越靠前)',
  97. 'default' => '1',
  98. 'desc' => '请输入排序',
  99. 'match' => 'option',
  100. 'update' => 'text',
  101. 'search' => 'order',
  102. 'list_name' => '排序',
  103. 'list' => true,
  104. 'order' => 'desc',
  105. 'edit' => true,
  106. ),
  107. 'comment' => array
  108. (
  109. 'type' => 'tinyint-1',
  110. 'name' => '是否允许评论',
  111. 'default' => '1',
  112. 'desc' => '请选择是否允许评论',
  113. 'match' => 'is_numeric',
  114. 'option' => $comment,
  115. //'update' => 'radio',
  116. //'list' => true,
  117. //'edit' => true,
  118. ),
  119. 'state' => array
  120. (
  121. 'type' => 'tinyint-1',
  122. 'name' => '状态',
  123. 'default' => '1',
  124. 'desc' => '请选择状态',
  125. 'match' => 'is_numeric',
  126. 'option' => $option,
  127. 'update' => 'radio',
  128. 'list' => true,
  129. ),
  130. 'cdate' => array
  131. (
  132. 'type' => 'int-11',
  133. 'name' => '录入时间',
  134. 'match' => array('is_numeric', time()),
  135. 'desc' => '',
  136. # 只有insert时才生效
  137. 'insert' => true,
  138. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  139. ),
  140. ),
  141. 'manage' => array
  142. (
  143. # 列表页的类型
  144. 'list_type' => 'parent',
  145. 'list_button' => array
  146. (
  147. 'add' => array('新增子分类', '"cate&option_cate_id={id}&oper_parent=cate"', '{cate_id}<=0'),
  148. //6 => '删除'
  149. ),
  150. ),
  151. # request 请求接口定义
  152. 'request' => array
  153. (
  154. # info 取一条正常的数据
  155. 'info' => array
  156. (
  157. 'where' => array
  158. (
  159. 'id' => 'is_numeric',
  160. 'state' => 1,
  161. ),
  162. 'type' => 'one',
  163. ),
  164. 'link' => array
  165. (
  166. 'where' => array
  167. (
  168. 'link' => 'is_string',
  169. 'state' => 1,
  170. ),
  171. 'type' => 'one',
  172. ),
  173. # main 取所有主分类
  174. 'main' => array
  175. (
  176. 'where' => array
  177. (
  178. 'cate_id' => -1,
  179. 'state' => 1,
  180. ),
  181. 'type' => 'all',
  182. 'order' => array('reorder` desc,`id', 'desc'),
  183. 'col' => '*|id',
  184. ),
  185. # 取所有下级分类
  186. 'child' => array
  187. (
  188. 'where' => array
  189. (
  190. 'cate_id' => array('1', '>='),
  191. 'state' => 1,
  192. ),
  193. 'type' => 'all',
  194. 'order' => array('reorder` desc,`id', 'desc'),
  195. 'col' => '*|cate_id|id|',
  196. ),
  197. # main 取所有主分类
  198. 'mainAll' => array
  199. (
  200. 'where' => array
  201. (
  202. 'cate_id' => -1,
  203. 'state' => 1,
  204. ),
  205. 'type' => 'all',
  206. 'order' => array('reorder` desc,`id', 'desc'),
  207. 'col' => '*|id',
  208. ),
  209. # 取所有下级分类
  210. 'childAll' => array
  211. (
  212. 'where' => array
  213. (
  214. 'cate_id' => array('1', '>='),
  215. 'state' => 1,
  216. ),
  217. 'type' => 'all',
  218. 'order' => array('reorder` desc,`id', 'desc'),
  219. 'col' => '*|cate_id|id|',
  220. ),
  221. ),
  222. );