id) { self::addVar('user', App::$user->id); } else { self::addVar('user', '0'); } $point = Point::model()->getByPK($pointId); if ($point->id == NULL) { App::error404(); } $point->descriptionHtml = nl2br($point->description); $point->name = htmlspecialchars($point->name); App::setConfig('title', $point->name . ' – wikipoints.ru'); self::addVar('pointLat', $point->lat); self::addVar('pointLng', $point->lng); self::addVar('pointId', $point->id); $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true)); $point->categoryIcon = $categories[$point->categoryId]['icon']; $point->categoryName = $categories[$point->categoryId]['name']; $point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml, 'html'); preg_match_all("/.*?((([^.?!\s]{3,}?)[.?!](?:\s|$))|$)/s", $point->descriptionHtml, $items); // Разбиваем текст на предложения. $point->inFavorites = Favorite::model()->checkIsMy($pointId); $point->iLike = Like::model()->checkIsMy($pointId); $photoLinks = PhotoLinks::model()->getAll(array('where' => '`pointId` = ' . $pointId)); $photoLinksRes = array(); if ($photoLinks) { foreach ($photoLinks as $photoLink) { if ($photoLink->host) { $photoLinksRes[strtolower($photoLink->host)] = 1; } } } $photoLinksRes = implode('; ', array_keys($photoLinksRes)); $similarPoints = Point::model()->getAll(array('where' => '`moderate` = 1 AND categoryId = ' . $point->categoryId . ' AND `id` <> ' . $point->id . ' ORDER BY RAND() LIMIT 6;')); $closestPoints = Point::model()->getClosestPoints($pointId); $randomPoint = Point::model()->getRandom(); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = Helper::replaceLinks($randomPoint->description); self::render('point.php', array( 'point' => $point, 'text' => $items[0], 'randomPoint' => $randomPoint, 'similarPoints' => $similarPoints, 'closestPoints' => $closestPoints, 'categories' => $categories, 'photos' => $point->photos, 'countInFavs' => Favorite::model()->countInFavs($pointId), 'countLikes' => Like::model()->countLikes($pointId), 'og' => Helper::buildOG($point), 'user' => App::$user, 'photoLinks' => $photoLinksRes, )); } else { App::error404(); } } }