CustomViewModel.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Admin\Model;
  3. use Think\Model;
  4. /**
  5. * 自定义页面模型
  6. * @author Devil
  7. * @blog http://gong.gg/
  8. * @version 0.0.1
  9. * @datetime 2016-12-01T21:51:08+0800
  10. */
  11. class CustomViewModel extends CommonModel
  12. {
  13. // 数据自动校验
  14. protected $_validate = array(
  15. // 添加,编辑
  16. array('title', 'CheckTitle', '{%article_title_format}', 1, 'callback', 3),
  17. array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
  18. array('is_header', array(0,1), '{%common_is_header_tips}', 1, 'in', 3),
  19. array('is_footer', array(0,1), '{%common_is_footer_tips}', 1, 'in', 3),
  20. array('is_full_screen', array(0,1), '{%common_is_full_screen_tips}', 1, 'in', 3),
  21. array('content', 'CheckContent', '{%article_content_format_mobile}', 1, 'callback', 3),
  22. );
  23. /**
  24. * [CheckTitle 标题校验]
  25. * @author Devil
  26. * @blog http://gong.gg/
  27. * @version 0.0.1
  28. * @datetime 2016-12-13T19:29:30+0800
  29. */
  30. public function CheckTitle()
  31. {
  32. $len = Utf8Strlen(I('title'));
  33. return ($len >= 3 && $len <= 60);
  34. }
  35. /**
  36. * [CheckContent 内容校验]
  37. * @author Devil
  38. * @blog http://gong.gg/
  39. * @version 0.0.1
  40. * @datetime 2016-12-13T19:29:30+0800
  41. */
  42. public function CheckContent()
  43. {
  44. $len = Utf8Strlen(I('content'));
  45. return ($len >= 50 && $len <= 105000);
  46. }
  47. }
  48. ?>