Files
AtomicOld/view/IndexView.php
2026-02-14 19:34:54 +03:00

105 lines
3.9 KiB
PHP

<?PHP
/**
* Simpla CMS
*
* @copyright 2011 Denis Pikusov
* @link http://simp.la
* @author Denis Pikusov
*
* Этот класс использует шаблон index.tpl,
* который содержит всю страницу кроме центрального блока
* По get-параметру module мы определяем что сожержится в центральном блоке
*
*/
require_once('View.php');
class IndexView extends View
{
public $modules_dir = 'view/';
public function __construct()
{
parent::__construct();
}
/**
*
* Отображение
*
*/
function fetch()
{
//callback
if ($this->request->method('post') && $this->request->post('callback')) {
$callback->phone = $this->request->post('phone');
$callback->name = $this->request->post('name');
//$callback->message = $this->request->post('message');
$callback->message = "___";
//$callback->name = "no_name";
$this->design->assign('callname', $callback->name);
$this->design->assign('callemail', $callback->phone);
$this->design->assign('callmessage', $callback->message);
$this->design->assign('call_sent', true);
$callback_id = $this->callbacks->add_callback($callback);
// Отправляем email
$this->callbacks->email_callback_admin($callback_id);
}
// Содержимое корзины
$this->design->assign('cart', $this->cart->get_cart());
//print_r($this->categories->get_categories_tree()); die;
// Категории товаров
$this->design->assign('categories', $this->categories->get_categories_tree());
// Категории статей
$this->design->assign('articles_categories', $this->articles->get_categories_tree());
// Страницы
$this->design->assign('pages', $this->pages->get_pages(array('visible' => 1, 'parent' => 0)));
// Услуги
$this->design->assign('services_tree', $this->services->get_tree());
$this->design->assign('services_root', $this->services->get_root_url());
// Текущий модуль (для отображения центрального блока)
$module = $this->request->get('module', 'string');
$module = preg_replace("/[^A-Za-z0-9]+/", "", $module);
// Если не задан - берем из настроек
if (empty($module))
return false;
//$module = $this->settings->main_module;
// Создаем соответствующий класс
if (is_file($this->modules_dir . "$module.php")) {
include_once($this->modules_dir . "$module.php");
if (class_exists($module)) {
$this->main = new $module($this);
} else return false;
} else return false;
// Создаем основной блок страницы
if (!$content = $this->main->fetch()) {
return false;
}
// Передаем основной блок в шаблон
$this->design->assign('content', $content);
// Передаем название модуля в шаблон, это может пригодиться
$this->design->assign('module', $module);
// Создаем текущую обертку сайта (обычно index.tpl)
$wrapper = $this->design->smarty->getTemplateVars('wrapper');
if (is_null($wrapper))
$wrapper = 'index.tpl';
if (!empty($wrapper)) //{$this->body = $this->design->fetch($wrapper); var_dump($this->body); return $this->body;}
return $this->body = $this->design->fetch($wrapper);
else
return $this->body = $content;
}
}