merge with master

This commit is contained in:
Krivchikov Dmitry 2014-08-03 23:57:44 +04:00
commit a1e92b7726
8 changed files with 118 additions and 113 deletions

View File

@ -15,5 +15,6 @@ return array(
'big' => array(1110, 900, 90), 'big' => array(1110, 900, 90),
), ),
//'version' => trim(file_get_contents(dirname(__FILE__).'/version')), //'version' => trim(file_get_contents(dirname(__FILE__).'/version')),
'metrika' => true,
); );

View File

@ -36,13 +36,12 @@ class IndexController extends Controller
if (!App::$user ) if (!App::$user )
self::addScript('//ulogin.ru/js/ulogin.js'); self::addScript('//ulogin.ru/js/ulogin.js');
$category = Category::model()->getAll(); $category = Category::model()->getAll(array('order' => 'ord ASC'));
$routes = array(); $routes = array();
if (App::$user) if (App::$user && App::$user->id)
{ {
$routes = new Route(); $routes = Route::model()->getByAuthor(App::$user->id);
$routes = $routes->getByAuthor(App::$user->id);
} }
self::addVar('isAdmin', (int)(App::$user && App::$user->isAdmin == 1) ); self::addVar('isAdmin', (int)(App::$user && App::$user->isAdmin == 1) );
@ -56,15 +55,14 @@ class IndexController extends Controller
{ {
$id = (int) $_GET['point']; $id = (int) $_GET['point'];
$point = new Point(); $point = Point::model()->getByPK($id);
$point = $point->getByPK($id);
$point->name = htmlspecialchars($point->name); $point->name = htmlspecialchars($point->name);
$point->descriptionHtml = htmlspecialchars($point->description); $point->descriptionHtml = htmlspecialchars($point->description);
$point->descriptionHtml .= ' Посмотреть на карте: http://wikipoints.ru/?point='.$id; $point->descriptionHtml .= ' Посмотреть на карте: http://wikipoints.ru/?point='.$id;
$point->descriptionHtml .= ' #wikipoints'; $point->descriptionHtml .= ' #wikipoints';
$og['title'] = $point->name . ' - wikipoints.ru'; $og['title'] = $point->name . ' [wikipoints.ru]';
$og['description'] = 'http://wikipoints.ru/?point='.$id.' '.$point->descriptionHtml; $og['description'] = $point->descriptionHtml;
$og['site_name'] = 'WikiPoints - '.$res['pointsCount'].' или даже больше поводов не сидеть дома'; $og['site_name'] = 'WikiPoints - '.$res['pointsCount'].' или даже больше поводов не сидеть дома';
$og['type'] = 'article'; $og['type'] = 'article';
$og['url'] = 'http://wikipoints.ru/?point='.$id; $og['url'] = 'http://wikipoints.ru/?point='.$id;
@ -90,8 +88,8 @@ class IndexController extends Controller
static function actionUser() static function actionUser()
{ {
$routes = new Route(); App::error404();
$routes = $routes->getByAuthor(App::$user->id); $routes = Route::model()->getByAuthor(App::$user->id);
var_dump($routes); var_dump($routes);
} }
@ -109,9 +107,8 @@ class IndexController extends Controller
//var_dump($uLoginUser);die; //var_dump($uLoginUser);die;
$uLoginUser['identity'] = md5($uLoginUser['uid'].$uLoginUser['network'].'=P'); $uLoginUser['identity'] = md5($uLoginUser['uid'].$uLoginUser['network'].'=P');
$user = new User(); $user = User::model()->getByUID($uLoginUser['identity']);
$user->getByUID($uLoginUser['identity']);
//var_dump($uLoginUser,'<br><br>', $user);die;
if( !$user->id ) if( !$user->id )
{ {
$user = $user->add(array( $user = $user->add(array(
@ -137,8 +134,7 @@ class IndexController extends Controller
{ {
$xml = new SimpleXMLElement('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>'); $xml = new SimpleXMLElement('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>');
$points = new Point(); $points = Point::model()->getAll(array('order' => 'ID DESC', 'asArray' => true));
$points = $points->getAll('', 'ID DESC');
foreach ($points as $point) foreach ($points as $point)
{ {

View File

@ -9,7 +9,7 @@ class JsonController extends Controller
static function actionPoints() static function actionPoints()
{ {
$points = Point::model()->getAll(); $points = Point::model()->getAll();
$categories = Category::model()->getAll(array('asArray' => true)); $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$result = array(); $result = array();
@ -60,7 +60,7 @@ class JsonController extends Controller
$point->images = $tmp; $point->images = $tmp;
} }
$categories = Category::model()->getAll(array('asArray' => true)); $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$point->categoryIcon = $categories[$point->categoryId]['icon']; $point->categoryIcon = $categories[$point->categoryId]['icon'];
$point->categoryName = $categories[$point->categoryId]['name']; $point->categoryName = $categories[$point->categoryId]['name'];
@ -77,7 +77,7 @@ class JsonController extends Controller
*/ */
static function actionCategories() static function actionCategories()
{ {
$categories = Category::model()->getAll(array('asArray' => true)); $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
self::renderPartial('json.php', array( self::renderPartial('json.php', array(
'data' => $categories, 'data' => $categories,
@ -247,8 +247,7 @@ class JsonController extends Controller
'points' => json_encode($_POST['points']), 'points' => json_encode($_POST['points']),
); );
$route = new Route(); $route = Route::model()->add($request);
$route = $route->add($request);
self::renderPartial('json.php', $route->id); self::renderPartial('json.php', $route->id);
} }
@ -258,8 +257,7 @@ class JsonController extends Controller
$id = (int) App::getParam('id'); $id = (int) App::getParam('id');
if ($id) if ($id)
{ {
$route = new Route(); $route = Route::model()->getByPK($id);
$route = $route->getByPK($id);
self::renderPartial('json.php', $route->points); self::renderPartial('json.php', $route->points);
} else } else
{ {
@ -272,8 +270,7 @@ class JsonController extends Controller
$id = (int) App::getParam('id'); $id = (int) App::getParam('id');
if ($id && App::$user) if ($id && App::$user)
{ {
$route = new Route(); $route = Route::model()->getByPK($id);
$route = $route->getByPK($id);
if ($route->author == App::$user->id) if ($route->author == App::$user->id)
{ {

View File

@ -15,7 +15,7 @@ class PageController extends Controller
$param['order']='id DESC'; $param['order']='id DESC';
$param['where']=App::getParam('category') ? 'categoryId = '.(int)App::getParam('category') : ''; $param['where']=App::getParam('category') ? 'categoryId = '.(int)App::getParam('category') : '';
$points = Point::model()->getAll($param); $points = Point::model()->getAll($param);
$categories = Category::model()->getAll(); $categories = Category::model()->getAll(array('order' => 'ord ASC'));
$result = array(); $result = array();
@ -25,7 +25,7 @@ class PageController extends Controller
$result[$id]['name'] = $point->name; $result[$id]['name'] = $point->name;
$result[$id]['lat'] = $point->lat; $result[$id]['lat'] = $point->lat;
$result[$id]['lng'] = $point->lng; $result[$id]['lng'] = $point->lng;
$result[$id]['author'] = $point->authorUser->name; $result[$id]['author'] = $point->authorUser->nick;
$result[$id]['categoryId'] = $point->categoryId; $result[$id]['categoryId'] = $point->categoryId;
$result[$id]['categoryIcon'] = $categories[$point->categoryId]->icon; $result[$id]['categoryIcon'] = $categories[$point->categoryId]->icon;
} }
@ -57,13 +57,11 @@ class PageController extends Controller
self::addStyle('/css/bootstrap.min.css'); self::addStyle('/css/bootstrap.min.css');
self::addStyle('/css/bootstrap-theme.min.css'); self::addStyle('/css/bootstrap-theme.min.css');
$point = new Point(); $point = Point::model()->getByPK($id);
$point = $point->getByPK($id);
$point->descriptionHtml = nl2br($point->description); $point->descriptionHtml = nl2br($point->description);
$point->name = htmlspecialchars($point->name); $point->name = htmlspecialchars($point->name);
$categories = new Category(); $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$categories = $categories->getAll();
$point->categoryIcon = $categories[$point->categoryId]->icon; $point->categoryIcon = $categories[$point->categoryId]->icon;
$point->categoryName = $categories[$point->categoryId]->name; $point->categoryName = $categories[$point->categoryId]->name;

View File

@ -45,6 +45,7 @@
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?> <?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
<?= self::renderPartial('modals/about.php', array(), true) ?> <?= self::renderPartial('modals/about.php', array(), true) ?>
<?= self::renderPartial('modals/howToUse.php', array(), true) ?> <?= self::renderPartial('modals/howToUse.php', array(), true) ?>
<?php if (App::getConfig('metrika')): ?>
<!-- Yandex.Metrika counter --> <!-- Yandex.Metrika counter -->
<script type="text/javascript"> <script type="text/javascript">
(function(d, w, c) { (function(d, w, c) {
@ -52,22 +53,28 @@
try { try {
w.yaCounter24682772 = new Ya.Metrika({id: 24682772, w.yaCounter24682772 = new Ya.Metrika({id: 24682772,
trackLinks: true}); trackLinks: true});
} catch(e) { } } catch (e) {
}
}); });
var n = d.getElementsByTagName("script")[0], var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"), s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); }; f = function() {
n.parentNode.insertBefore(s, n);
};
s.type = "text/javascript"; s.type = "text/javascript";
s.async = true; s.async = true;
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") { if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false); d.addEventListener("DOMContentLoaded", f, false);
} else { f(); } } else {
f();
}
})(document, window, "yandex_metrika_callbacks"); })(document, window, "yandex_metrika_callbacks");
</script> </script>
<noscript><div><img src="//mc.yandex.ru/watch/24682772" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <noscript><div><img src="//mc.yandex.ru/watch/24682772" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter --> <!-- /Yandex.Metrika counter -->
<?php endif; ?>
</body> </body>
</html> </html>

View File

@ -1,22 +1,22 @@
.marker-cluster-small { .marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6); background-color: rgba(100, 187, 100, 0.5);
} }
.marker-cluster-small div { .marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6); background-color: rgba(34, 187, 34, 0.6);
} }
.marker-cluster-medium { .marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6); background-color: rgba(255, 193, 100, 0.5);
} }
.marker-cluster-medium div { .marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6); background-color: rgba(255, 193, 31, 0.6);
} }
.marker-cluster-large { .marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6); background-color: rgba(187, 100, 100, 0.5);
} }
.marker-cluster-large div { .marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6); background-color: rgba(187, 34, 34, 0.6);
} }
/* IE 6-8 fallback colors */ /* IE 6-8 fallback colors */

