posts.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '正常',
  6. 2 => '删除',
  7. );
  8. $cate = function () {
  9. $array = array();
  10. $cate = Dever::load('doc/cate-mainAll');
  11. if ($cate) {
  12. $array += $cate;
  13. }
  14. return $array;
  15. };
  16. $cate_child = function () {
  17. $cate = Dever::load('doc/cate-childAll');
  18. return $cate;
  19. };
  20. # 分类
  21. $search_cate = function () {
  22. $array = array
  23. (
  24. -1 => array('id' => '-1', 'name' => '所有分类'),
  25. );
  26. $cate = Dever::load('doc/cate.all');
  27. if ($cate) {
  28. $array += $cate;
  29. }
  30. return $array;
  31. };
  32. return array
  33. (
  34. # 表名
  35. 'name' => 'posts',
  36. # 显示给用户看的名称
  37. 'lang' => '文档',
  38. 'order' => 9,
  39. # 数据结构
  40. 'struct' => array
  41. (
  42. 'id' => array
  43. (
  44. 'type' => 'int-11',
  45. 'name' => 'ID',
  46. 'default' => '',
  47. 'desc' => '',
  48. 'match' => 'is_numeric',
  49. 'search' => 'order',
  50. 'list' => true,
  51. ),
  52. 'name' => array
  53. (
  54. 'type' => 'varchar-80',
  55. 'name' => '标题',
  56. 'default' => '',
  57. 'desc' => '请输入文档标题',
  58. 'match' => 'is_string',
  59. 'update' => 'text',
  60. 'search' => 'fulltext',
  61. 'list' => '"<a href=\"".Dever::url("doc/view?id={id}","main")."\" target=\"_blank\" >{name}</a>"',
  62. ),
  63. 'author' => array
  64. (
  65. 'type' => 'varchar-100',
  66. 'name' => '作者',
  67. 'default' => Dever::load('manage/auth.info#username'),
  68. 'desc' => '请填写作者',
  69. 'match' => 'is_string',
  70. 'update' => 'text',
  71. 'search' => 'fulltext',
  72. 'list' => true,
  73. ),
  74. 'cate_id_parent' => array
  75. (
  76. 'type' => 'int-11',
  77. 'name' => '父级分类',
  78. 'default' => '0',
  79. 'desc' => '请选择父级分类',
  80. 'match' => 'is_numeric',
  81. 'update' => 'select',
  82. //'search' => 'order,select',
  83. 'option' => $cate,
  84. # 当值改变时,执行下一步操作
  85. 'child_name' => 'cate_id',
  86. 'child' => $cate_child,
  87. 'child_value' => '{cate_id}',
  88. ),
  89. 'cate_id' => array
  90. (
  91. 'type' => 'int-11',
  92. 'name' => '子分类',
  93. 'default' => '0',
  94. 'desc' => '请选择子分类',
  95. 'match' => 'is_numeric',
  96. //'search' => 'order',
  97. 'list_name' => '分类',
  98. 'list' => '{cate_id} > 0 ? Dever::load("doc/cate-one#name", {cate_id}) : "无子分类"',
  99. ),
  100. 'num_view' => array
  101. (
  102. 'type' => 'int-11',
  103. 'name' => '浏览量',
  104. 'default' => '0',
  105. 'desc' => '请填写浏览量',
  106. 'match' => 'option',
  107. 'search' => 'order',
  108. 'list' => true,
  109. ),
  110. 'info' => array
  111. (
  112. 'type' => 'varchar-500',
  113. 'name' => '简介',
  114. 'default' => '',
  115. 'desc' => '请输入简介',
  116. 'match' => 'is_string',
  117. 'update' => 'textarea',
  118. ),
  119. //使用请直接$data['content'] = json_decode(base64_decode($data['content']), true);
  120. 'content' => array
  121. (
  122. 'type' => 'text-255',
  123. 'name' => '内容',
  124. 'default' => '',
  125. 'desc' => '请输入内容',
  126. 'match' => 'is_string',
  127. 'update' => array
  128. (
  129. array
  130. (
  131. 'col' => 'title',
  132. 'name' => '标题',
  133. 'default' => '',
  134. 'desc' => '请输入标题',
  135. 'match' => 'is_string',
  136. 'update' => 'text',
  137. ),
  138. array
  139. (
  140. 'col' => 'content',
  141. 'name' => '内容',
  142. 'default' => '',
  143. 'desc' => '请输入内容',
  144. 'match' => 'is_string',
  145. 'update' => 'editor',
  146. ),
  147. ),
  148. ),
  149. 'state' => array
  150. (
  151. 'type' => 'tinyint-1',
  152. 'name' => '状态',
  153. 'default' => '1',
  154. 'desc' => '请选择状态',
  155. 'match' => 'is_numeric',
  156. 'option' => $option,
  157. 'update' => 'radio',
  158. 'list' => true,
  159. ),
  160. 'cdate' => array
  161. (
  162. 'type' => 'int-11',
  163. 'name' => '录入时间',
  164. 'match' => array('is_numeric', time()),
  165. 'desc' => '',
  166. # 只有insert时才生效
  167. 'insert' => true,
  168. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  169. ),
  170. ),
  171. # request 请求接口定义
  172. 'request' => array
  173. (
  174. # 更新浏览量
  175. 'addView' => array
  176. (
  177. 'type' => 'update',
  178. 'where' => array
  179. (
  180. 'id' => 'yes',
  181. ),
  182. 'set' => array
  183. (
  184. 'num_view' => array('1', '+='),
  185. ),
  186. ),
  187. ),
  188. );