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 @@ -
+