diff --git a/ground/app.php b/ground/app.php index 31921d9..40d8887 100644 --- a/ground/app.php +++ b/ground/app.php @@ -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'; + } + } } diff --git a/ground/classes/Helper.php b/ground/classes/Helper.php index 833039d..e7adbc0 100644 --- a/ground/classes/Helper.php +++ b/ground/classes/Helper.php @@ -35,7 +35,7 @@ class Helper switch ($replaceType) { case 'html': $linkName = $linkName ? $linkName : ''; - $string = str_replace($link, '' . $linkName . '', $string); + $string = str_replace($link, '' . $linkName . '', $string); break; case 'js': $linkName = $linkName ? $linkName : ''; diff --git a/ground/controllers/IndexController.php b/ground/controllers/IndexController.php index d6c2762..3107e88 100644 --- a/ground/controllers/IndexController.php +++ b/ground/controllers/IndexController.php @@ -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"); diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index 4189fba..286dee9 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -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(); } diff --git a/ground/controllers/PointController.php b/ground/controllers/PointController.php new file mode 100644 index 0000000..bc12d53 --- /dev/null +++ b/ground/controllers/PointController.php @@ -0,0 +1,96 @@ +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(); + } + } +} diff --git a/ground/views/article.php b/ground/views/article.php index e166354..41524cd 100644 --- a/ground/views/article.php +++ b/ground/views/article.php @@ -16,11 +16,11 @@
- +

Это интересно: name ?>

- description, 0, 400, 'UTF-8') ?>... - читать далее » + description, 0, 400, 'UTF-8') ?>… + читать далее »

diff --git a/ground/views/error404.php b/ground/views/error404.php index 5ae8df5..aff674b 100644 --- a/ground/views/error404.php +++ b/ground/views/error404.php @@ -10,7 +10,7 @@

Не беда! Возможно вас заинтересует точка «name ?>»?

- +
diff --git a/ground/views/point.php b/ground/views/point.php index a9cfaaa..a2717be 100644 --- a/ground/views/point.php +++ b/ground/views/point.php @@ -95,7 +95,7 @@ $index = 0; нет известных нам точек. - + @@ -103,17 +103,17 @@ $index = 0;

Похожие:

- +

- +

Это интересно: name ?>

- description, 0, 400, 'UTF-8') ?>... - читать далее » + description, 0, 400, 'UTF-8') ?>… + читать далее »

diff --git a/ground/views/pointsTemplate.php b/ground/views/pointsTemplate.php index 8b8626c..438f143 100644 --- a/ground/views/pointsTemplate.php +++ b/ground/views/pointsTemplate.php @@ -13,7 +13,7 @@ # - +
@@ -37,7 +37,7 @@

- # + #
@@ -47,11 +47,11 @@
- +

Это интересно: name ?>

- description, 0, 400, 'UTF-8') ?>... - читать далее » + description, 0, 400, 'UTF-8') ?>… + читать далее »

diff --git a/ground/views/vkPoint.php b/ground/views/vkPoint.php index 6b0988e..2a66b2a 100644 --- a/ground/views/vkPoint.php +++ b/ground/views/vkPoint.php @@ -7,6 +7,6 @@ foreach ($photos as $photo) {
description ?>

-Продолжить чтение и посмотреть на карте: http://wikipoints.ru/page/point/id/id ?>
+Продолжить чтение и посмотреть на карте: http://wikipoints.ru/point/id ?>

#wikipoints # # # # # # # # # # # # # # # # #выходные #путешествия #путешествие #туризм #weekend #travels #journey #tourism diff --git a/public/js/map.js b/public/js/map.js index 4a4352c..dad4a7b 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -279,7 +279,7 @@ function drawInfoPopup(id, showPopup, doNotPushToHistory) { description += data.descriptionHtml; description += '
'; description += '
'; - description += ' Подробнее'; + description += ' Подробнее'; description += ''; description += ''; description += ''; diff --git a/public/js/mapPoint.js b/public/js/mapPoint.js index 1e7b48f..a6aaedf 100644 --- a/public/js/mapPoint.js +++ b/public/js/mapPoint.js @@ -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];