Множественые изменения в форматировани и добален функционал добавления В ИЗБРАННОЕ
This commit is contained in:
parent
0f97e00cfe
commit
2a253676b4
|
|
@ -165,7 +165,7 @@ abstract class Model
|
|||
$ready[$row[$this->_primaryKey_]] = isset($params['asArray'])&&$params['asArray'] ? $row : new $calledClass($row);
|
||||
}
|
||||
|
||||
return $ready;
|
||||
return (isset($params['limit'])&&$params['limit']==1) ? array_shift($ready) : $ready;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ class IndexController extends Controller
|
|||
if (App::$user && App::$user->id)
|
||||
{
|
||||
$routes = Route::model()->getByAuthor(App::$user->id);
|
||||
self::addVar('user', App::$user->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::addVar('user', '0');
|
||||
}
|
||||
|
||||
self::addVar('isAdmin', (int)(App::$user && App::$user->isAdmin == 1) );
|
||||
|
|
@ -152,4 +157,10 @@ class IndexController extends Controller
|
|||
print($xml->asXML());
|
||||
}
|
||||
|
||||
static function actionTest()
|
||||
{
|
||||
|
||||
var_dump( Favorite::model()->getAllMy() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ class JsonController extends Controller
|
|||
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
||||
$point->categoryName = $categories[$point->categoryId]['name'];
|
||||
$point->photosCount = $photosCount;
|
||||
$point->inFavorites = Favorite::model()->checkIsMy($id);
|
||||
|
||||
self::renderPartial('json.php', $point->getValues());
|
||||
} else
|
||||
|
|
@ -306,4 +307,15 @@ class JsonController extends Controller
|
|||
self::renderPartial('json.php', $coords);
|
||||
}
|
||||
|
||||
static function actionAddRemoveFavorites()
|
||||
{
|
||||
$id = (int) App::getParam('id');
|
||||
if (!$id || !App::$user)
|
||||
{
|
||||
App::error404();
|
||||
}
|
||||
|
||||
self::renderPartial('json.php', boolval(Favorite::addRemove($id)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
class Favorite extends Model
|
||||
{
|
||||
function __construct($fromArray = array())
|
||||
{
|
||||
$this->_tableName_ = 'favorites';
|
||||
parent::__construct($fromArray);
|
||||
$this->setRelation('user', 'userId', 'User', 'id', self::TO_ONE);
|
||||
$this->setRelation('point', 'pointId', 'Point', 'id', self::TO_ONE);
|
||||
}
|
||||
|
||||
static function model()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
public static function addRemove($pointId)
|
||||
{
|
||||
if (!App::$user || !App::$user->id || !$pointId)
|
||||
return false;
|
||||
|
||||
$res = self::model()->getAll(array('where' => '`userId` = '.(int)App::$user->id.' AND `pointId` = '.(int)$pointId, 'limit'=>1));
|
||||
|
||||
if ($res)
|
||||
{
|
||||
return boolval(Favorite::model()->delete($res->id));
|
||||
} else {
|
||||
return Favorite::model()->add(array('userId'=>App::$user->id, 'pointId'=>$pointId));
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllMy()
|
||||
{
|
||||
if (!App::$user || !App::$user->id)
|
||||
return false;
|
||||
|
||||
return $this->getAll(array('where' => '`userId` = '.(int)App::$user->id));
|
||||
}
|
||||
|
||||
public function checkIsMy($pointId)
|
||||
{
|
||||
if (!App::$user || !App::$user->id || !$pointId)
|
||||
return false;
|
||||
|
||||
return boolval($this->getAll(array('where' => '`userId` = '.(int)App::$user->id.' AND `pointId` = '.(int)$pointId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,36 +46,6 @@
|
|||
<?= 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";
|
||||
|
||||
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; ?>
|
||||
<?= self::renderPartial('metrika.php', array(), true) ?>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?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";
|
||||
|
||||
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; ?>
|
||||
|
|
@ -27,6 +27,11 @@ div.add {cursor: pointer;}
|
|||
#addPointModal .extraImage .type.button:hover {background-color: #ddd;}
|
||||
#addPointModal .extraImage .input-group-addon.type.button {border-left: 0px;}
|
||||
|
||||
div.leaflet-popup-content div.control {margin-top: 7px;}
|
||||
div.leaflet-popup-content button span.label {display: none; font-size: 90%; font-weight: normal; color: #333;}
|
||||
div.leaflet-popup-content button:hover {min-width: 150px;}
|
||||
div.leaflet-popup-content button:hover span.label {display: inline;}
|
||||
|
||||
.form-group .error {display: none;}
|
||||
.form-group.has-error .error {display: inline-block;}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 916 B |
Binary file not shown.
|
After Width: | Height: | Size: 595 B |
Binary file not shown.
|
After Width: | Height: | Size: 917 B |
Binary file not shown.
|
After Width: | Height: | Size: 852 B |
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
function loadGif($imgname)
|
||||
{
|
||||
$res = array();
|
||||
$im = @imagecreatefromgif($imgname);
|
||||
|
||||
$b = imagecolorat($im, 0, 0);
|
||||
$w = imagecolorat($im, 3, 3);
|
||||
|
||||
$digits = array(
|
||||
0 => array($b,$b,$b,$w,$b,$b),
|
||||
1 => array($w,$w,$w,$b,$w,$w),
|
||||
2 => array($b,$w,$b,$b,$b,$w),
|
||||
3 => array($b,$w,$b,$b,$w,$b),
|
||||
4 => array($w,$b,$b,$b,$w,$b),
|
||||
5 => array($b,$b,$w,$b,$w,$b),
|
||||
6 => array($b,$b,$w,$b,$b,$b),
|
||||
7 => array($b,$w,$b,$w,$w,$b),
|
||||
8 => array($b,$b,$b,$b,$b,$b),
|
||||
9 => array($b,$b,$b,$b,$w,$b),
|
||||
);
|
||||
|
||||
if($im)
|
||||
{
|
||||
for ($index = 0; $index < 10; $index++) {
|
||||
$block = 0;
|
||||
if ($index >= 3) $block++;
|
||||
if ($index >= 6) $block++;
|
||||
if ($index >= 9) $block++;
|
||||
|
||||
$x = 78 - 5*$index - 2*$block;
|
||||
$y = 72;
|
||||
|
||||
$digit = array(
|
||||
imagecolorat($im, $x+1, $y),
|
||||
imagecolorat($im, $x, $y+1),
|
||||
imagecolorat($im, $x+3, $y+1),
|
||||
imagecolorat($im, $x+2, $y+2),
|
||||
imagecolorat($im, $x, $y+3),
|
||||
imagecolorat($im, $x+3, $y+3),
|
||||
);
|
||||
|
||||
$d = array_search($digit, $digits);
|
||||
|
||||
if ($d !== false) {
|
||||
$res[] = array_search($digit, $digits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode('', array_reverse($res));
|
||||
}
|
||||
|
||||
for ($index = 0; $index <= 2; $index++) {
|
||||
print loadGif('/home/web/poi/public/hit'.$index.'.gif');
|
||||
print '<br/>';
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 855 B |
|
|
@ -104,3 +104,20 @@ function showImage(id)
|
|||
|
||||
$('#imageModal').modal('show');
|
||||
}
|
||||
|
||||
function addRemoveFavorite(id)
|
||||
{
|
||||
if (user != '0')
|
||||
{
|
||||
$.ajax({
|
||||
url: "/json/addRemoveFavorites/id/" + id,
|
||||
success: function(data) {
|
||||
if (data){
|
||||
// Тут переключалку классов звёздочки
|
||||
$('#myFavoritesButton').toggleClass('glyphicon glyphicon-star-empty').toggleClass('glyphicon glyphicon-star');
|
||||
}
|
||||
}});
|
||||
} else {
|
||||
alert('Для выполнения действия необходимо войти.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,9 @@ function init(lat, lng) {
|
|||
}
|
||||
});
|
||||
|
||||
$('.filterSelector').bind('change', function(){filter()});
|
||||
$('.filterSelector').bind('change', function () {
|
||||
filter()
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -110,7 +112,9 @@ function constructPoint(data)
|
|||
|
||||
points[id] = L.marker(
|
||||
[data['lat'], data['lng']], {icon: categories[data['categoryId']], title: data['name'], id: id, categoryId: data['categoryId']}
|
||||
).on('click', function(e){showInfo(e.target.options.id);});
|
||||
).on('click', function (e) {
|
||||
showInfo(e.target.options.id);
|
||||
});
|
||||
|
||||
return points[id];
|
||||
}
|
||||
|
|
@ -171,32 +175,22 @@ function showInfo(id)
|
|||
pointsSources[id] = data;
|
||||
if (typeof (data.images) == 'object')
|
||||
{
|
||||
ph = '<div style="position: relative;">';
|
||||
photos = '<div style="position: relative;">';
|
||||
|
||||
if (data.images.length > 1)
|
||||
ph += '<div class="photosCount"><span class="glyphicon glyphicon-camera"></span> <b>+' + (data.photosCount-1) + '</b></div>';
|
||||
photos += '<div class="photosCount"><span class="glyphicon glyphicon-camera"></span> <b>+' + (data.photosCount - 1) + '</b></div>';
|
||||
|
||||
ph += '<img src="/photos/small/' + data.img + '" onclick="showImage(\''+ id +'\')" />';
|
||||
ph += '</div>';
|
||||
photos += '<img src="/photos/small/' + data.img + '" onclick="showImage(\'' + id + '\')" />';
|
||||
photos += '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
ph = '<img src="' + data.img + '" onclick="showImage(\''+ id +'\')" />';
|
||||
photos = '<img src="' + data.img + '" onclick="showImage(\'' + id + '\')" />';
|
||||
}
|
||||
|
||||
description = '<div class="infoCard">' +
|
||||
'<h3>' + data.name + '</h3>' +
|
||||
ph +
|
||||
'<button type="button" class="btn btn-default btn-xs" onclick="addToRoute(' + id + ')">' +
|
||||
'<span class="glyphicon glyphicon-plus"></span> Добавить в маршрут' +
|
||||
'</button><br/>';
|
||||
|
||||
if (isAdmin == '1')
|
||||
{
|
||||
description = description + '<button type="button" class="btn btn-default btn-xs" onclick="editPoint(' + id + ')">' +
|
||||
'<span class="glyphicon glyphicon-pencil"></span> Редактировать' +
|
||||
'</button><br/>';
|
||||
}
|
||||
photos;
|
||||
|
||||
description = description + data.descriptionHtml;
|
||||
//description = description + ' <a href="/page/point/id/' + id + '" target="blank">Подробнее...</a>';
|
||||
|
|
@ -208,6 +202,18 @@ function showInfo(id)
|
|||
|
||||
description = description + '</div><div class="clear"></div>';
|
||||
|
||||
description = description + '<div class="btn-group control">';
|
||||
description = description + '<button type="button" class="btn btn-default" onclick="addToRoute(' + id + ')"><span class="glyphicon glyphicon-map-marker"></span> <span class="label">В маршрут</span></button>';
|
||||
description = description + '<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> <span class="label">Был здесь</span></button>';
|
||||
description = description + '<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-thumbs-up"></span> <span class="label">Нравится</span></button>';
|
||||
description = description + '<button type="button" class="btn btn-default" onclick="addRemoveFavorite(' + id + ')"><span id="myFavoritesButton" class="glyphicon glyphicon-star' + (data.inFavorites ? '' : '-empty') + ' "></span> <span class="label">Хочу посетить</span></button>';
|
||||
|
||||
if (isAdmin == '1')
|
||||
{
|
||||
description = description + '<button type="button" class="btn btn-default" onclick="editPoint(' + id + ')"><span class="glyphicon glyphicon-pencil"></span> <span class="label">Редактировать</span></button>';
|
||||
}
|
||||
description = description + '</div>';
|
||||
|
||||
marker.options.description = description;
|
||||
marker.bindPopup(marker.options.description, {maxWidth: 500, maxHeight: 300});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue