Merge branch 'master' into newButtonIcons

This commit is contained in:
Krivchikov Dmitry 2015-09-13 09:29:21 +03:00
commit f2ab960fb4
37 changed files with 1062 additions and 281 deletions

2
.gitignore vendored
View File

@ -20,3 +20,5 @@ public/photos/big/*.jpg
public/photos/big/*.jpeg
public/photos/big/*.png
public/photos/big/*.gif
logs/*.log

View File

@ -33,6 +33,7 @@ class App
private static $DB = null;
public static $user = null;
public static $request = array();
public static $defaultTitle = 'Лучшие выходные это выходные в путешествии! wikipoints.ru';
/**
* Разбивает урл на контроллер, метод и выбирает параметры.
@ -205,4 +206,17 @@ class App
);
}
public static function log($logName, $value)
{
$fileName = App::getBasedir() .
'../logs/' .
$logName . '.log';
return file_put_contents(
$fileName, date('d-m-Y H:i:s') . " - " .
print_r($value, true) .
"\n-------------------\n", FILE_APPEND
);
}
}

View File

@ -8,9 +8,15 @@ class Helper
return (bool) $var;
}
public static function replaceLinks($string, $linkTemplate = '/page/point/id/')
/**
* TYPES: 'clear','html','js'
* @param type $string
* @param type $replaceType
* @return type
*/
public static function replaceLinks($string, $replaceType = 'clear')
{
preg_match_all("(\[#(\d+)[>\|](.*?)\])", $string, $links);
preg_match_all("((\[#(\d+)[>\|](.*?)\])|(\[#(\d+)\]))", $string, $links);
$links = isset($links[0]) ? $links[0] : FALSE;
if ($links) {
foreach ($links as $link) {
@ -19,13 +25,26 @@ class Helper
$idAndLink = explode($delimiter, $idAndLink);
$linkId = $idAndLink[0];
$linkName = isset($idAndLink[1]) ? $idAndLink[1] : '<span class="glyphicon glyphicon-link"></span>';
$linkName = isset($idAndLink[1]) ? $idAndLink[1] : '';
if ($linkId) {
$linkPoint = Point::model()->getByPK($linkId);
if ($linkPoint->id) {
$linkPoint->name = str_replace('"', 'ʺ', $linkPoint->name);
$string = str_replace($link, '<a href="' . $linkTemplate . $linkId . '" title="' . $linkPoint->name . '">' . $linkName . '</a>', $string);
if ($linkPoint && $linkPoint->id) {
$linkTitle = str_replace('"', 'ʺ', $linkPoint->name);
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);
break;
case 'js':
$linkName = $linkName ? $linkName : '<span class="glyphicon glyphicon-link"></span>';
$string = str_replace($link, '<a href="/?point=' . $linkId . '" title="' . $linkTitle . '">' . $linkName . '</a>', $string);
break;
default:
$string = str_replace($link, $linkName, $string);
break;
}
}
}
}
@ -34,13 +53,69 @@ class Helper
return $string;
}
public static function replaceImgs($string, $replaceType = 'clear')
{
preg_match_all("(\[img[\|]#(\d+)\])", $string, $images);
$images = isset($images[0]) ? $images[0] : FALSE;
if ($images) {
foreach ($images as $img) {
$imgAndId = mb_substr($img, 2, -1);
$imgAndId = explode('#', $imgAndId);
$imgId = (int)$imgAndId[1];
$imgObj = ArticlePhotos::model()->getByPK($imgId);
if ($imgObj->name) {
switch ($replaceType) {
case 'html':
$imgObj->caption = $linkTitle = str_replace('"', 'ʺ', $imgObj->caption);
$imgTag = '<div style="text-align: center;"><img src="/photos/articles/middle/' . $imgObj->name . '" title="' . $imgObj->caption . '" class="imageInArticle" /></div>';
$string = str_replace($img, $imgTag, $string);
break;
default:
$imgTag = '';
$string = str_replace($img, $imgTag, $string);
break;
}
} else {
switch ($replaceType) {
case 'html':
$imgTag = '<div style="text-align: center;"><img src="/img/noPhoto.png" title="Фотография потерялась" class="imageInArticle" /></div>';
$string = str_replace($img, $imgTag, $string);
break;
default:
$imgTag = '';
$string = str_replace($img, $imgTag, $string);
break;
}
}
}
}
return $string;
}
public static function getFirstImg($string)
{
preg_match_all("(\[img[\|]#(\d+)\])", $string, $images);
$images = isset($images[0]) ? $images[0] : FALSE;
$img = isset($images[0]) ? $images[0] : FALSE;
if ($img) {
$imgId = (int) mb_substr($img, 6, -1);
$imgObj = ArticlePhotos::model()->getByPK($imgId);
return $imgObj->name ? (int)$imgObj->id : 0;
}
return 0;
}
public static function buildOG($point)
{
$og = array();
$og['title'] = str_replace('"', 'ʺ', $point->name) . ' [wikipoints.ru]';
$point->description = str_replace('"', 'ʺ', $point->description);
$og['description'] = mb_substr($point->description, 0, 97, 'UTF-8') . '...';
$og['site_name'] = 'WikiPoints: Лучшие выходные - это выходные в путешествии!';
$og['description'] = mb_substr($point->description, 0, 99, 'UTF-8') . '…';
$og['site_name'] = App::$defaultTitle;
$og['type'] = 'website';
$og['url'] = 'http://wikipoints.ru/?point=' . $point->id;
$og['image'] = $point->getImg('middle');
@ -48,4 +123,18 @@ class Helper
return $og;
}
public static function buildArticleOG($article)
{
$og = array();
$og['title'] = str_replace('"', 'ʺ', $article->title) . ' [wikipoints.ru]';
$article->text = Markdown::getClear(str_replace('"', 'ʺ', $article->text));
$og['description'] = mb_substr($article->text, 0, 99, 'UTF-8') . '…';
$og['site_name'] = App::$defaultTitle;
$og['type'] = 'website';
$og['url'] = 'http://wikipoints.ru/page/article/id/' . $article->id;
$og['image'] = $article->getImg('middle');
return $og;
}
}

View File

@ -29,15 +29,17 @@ class Image
* Создаёт все требуемые размеры изображения и раскладывает их по папкам.
* @param type $imgName
*/
public static function createAllSizes($imgName)
public static function createAllSizes($imgName, $noWatermark = false, $folder = '')
{
$sizes = App::getConfig('images');
$pathInfo = pathinfo($_SERVER['SCRIPT_FILENAME']);
$uploaddir = $pathInfo['dirname'] . '/photos/';
$uploaddir = $pathInfo['dirname'] . '/photos/' . $folder;
$watermarkDir = App::getBasedir() . 'watermarks/';
foreach ($sizes as $dir => $size) {
$watermark = isset($size[3]) ? $watermarkDir . $size[3] : '';
$watermark = $noWatermark ? '' : $watermark;
self::imgResize(
$uploaddir . $imgName, // Source - original image
$uploaddir . $dir . '/' . $imgName, // Destination

136
ground/classes/Markdown.php Normal file
View File

@ -0,0 +1,136 @@
<?php
class Markdown
{
static function processing($string)
{
$string = self::replaceHeaders($string);
$string = self::replaceBold($string);
$string = self::replaceItalic($string);
$string = self::replaceUnderline($string);
$string = self::replaceChars($string);
$string = self::replaceUrls($string);
return $string;
}
static private function replaceHeaders($string)
{
for ($index = 3; $index > 0; $index--) {
$pr = '/(^#{' . $index . '} .{1,})/m';
preg_match_all($pr, $string, $headers);
if (isset($headers[0][0])) {
foreach ($headers[0] as $header) {
$hI = $index+1;
$string = str_replace($header, "<h$hI>" . mb_substr($header, $index + 1, NULL, 'UTF-8') . "</h$hI>", $string);
}
}
}
return $string;
}
static private function replaceBold($string)
{
$pr = '(\*{2}(.+?)\*{2})';
$rep = '<b>$1</b>';
return preg_replace($pr, $rep, $string);
}
static private function replaceItalic($string)
{
$pr = '(\*{1}(.+?)\*{1})';
$rep = '<i>$1</i>';
return preg_replace($pr, $rep, $string);
}
static private function replaceUnderline($string)
{
$pr = '(\_{1}(.+?)\_{1})';
$rep = '<u>$1</u>';
return preg_replace($pr, $rep, $string);
}
static private function replaceUrls($string)
{
$pr = '((https{0,1}:\/\/[\da-z\.-]+\.[a-z]{2,6})([\/\w\?=&#%+,-]|(\.[^\s]))*\/?)';
$rep = '<a href="$0" title="$0" target="_blank">$1</a>';
return preg_replace($pr, $rep, $string);
}
static private function replaceChars($string)
{
$pr = '((^|\s)-{2}($|\s))';
$rep = '$1$2';
$string = preg_replace($pr, $rep, $string);
$pr = '((^|\s)\((c|с)\)($|\s))';
$rep = '$1©$3';
$string = preg_replace($pr, $rep, $string);
$string = str_replace(
array("\r", '"', '«', '»'),
array('', 'ʺ', 'ʺ', 'ʺ'),
$string);
return $string;
}
static function getClear($string)
{
// Headers
for ($index = 3; $index > 0; $index--) {
$pr = '/(^#{' . $index . '} .{1,})/m';
preg_match_all($pr, $string, $headers);
if (isset($headers[0][0])) {
foreach ($headers[0] as $header) {
$hI = $index+1;
$string = str_replace($header, '', $string);
}
}
}
// Bold & Italic
$pr = '(\*{1,3}(.+?)\*{1,3})';
$rep = '$1';
$string = preg_replace($pr, $rep, $string);
// Uderline
$pr = '(\_{1}(.+?)\_{1})';
$rep = '$1';
$string = preg_replace($pr, $rep, $string);
// Images
$pr = '(\[img[\|]#(\d+)\])';
$rep = ' ';
$string = preg_replace($pr, $rep, $string);
// \n & \r
$string = str_replace(array("\n","\r",' -- '), array(' ', ' ',' '), $string);
// URL
$pr = '((https{0,1}:\/\/[\da-z\.-]+\.[a-z]{2,6})[\/\w\?=&#%+\.,-]*\/?)';
$rep = '';
$string = preg_replace($pr, $rep, $string);
// Points
$pr = '((\[#(\d+)[>\|](.*?)\])|(\[#(\d+)\]))';
$rep = ' ';
$string = preg_replace($pr, $rep, $string);
// multi-space
$pr = '(\s{2,})';
$rep = ' ';
$string = preg_replace($pr, $rep, $string);
return trim($string);
}
}

View File

@ -154,7 +154,15 @@ abstract class Model
$calledClass = get_called_class();
while ($res && $row = $res->fetch(PDO::FETCH_ASSOC)) {
$ready[$row[$this->_primaryKey_]] = isset($params['asArray']) && $params['asArray'] ? $row : new $calledClass($row);
if (isset($params['noKeys'])) {
$ready[] = isset($params['asArray']) && $params['asArray'] ? $row : new $calledClass($row);
} else {
if (isset($params['asArrayOf'])) {
$ready[] = isset($params['asArray']) && $params['asArray'] ? $row : new $calledClass($row);
} else {
$ready[$row[$this->_primaryKey_]] = isset($params['asArray']) && $params['asArray'] ? $row : new $calledClass($row);
}
}
}
return (isset($params['limit']) && $params['limit'] == 1) ? array_shift($ready) : $ready;

View File

@ -1,7 +1,7 @@
<?php
return array(
'title' => 'Интересные выходные вместе с wikipoints.ru',
'title' => 'Лучшие выходные это выходные в путешествии! wikipoints.ru',
'DB' => array(
'host' => 'localhost',
'user' => 'root',

View File

@ -0,0 +1,121 @@
<?php
class ArticlesController extends Controller
{
static function actionIndex()
{
self::$layout = 'layoutPage.php';
self::addStyle('/css/style.css?ver=' . App::getConfig('version'));
self::addStyle('/css/pageStyle.css?ver=' . App::getConfig('version'));
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::addStyle('/css/bootstrap.min.css');
self::addStyle('/css/bootstrap-theme.min.css');
if (!App::$user || !App::$user->isAdmin) {
App::error404();
}
// ------------------------------------------
App::setConfig('title', App::$defaultTitle);
self::render('articles/index.php', array(
'user' => App::$user,
'articles' => Article::model()->getAll(),
'randomPoint' => Point::model()->getRandom(),
));
}
static function actionEdit()
{
if (!App::$user || !App::$user->isAdmin) {
App::error404();
}
$articleId = (int) App::getParam('id');
self::$layout = 'layoutPage.php';
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/app.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');
$article = Article::model()->getByPK($articleId);
if (!$article) {
App::error404();
}
App::setConfig('title', 'Редактирование статьи ' . $article->title . ' wikipoints.ru');
self::render('articles/edit.php', array(
'article' => $article,
'randomPoint' => Point::model()->getRandom(),
));
}
static function actionSave()
{
if (!App::$user || !App::$user->isAdmin) {
App::error404();
}
if (!(isset($_POST['id']) && isset($_POST['title']) && isset($_POST['text']))) {
App::error404();
}
$id = (int) $_POST['id'];
$title = strip_tags($_POST['title']);
$text = str_replace(array('<','>'), array('&lt;','&gt;'), $_POST['text']);
$html = strip_tags($_POST['text']);
$html = str_replace(array('<','>',"'"), array('&lt;','&gt;','&prime;'), $html);
$html = Markdown::processing($html);
$html = nl2br($html);
$allowComments = (int) isset($_POST['allowComments']);
$article = $id ? Article::model()->getByPK($id) : new Article();
if (!$article) {
App::error404();
}
if ($id == 0) {
$article->author = App::$user->id;
}
$article->title = $title;
$article->text = $text;
$article->html = $html;
$article->photoId = Helper::getFirstImg($text);
$article->allowComments = $allowComments;
$article->save();
App::redirect('/articles');
}
static function actionMarkdown()
{
if (isset($_POST['text']) ){
$html = strip_tags($_POST['text']);
$html = str_replace(array('<','>',"'"), array('&lt;','&gt;','&prime;'), $html);
$html = Markdown::processing($html);
$html = nl2br($html);
$html = Helper::replaceLinks($html, 'html');
$html = Helper::replaceImgs($html, 'html');
print $html;
}
die;
}
}

View File

@ -45,4 +45,38 @@ class ImagesController extends Controller
// print $photo;
}
static function actionLoadPhoto()
{
if (isset($_FILES) && !empty($_FILES) && App::$user) {
$userId = App::$user->id;
$uploaddir = App::getBasedir() . '../public/photos/articles/';
$fileName = (string)$_FILES['photo']['name'];
$temp = pathinfo($fileName);
$extension = strtolower($temp['extension']);
if (array_search($extension, array('jpg','jpeg','png')) === FALSE || getimagesize($_FILES['photo']['tmp_name']) === false) {
print 'error';
die;
}
$photo = $userId . strtolower('_' . substr(md5($fileName . time()), 0, 5) . '.' . $extension);
if (move_uploaded_file($_FILES['photo']['tmp_name'], $uploaddir . $photo)) {
ArticlePhotos::model()->add(array(
'name' => $photo,
'owner' => $userId,
'caption' => isset($_POST['caption'])?$_POST['caption']:'',
'uploaded' => time(),
));
Image::createAllSizes($photo, true, 'articles/');
die($photo);
}
} else {
App::error404();
}
die;
}
}

View File

@ -56,12 +56,9 @@ class IndexController extends Controller
$favorites = Favorite::model()->getAllMy();
}
App::setConfig('title', App::$defaultTitle);
self::addVar('isAdmin', (int) (App::$user && App::$user->isAdmin == 1));
$res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points` where `moderate` = 1")->fetch(PDO::FETCH_ASSOC);
App::setConfig('title', $res['pointsCount'] . ' или даже больше поводов не сидеть дома');
self::addVar('pointsCount', $res['pointsCount']);
self::addVar('pointLat', 0);
self::addVar('pointLng', 0);
@ -85,12 +82,12 @@ class IndexController extends Controller
self::addVar('pointLat', $point->lat);
self::addVar('pointLng', $point->lng);
} else if (isset($_GET['point']) && $_GET['point'] && strtolower($_GET['point']) == 'random') {
$og['title'] = 'Случайная точка на wikipoints.ru';
$og['description'] = 'Загляните сюда: http://vk.com/wikipoints Случайная точка на карте - лучший способ узнать что-то новое!';
$og['site_name'] = 'WikiPoints - ' . $res['pointsCount'] . ' или даже больше поводов не сидеть дома';
$og['title'] = 'Случайная точка на карте wikipoints.ru';
$og['description'] = 'Случайная точка на карте это лучший способ узнать что-то новое! wikipoints.ru';
$og['site_name'] = App::$defaultTitle;
$og['type'] = 'article';
$og['url'] = 'http://wikipoints.ru/?point=random';
$og['image'] = 'http://wikipoints.ru/img/compas.jpg';
$og['image'] = 'http://wikipoints.ru/img/logo.png';
}
self::render('indexTemplate.php', array(
@ -148,6 +145,12 @@ class IndexController extends Controller
{
$xml = new SimpleXMLElement('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>');
$url = $xml->addChild('url');
$url->addChild('loc', 'http://wikipoints.ru/');
$url->addChild('lastmod', date("Y-m-d"));
$url->addChild('changefreq', "daily");
$url->addChild('priority', "0.9");
$articles = Article::model()->getAll(array('order' => 'ID DESC', 'asArray' => true));
foreach ($articles as $article) {
$url = $xml->addChild('url');
@ -161,7 +164,7 @@ class IndexController extends Controller
foreach ($points as $point) {
$url = $xml->addChild('url');
$url->addChild('loc', 'http://wikipoints.ru/page/point/id/' . $point['id']);
$url->addChild('lastmod', date("Y-m-d", $point['date']));
$url->addChild('lastmod', date("Y-m-d", $point['dateEdit']));
$url->addChild('changefreq', "weekly");
$url->addChild('priority', "0.8");
}

View File

@ -29,13 +29,14 @@ class JsonController extends Controller
$result = array();
foreach ($points as $point) {
$id = $point->id;
$result[$id]['id'] = $point->id;
$result[$id]['name'] = $point->name;
$result[$id]['lat'] = $point->lat;
$result[$id]['lng'] = $point->lng;
$result[$id]['categoryId'] = $point->categoryId;
$result[$id]['moderate'] = $point->moderate ? 'show' : 'hide';
$tempPoint['id'] = $point->id;
$tempPoint['name'] = $point->name;
$tempPoint['lat'] = $point->lat;
$tempPoint['lng'] = $point->lng;
$tempPoint['categoryId'] = $point->categoryId;
$tempPoint['moderate'] = $point->moderate ? 'show' : 'hide';
$result[] = $tempPoint;
}
self::renderPartial('json.php', array(
@ -53,7 +54,7 @@ class JsonController extends Controller
$point = Point::model()->getByPK($id);
$point->descriptionHtml = nl2br($point->description);
$point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml, '/?point=');
$point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml, 'js');
$point->name = htmlspecialchars($point->name);
$point->moderate = $point->moderate ? 'show' : 'hide';
$imgs = $point->photos;
@ -93,7 +94,7 @@ class JsonController extends Controller
*/
static function actionCategories()
{
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true, 'noKeys' => true));
self::renderPartial('json.php', array(
'data' => $categories,
@ -185,6 +186,14 @@ class JsonController extends Controller
App::redirect('/?point=' . $id);
}
if (isset($_POST['name'])) {
$_POST['name'] = strip_tags($_POST['name']);
}
if (isset($_POST['description'])) {
$_POST['description'] = strip_tags($_POST['description']);
}
if (!( isset($_POST['name']) && $_POST['name'] && strlen($_POST['name']) > 1 ))
$errors[1] = 'Неверное название точки';
if (!( isset($_POST['img']) && (int) $_POST['img']))
@ -254,6 +263,10 @@ class JsonController extends Controller
static function actionSaveRoute()
{
if (!(isset($_POST['name']) && $_POST['name'] && isset($_POST['points']) && $_POST['points'])) {
App::error404('Неправильное значение!');
}
$request = array(
'author' => App::$user->id,
'date' => time(),
@ -300,10 +313,13 @@ class JsonController extends Controller
$res = @file_get_contents('http://geocode-maps.yandex.ru/1.x/?format=json&geocode=' . urlencode($address));
$res = json_decode($res, true);
if (isset($res['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos']))
if (isset($res['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos'])) {
$point = explode(' ', $res['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos']);
else
} else if (isset($res['response']['GeoObjectCollection']['metaDataProperty']['GeocoderResponseMetaData']['Point']['pos'])) {
$point = explode(' ', $res['response']['GeoObjectCollection']['metaDataProperty']['GeocoderResponseMetaData']['Point']['pos']);
} else {
$point = array(0, 0);
}
$coords = array();
$coords['lat'] = $point[1];
@ -336,6 +352,7 @@ class JsonController extends Controller
$results = array();
if ($search) {
App::log('searchQueries', $search);
// ====== POINTS ============
$points = Point::model()->searchByString($search);
if (!empty($points)) {
@ -344,14 +361,14 @@ class JsonController extends Controller
}
}
if (count($results) < 10) {
if (count($results) < 10 && strlen($search) > 5) {
// ====== YANDEX ============
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($search));
curl_setopt($ch, CURLOPT_URL, 'https://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($search));
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = null;
$out = curl_exec($ch); // выполняем запрос curl - обращаемся к сервера php.su
$out = curl_exec($ch);
if (!empty($out)) {
$obj = simplexml_load_string($out);
@ -366,6 +383,39 @@ class JsonController extends Controller
$lng = $coords[0];
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13");
}
} else if (isset($obj->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->Point)) {
$coords = explode(' ', (string) $obj->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->Point->pos);
$lat = $coords[1];
$lng = $coords[0];
$name = "Координаты N°" . $lat . ' E°' . $lng;
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13");
}
}
}
curl_close($ch);
}
if (count($results) < 10 && strlen($search) > 5) {
// ====== GOOGLE ============
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/geocode/json?language=ru&key=AIzaSyDuWmguxO35oV9WGc6D8xUPvQBaUS4kt78&address=' . urlencode($search));
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_REFERER, "http://wikipoints.ru");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = null;
$out = curl_exec($ch);
if (!empty($out)) {
$obj = json_decode($out);
if ((string) $obj->status == 'OK') {
$count = count($obj->results);
if ($count > 0) {
for ($index = 0; $index < $count && $index < 5 && count($results) < 25; $index++) {
$name = (string) $obj->results[$index]->formatted_address;
$lat = (string) $obj->results[$index]->geometry->location->lat;
$lng = (string) $obj->results[$index]->geometry->location->lng;
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13");
}
}
}
}
@ -390,7 +440,7 @@ class JsonController extends Controller
}
self::renderPartial('modals/article.php', array(
'title' => $article->title,
'text' => $article->text,
'text' => $article->html,
));
}
}
@ -404,7 +454,25 @@ class JsonController extends Controller
}
self::renderPartial('modals/pointAgreement.php', array(
'title' => $article->title,
'text' => $article->text,
'text' => $article->html,
));
}
static function actionGetmyartphotos()
{
if (!App::$user) {
App::error404();
}
self::renderPartial('json.php', array(
'data' => ArticlePhotos::model()->getAll(
array(
'where' => '`owner` = ' . (int) App::$user->id,
'order' => '`id` DESC',
'asArray' => true,
'noKeys' => true
)
)
));
}

View File

@ -63,8 +63,7 @@ class PageController extends Controller
$result[$id]['categoryIcon'] = $categories[$point->categoryId]->icon;
}
$res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points`")->fetch(PDO::FETCH_ASSOC);
App::setConfig('title', $res['pointsCount'] . ' или даже больше поводов не сидеть дома');
App::setConfig('title', App::$defaultTitle);
self::render('pointsTemplate.php', array(
'categories' => $categories,
@ -115,7 +114,7 @@ class PageController extends Controller
$point->descriptionHtml = nl2br($point->description);
$point->name = htmlspecialchars($point->name);
App::setConfig('title', $point->name . ' - wikipoints.ru');
App::setConfig('title', $point->name . ' wikipoints.ru');
self::addVar('pointLat', $point->lat);
self::addVar('pointLng', $point->lng);
self::addVar('pointId', $point->id);
@ -124,7 +123,7 @@ class PageController extends Controller
$point->categoryIcon = $categories[$point->categoryId]['icon'];
$point->categoryName = $categories[$point->categoryId]['name'];
$point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml);
$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);
@ -192,12 +191,14 @@ class PageController extends Controller
App::error404();
}
App::setConfig('title', $article->title . ' - wikipoints.ru');
App::setConfig('title', $article->title . ' wikipoints.ru');
$article->html = Helper::replaceLinks($article->html, 'html');
$article->html = Helper::replaceImgs($article->html, 'html');
self::render('article.php', array(
'article' => $article,
'randomPoint' => Point::model()->getRandom(),
// 'og' => Helper::buildOG($point),
'og' => Helper::buildArticleOG($article),
// 'user' => App::$user,
));
} else {
@ -205,6 +206,19 @@ class PageController extends Controller
}
}
static function actionMyprofile()
{
$userId = App::$user ? App::$user->id : 0;
die($userId);
}
// static function actionProfile()
// {
// $userId = (int) App::getParam('user');
//
// }
static function actionVkpoint()
{
$pointId = (int) App::getParam('id');
@ -220,7 +234,7 @@ class PageController extends Controller
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$point->descriptionHtml = Helper::replaceLinks($point->descriptionHtml);
$point->description = Helper::replaceLinks($point->description);
self::renderPartial('vkPoint.php', array(
'point' => $point,

View File

@ -15,4 +15,20 @@ class Article extends Model
return new self();
}
public function getImg($size = 'small')
{
$imgId = (int)$this->photoId;
if ($imgId) {
$img = ArticlePhotos::model()->getByPK($imgId);
if ($img) {
return '/photos/articles/' . $size . '/' . $img->name;
}
}
return '/img/logo.png';
}
}

View File

@ -0,0 +1,18 @@
<?php
class ArticlePhotos extends Model
{
function __construct($fromArray = array())
{
$this->_tableName_ = 'articlePhotos';
parent::__construct($fromArray);
$this->setRelation('authorUser', 'owner', 'User', 'id', self::TO_ONE);
}
static function model()
{
return new self();
}
}

View File

@ -16,4 +16,13 @@ class Photo extends Model
return new self();
}
/**
* Возвращает ссылку на исходное изображение (если она есть)
* @return type
*/
function getOriginalLink()
{
$link = $this->link;
return $link ? $link->url : '';
}
}

View File

@ -8,9 +8,7 @@
</div>
<div style="text-align: justify;">
<?php
print $article->text;
?>
<?= $article->html; ?>
</div>
</div>

View File

@ -0,0 +1,142 @@
<script>
function updatePhotobank() {
if (document.getElementById("hiddenframe").contentWindow.document.body.innerText == 'error') {
alert('Ошибка при загрузке.');
return false;
}
$('#photo').val('');
$('#caption').val('');
$.getJSON("/json/getmyartphotos", function (data) {
$('#photobank').html('');
$.each(data, function (key, val) {
$("<img/> ", {
"class": "my-new-list",
src: '/photos/articles/small/' + val.name,
title: 'img #' + val.id + ' :: ' + val.caption,
photoId: val.id
}).appendTo('#photobank');
});
$("#photobank img").on("click", function () {
articleText = document.getElementById('articleText');
imgText = '\n[img|#' + $(this).attr('photoid') + ']\n';
insertAtCursor(articleText, imgText);
markdown();
});
});
}
function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA and others
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}
</script>
<div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>
<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;padding-bottom: 30px; width: 100%;">
<div class="row">
<div class="col-md-12">
<h1 style="text-align: right;">Редактирование статьи</h1>
<div class="coords-container">
Вернуться: <a href="/articles">к списку статей</a> / <a href="/">на карту</a>.
</div>
<div style="text-align: justify;">
<form method="POST" action="/articles/save">
<input type="hidden" name="id" value="<?= $article->id ?>" />
<div class="form-group">
<label for="articleTitle">Название статьи</label>
<input type="text" name="title" id="articleTitle" class="form-control" value="<?= $article->title ?>" placeholder="" />
</div>
<div class="form-group">
<table class="col-md-12" >
<tr>
<td style="width: 50%;">
<label for="articleText">Текст статьи</label>
<textarea name="text" id="articleText" class="form-control" onscroll="monitor.scrollTop=scrollTop" style="height: 250px; resize: none;" ><?= $article->text ?></textarea>
</td>
<td style="width: 50%; padding-left: 3px;">
<label for="monitor">Предпросмотр</label>
<div id="monitor" style="height: 250px; width: 100%; background-color: white; overflow-y: scroll; padding: 5px 10px; border: solid 1px #ccc; border-radius: 4px;"></div>
</td>
</tr>
</table>
<i>*текст*</i> <b>**текст**</b> <b><i>***текст***</i></b> <a href="#">http://ссылка.ру</a> # заголвок1 ## заголовк2 ### заголовк3 [#512|ссылка на точку 512]
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="allowComments" id="articleComments" <?= $article->allowComments ? 'checked' : '' ?> />Разрешить комментарии
</label>
</div>
<button type="submit" class="btn btn-default">Сохранить</button>
</form>
</div>
</div>
<div class="col-md-12" style="margin: 20px 0; border-top: solid 1px #bbb; border-bottom: solid 1px #bbb;">
<form enctype="multipart/form-data" id="articlePhotoloader" action="/images/loadPhoto" method="POST" name="loadavatar" target="hiddenframe" class="form-inline">
<input type="hidden" name="MAX_FILE_SIZE" value="5242880" />
<div class="form-group">
<label for="photo">Загрузить новое изображение (MAX 5MB) (jpg, png)</label>
<input id="photo" name="photo" type="file" class="form-control" accept=".jpg,.png,.jpeg" />
</div>
<div class="form-group">
<input id="caption" name="caption" type="text" class="form-control" placeholder="Описание (по желанию)" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-sm btn-default">Загрузить на сервер</button>
</div>
</form>
</div>
<div class="col-md-12" id="photobank"></div>
<iframe id="hiddenframe" name="hiddenframe" style="width:0px; height:0px; border:0px" onload="updatePhotobank()"></iframe>
</div>
</div>
<script>
var monitorTimeout;
function markdown()
{
$.post('/articles/markdown', {text: $('#articleText').val()}, function (data) {
$('#monitor').html(data);
});
}
$('#articleText').keyup(function () {
clearTimeout(monitorTimeout);
monitorTimeout = setTimeout(function () {
markdown();
}, 300);
}).keydown(function () {
clearTimeout(monitorTimeout)
}).scroll(function () {
monH = document.getElementById('monitor').scrollHeight - document.getElementById('monitor').clientHeight;
areH = document.getElementById('articleText').scrollHeight - document.getElementById('articleText').clientHeight;
areS = $('#articleText').scrollTop();
monS = Math.round((areS / areH) * monH);
$('#monitor').scrollTop(monS);
});
$(document).ready(function(){
markdown();
});
</script>

View File

@ -0,0 +1,19 @@
<div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>
<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;padding-bottom: 30px;">
<div class="row">
<div class="col-md-12">
<h1 style="text-align: right;">Список всех статей</h1>
<div class="coords-container">
Вернуться <a href="/">на карту</a>.
</div>
<div style="text-align: justify;">
<a href="/articles/edit/id/0" class="btn btn-default" title="Добавить новую статью"><span class="glyphicon glyphicon-plus"></span> Добавить новую статью</a><br/>
<br/>
<?php foreach ($articles as $article): ?>
<a href="/page/article/id/<?= $article->id ?>" target="_blank"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> просмотр</a>&emsp;&emsp;<a href="/articles/edit/id/<?= $article->id ?>">#<?= $article->id ?> <?= $article->title ? $article->title : 'НАЗВАНИЕ НЕ ЗАДАНО!' ?></a><br/>
<?php endforeach; ?>
</div>
</div>
</div>
</div>

View File

@ -36,6 +36,9 @@ if (App::$user) {
<a onclick="showArticle(2);" href="#">Как пользоваться</a><br/>
<a onclick="$('#categoriesModal').modal('show');" href="#">Легенда</a><br/>
<a href="/page/points">Список точек</a><br/>
<?php if (App::$user && App::$user->isAdmin): ?>
<a href="/articles">Статьи</a><br/>
<?php endif; ?>
<br/>
<a href="/?point=random" onclick="showRandomPoint();
return false;">Случайная точка</a>
@ -45,7 +48,7 @@ if (App::$user) {
<div id="boxLayers">
<h3>Карты</h3>
<div onclick="setLayer('quest')" class="layers questLayer">map Quest</div>
<div onclick="setLayer('topo')" class="layers osmLayer">Генштаб от маршруты.ру</div>
<div onclick="setLayer('topo')" class="layers topoLayer">Генштаб от маршруты.ру</div>
<div onclick="setLayer('google')" class="layers googleLayer">Google maps</div>
<div onclick="setLayer('yandex')" class="layers yandexLayer">Яндекс.Карты</div>
<div onclick="setLayer('osm')" class="layers osmLayer">Open Street Map</div>
@ -111,6 +114,7 @@ if (App::$user) {
</div>
<?= $user ? '' : self::renderPartial('modals/login.php', null, true) ?>
<?= $user ? self::renderPartial('modals/addPoint.php', array('categories' => $categories), true) : '' ?>
<?= self::renderPartial('modals/categories.php', array('categories' => $categories), true) ?>
<?= self::renderPartial('modals/image.php', array(), true) ?>
<map name="vkbutton">
<area onclick="hideBigLogo();" shape="rect" coords="0,0,40,40" style="cursor: pointer" title="Спрятать надолго"/>
@ -121,21 +125,3 @@ if (App::$user) {
var categoryArray = '<?= json_encode($categoryArray) ?>';
</script>
<?php endif; ?>
<script>
$(document).ready(function () {
if ($.cookie('doNotShowVKgroup')) {
$('#vkBigLogo').remove();
} else {
setTimeout(function () {
$('#vkBigLogo').css({'display': 'block'}).animate({'margin-left': "-225px"}, 1500);
}, 10000);
}
})
function hideBigLogo() {
$.cookie('doNotShowVKgroup', true, {expires: 100, path: '/'});
$('#vkBigLogo').animate({'margin-left': "285px"}, 1500, function () {
$('#vkBigLogo').remove();
});
}
</script>

File diff suppressed because one or more lines are too long

View File

@ -4,72 +4,74 @@
prefix="og: http://ogp.me/ns#"
xmlns:fb="http://ogp.me/ns/fb#"
xmlns:og="http://ogp.me/ns#">
<head>
<title><?= App::getConfig('title') ?></title>
<head>
<title><?= App::getConfig('title') ?></title>
<?php if ($styles): ?>
<?php foreach ($styles as $style): ?>
<link href="<?= $style ?>" media="all" rel="stylesheet" type="text/css" />
<?php endforeach; ?>
<?php endif; ?>
<?php if ($styles): ?>
<?php foreach ($styles as $style): ?>
<link href="<?= $style ?>" media="all" rel="stylesheet" type="text/css" />
<?php endforeach; ?>
<?php endif; ?>
<?php if ($scripts): ?>
<?php foreach ($scripts as $script): ?>
<script src="<?= $script ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($scripts): ?>
<?php foreach ($scripts as $script): ?>
<script src="<?= $script ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($vars): ?>
<script type="text/javascript">
<?php foreach ($vars as $varName => $var): ?>
<?php if ($vars): ?>
<script type="text/javascript">
<?php foreach ($vars as $varName => $var): ?>
var <?= $varName ?> = '<?= $var ?>';
<?php endforeach; ?>
</script>
<?php endif; ?>
<?php endforeach; ?>
</script>
<?php endif; ?>
<?php if (isset($data['og']) && $data['og']): ?>
<meta property="og:title" content="<?= $data['og']['title'] ?>" />
<meta property="og:description" content="<?= $data['og']['description'] ?>" />
<meta property="og:site_name" content="<?= $data['og']['site_name'] ?>" />
<meta property="og:type" content="<?= $data['og']['type'] ?>" />
<meta property="og:url" content="<?= $data['og']['url'] ?>" />
<meta property="og:image" content="<?= $data['og']['image'] ?>" />
<?php endif; ?>
<?php if (isset($data['og']) && $data['og']): ?>
<meta property="og:title" content="<?= $data['og']['title'] ?>" />
<meta property="og:description" content="<?= $data['og']['description'] ?>" />
<meta property="og:site_name" content="<?= $data['og']['site_name'] ?>" />
<meta property="og:type" content="<?= $data['og']['type'] ?>" />
<meta property="og:url" content="<?= $data['og']['url'] ?>" />
<meta property="og:image" content="<?= $data['og']['image'] ?>" />
<?php endif; ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:400&subset=Cyrillic">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:400&subset=Cyrillic" />
<link rel="apple-touch-icon" href="/img/touch-icon-iphone.png">
<link rel="apple-touch-icon" sizes="76x76" href="/img/touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="120x120" href="/img/touch-icon-iphone-retina.png">
<link rel="apple-touch-icon" sizes="152x152" href="/img/touch-icon-ipad-retina.png">
</head>
<body style="padding: 10px 25px; overflow-y: scroll;">
<div class="header">
<a href="/"><img src="/img/logo.png" title="WIKIPOINTS.RU" /></a>
</div>
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
<?= self::renderPartial('metrika.php', array(), true) ?>
<?= self::renderPartial('ganalytics.php', array(), true) ?>
</body>
<script lang="javascript">
function setSizeForAdditional() {
width = $('.col-md-12').width() / 6 - 4;
<link rel="apple-touch-icon" href="/img/touch-icon-iphone.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/img/touch-icon-ipad.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/img/touch-icon-iphone-retina.png" />
<link rel="apple-touch-icon" sizes="152x152" href="/img/touch-icon-ipad-retina.png" />
</head>
<body style="padding: 10px 25px; overflow-y: scroll;">
<div class="header">
<a href="/"><img src="/img/logo.png" title="WIKIPOINTS.RU" /></a>
</div>
if (width < 100)
width = $('.col-md-12').width() / 3 - 4;
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
<?= self::renderPartial('metrika.php', array(), true) ?>
<?= self::renderPartial('ganalytics.php', array(), true) ?>
height = width / 4 * 3;
$('.pagePoinsNearCards').width(width);
$('.pagePoinsNearCardsImg').width(width);
$('.pagePoinsNearCards').height(height);
$('.pagePoinsNearCardsImg').height(height);
}
</body>
<script lang="javascript">
function setSizeForAdditional() {
width = $('.col-md-12').width() / 6 - 4;
setSizeForAdditional();
if (width < 100)
width = $('.col-md-12').width() / 3 - 4;
$(window).resize(function () {
setSizeForAdditional();
});
</script>
</html>
height = width / 4 * 3;
$('.pagePoinsNearCards').width(width);
$('.pagePoinsNearCardsImg').width(width);
$('.pagePoinsNearCards').height(height);
$('.pagePoinsNearCardsImg').height(height);
}
setSizeForAdditional();
$(window).resize(function () {
setSizeForAdditional();
});
</script>
</html>

View File

@ -1,32 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title><?= App::getConfig('title') ?></title>
<?php if ($styles): ?>
<?php foreach ($styles as $style): ?>
<link href="<?= $style ?>" media="all" rel="stylesheet" type="text/css" />
<?php endforeach; ?>
<?php endif; ?>
<?php if ($scripts): ?>
<?php foreach ($scripts as $script): ?>
<script src="<?= $script ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($vars): ?>
<script type="text/javascript">
<?php foreach ($vars as $varName => $var): ?>
var <?= $varName ?> = '<?= $var ?>';
<?php endforeach; ?>
</script>
<?php endif; ?>
<head>
<title><?= App::getConfig('title') ?></title>
<?php if ($styles): ?>
<?php foreach ($styles as $style): ?>
<link href="<?= $style ?>" media="all" rel="stylesheet" type="text/css" />
<?php endforeach; ?>
<?php endif; ?>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:400&subset=Cyrillic">
</head>
<body>
<?php if ($scripts): ?>
<?php foreach ($scripts as $script): ?>
<script src="<?= $script ?>" type="text/javascript"></script>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($vars): ?>
<script type="text/javascript">
<?php foreach ($vars as $varName => $var): ?>
var <?= $varName ?> = '<?= $var ?>';
<?php endforeach; ?>
</script>
<?php endif; ?>
</head>
<body>
<h1>WikiPoints.ru</h1>
<hr/>
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>

View File

@ -74,71 +74,3 @@
</div>
</div>
</div>
<script>
function addNewImage(link)
{
if ($('.extraImage', '#addPointForm').length < 10)
{
$('.extraImage', '#newIm').clone().appendTo('#imgsContainer').show(200);
if (link != undefined)
{
$('.form-control.images', '#addPointForm').last().attr('readonly', 'readonly').val(link);
$('.input-group-addon.type.button', '#addPointForm').remove();
}
}
}
function removeInput(el)
{
container = $(el).parent().parent();
container.hide(300, function () {
container.remove()
});
}
function switchType(el)
{
container = $(el).parent().parent();
if (container.hasClass('asLink'))
{
$('.ordering', container).val('FILE');
$('.ico span', container).removeClass('glyphicon-link').addClass('glyphicon-paperclip');
$('.form-control.images', container).attr('type', 'file').attr('name', 'photos[]');
$('.form-control.photoLinks', container).show();
container.removeClass('asLink');
el.attr('title', 'Указать ссылку на изображение');
$('.input-group-addon.type.ico', container).attr('title', 'Загрузите файл с изображением');
$('.input-group-addon.type.preview', container).hide();
}
else
{
$('.ordering', container).val('LINK');
$('.ico span', container).removeClass('glyphicon-paperclip').addClass('glyphicon-link');
$('.form-control.images', container).attr('type', 'text').attr('name', 'imgs[]');
$('.form-control.photoLinks', container).hide();
container.addClass('asLink');
el.attr('title', 'Загрузить файл');
$('.input-group-addon.type.ico', container).attr('title', 'Укажите ссылку на изображение');
$('.input-group-addon.type.preview', container).show();
}
}
function showPreview(el) {
img = $('input.images', el.parent()).val();
if ($('input.ordering', el.parent()).val() == 'FILE' || img.length < 12) {
return true;
}
if (img.toLowerCase().indexOf('http') == -1) {
img = '/photos/small/' + img;
}
$('#imgPreview').attr('src', img);
$('#imgPreview').show();
}
function hidePerview() {
$('#imgPreview').hide();
}
</script>

View File

@ -45,7 +45,7 @@ $index = 0;
<?php endif; ?>
<?php if ($photos): ?>
<?php foreach ($photos as $photo): ?>
<img data-thumb="/photos/small/<?= $photo->name ?>" src="/photos/middle/<?= $photo->name ?>">
<img data-thumb="/photos/small/<?= $photo->name ?>" src="/photos/middle/<?= $photo->name ?>" data-caption="<?= $photo->getOriginalLink()?>">
<?php endforeach; ?>
<?php endif; ?>
<span data-thumb="/img/mapThumb.png">

View File

@ -9,4 +9,4 @@ foreach ($photos as $photo) {
<br/>
Продолжить чтение и посмотреть на карте: http://wikipoints.ru/page/point/id/<?= $point->id ?><br/>
<br/>
#wikipoints #выходные #путешествия #туризм # # # #
#wikipoints # # # # # # # # # # # # # # # # #выходные #путешествия #путешествие #туризм #weekend #travels #journey #tourism

0
logs/.gitKeep Normal file
View File

View File

@ -93,6 +93,8 @@ div#box {background-image: url('/img/back.png'); background-repeat: no-repeat; b
.pagePoinsNearCards {display: inline-block; overflow: hidden; padding: 0 2px 4px 2px;width: 186px; height: 139px;}
.pagePoinsNearCardsImg {width: 186px; height: 139px;}
#photobank img {margin: 2px; border: solid 1px white;}
img.imageInArticle {border: solid 3px white;}
/* -------------------------------------------*/
/* ------------- ADAPTIVE --------------------*/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -146,7 +146,7 @@ window.addEventListener('popstate', function(e)
setStatus(statusMovingInHistory);
if (e.state.hasOwnProperty('pointId'))
{
points[e.state.pointId].openPopup();
showInfo(e.state.pointId, false, true);
} else
if (e.state.hasOwnProperty('zoom'))
{

View File

@ -63,7 +63,7 @@ ymaps.ready(function () {
*/
function init(lat, lng) {
myMap = L.map('map', {zoomControl: false}).setView([lat, lng], defaultZoom);
markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 45});
markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 30});
layers['quest'] = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', maxZoom: 18});
layers['osm'] = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery ©</a>', maxZoom: 18});
@ -111,7 +111,7 @@ function init(lat, lng) {
myMap.on('moveend', function (e) {
if (!myMap._popup && $('#boxRoute').css('display') == 'none' && status != statusMovingInHistory)
{
document.title = pointsCount + ' или даже больше поводов не сидеть дома';
document.title = 'Лучшие выходные это выходные в путешествии! wikipoints.ru';
history.pushState({lat: myMap.getCenter().lat, lng: myMap.getCenter().lng, zoom: myMap.getZoom()}, document.title, "/?lat=" + myMap.getCenter().lat + "&lng=" + myMap.getCenter().lng + "&zoom=" + myMap.getZoom());
}
@ -189,9 +189,9 @@ function initPoints(useBounds)
bounds: bounds
},
success: function (data) {
for (var k in data) {
if (typeof points[k] == 'undefined') {
markers.addLayer(constructPoint(data[k]));
for(var i=0; i<data.length; i++) {
if (typeof points[data[i].id] == 'undefined') {
markers.addLayer(constructPoint(data[i]));
}
}
myMap.addLayer(markers);
@ -229,13 +229,14 @@ function initPoints(useBounds)
* @param {type} id
* @returns {Boolean}
*/
function showInfo(id, mapClick)
function showInfo(id, mapClick,doNotPushToHistory)
{
if (!(id in points)) {
return false;
}
mapClick = Boolean(mapClick !== undefined && mapClick === true); // true если это клик по маркеру на карте
doNotPushToHistory = Boolean(doNotPushToHistory !== undefined && doNotPushToHistory === true); // true если НЕ добавляем в history
marker = points[id];
if (!(id in pointsSources))
{
@ -248,11 +249,11 @@ function showInfo(id, mapClick)
}
});
} else {
drawInfoPopup(id, !mapClick);
drawInfoPopup(id, !mapClick, doNotPushToHistory);
}
}
function drawInfoPopup(id, showPopup) {
function drawInfoPopup(id, showPopup, doNotPushToHistory) {
data = pointsSources[id];
if (typeof (data.images) == 'object')
{
@ -307,8 +308,11 @@ function drawInfoPopup(id, showPopup) {
marker.openPopup();
}
history.pushState({pointId: id}, document.title, "/?point=" + id);
document.title = marker.options.title;
if (!doNotPushToHistory) {
history.pushState({pointId: id}, document.title, "/?point=" + id);
}
document.title = marker.options.title + ' wikipoints.ru';
});
return true;
@ -349,3 +353,91 @@ function showPointagreement()
}
});
}
// =============== ADD POINT
function addNewImage(link)
{
if ($('.extraImage', '#addPointForm').length < 10)
{
$('.extraImage', '#newIm').clone().appendTo('#imgsContainer').show(200);
if (link != undefined)
{
$('.form-control.images', '#addPointForm').last().attr('readonly', 'readonly').val(link);
$('.input-group-addon.type.button', '#addPointForm').remove();
}
}
}
function removeInput(el)
{
container = $(el).parent().parent();
container.hide(300, function () {
container.remove()
});
}
function switchType(el)
{
container = $(el).parent().parent();
if (container.hasClass('asLink'))
{
$('.ordering', container).val('FILE');
$('.ico span', container).removeClass('glyphicon-link').addClass('glyphicon-paperclip');
$('.form-control.images', container).attr('type', 'file').attr('name', 'photos[]');
$('.form-control.photoLinks', container).show();
container.removeClass('asLink');
el.attr('title', 'Указать ссылку на изображение');
$('.input-group-addon.type.ico', container).attr('title', 'Загрузите файл с изображением');
$('.input-group-addon.type.preview', container).hide();
}
else
{
$('.ordering', container).val('LINK');
$('.ico span', container).removeClass('glyphicon-paperclip').addClass('glyphicon-link');
$('.form-control.images', container).attr('type', 'text').attr('name', 'imgs[]');
$('.form-control.photoLinks', container).hide();
container.addClass('asLink');
el.attr('title', 'Загрузить файл');
$('.input-group-addon.type.ico', container).attr('title', 'Укажите ссылку на изображение');
$('.input-group-addon.type.preview', container).show();
}
}
function showPreview(el) {
img = $('input.images', el.parent()).val();
if ($('input.ordering', el.parent()).val() == 'FILE' || img.length < 12) {
return true;
}
if (img.toLowerCase().indexOf('http') == -1) {
img = '/photos/small/' + img;
}
$('#imgPreview').attr('src', img);
$('#imgPreview').show();
}
function hidePerview() {
$('#imgPreview').hide();
}
// ======================= VK Button
$(document).ready(function () {
if ($.cookie('doNotShowVKgroup')) {
$('#vkBigLogo').remove();
} else {
setTimeout(function () {
$('#vkBigLogo').css({'display': 'block'}).animate({'margin-left': "-225px"}, 1500);
}, 10000);
}
})
function hideBigLogo() {
$.cookie('doNotShowVKgroup', true, {expires: 100, path: '/'});
$('#vkBigLogo').animate({'margin-left': "285px"}, 1500, function () {
$('#vkBigLogo').remove();
});
}

View File

@ -42,7 +42,7 @@ ymaps.ready(function () {
* @returns true
*/
function init(lat, lng) {
myMap = L.map('map', {zoomControl: false}).setView([lat, lng], defaultZoom);
myMap = L.map('map', {zoomControl: true}).setView([lat, lng], defaultZoom);
markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 45});
layers['quest'] = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', maxZoom: 18});
@ -89,12 +89,12 @@ function initPoints()
$.ajax({
url: "/json/points/",
success: function (data) {
for (var k in data) {
if (k == pointId) {
constructPoint(data[k]);
points[k].addTo(myMap);
for(var i=0; i<data.length; i++) {
if (data[i].id == pointId) {
constructPoint(data[i]);
points[data[i].id].addTo(myMap);
} else {
markers.addLayer(constructPoint(data[k]));
markers.addLayer(constructPoint(data[i]));
}
}
myMap.addLayer(markers);

BIN
source/logoApp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

76
source/logoApp.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB