Исправлены ошибки от новых моделей, исправлена ошибка в JS, при близких точках и зумме

This commit is contained in:
Krivchikov Dmitry 2014-07-27 01:06:10 +04:00
parent 27e4f6d577
commit e3dacb03ab
5 changed files with 31 additions and 35 deletions

View File

@ -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,'<br><br>', $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('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>');
$points = new Point();
$points = $points->getAll('', 'ID DESC');
$points = Point::model()->getAll(array('order' => 'ID DESC', 'asArray' => true));
foreach ($points as $point)
{

View File

@ -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)
{

View File

@ -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'];

View File

@ -28,8 +28,8 @@
<label class="control-label" for="categoryId">Тип</label>
<select id="addPointCategoryId" name="categoryId" class="form-control">
<?php foreach ($categories as $category): ?>
<option value="<?=$category['id']?>"><?=$category['name']?></option>
<?php endforeach; ?>
<option value="<?= $category->id ?>"><?= $category->name ?></option>
<?php endforeach; ?>
</select>
</div>

View File

@ -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 &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});
@ -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 + '</div><div class="clear"></div>';
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);
});
}