diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index 33008fa..29d7c79 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -120,6 +120,46 @@ class PageController extends Controller } } + static function actionArticle() + { + self::$layout = 'layoutPage.php'; + + $articleId = (int) App::getParam('id'); + if ($articleId) + { + self::addScript('/js/jquery-2.1.0.min.js'); + self::addScript('/js/jquery-ui-1.10.4.custom.min.js'); + self::addScript('/js/bootstrap.min.js'); + + self::addScript('/js/app.js?ver=' . App::getConfig('version')); + self::addScript('http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/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('http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.3/fotorama.css'); + + $article = Article::model()->getByPK($articleId); + + if ($article->id == NULL) + { + App::error404(); + } + + App::setConfig('title', $article->title. ' - wikipoints.ru'); + + self::render('article.php', array( + 'article' => $article, + 'randomPoint' => Point::model()->getRandom(), +// 'og' => Helper::buildOG($point), +// 'user' => App::$user, + )); + } else + { + App::error404(); + } + } + static function action404($message) { self::renderPartial('error404.php', array( diff --git a/ground/models/Article.php b/ground/models/Article.php new file mode 100644 index 0000000..a95aedf --- /dev/null +++ b/ground/models/Article.php @@ -0,0 +1,18 @@ +_tableName_ = 'articles'; + parent::__construct($fromArray); + $this->setRelation('authorUser', 'author', 'User', 'id', self::TO_ONE); + } + + static function model() + { + return new self(); + } + +} + diff --git a/ground/views/article.php b/ground/views/article.php new file mode 100644 index 0000000..733e1bf --- /dev/null +++ b/ground/views/article.php @@ -0,0 +1,29 @@ +
+
+ = mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>...
+