From 101dd5832ac886392cafbd7f59c0291c6a61a7eb Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Fri, 18 Sep 2015 16:53:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D1=91=D1=81=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D1=8C=D0=B8=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80,=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BE=D0=BD=D0=B8=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=BA=20=D0=B8=20=D1=82=D0=BE=D1=87=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BE=D1=80=D0=BE=D1=82=D0=BA=D0=BE=D0=B9=20?= =?UTF-8?q?=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ground/classes/Helper.php | 2 +- ground/controllers/ArticleController.php | 54 ++++++++++++++++++++++++ ground/controllers/IndexController.php | 4 +- ground/controllers/PageController.php | 32 +------------- ground/views/article.php | 2 +- ground/views/articles/index.php | 2 +- ground/views/indexTemplate.php | 3 +- ground/views/user/index.php | 2 +- 8 files changed, 63 insertions(+), 38 deletions(-) create mode 100644 ground/controllers/ArticleController.php diff --git a/ground/classes/Helper.php b/ground/classes/Helper.php index fa5795b..7859a6f 100644 --- a/ground/classes/Helper.php +++ b/ground/classes/Helper.php @@ -131,7 +131,7 @@ class Helper $og['description'] = mb_substr($article->text, 0, 99, 'UTF-8') . '…'; $og['site_name'] = App::$defaultTitle; $og['type'] = 'website'; - $og['url'] = 'http://wikipoints.ru/page/article/id/' . $article->id; + $og['url'] = 'http://wikipoints.ru/article/' . $article->id; $og['image'] = $article->getImg('middle'); return $og; diff --git a/ground/controllers/ArticleController.php b/ground/controllers/ArticleController.php new file mode 100644 index 0000000..6bbb75c --- /dev/null +++ b/ground/controllers/ArticleController.php @@ -0,0 +1,54 @@ +getByPK($articleId); + + if ($article->id == NULL or $article->author == 0) { + App::error404(); + } + + App::setConfig('title', $article->title . ' – wikipoints.ru'); + $article->html = Helper::replaceLinks($article->html, 'html'); + $article->html = Helper::replaceImgs($article->html, 'html'); + + $randomPoint = Point::model()->getRandom(); + + if ($article->photoId) { + $photo = ArticlePhotos::model()->getByPK($article->photoId); + $background = '/photos/articles/middle/' . $photo->name; + } else { + $background = $randomPoint->getImg('middle'); + } + + self::render('article.php', array( + 'article' => $article, + 'randomPoint' => $randomPoint, + 'og' => Helper::buildArticleOG($article), + 'background' => $background, +// 'user' => App::$user, + )); + } else { + App::error404(); + } + } +} \ No newline at end of file diff --git a/ground/controllers/IndexController.php b/ground/controllers/IndexController.php index 286d480..07daac7 100644 --- a/ground/controllers/IndexController.php +++ b/ground/controllers/IndexController.php @@ -154,10 +154,10 @@ class IndexController extends Controller $url->addChild('changefreq', "daily"); $url->addChild('priority', "0.9"); - $articles = Article::model()->getAll(array('order' => 'ID DESC', 'asArray' => true)); + $articles = Article::model()->getAll(array('where'=>'`author` != 0', 'order' => 'ID DESC', 'asArray' => true)); foreach ($articles as $article) { $url = $xml->addChild('url'); - $url->addChild('loc', 'http://wikipoints.ru/page/article/id/' . $article['id']); + $url->addChild('loc', 'http://wikipoints.ru/article/' . $article['id']); $url->addChild('lastmod', date("Y-m-d", strtotime('- 5 days'))); $url->addChild('changefreq', "weekly"); $url->addChild('priority', "0.8"); diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index 286dee9..ee0987d 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -86,39 +86,9 @@ 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/pageStyle.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'); - $article->html = Helper::replaceLinks($article->html, 'html'); - $article->html = Helper::replaceImgs($article->html, 'html'); - - self::render('article.php', array( - 'article' => $article, - 'randomPoint' => Point::model()->getRandom(), - 'og' => Helper::buildArticleOG($article), -// 'user' => App::$user, - )); + App::redirect('/article/'.$articleId, 301); } else { App::error404(); } diff --git a/ground/views/article.php b/ground/views/article.php index 41524cd..d501b0c 100644 --- a/ground/views/article.php +++ b/ground/views/article.php @@ -1,4 +1,4 @@ -
+
diff --git a/ground/views/articles/index.php b/ground/views/articles/index.php index 0cb2b58..7b7a5c4 100644 --- a/ground/views/articles/index.php +++ b/ground/views/articles/index.php @@ -11,7 +11,7 @@ Добавить новую статью

- просмотр — #id ?> title ? $article->title : 'НАЗВАНИЕ НЕ ЗАДАНО!' ?>
+ просмотр — #id ?> title ? $article->title : 'НАЗВАНИЕ НЕ ЗАДАНО!' ?>
diff --git a/ground/views/indexTemplate.php b/ground/views/indexTemplate.php index 6195364..a334123 100644 --- a/ground/views/indexTemplate.php +++ b/ground/views/indexTemplate.php @@ -32,7 +32,7 @@ if (App::$user) { ×

Информация

- О проекте
+ О проекте
Как пользоваться
Легенда
Список точек
@@ -108,6 +108,7 @@ if (App::$user) { diff --git a/ground/views/user/index.php b/ground/views/user/index.php index c97c6c1..d500676 100644 --- a/ground/views/user/index.php +++ b/ground/views/user/index.php @@ -13,7 +13,7 @@

Статьи:

- title ?>
+ title ?>
Пока нет статей.