article.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '发布',
  6. 2 => '未发布',
  7. );
  8. $channel = function()
  9. {
  10. $array = array();
  11. $channel = Dever::db('atom/channel')->parent();
  12. if ($channel) {
  13. $array += $channel;
  14. }
  15. return $array;
  16. };
  17. $channel_child = function()
  18. {
  19. $channel = Dever::db('atom/channel')->child();
  20. return $channel;
  21. };
  22. # 栏目
  23. $search_channel = function()
  24. {
  25. $array = array
  26. (
  27. -1 => array('id' => '-1', 'name' => '所有栏目'),
  28. );
  29. $channel = Dever::load('atom/service/article/channel.all');
  30. if ($channel) {
  31. $array += $channel;
  32. }
  33. return $array;
  34. };
  35. return array
  36. (
  37. # 表名
  38. 'name' => 'article',
  39. # 显示给用户看的名称
  40. 'lang' => '文章',
  41. 'order' => 20,
  42. # 数据结构
  43. 'struct' => array
  44. (
  45. 'id' => array
  46. (
  47. 'type' => 'int-11',
  48. 'name' => 'ID',
  49. 'default' => '',
  50. 'desc' => '',
  51. 'match' => 'is_numeric',
  52. 'search' => 'order',
  53. 'list' => true,
  54. ),
  55. 'name' => array
  56. (
  57. 'type' => 'varchar-80',
  58. 'name' => '标题',
  59. 'default' => '',
  60. 'desc' => '请输入主题标题',
  61. 'match' => 'is_string',
  62. 'update' => 'text',
  63. 'search' => 'fulltext',
  64. 'list' => true,
  65. ),
  66. 'author' => array
  67. (
  68. 'type' => 'varchar-80',
  69. 'name' => '作者-请填写用户id',
  70. 'default' => '1',
  71. 'desc' => '请填写作者',
  72. 'match' => 'is_string',
  73. 'update' => 'text',
  74. //'search' => 'select',
  75. 'list' => true,
  76. ),
  77. 'channel_id_parent' => array
  78. (
  79. 'type' => 'int-11',
  80. 'name' => '父级栏目',
  81. 'default' => '0',
  82. 'desc' => '请选择父级栏目',
  83. 'match' => 'is_numeric',
  84. 'update' => 'select',
  85. //'search' => 'order,select',
  86. //'list' => '{channel_id_parent} > 0 ? Dever::load("atom/channel-one#name", {channel_id_parent}) : "临时栏目"',
  87. 'option' => $channel,
  88. # 当值改变时,执行下一步操作
  89. 'child_name' => 'channel_id',
  90. 'child' => $channel_child,
  91. 'child_value' => '{channel_id}',
  92. ),
  93. 'channel_id' => array
  94. (
  95. 'type' => 'int-11',
  96. 'name' => '子栏目',
  97. 'default' => '0',
  98. 'desc' => '请选择子栏目',
  99. 'match' => 'is_numeric',
  100. //'search' => 'order',
  101. 'list_name' => '栏目',
  102. 'list' => '{channel_id} > 0 ? Dever::load("atom/channel-one#name", {channel_id}) : "无子栏目"',
  103. ),
  104. 'reorder' => array
  105. (
  106. 'type' => 'int-11',
  107. 'name' => '排序(数值越大越靠前)',
  108. 'default' => '1',
  109. 'desc' => '请输入排序',
  110. 'match' => 'option',
  111. 'update' => 'text',
  112. 'search' => 'order',
  113. 'list_name' => '排序',
  114. 'list' => true,
  115. 'order' => 'desc',
  116. 'edit' => true,
  117. ),
  118. 'pic' => array
  119. (
  120. 'type' => 'varchar-200',
  121. 'name' => '封面标准图-请上传等比例图片300X300',
  122. 'default' => '',
  123. 'desc' => '封面标准图',
  124. 'match' => 'is_string',
  125. 'update' => 'image',
  126. 'key' => 1
  127. ),
  128. 'content' => array
  129. (
  130. 'type' => 'text-255',
  131. 'name' => '内容',
  132. 'default' => '',
  133. 'desc' => '请输入内容',
  134. 'match' => 'is_string',
  135. 'update' => 'editor',
  136. 'key' => 1,
  137. ),
  138. 'status' => array
  139. (
  140. 'type' => 'tinyint-1',
  141. 'name' => '状态',
  142. 'default' => '1',
  143. 'desc' => '请选择状态',
  144. 'match' => 'is_numeric',
  145. 'option' => $option,
  146. 'update' => 'radio',
  147. 'list' => true,
  148. ),
  149. 'state' => array
  150. (
  151. 'type' => 'tinyint-1',
  152. 'name' => '状态',
  153. 'default' => '1',
  154. 'desc' => '请选择状态',
  155. 'match' => 'is_numeric',
  156. ),
  157. 'cdate' => array
  158. (
  159. 'type' => 'int-11',
  160. 'name' => '录入时间',
  161. 'match' => array('is_numeric', time()),
  162. 'desc' => '',
  163. # 只有insert时才生效
  164. 'insert' => true,
  165. 'list' => 'date("Y-m-d H:i:s", {cdate})',
  166. ),
  167. ),
  168. # 管理功能
  169. 'manage' => array
  170. (
  171. //'insert' => false,
  172. # 列表
  173. 'list' => array
  174. (
  175. array
  176. (
  177. 1 => array('分页', '"page&option_article_id={id}"')
  178. ),
  179. ),
  180. ),
  181. # request 请求接口定义
  182. 'request' => array
  183. (
  184. # 获取默认主题,按照置顶和时间排序的
  185. 'default' => array
  186. (
  187. # 匹配的正则或函数 选填项
  188. 'option' => array
  189. (
  190. 'cate_id' => 'yes',
  191. 'cate_id_parent' => 'yes',
  192. 'uid' => 'yes',
  193. ),
  194. 'type' => 'all',
  195. 'order' => array('top' => 'desc', 'reorder' => 'desc', 'id' => 'desc'),
  196. 'page' => array(15, 'list'),
  197. 'col' => '*',
  198. ),
  199. # 更新浏览量
  200. 'addView' => array
  201. (
  202. 'type' => 'update',
  203. 'where' => array
  204. (
  205. 'id' => 'yes',
  206. ),
  207. 'set' => array
  208. (
  209. 'num_view' => array('1', '+='),
  210. ),
  211. ),
  212. # 更新回复数
  213. 'addReview' => array
  214. (
  215. 'type' => 'update',
  216. 'where' => array
  217. (
  218. 'id' => 'yes',
  219. ),
  220. 'set' => array
  221. (
  222. 'num_review' => array('1', '+='),
  223. ),
  224. ),
  225. # 更新点赞数
  226. 'addUp' => array
  227. (
  228. 'type' => 'update',
  229. 'where' => array
  230. (
  231. 'id' => 'yes',
  232. ),
  233. 'set' => array
  234. (
  235. 'num_up' => array('1', '+='),
  236. ),
  237. ),
  238. # 更新点赞数
  239. 'desUp' => array
  240. (
  241. 'type' => 'update',
  242. 'where' => array
  243. (
  244. 'id' => 'yes',
  245. ),
  246. 'set' => array
  247. (
  248. 'num_up' => array('1', '-='),
  249. ),
  250. ),
  251. ),
  252. );