154 lines
4.2 KiB
PHP
154 lines
4.2 KiB
PHP
<?php
|
|
|
|
class PageController extends Controller
|
|
{
|
|
|
|
static function actionPoints()
|
|
{
|
|
self::$layout = 'layouts/page.php';
|
|
self::addStyle('/css/style.css?ver=' . App::getConfig('version'));
|
|
self::addStyle('/css/pageStyle.css?ver=' . App::getConfig('version'));
|
|
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');
|
|
|
|
$notModeratedPoints = $result = array();
|
|
|
|
// On moderation
|
|
if (App::$user && App::$user->isAdmin) {
|
|
$param['order'] = 'id DESC';
|
|
$param['where'] = '`moderate` = 0';
|
|
$points = Point::model()->getAll($param);
|
|
$categories = Category::model()->getAll(array('order' => 'ord ASC'));
|
|
|
|
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;
|
|
}
|
|
$notModeratedPoints = $result;
|
|
}
|
|
// ------------------------------------------
|
|
|
|
$param = array();
|
|
$param['order'] = 'id DESC';
|
|
if (App::getParam('category')) {
|
|
$param['where'] = 'categoryId = ' . (int) App::getParam('category') . ' AND `moderate` = 1';
|
|
} else if (App::getParam('user')) {
|
|
$param['where'] = '`author` = ' . (int) App::getParam('user') . ' AND `moderate` = 1';
|
|
} else {
|
|
$param['where'] = '`moderate` = 1';
|
|
if (!(App::$user && App::$user->isAdmin)) {
|
|
$param['limit'] = 100;
|
|
}
|
|
}
|
|
$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;
|
|
}
|
|
|
|
App::setConfig('title', App::$defaultTitle);
|
|
|
|
self::render('pointsTemplate.php', array(
|
|
'categories' => $categories,
|
|
// 'user' => App::$user,
|
|
'points' => $result,
|
|
'notModeratedPoints' => $notModeratedPoints,
|
|
'randomPoint' => Point::model()->getRandom(),
|
|
));
|
|
}
|
|
|
|
static function actionPoint()
|
|
{
|
|
$pointId = (int) App::getParam('id');
|
|
if ($pointId) {
|
|
App::redirect('/point/'.$pointId, 301);
|
|
} else {
|
|
App::error404();
|
|
}
|
|
}
|
|
|
|
static function actionArticle()
|
|
{
|
|
$articleId = (int) App::getParam('id');
|
|
if ($articleId) {
|
|
App::redirect('/article/'.$articleId, 301);
|
|
} else {
|
|
App::error404();
|
|
}
|
|
}
|
|
|
|
static function actionMyprofile()
|
|
{
|
|
$userId = App::$user ? App::$user->id : 0;
|
|
|
|
die($userId);
|
|
}
|
|
|
|
// static function actionProfile()
|
|
// {
|
|
// $userId = (int) App::getParam('user');
|
|
//
|
|
// }
|
|
|
|
static function actionVkpoint()
|
|
{
|
|
$pointId = (int) App::getParam('id');
|
|
if (App::$user && App::$user->isAdmin == 1 && $pointId) {
|
|
$point = Point::model()->getByPK($pointId);
|
|
|
|
if ($point->id == NULL) {
|
|
App::error404();
|
|
}
|
|
|
|
$point->descriptionHtml = nl2br($point->description);
|
|
$point->name = htmlspecialchars($point->name);
|
|
|
|
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
|
|
|
|
$point->description = Helper::replaceLinks($point->description);
|
|
|
|
self::renderPartial('vkPoint.php', array(
|
|
'point' => $point,
|
|
'photos' => $point->photos,
|
|
));
|
|
} else {
|
|
App::error404();
|
|
}
|
|
}
|
|
|
|
static function action404($message)
|
|
{
|
|
self::$layout = 'layouts/page.php';
|
|
self::addStyle('/css/style.css?ver=' . App::getConfig('version'));
|
|
self::addStyle('/css/pageStyle.css?ver=' . App::getConfig('version'));
|
|
self::addStyle('/css/bootstrap.min.css');
|
|
self::addScript('/js/jquery-2.1.0.min.js');
|
|
self::addScript('/js/bootstrap.min.js');
|
|
|
|
App::setConfig('title', App::$defaultTitle);
|
|
self::render('error404.php', array(
|
|
'randomPoint' => Point::model()->getRandom(),
|
|
));
|
|
}
|
|
|
|
}
|