Просмотр файла mc-2.7.0/modules/index_page/controllers/index_page.php

Размер файла: 2.04Kb
  1. <?php
  2.  
  3. /**
  4. * MobileCMS
  5. *
  6. * Open source content management system for mobile sites
  7. *
  8. * @author MobileCMS Team <support@mobilecms.pro>
  9. * @copyright Copyright (c) 2011-2019, MobileCMS Team
  10. * @link https://mobilecms.pro Official site
  11. * @license MIT license
  12. */
  13. defined('IN_SYSTEM') or die('<b>403<br />Запрет доступа!</b>');
  14.  
  15. //---------------------------------------------
  16.  
  17. /**
  18. * Контроллер пользовательской части модуля главной страницы
  19. */
  20. class Index_Page_Controller extends Controller {
  21.  
  22. /**
  23. * Уровень пользовательского доступа
  24. */
  25. public $access_level = 0;
  26.  
  27. /**
  28. * Метод по умолчанию
  29. */
  30. public function action_index() {
  31. $this->action_view_page();
  32. }
  33.  
  34. /**
  35. * Показ главной страницы
  36. */
  37. public function action_view_page() {
  38. $blocks = $this->cache->get('index_page', 180);
  39. $blocks = $blocks;
  40.  
  41. if (empty($blocks)) {
  42. $result = $this->model->getPageBlocks();
  43. $blocks = array();
  44. while ($block = $this->db->fetch_array($result)) {
  45. $result1 = $this->model->getPageWidgets($block['block_id']);
  46. $block['widgets'] = array();
  47. while ($widget = $this->db->fetch_array($result1)) {
  48. # Подключаем класс виджета
  49. if (!class_exists($widget['module'] . '_widget'))
  50. a_import('modules/' . $widget['module'] . '/helpers/' . $widget['module'] . '_widget.php');
  51. # Получаем display виджета
  52. $block['widgets'][] = call_user_func(array($widget['module'] . '_widget', 'display'), $widget['widget_id']);
  53. }
  54.  
  55. $blocks[] = $block;
  56. }
  57.  
  58. $this->cache->set('index_page', $blocks);
  59. }
  60.  
  61. $this->tpl->assign(array(
  62. 'blocks' => $blocks
  63. ));
  64.  
  65. $this->tpl->display('view_page');
  66. }
  67.  
  68. }
  69.  
  70. ?>