Первый вариант новой страницы точки
This commit is contained in:
parent
a15c92d99e
commit
1d66404972
|
|
@ -52,10 +52,12 @@ class PageController extends Controller
|
||||||
self::addScript('/js/bootstrap.min.js');
|
self::addScript('/js/bootstrap.min.js');
|
||||||
|
|
||||||
self::addScript('/js/app.js?ver=' . App::getConfig('version'));
|
self::addScript('/js/app.js?ver=' . App::getConfig('version'));
|
||||||
|
self::addScript('/js/fotorama.js');
|
||||||
|
|
||||||
self::addStyle('/css/style.css?ver=' . App::getConfig('version'));
|
self::addStyle('/css/style.css?ver=' . App::getConfig('version'));
|
||||||
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');
|
||||||
|
self::addStyle('/css/fotorama.css');
|
||||||
|
|
||||||
$point = Point::model()->getByPK($id);
|
$point = Point::model()->getByPK($id);
|
||||||
$point->descriptionHtml = nl2br($point->description);
|
$point->descriptionHtml = nl2br($point->description);
|
||||||
|
|
@ -63,11 +65,15 @@ class PageController extends Controller
|
||||||
|
|
||||||
$categories = Category::model()->getAll(array('order' => 'ord ASC', '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'];
|
||||||
|
|
||||||
|
$randomPoint = Point::model()->getRandom();
|
||||||
|
// print_r($randomPoint->name);
|
||||||
|
|
||||||
self::render('point.php', array(
|
self::render('point.php', array(
|
||||||
'point' => $point,
|
'point' => $point,
|
||||||
|
'randomPoint' => $randomPoint,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'photos' => $point->photos,
|
'photos' => $point->photos,
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,33 @@ class Point extends Model
|
||||||
$img = $this->img;
|
$img = $this->img;
|
||||||
if ($img == '')
|
if ($img == '')
|
||||||
{
|
{
|
||||||
$img = array_shift($this->photos);
|
$photos = $this->photos;
|
||||||
$img = '/photos/middle/' . $img->name;
|
$img = array_shift($photos);
|
||||||
|
|
||||||
|
if (!$img)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$img = '/photos/small/'.$img->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRandom()
|
||||||
|
{
|
||||||
|
$res = App::DB()->query("SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `" . $this->_tableName_ . "`")->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$offset = $res['offset'];
|
||||||
|
|
||||||
|
$res = App::DB()->query('SELECT `id` FROM ' . $this->_tableName_ . ' LIMIT ' . $offset . ',1;')->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$pointId = $res['id'];
|
||||||
|
|
||||||
|
return $this->getByPK($pointId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCountByUser($userId)
|
||||||
|
{
|
||||||
|
$res = App::DB()->query('SELECT count(`id`) AS `cnt` FROM ' . $this->_tableName_ . ' WHERE `author` = ' . $userId . ' ;')->fetch(PDO::FETCH_ASSOC);
|
||||||
|
return $res['cnt'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,10 @@ class User extends Model
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPointsCount()
|
||||||
|
{
|
||||||
|
return Point::model()->getCountByUser($this->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,44 +25,9 @@
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body style="padding: 10px 25px; overflow-y: scroll;">
|
<body style="padding: 10px 25px; overflow-y: scroll;">
|
||||||
<div class="header">
|
|
||||||
<h1>WikiPoints</h1>
|
|
||||||
<span class="mainMenu">
|
|
||||||
<a href="/">На карту</a>
|
|
||||||
|
|
|
||||||
<a onclick="$('#aboutModal').modal('show');" href="#">О проекте</a>
|
|
||||||
|
|
|
||||||
<a onclick="$('#howToUseModal').modal('show');" href="#">Как пользоваться</a>
|
|
||||||
|
|
|
||||||
<a onclick="$('#categoriesModal').modal('show');" href="#">Легенда</a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<?= 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) ?>
|
||||||
<!-- Yandex.Metrika counter -->
|
<?= self::renderPartial('metrika.php', array(), true) ?>
|
||||||
<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 -->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -1,33 +1,110 @@
|
||||||
<br/><br/>
|
<div class="row">
|
||||||
<h3><?= $point->name ?></h3>
|
<div class="col-md-2" style="width: 250px!important;">
|
||||||
|
<a href="/"><img src="/img/logo.png" style="width: 198px;"/></a>
|
||||||
|
<br/>
|
||||||
|
<h2>Автор точки</h2>
|
||||||
|
<img src="<?= $point->authorUser->photo ?>" style="max-width: 180px;" />
|
||||||
|
<p><span class="glyphicon glyphicon-user"></span> <?= $point->authorUser->nick ?></p>
|
||||||
|
<p><span class="glyphicon glyphicon-pencil"></span> <?= $point->authorUser->getPointsCount() ?> - создано точек</p>
|
||||||
|
<!-- <p><span class="glyphicon glyphicon-thumbs-up"></span> 10 - рейтинг</p>-->
|
||||||
|
<hr/>
|
||||||
|
<h3><?= $randomPoint->name ?></h3>
|
||||||
|
<p style="text-align: center;"><a href="/page/point/id/41"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a></p>
|
||||||
|
<p>
|
||||||
|
<?= mb_substr($randomPoint->description, 0, 120, 'UTF-8') ?>...
|
||||||
|
<a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr>далее »</nobr></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<h1><?= $point->name ?></h1>
|
||||||
|
|
||||||
Координаты:
|
Координаты:
|
||||||
<nobr>
|
<nobr>
|
||||||
<?= $point->lat > 0 ? 'N' : 'S' ?><?= $point->lat > 0 ? $point->lat : (-1 * $point->lat) ?>°
|
<?= $point->lat > 0 ? 'N' : 'S' ?><?= $point->lat > 0 ? $point->lat : (-1 * $point->lat) ?>°
|
||||||
<?= $point->lng > 0 ? 'E' : 'W' ?><?= $point->lng > 0 ? $point->lng : (-1 * $point->lng) ?>°
|
<?= $point->lng > 0 ? 'E' : 'W' ?><?= $point->lng > 0 ? $point->lng : (-1 * $point->lng) ?>°
|
||||||
</nobr>
|
</nobr>
|
||||||
/
|
/
|
||||||
<nobr>
|
<nobr>
|
||||||
<?= $point->lat > 0 ? 'N' : 'S' ?><?= Coord::dergeeToMinute($point->lat) ?>
|
<?= $point->lat > 0 ? 'N' : 'S' ?><?= Coord::dergeeToMinute($point->lat) ?>
|
||||||
<?= $point->lng > 0 ? 'E' : 'W' ?><?= Coord::dergeeToMinute($point->lng) ?>
|
<?= $point->lng > 0 ? 'E' : 'W' ?><?= Coord::dergeeToMinute($point->lng) ?>
|
||||||
</nobr>
|
</nobr>
|
||||||
/
|
/
|
||||||
<a href="/?point=<?= $point->id ?>">На карте</a>
|
<a href="/?point=<?= $point->id ?>">На карте</a>
|
||||||
|
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<?= $point->descriptionHtml ?>
|
<?php
|
||||||
<br/>
|
preg_match_all("/.*?[.?!](?:\s|$)/s", $point->descriptionHtml, $items);
|
||||||
|
$text = $items[0];
|
||||||
|
if (count($text) > 4)
|
||||||
|
{
|
||||||
|
for ($index = 0; $index < 4; $index++)
|
||||||
|
{
|
||||||
|
print $text[$index];
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
print $point->descriptionHtml;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<?php if ($point->img): ?>
|
<?php if ($photos || $point->img): ?>
|
||||||
<div style="text-align: center">
|
<br/><br/>
|
||||||
<img src="<?= $point->img ?>" style="max-width: 800px;">
|
<table border="0">
|
||||||
</div>
|
<tr>
|
||||||
<?php endif; ?>
|
<td width="33%"></td>
|
||||||
|
<td width="34%">
|
||||||
<?php if ($photos): ?>
|
<div class="fotorama" data-maxwidth="555">
|
||||||
<div style="text-align: center">
|
<?php if ($point->img): ?>
|
||||||
|
<a href="<?= $point->img ?>">
|
||||||
|
<img src="<?= $point->img ?>" />
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($photos): ?>
|
||||||
<?php foreach ($photos as $photo): ?>
|
<?php foreach ($photos as $photo): ?>
|
||||||
<img src="/photos/<?= $photo->name ?>" style="max-width: 800px;">
|
<a href="/photos/middle/<?= $photo->name ?>">
|
||||||
|
<img src="/photos/small/<?= $photo->name ?>">
|
||||||
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
</td>
|
||||||
|
<td width="33%"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (count($text) > 3)
|
||||||
|
{
|
||||||
|
for ($index = $index; $index < count($text); $index++)
|
||||||
|
{
|
||||||
|
print $text[$index] . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<p>
|
||||||
|
[ <span class="glyphicon glyphicon-star"></span> 13 - в закладках ]
|
||||||
|
[ <span class="glyphicon glyphicon-thumbs-up"></span> 120 - нравится ]
|
||||||
|
|
||||||
|
[ <span class="glyphicon glyphicon-star"></span>
|
||||||
|
<span class="glyphicon glyphicon-star"></span>
|
||||||
|
<span class="glyphicon glyphicon-star"></span>
|
||||||
|
<span class="glyphicon glyphicon-star"></span>
|
||||||
|
<span class="glyphicon glyphicon-star-empty"></span> ]
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2" style="width: 250px!important;">
|
||||||
|
<h2>Поблизости:</h2>
|
||||||
|
<p><img src="/photos/small/_03bad.jpg" style="width: 105px;"/> <img src="/photos/small/1_0a464.jpg" style="width: 105px;"/></p>
|
||||||
|
<p><img src="/photos/small/15_165ea.jpg" style="width: 105px;"/> <img src="/photos/small/271_6506d.jpg" style="width: 105px;"/></p>
|
||||||
|
<p><img src="/photos/small/305_337c1.jpg" style="width: 105px;"/> <img src="/photos/small/300_81352.jpg" style="width: 105px;"/></p>
|
||||||
|
<hr/>
|
||||||
|
<h2>Похожие:</h2>
|
||||||
|
<p><img src="/photos/small/41_4cd05.jpg" style="width: 105px;"/> <img src="/photos/small/35_2f786.jpg" style="width: 105px;"/></p>
|
||||||
|
<p><img src="/photos/small/90_3e312.jpg" style="width: 105px;"/> <img src="/photos/small/271_3f479.jpg" style="width: 105px;"/></p>
|
||||||
|
<p><img src="/photos/small/303_85515.jpg" style="width: 105px;"/> <img src="/photos/small/298_206be.jpg" style="width: 105px;"/></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue