diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index 3a41448..e045028 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -52,10 +52,12 @@ class PageController extends Controller self::addScript('/js/bootstrap.min.js'); 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/bootstrap.min.css'); self::addStyle('/css/bootstrap-theme.min.css'); + self::addStyle('/css/fotorama.css'); $point = Point::model()->getByPK($id); $point->descriptionHtml = nl2br($point->description); @@ -63,11 +65,15 @@ class PageController extends Controller $categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true)); - $point->categoryIcon = $categories[$point->categoryId]->icon; - $point->categoryName = $categories[$point->categoryId]->name; + $point->categoryIcon = $categories[$point->categoryId]['icon']; + $point->categoryName = $categories[$point->categoryId]['name']; + + $randomPoint = Point::model()->getRandom(); +// print_r($randomPoint->name); self::render('point.php', array( 'point' => $point, + 'randomPoint' => $randomPoint, 'categories' => $categories, 'photos' => $point->photos, )); diff --git a/ground/models/Point.php b/ground/models/Point.php index 98f2d16..a941300 100644 --- a/ground/models/Point.php +++ b/ground/models/Point.php @@ -21,12 +21,33 @@ class Point extends Model $img = $this->img; if ($img == '') { - $img = array_shift($this->photos); - $img = '/photos/middle/' . $img->name; + $photos = $this->photos; + $img = array_shift($photos); + + if (!$img) + return null; + + $img = '/photos/small/'.$img->name; } 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']; + } } diff --git a/ground/models/User.php b/ground/models/User.php index ab9119e..940cc99 100644 --- a/ground/models/User.php +++ b/ground/models/User.php @@ -30,5 +30,10 @@ class User extends Model return false; } } + + function getPointsCount() + { + return Point::model()->getCountByUser($this->id); + } } diff --git a/ground/views/layoutPage.php b/ground/views/layoutPage.php index 3e5e011..1f5bfb3 100644 --- a/ground/views/layoutPage.php +++ b/ground/views/layoutPage.php @@ -3,66 +3,31 @@ <?= App::getConfig('title') ?> - - - - - + + + + + - - - - - + + + + + - + -
-

WikiPoints

- - На карту - | - О проекте - | - Как пользоваться - | - Легенда - -
- + - - - - - + + \ No newline at end of file diff --git a/ground/views/point.php b/ground/views/point.php index 1cd4753..386f8b9 100644 --- a/ground/views/point.php +++ b/ground/views/point.php @@ -1,33 +1,110 @@ -

-

name ?>

- -Координаты:  - - lat > 0 ? 'N' : 'S' ?>lat > 0 ? $point->lat : (-1 * $point->lat) ?>° - lng > 0 ? 'E' : 'W' ?>lng > 0 ? $point->lng : (-1 * $point->lng) ?>° - -  /   - - lat > 0 ? 'N' : 'S' ?>lat) ?> - lng > 0 ? 'E' : 'W' ?>lng) ?> - -  /   -На карте - -

-descriptionHtml ?> -
- -img): ?> -
- -
- - - -
- - - +
+
+ +
+

Автор точки

+ +

authorUser->nick ?>

+

authorUser->getPointsCount() ?> - создано точек

+ +
+

name ?>

+

+

+ description, 0, 120, 'UTF-8') ?>... + далее » +

- +
+

name ?>

+ + Координаты:  + + lat > 0 ? 'N' : 'S' ?>lat > 0 ? $point->lat : (-1 * $point->lat) ?>° + lng > 0 ? 'E' : 'W' ?>lng > 0 ? $point->lng : (-1 * $point->lng) ?>° + +   /   + + lat > 0 ? 'N' : 'S' ?>lat) ?> + lng > 0 ? 'E' : 'W' ?>lng) ?> + +   /   + На карте + +

+ descriptionHtml, $items); + $text = $items[0]; + if (count($text) > 4) + { + for ($index = 0; $index < 4; $index++) + { + print $text[$index]; + } + } else + { + print $point->descriptionHtml; + } + ?> + + img): ?> +

+ + + + + + +
+
+ img): ?> + + + + + + + + + + + +
+
+

+ + + 3) + { + for ($index = $index; $index < count($text); $index++) + { + print $text[$index] . ' '; + } + } + ?> + +
+

+ [ 13 - в закладках ] + [ 120 - нравится ] + + [ + + + + ] +

+
+
+

Поблизости:

+

+

+

+
+

Похожие:

+

+

+

+
+