diff --git a/ground/controllers/IndexController.php b/ground/controllers/IndexController.php index 519092e..ffcfbf1 100644 --- a/ground/controllers/IndexController.php +++ b/ground/controllers/IndexController.php @@ -39,10 +39,9 @@ class IndexController extends Controller $category = Category::model()->getAll(); $routes = array(); - if (App::$user) + if (App::$user && App::$user->id) { - $routes = new Route(); - $routes = $routes->getByAuthor(App::$user->id); + $routes = Route::model()->getByAuthor(App::$user->id); } self::addVar('isAdmin', (int)(App::$user && App::$user->isAdmin == 1) ); @@ -56,8 +55,7 @@ class IndexController extends Controller { $id = (int) $_GET['point']; - $point = new Point(); - $point = $point->getByPK($id); + $point = Point::model()->getByPK($id); $point->name = htmlspecialchars($point->name); $point->descriptionHtml = htmlspecialchars($point->description); $point->descriptionHtml .= ' Посмотреть на карте: http://wikipoints.ru/?point='.$id; @@ -90,8 +88,8 @@ class IndexController extends Controller static function actionUser() { - $routes = new Route(); - $routes = $routes->getByAuthor(App::$user->id); + App::error404(); + $routes = Route::model()->getByAuthor(App::$user->id); var_dump($routes); } @@ -109,9 +107,8 @@ class IndexController extends Controller //var_dump($uLoginUser);die; $uLoginUser['identity'] = md5($uLoginUser['uid'].$uLoginUser['network'].'=P'); - $user = new User(); - $user->getByUID($uLoginUser['identity']); -//var_dump($uLoginUser,'

', $user);die; + $user = User::model()->getByUID($uLoginUser['identity']); + if( !$user->id ) { $user = $user->add(array( @@ -137,8 +134,7 @@ class IndexController extends Controller { $xml = new SimpleXMLElement(''); - $points = new Point(); - $points = $points->getAll('', 'ID DESC'); + $points = Point::model()->getAll(array('order' => 'ID DESC', 'asArray' => true)); foreach ($points as $point) { diff --git a/ground/controllers/JsonController.php b/ground/controllers/JsonController.php index bbfd03c..795f421 100644 --- a/ground/controllers/JsonController.php +++ b/ground/controllers/JsonController.php @@ -149,8 +149,7 @@ class JsonController extends Controller 'points' => json_encode($_POST['points']), ); - $route = new Route(); - $route = $route->add($request); + $route = Route::model()->add($request); self::renderPartial('json.php', $route->id); } @@ -160,8 +159,7 @@ class JsonController extends Controller $id = (int) App::getParam('id'); if ($id) { - $route = new Route(); - $route = $route->getByPK($id); + $route = Route::model()->getByPK($id); self::renderPartial('json.php', $route->points); } else { @@ -174,8 +172,7 @@ class JsonController extends Controller $id = (int) App::getParam('id'); if ($id && App::$user) { - $route = new Route(); - $route = $route->getByPK($id); + $route = Route::model()->getByPK($id); if ($route->author == App::$user->id) { diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index 6907926..46d4637 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -57,13 +57,11 @@ class PageController extends Controller self::addStyle('/css/bootstrap.min.css'); self::addStyle('/css/bootstrap-theme.min.css'); - $point = new Point(); - $point = $point->getByPK($id); + $point = Point::model()->getByPK($id); $point->descriptionHtml = nl2br($point->description); $point->name = htmlspecialchars($point->name); - $categories = new Category(); - $categories = $categories->getAll(); + $categories = Category::model()->getAll(array('asArray' => true)); $point->categoryIcon = $categories[$point->categoryId]['icon']; $point->categoryName = $categories[$point->categoryId]['name']; diff --git a/ground/views/modals/addPoint.php b/ground/views/modals/addPoint.php index c30efc8..e3e7105 100644 --- a/ground/views/modals/addPoint.php +++ b/ground/views/modals/addPoint.php @@ -28,8 +28,8 @@ diff --git a/public/js/map.js b/public/js/map.js index 41e26bb..239ab1d 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -12,6 +12,7 @@ var route = false; var addPointInProcess = false; var layer; var layers = Array(); +var defaultZoom = 13; categories.im = L.icon({ iconUrl: '/ico/man.png', @@ -40,7 +41,7 @@ ymaps.ready(function(){ * @returns true */ 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}); layers['quest'] = L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',maxZoom: 18}); @@ -164,11 +165,10 @@ function initPoints() function showInfo(id) { marker = points[id]; - markers.zoomToShowLayer(marker,function() {}); if (!(id in points) || marker.options.description == undefined) { - marker.bindPopup("Загрузка...").openPopup(); + marker.bindPopup("Загрузка...").openPopup(); $.ajax({ url: "/json/point/id/" + id, success: function(data) { @@ -198,14 +198,19 @@ function showInfo(id) 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}); - bounds = myMap.getBounds(); - diff = (bounds._northEast.lat - bounds._southWest.lat)/4; - myMap.setView([points[id]._latlng.lat+diff, points[id]._latlng.lng], myMap.getZoom()); + markers.zoomToShowLayer(marker,function() { + marker.openPopup(); + history.pushState({}, document.title, "/?point=" + id); - history.pushState({}, document.title, "/?point=" + id); - document.title = data.name; + bounds = myMap.getBounds(); + diff = (bounds._northEast.lat - bounds._southWest.lat)/4; + myMap.setView([points[id]._latlng.lat+diff, points[id]._latlng.lng], myMap.getZoom()); + + history.pushState({}, document.title, "/?point=" + id); + document.title = data.name; + }); } }); } else { @@ -258,7 +263,7 @@ function searchAdderess() { if (data.lat && data.lng) { - myMap.setView([data.lat, data.lng], 13); + myMap.setView([data.lat, data.lng], defaultZoom); L.popup() .setLatLng([data.lat, data.lng]) .setContent('Координаты: lat:'+data.lat+' lng:'+data.lng) @@ -281,7 +286,7 @@ function showMeOnTheMap() coords = [pos.coords.latitude, pos.coords.longitude]; myMap.removeLayer(points.im); points.im.setLatLng(coords).addTo(myMap); - myMap.setView(coords, 15); + myMap.setView(coords, defaultZoom); }); }