Измененение УРЛа точки - теперь /page/id
This commit is contained in:
parent
2e8132dfda
commit
126fa21079
|
|
@ -52,6 +52,14 @@ class App
|
|||
$paramValue = isset(self::$url[$index + 1]) && self::$url[$index + 1] ? self::$url[$index + 1] : NULL;
|
||||
self::$urlParams[$paramName] = $paramValue;
|
||||
}
|
||||
} else if (isset (self::$url[2])) {
|
||||
$controller = self::$controller;
|
||||
$action = self::$action;
|
||||
if (!method_exists($controller, $action)) {
|
||||
self::$urlParams['id'] = (int)self::$url[2];
|
||||
self::$action = 'actionIndex';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Helper
|
|||
switch ($replaceType) {
|
||||
case 'html':
|
||||
$linkName = $linkName ? $linkName : '<span class="glyphicon glyphicon-link"></span>';
|
||||
$string = str_replace($link, '<a href="/page/point/id/' . $linkId . '" title="' . $linkTitle . '">' . $linkName . '</a>', $string);
|
||||
$string = str_replace($link, '<a href="/point/' . $linkId . '" title="' . $linkTitle . '">' . $linkName . '</a>', $string);
|
||||
break;
|
||||
case 'js':
|
||||
$linkName = $linkName ? $linkName : '<span class="glyphicon glyphicon-link"></span>';
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class IndexController extends Controller
|
|||
$points = Point::model()->getAll(array('order' => 'ID DESC', 'asArray' => true));
|
||||
foreach ($points as $point) {
|
||||
$url = $xml->addChild('url');
|
||||
$url->addChild('loc', 'http://wikipoints.ru/page/point/id/' . $point['id']);
|
||||
$url->addChild('loc', 'http://wikipoints.ru/point/' . $point['id']);
|
||||
$url->addChild('lastmod', date("Y-m-d", $point['dateEdit']));
|
||||
$url->addChild('changefreq', "weekly");
|
||||
$url->addChild('priority', "0.8");
|
||||
|
|
|
|||
|
|
@ -76,91 +76,9 @@ class PageController extends Controller
|
|||
|
||||
static function actionPoint()
|
||||
{
|
||||
self::$layout = 'layoutPage.php';
|
||||
|
||||
$pointId = (int) App::getParam('id');
|
||||
if ($pointId) {
|
||||
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/leaflet-0.7.3.js');
|
||||
self::addScript('http://api-maps.yandex.ru/2.0/?load=package.map&lang=ru-RU');
|
||||
self::addScript('/js/leaflet.markercluster.js');
|
||||
|
||||
self::addScript('/js/app.js?ver=' . App::getConfig('version'));
|
||||
self::addScript('/js/mapPoint.js?ver=' . App::getConfig('version'));
|
||||
self::addScript('http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.js');
|
||||
|
||||
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::addStyle('/css/bootstrap-theme.min.css');
|
||||
self::addStyle('http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.css');
|
||||
self::addStyle('/css/leaflet-0.7.3.css');
|
||||
self::addStyle('/css/MarkerCluster.css');
|
||||
self::addStyle('/css/MarkerCluster.Default.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) {
|
||||
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|$))|$)/s", $point->descriptionHtml, $items);
|
||||
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,
|
||||
));
|
||||
App::redirect('/point/'.$pointId, 301);
|
||||
} else {
|
||||
App::error404();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
class PointController extends Controller
|
||||
{
|
||||
static function actionIndex()
|
||||
{
|
||||
self::$layout = 'layoutPage.php';
|
||||
|
||||
$pointId = (int) App::getParam('id');
|
||||
if ($pointId) {
|
||||
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/leaflet-0.7.3.js');
|
||||
self::addScript('http://api-maps.yandex.ru/2.0/?load=package.map&lang=ru-RU');
|
||||
self::addScript('/js/leaflet.markercluster.js');
|
||||
|
||||
self::addScript('/js/app.js?ver=' . App::getConfig('version'));
|
||||
self::addScript('/js/mapPoint.js?ver=' . App::getConfig('version'));
|
||||
self::addScript('http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.js');
|
||||
|
||||
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::addStyle('/css/bootstrap-theme.min.css');
|
||||
self::addStyle('http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.css');
|
||||
self::addStyle('/css/leaflet-0.7.3.css');
|
||||
self::addStyle('/css/MarkerCluster.css');
|
||||
self::addStyle('/css/MarkerCluster.Default.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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,11 +16,11 @@
|
|||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<a href="/page/point/id/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<a href="/point/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<h3 style="margin-top: 0;">Это интересно: <?= $randomPoint->name ?></h3>
|
||||
<p>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>...
|
||||
<a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>…
|
||||
<a class="" href="/point/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<noindex>
|
||||
<div style="text-align: center;">
|
||||
<h2>Не беда! Возможно вас заинтересует точка «<?= $point->name ?>»?</h2>
|
||||
<a href="/page/point/id/<?= $point->id ?>">
|
||||
<a href="/point/<?= $point->id ?>">
|
||||
<img src="<?= $point->getImg() ?>" style="max-width: 400px; margin: 0 20px 10px 0;" />
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ $index = 0;
|
|||
<?php if (empty($closestPoints)): ?>
|
||||
нет известных нам точек.
|
||||
<?php else: ?>
|
||||
<?php foreach ($closestPoints as $cPoint): ?><a href="/page/point/id/<?= $cPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $cPoint->getImg() ?>" title="<?= $cPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
|
||||
<?php foreach ($closestPoints as $cPoint): ?><a href="/point/<?= $cPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $cPoint->getImg() ?>" title="<?= $cPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -103,17 +103,17 @@ $index = 0;
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 style="margin-top: 0;">Похожие:</h3>
|
||||
<?php foreach ($similarPoints as $sPoint): ?><a href="/page/point/id/<?= $sPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $sPoint->getImg() ?>" title="<?= $sPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
|
||||
<?php foreach ($similarPoints as $sPoint): ?><a href="/point/<?= $sPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $sPoint->getImg() ?>" title="<?= $sPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<a href="/page/point/id/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<a href="/point/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<h3 style="margin-top: 0;">Это интересно: <?= $randomPoint->name ?></h3>
|
||||
<p>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>...
|
||||
<a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>…
|
||||
<a class="" href="/point/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<?php foreach ($notModeratedPoints as $point): ?>
|
||||
#<?= $point['id'] ?> <img src="/ico/lock.png" />
|
||||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
||||
<img src="<?= $point['categoryIcon'] ?>" /> <a href="/page/point/id/<?= $point['id'] ?>"><?= $point['name'] ?></a>
|
||||
<img src="<?= $point['categoryIcon'] ?>" /> <a href="/point/<?= $point['id'] ?>"><?= $point['name'] ?></a>
|
||||
<?= $point['author'] ?>
|
||||
<br/>
|
||||
<?php endforeach; ?>
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
<h3><?= $header ?></h3>
|
||||
|
||||
<?php foreach ($points as $point): ?>
|
||||
#<?= $point['id'] ?> <img src="<?= $point['categoryIcon'] ?>" /> <a href="/page/point/id/<?= $point['id'] ?>"><?= $point['name'] ?></a>
|
||||
#<?= $point['id'] ?> <img src="<?= $point['categoryIcon'] ?>" /> <a href="/point/<?= $point['id'] ?>"><?= $point['name'] ?></a>
|
||||
<?= $point['author'] ?>
|
||||
<br/>
|
||||
<?php endforeach; ?>
|
||||
|
|
@ -47,11 +47,11 @@
|
|||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<a href="/page/point/id/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<a href="/point/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<h3 style="margin-top: 0;">Это интересно: <?= $randomPoint->name ?></h3>
|
||||
<p>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>...
|
||||
<a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>…
|
||||
<a class="" href="/point/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ foreach ($photos as $photo) {
|
|||
<br>
|
||||
<?= $point->description ?><br/>
|
||||
<br/>
|
||||
Продолжить чтение и посмотреть на карте: http://wikipoints.ru/page/point/id/<?= $point->id ?><br/>
|
||||
Продолжить чтение и посмотреть на карте: http://wikipoints.ru/point/<?= $point->id ?><br/>
|
||||
<br/>
|
||||
#wikipoints # # # # # # # # # # # # # # # # #выходные #путешествия #путешествие #туризм #weekend #travels #journey #tourism
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ function drawInfoPopup(id, showPopup, doNotPushToHistory) {
|
|||
description += data.descriptionHtml;
|
||||
description += '</div><div class="clear"></div>';
|
||||
description += '<div class="btn-group control">';
|
||||
description += '<a type="button" class="btn btn-default" href="/page/point/id/' + id + '"><span class="glyphicon glyphicon-eye-open"></span> <span class="label">Подробнее</span></a>';
|
||||
description += '<a type="button" class="btn btn-default" href="/point/' + id + '"><span class="glyphicon glyphicon-eye-open"></span> <span class="label">Подробнее</span></a>';
|
||||
description += '<button type="button" class="btn btn-default" onclick="addToRoute(' + id + ')"><span class="glyphicon glyphicon-map-marker"></span> <span class="label">В маршрут</span></button>';
|
||||
description += '<button type="button" class="btn btn-default" onclick="addRemoveLike(' + id + ')"><span id="myLikesButton" class="glyphicon glyphicon-' + (data.iLike ? 'ok' : 'thumbs-up') + '"></span> <span class="label">Нравится</span></button>';
|
||||
description += '<button type="button" class="btn btn-default" onclick="addRemoveFavorite(' + id + ')"><span id="myFavoritesButton" class="glyphicon glyphicon-star' + (data.inFavorites ? '' : '-empty') + ' "></span> <span class="label">Хочу посетить</span></button>';
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ function constructPoint(data)
|
|||
points[id] = L.marker(
|
||||
[data['lat'], data['lng']], {icon: icon, title: data['name'], id: id, categoryId: data['categoryId']}
|
||||
).on('click', function (e) {
|
||||
window.location.href = "/page/point/id/"+e.target.options.id;
|
||||
window.location.href = "/point/"+e.target.options.id;
|
||||
});
|
||||
|
||||
return points[id];
|
||||
|
|
|
|||
Loading…
Reference in New Issue