From f3569f5ae4dc7f2a5269a447527ec8cb0b14b29f Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Wed, 3 Jun 2015 23:04:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=20=D0=BF=D0=BE=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=D1=8F=D0=BC=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=BC=20=D0=BE=D0=BA=D0=BD=D0=B5?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ground/controllers/JsonController.php | 22 ++++++++++++++++++++++ ground/models/User.php | 2 +- ground/views/indexTemplate.php | 8 +++++++- ground/views/modals/article.php | 16 ++++++++++++++++ public/js/map.js | 11 +++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 ground/views/modals/article.php diff --git a/ground/controllers/JsonController.php b/ground/controllers/JsonController.php index b1270c7..859e324 100644 --- a/ground/controllers/JsonController.php +++ b/ground/controllers/JsonController.php @@ -406,4 +406,26 @@ class JsonController extends Controller self::renderPartial('json.php', array('query' => $search, 'suggestions' => $results)); } + /** + * Article / K.O. =) + */ + static function actionArticle() + { + $id = (int) App::getParam('id'); + if ($id) + { + $article = Article::model()->getByPK($id); + + if (!$article) { + die; + } +// print_r($article->text); + self::renderPartial('modals/article.php', + array( + 'title' => $article->title, + 'text' => $article->text, + )); + } + } + } diff --git a/ground/models/User.php b/ground/models/User.php index b568342..93eda50 100644 --- a/ground/models/User.php +++ b/ground/models/User.php @@ -6,7 +6,7 @@ class User extends Model { $this->_tableName_ = 'users'; parent::__construct($fromArray); - $this->setRelation('category', 'catogoryId', 'Category', 'id', self::TO_ONE); + $this->setRelation('points', 'id', 'Point', 'id', self::TO_MANY); } static function model() diff --git a/ground/views/indexTemplate.php b/ground/views/indexTemplate.php index 3ab8295..ea75dfe 100644 --- a/ground/views/indexTemplate.php +++ b/ground/views/indexTemplate.php @@ -1,3 +1,9 @@ +getCountByUser(App::$user->id) > 0; + } +?>
@@ -12,7 +18,7 @@ -
+
diff --git a/ground/views/modals/article.php b/ground/views/modals/article.php new file mode 100644 index 0000000..f06cc76 --- /dev/null +++ b/ground/views/modals/article.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/public/js/map.js b/public/js/map.js index 6d13d6d..6411689 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -297,3 +297,14 @@ function setLayer(name) $.cookie('mapLayer', layer); } +function showArticle(id) +{ + $.ajax({ + url: "/json/article/id/" + id, + success: function (data) { + $('#articleModal').modal('hide').remove(); + $('body').append($(data)); + $('#articleModal').modal('show'); + } + }); +}