Лайки на странице точки

This commit is contained in:
Krivchikov Dmitry 2014-12-07 13:04:30 +03:00
parent d5474fd524
commit 4cfe36bd02
2 changed files with 17 additions and 2 deletions

View File

@ -59,6 +59,12 @@ class PageController extends Controller
self::addStyle('/css/bootstrap-theme.min.css');
self::addStyle('/css/fotorama.css');
if (App::$user && App::$user->id) {
self::addVar('user', App::$user->id);
} else {
self::addVar('user', '0');
}
$point = Point::model()->getByPK($pointId);
if ($point->id == NULL)
@ -76,6 +82,9 @@ class PageController extends Controller
$point->categoryName = $categories[$point->categoryId]['name'];
$point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml);
preg_match_all("/.*?(([.?!](?:\s|$))|$)/s", $point->descriptionHtml, $items);
$point->inFavorites = Favorite::model()->checkIsMy($pointId);
$point->iLike = Like::model()->checkIsMy($pointId);
$similarPoints = Point::model()->getAll(array('where' => 'categoryId = '.$point->categoryId.' AND `id` <> '.$point->id.' ORDER BY RAND() LIMIT 6;'));
$closestPoints = Point::model()->getClosestPoints($pointId);
$randomPoint = Point::model()->getRandom();
@ -93,6 +102,7 @@ class PageController extends Controller
'countInFavs' => Favorite::model()->countInFavs($pointId),
'countLikes' => Like::model()->countLikes($pointId),
'og' => Helper::buildOG($point),
'user' => App::$user,
));
} else
{

View File

@ -70,8 +70,13 @@
</div>
<p style="margin-top: 25px; text-align: right;">
[ <span class="glyphicon glyphicon-star"></span> <?= $countInFavs ?> - в закладках ]
[ <span class="glyphicon glyphicon-thumbs-up"></span> <?= $countLikes ?> - нравится ]
<?php if (App::$user && App::$user->id): ?>
[ <button type="button" class="btn btn-link" style="color: #333;" onclick="addRemoveFavorite(<?= $point->id ?>)"><span id="myFavoritesButton" class="glyphicon glyphicon-star<?= $point->inFavorites ? '' : '-empty' ?>"></span> Хочу посетить</button> ]
[ <button type="button" class="btn btn-link" style="color: #333;" onclick="addRemoveLike(<?= $point->id ?>)"><span id="myLikesButton" class="glyphicon glyphicon-<?= $point->iLike ? 'ok' : 'thumbs-up' ?>"></span> Нравится</button> ]
<?php else: ?>
[ <span class="glyphicon glyphicon-star"></span> <?= $countInFavs ?> - в закладках ]
[ <span class="glyphicon glyphicon-thumbs-up"></span> <?= $countLikes ?> - нравится ]
<?php endif; ?>
[ <span class="glyphicon glyphicon-user"></span> <?= $point->authorUser->nick ?> - <span class="glyphicon glyphicon-pencil"></span> <?= $point->authorUser->getPointsCount() ?> ]
[ <span class="glyphicon glyphicon-new-window"></span> <a href="<?= $point->source ?>" target="_blank">источник</a> ]