64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?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,
|
|
));
|
|
}
|
|
}
|