88 lines
2.8 KiB
PHP
88 lines
2.8 KiB
PHP
<?php
|
|
|
|
class PageController extends Controller
|
|
{
|
|
|
|
static function actionPoints()
|
|
{
|
|
self::$layout = 'layoutPage.php';
|
|
self::addScript('/js/jquery-2.1.0.min.js');
|
|
self::addScript('/js/jquery-ui-1.10.4.custom.min.js');
|
|
self::addScript('/js/bootstrap.min.js');
|
|
self::addStyle('/css/bootstrap.min.css');
|
|
self::addStyle('/css/bootstrap-theme.min.css');
|
|
|
|
$param['order']='id DESC';
|
|
$param['where']=App::getParam('category') ? 'categoryId = '.(int)App::getParam('category') : '';
|
|
$points = Point::model()->getAll($param);
|
|
$categories = Category::model()->getAll(array('order' => 'ord ASC'));
|
|
|
|
$result = array();
|
|
|
|
foreach ($points as $point) {
|
|
$id = $point->id;
|
|
$result[$id]['id'] = $point->id;
|
|
$result[$id]['name'] = $point->name;
|
|
$result[$id]['lat'] = $point->lat;
|
|
$result[$id]['lng'] = $point->lng;
|
|
$result[$id]['author'] = $point->authorUser->nick;
|
|
$result[$id]['categoryId'] = $point->categoryId;
|
|
$result[$id]['categoryIcon'] = $categories[$point->categoryId]->icon;
|
|
}
|
|
|
|
$res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points`")->fetch(PDO::FETCH_ASSOC);
|
|
App::setConfig('title', $res['pointsCount'] . ' или даже больше поводов не сидеть дома');
|
|
|
|
self::render('pointsTemplate.php', array(
|
|
'categories' => $categories,
|
|
'user' => App::$user,
|
|
'points' => $result,
|
|
));
|
|
}
|
|
|
|
static function actionPoint()
|
|
{
|
|
self::$layout = 'layoutPage.php';
|
|
|
|
$id = (int) App::getParam('id');
|
|
if ($id)
|
|
{
|
|
self::addScript('/js/jquery-2.1.0.min.js');
|
|
self::addScript('/js/jquery-ui-1.10.4.custom.min.js');
|
|
self::addScript('/js/bootstrap.min.js');
|
|
|
|
self::addScript('/js/app.js?ver=' . App::getConfig('version'));
|
|
self::addScript('/js/fotorama.js');
|
|
|
|
self::addStyle('/css/style.css?ver=' . App::getConfig('version'));
|
|
self::addStyle('/css/bootstrap.min.css');
|
|
self::addStyle('/css/bootstrap-theme.min.css');
|
|
self::addStyle('/css/fotorama.css');
|
|
|
|
$point = Point::model()->getByPK($id);
|
|
$point->descriptionHtml = nl2br($point->description);
|
|
$point->name = htmlspecialchars($point->name);
|
|
|
|
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
|
|
|
|
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
|
$point->categoryName = $categories[$point->categoryId]['name'];
|
|
|
|
$randomPoint = Point::model()->getRandom();
|
|
$similarPoints = Point::model()->getAll(array('where' => 'categoryId = '.$point->categoryId.' AND `id` <> '.$point->id.' ORDER BY RAND() LIMIT 6;'));
|
|
|
|
self::render('point.php', array(
|
|
'point' => $point,
|
|
'randomPoint' => $randomPoint,
|
|
'similarPoints' => $similarPoints,
|
|
'categories' => $categories,
|
|
'photos' => $point->photos,
|
|
));
|
|
} else
|
|
{
|
|
App::error404();
|
|
}
|
|
}
|
|
|
|
}
|