Убрано ненужное + добавлен JSON-controller + реализованы базовые методы

This commit is contained in:
Krivchikov Dmitry 2014-04-03 10:50:04 +04:00
parent f7f8b8f93f
commit ce24c29882
4 changed files with 66 additions and 69 deletions

View File

@ -14,51 +14,4 @@ class IndexController extends Controller
'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();
}
}
}

View File

@ -0,0 +1,63 @@
<?php
class JsonController extends Controller
{
/**
* Точки
*/
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,
));
}
/**
* Точка
*/
static function actionPoint()
{
$id = (int) App::getParam('id');
if ($id)
{
$point = new Point();
$point = $point->getByPK($id);
$categories = new Category();
$categories = $categories->getAll();
$point['categoryIcon'] = $categories[$point['categoryId']]['icon'];
$point['categoryName'] = $categories[$point['categoryId']]['name'];
self::renderPartial('json.php', $point);
} else
{
App::error404();
}
}
/**
* Категории
*/
static function actionCategories()
{
$categories = new Category();
$categories = $categories->getAll();
self::renderPartial('json.php', array(
'data' => $categories,
));
}
}

View File

@ -1,21 +0,0 @@
<?php
class YandexController extends Controller
{
static function actionIndex()
{
$goods = new Goods();
$category = new Category();
$categorySet = $category->getAll();
$goodsSet = $goods->getAll();
self::renderPartial('yandexMarket.php', array(
'categorySet' => $categorySet,
'goodsSet' => $goodsSet,
));
}
}

View File

@ -6,7 +6,9 @@
<h1><?=App::getConfig('title')?></h1>
<hr/>
<a href="/">Главная</a> |
<a href="/index/points/">Точки</a>
<a href="/json/points/">Точки</a> |
<a href="/json/point/id/1">Выбранная точка</a> |
<a href="/json/categories/">Категории</a>
<hr/>
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
</body>