View File

@ -12,6 +12,7 @@ var route = false;
var addPointInProcess = false; var addPointInProcess = false;
var layer; var layer;
var layers = Array(); var layers = Array();
var defaultZoom = 13;
categories.im = L.icon({ categories.im = L.icon({
iconUrl: '/ico/man.png', iconUrl: '/ico/man.png',
@ -40,7 +41,7 @@ ymaps.ready(function(){
* @returns true * @returns true
*/ */
function init(lat, lng) { function init(lat, lng) {
myMap = L.map('map',{zoomControl: false}).setView([lat, lng], 11); 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: 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}); 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});
@ -58,6 +59,7 @@ function init(lat, lng) {
{ {
$('#addPointId').remove(); $('#addPointId').remove();
$('#addPointForm input:text').val(''); $('#addPointForm input:text').val('');
$('#addPointForm textarea').val('');
$("#addPointCategoryId option" ).attr('selected', null); $("#addPointCategoryId option" ).attr('selected', null);
$('#addPointLat').val(e.latlng.lat); $('#addPointLat').val(e.latlng.lat);
$('#addPointLng').val(e.latlng.lng); $('#addPointLng').val(e.latlng.lng);
@ -165,7 +167,6 @@ function initPoints()
function showInfo(id) function showInfo(id)
{ {
marker = points[id]; marker = points[id];
markers.zoomToShowLayer(marker,function() {});
if (!(id in points) || marker.options.description == undefined) if (!(id in points) || marker.options.description == undefined)
{ {
@ -199,7 +200,11 @@ function showInfo(id)
description = description + '</div><div class="clear"></div>'; description = description + '</div><div class="clear"></div>';
marker.options.description = description; marker.options.description = description;
marker.bindPopup(marker.options.description, {maxWidth: 500, maxHeight: 300}).openPopup(); marker.bindPopup(marker.options.description, {maxWidth: 500, maxHeight: 300});
markers.zoomToShowLayer(marker,function() {
marker.openPopup();
history.pushState({}, document.title, "/?point=" + id);
bounds = myMap.getBounds(); bounds = myMap.getBounds();
diff = (bounds._northEast.lat - bounds._southWest.lat)/4; diff = (bounds._northEast.lat - bounds._southWest.lat)/4;
@ -207,6 +212,7 @@ function showInfo(id)
history.pushState({}, document.title, "/?point=" + id); history.pushState({}, document.title, "/?point=" + id);
document.title = data.name; document.title = data.name;
});
} }
}); });
} else { } else {
@ -259,7 +265,7 @@ function searchAdderess()
{ {
if (data.lat && data.lng) if (data.lat && data.lng)
{ {
myMap.setView([data.lat, data.lng], 13); myMap.setView([data.lat, data.lng], defaultZoom);
L.popup() L.popup()
.setLatLng([data.lat, data.lng]) .setLatLng([data.lat, data.lng])
.setContent('Координаты: lat:'+data.lat+' lng:'+data.lng) .setContent('Координаты: lat:'+data.lat+' lng:'+data.lng)
@ -282,7 +288,7 @@ function showMeOnTheMap()
coords = [pos.coords.latitude, pos.coords.longitude]; coords = [pos.coords.latitude, pos.coords.longitude];
myMap.removeLayer(points.im); myMap.removeLayer(points.im);
points.im.setLatLng(coords).addTo(myMap); points.im.setLatLng(coords).addTo(myMap);
myMap.setView(coords, 15); myMap.setView(coords, defaultZoom);
}); });
} }