начата работа по выводу избранного + странное выравнивание строчек

This commit is contained in:
Krivchikov Dmitry 2014-09-26 21:45:24 +04:00
parent 2a253676b4
commit 7a762de04d
3 changed files with 78 additions and 64 deletions

View File

@ -46,12 +46,17 @@ class IndexController extends Controller
{ {
$routes = Route::model()->getByAuthor(App::$user->id); $routes = Route::model()->getByAuthor(App::$user->id);
self::addVar('user', App::$user->id); self::addVar('user', App::$user->id);
} } else
else
{ {
self::addVar('user', '0'); self::addVar('user', '0');
} }
$favorites = array();
if (App::$user && App::$user->id)
{
$favorites = Favorite::model()->getAllMy();
}
self::addVar('isAdmin', (int) (App::$user && App::$user->isAdmin == 1)); self::addVar('isAdmin', (int) (App::$user && App::$user->isAdmin == 1));
$res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points`")->fetch(PDO::FETCH_ASSOC); $res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points`")->fetch(PDO::FETCH_ASSOC);
@ -75,8 +80,7 @@ class IndexController extends Controller
$og['type'] = 'article'; $og['type'] = 'article';
$og['url'] = 'http://wikipoints.ru/?point=' . $id; $og['url'] = 'http://wikipoints.ru/?point=' . $id;
$og['image'] = $point->getImg(); $og['image'] = $point->getImg();
} } else if (isset($_GET['point']) && $_GET['point'] && strtolower($_GET['point']) == 'random')
else if(isset($_GET['point']) && $_GET['point'] && strtolower($_GET['point']) == 'random')
{ {
$og['title'] = 'Случайная точка на wikipoints.ru'; $og['title'] = 'Случайная точка на wikipoints.ru';
$og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!'; $og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!';
@ -90,6 +94,7 @@ class IndexController extends Controller
'categories' => $category, 'categories' => $category,
'user' => App::$user, 'user' => App::$user,
'routes' => $routes, 'routes' => $routes,
'favorites' => $favorites,
'og' => $og, 'og' => $og,
)); ));
} }

View File

@ -2,6 +2,7 @@
class Favorite extends Model class Favorite extends Model
{ {
function __construct($fromArray = array()) function __construct($fromArray = array())
{ {
$this->_tableName_ = 'favorites'; $this->_tableName_ = 'favorites';
@ -25,7 +26,8 @@ class Favorite extends Model
if ($res) if ($res)
{ {
return boolval(Favorite::model()->delete($res->id)); return boolval(Favorite::model()->delete($res->id));
} else { } else
{
return Favorite::model()->add(array('userId' => App::$user->id, 'pointId' => $pointId)); return Favorite::model()->add(array('userId' => App::$user->id, 'pointId' => $pointId));
} }
} }
@ -45,5 +47,5 @@ class Favorite extends Model
return boolval($this->getAll(array('where' => '`userId` = ' . (int) App::$user->id . ' AND `pointId` = ' . (int) $pointId))); return boolval($this->getAll(array('where' => '`userId` = ' . (int) App::$user->id . ' AND `pointId` = ' . (int) $pointId)));
} }
}
}

View File

@ -79,6 +79,13 @@
<div id="boxUser"> <div id="boxUser">
<h3>Профиль</h3> <h3>Профиль</h3>
<a class="btn btn-default" type="button" href="/index/logout"><span class="glyphicon glyphicon-ban-circle"></span> Выйти</a> <a class="btn btn-default" type="button" href="/index/logout"><span class="glyphicon glyphicon-ban-circle"></span> Выйти</a>
<hr/>
<?php var_dump($favorite); ?>
<?php if (false && $favorites): ?>
<?php foreach ($favorites as $favorite) : ?>
<?= $favorite->point->name ?><br/>
<?php endforeach; ?>
<?php endif; ?>
</div> </div>
</div> </div>
<?= $user ? '' : self::renderPartial('modals/login.php', null, true) ?> <?= $user ? '' : self::renderPartial('modals/login.php', null, true) ?>