wikipoints/ground/controllers/IndexController.php

65 lines
1.4 KiB
PHP

<?php
class IndexController extends Controller
{
/**
* Действие по умолчанию - вывоим каталог товаров.
*/
static function actionIndex()
{
$category = new Category();
self::render('indexTemplate.php', array(
'category' => $category->getAll(),
));
}
/**
* Проверка передачи переменных в шаблон
*/
static function actionTest()
{
self::render('testTemplate.php', array(
'name' => 'Dmitry',
'fname' => 'Krivchikov',
'phone' => '+7-904-610-6141',
));
}
static function actionPoints()
{
$points = new Point();
$points = $points->getAll();
$categories = new Category();
$categories = $categories->getAll();
foreach ($points as &$point) {
$point['categoryIcon'] = $categories[$point['categoryId']]['icon'];
$point['categoryName'] = $categories[$point['categoryId']]['name'];
}
self::renderPartial('json.php', array(
'data' => $points,
));
}
/**
* Вывод элемента каталога. ID товара берётся из параметра /index/catalog/id/1
*/
static function actionCatalog()
{
$id = (int) App::getParam('id');
if ($id)
{
$goods = new Goods();
self::render('goods.php', $goods->getByPK($id));
} else
{
App::error404();
}
}
}