111
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

75 lines
2.7 KiB

  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2018年2月14日
  7. * 列表控制器
  8. */
  9. namespace app\home\controller;
  10. use app\home\model\ParserModel;
  11. use core\basic\Controller;
  12. class ListController extends Controller
  13. {
  14. protected $parser;
  15. protected $model;
  16. public function __construct()
  17. {
  18. $this->parser = new ParserController();
  19. $this->model = new ParserModel();
  20. }
  21. // 内容列表
  22. public function index()
  23. {
  24. if (! ! $scode = get('scode', 'vars')) {
  25. if (! ! $sort = $this->model->getSort($scode)) {
  26. // 如果访问的内容和当前区域不一致,则自动切换
  27. if ($sort->acode != cookie('lg')) {
  28. $lgs = $this->config('lgs');
  29. if (isset($lgs[$sort->acode])) {
  30. cookie('lg', $sort->acode);
  31. }
  32. }
  33. if ($sort->listtpl) {
  34. $content = parent::parser($sort->listtpl); // 框架标签解析
  35. $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  36. $pagetitle = $sort->title ? "{sort:title}" : "{sort:name}"; // 页面标题
  37. $content = str_replace('{pboot:pagetitle}', $pagetitle . '-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
  38. $content = $this->parser->parserPositionLabel($content, $sort->scode); // CMS当前位置标签解析
  39. $content = $this->parser->parserSortLabel($content, $sort); // CMS分类信息标签解析
  40. $content = $this->parser->parserListLabel($content, $sort->scode); // CMS分类列表标签解析
  41. $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  42. } else {
  43. error('请到后台设置分类栏目列表页模板!');
  44. }
  45. } else {
  46. header('HTTP/1.1 404 Not Found');
  47. header('status: 404 Not Found');
  48. $file_404 = ROOT_PATH . '/404.html';
  49. if (file_exists($file_404)) {
  50. require $file_404;
  51. exit();
  52. } else {
  53. error('您访问的分类不存在,请核对后再试!');
  54. }
  55. }
  56. } else {
  57. error('您访问的地址有误,必须传递栏目scode参数!');
  58. }
  59. $this->cache($content, true);
  60. }
  61. // 空拦截
  62. public function _empty()
  63. {
  64. error('您访问的地址有误,请核对后重试!');
  65. }
  66. }