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

@ -14,6 +14,7 @@ return array(
'middle' => array(555, 450, 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 )
self::addScript('//ulogin.ru/js/ulogin.js');
$category = Category::model()->getAll();
$category = Category::model()->getAll(array('order' => 'ord ASC'));
$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,15 +55,14 @@ 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;
$point->descriptionHtml .= ' #wikipoints';
$og['title'] = $point->name . ' - wikipoints.ru';
$og['description'] = 'http://wikipoints.ru/?point='.$id.' '.$point->descriptionHtml;
$og['title'] = $point->name . ' [wikipoints.ru]';
$og['description'] = $point->descriptionHtml;
$og['site_name'] = 'WikiPoints - '.$res['pointsCount'].' или даже больше поводов не сидеть дома';
$og['type'] = 'article';
$og['url'] = '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

@ -3,13 +3,13 @@
class JsonController extends Controller
{
/**
* Точки
*/
static function actionPoints()
{
$points = Point::model()->getAll();
$categories = Category::model()->getAll(array('asArray' => true));
/**
* Точки
*/
static function actionPoints()
{
$points = Point::model()->getAll();
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$result = array();
@ -60,10 +60,10 @@ class JsonController extends Controller
$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->categoryName = $categories[$point->categoryId]['name'];
$point->categoryName = $categories[$point->categoryId]['name'];
self::renderPartial('json.php', $point->getValues());
} else
@ -72,12 +72,12 @@ class JsonController extends Controller
}
}
/**
* Категории
*/
static function actionCategories()
{
$categories = Category::model()->getAll(array('asArray' => true));
/**
* Категории
*/
static function actionCategories()
{
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
self::renderPartial('json.php', array(
'data' => $categories,
@ -247,8 +247,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);
}
@ -258,8 +257,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
{
@ -272,8 +270,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

@ -15,7 +15,7 @@ class PageController extends Controller
$param['order']='id DESC';
$param['where']=App::getParam('category') ? 'categoryId = '.(int)App::getParam('category') : '';
$points = Point::model()->getAll($param);
$categories = Category::model()->getAll();
$categories = Category::model()->getAll(array('order' => 'ord ASC'));
$result = array();
@ -25,8 +25,8 @@ class PageController extends Controller
$result[$id]['name'] = $point->name;
$result[$id]['lat'] = $point->lat;
$result[$id]['lng'] = $point->lng;
$result[$id]['author'] = $point->authorUser->name;
$result[$id]['categoryId'] = $point->categoryId;
$result[$id]['author'] = $point->authorUser->nick;
$result[$id]['categoryId'] = $point->categoryId;
$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-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('order' => 'ord ASC', 'asArray' => true));
$point->categoryIcon = $categories[$point->categoryId]->icon;
$point->categoryName = $categories[$point->categoryId]->name;

View File

@ -7,67 +7,74 @@
<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($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 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 ($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 ($vars): ?>
<script type="text/javascript">
<?php foreach ($vars as $varName => $var): ?>
var <?= $varName ?> = '<?= $var ?>';
<?php endforeach; ?>
</script>
<?php endif; ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<?php foreach ($vars as $varName => $var): ?>
var <?= $varName ?> = '<?= $var ?>';
<?php endforeach; ?>
</script>
<?php endif; ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<div class="header">
<a href="/"><h1>WikiPoints</h1></a>
</div>
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
<?= self::renderPartial('modals/about.php', array(), true) ?>
<?= self::renderPartial('modals/howToUse.php', array(), true) ?>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter24682772 = new Ya.Metrika({id:24682772,
trackLinks:true});
} catch(e) { }
});
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
<?= self::renderPartial('modals/about.php', array(), true) ?>
<?= self::renderPartial('modals/howToUse.php', array(), true) ?>
<?php if (App::getConfig('metrika')): ?>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function(d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter24682772 = new Ya.Metrika({id: 24682772,
trackLinks: true});
} catch (e) {
}
});
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function() {
n.parentNode.insertBefore(s, n);
};
s.type = "text/javascript";
s.async = true;
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="//mc.yandex.ru/watch/24682772" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else {
f();
}
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="//mc.yandex.ru/watch/24682772" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
<?php endif; ?>
</body>
</html>

View File

@ -31,8 +31,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

@ -1,22 +1,22 @@
.marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6);
background-color: rgba(100, 187, 100, 0.5);
}
.marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6);
background-color: rgba(34, 187, 34, 0.6);
}
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
background-color: rgba(255, 193, 100, 0.5);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
background-color: rgba(255, 193, 31, 0.6);
}
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
background-color: rgba(187, 100, 100, 0.5);
}
.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 */

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});
@ -58,6 +59,7 @@ function init(lat, lng) {
{
$('#addPointId').remove();
$('#addPointForm input:text').val('');
$('#addPointForm textarea').val('');
$("#addPointCategoryId option" ).attr('selected', null);
$('#addPointLat').val(e.latlng.lat);
$('#addPointLng').val(e.latlng.lng);
@ -165,11 +167,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) {
@ -199,14 +200,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 {
@ -259,7 +265,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)
@ -282,7 +288,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);
});
}