Перенёс статьи в отдельный контроллер, теперь они открываются как и точки по короткой ссылке
This commit is contained in:
parent
1a2b5f3d4c
commit
101dd5832a
|
|
@ -131,7 +131,7 @@ class Helper
|
||||||
$og['description'] = mb_substr($article->text, 0, 99, 'UTF-8') . '…';
|
$og['description'] = mb_substr($article->text, 0, 99, 'UTF-8') . '…';
|
||||||
$og['site_name'] = App::$defaultTitle;
|
$og['site_name'] = App::$defaultTitle;
|
||||||
$og['type'] = 'website';
|
$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');
|
$og['image'] = $article->getImg('middle');
|
||||||
|
|
||||||
return $og;
|
return $og;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ArticleController extends Controller
|
||||||
|
{
|
||||||
|
static function actionIndex()
|
||||||
|
{
|
||||||
|
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 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -154,10 +154,10 @@ class IndexController extends Controller
|
||||||
$url->addChild('changefreq', "daily");
|
$url->addChild('changefreq', "daily");
|
||||||
$url->addChild('priority', "0.9");
|
$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) {
|
foreach ($articles as $article) {
|
||||||
$url = $xml->addChild('url');
|
$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('lastmod', date("Y-m-d", strtotime('- 5 days')));
|
||||||
$url->addChild('changefreq', "weekly");
|
$url->addChild('changefreq', "weekly");
|
||||||
$url->addChild('priority', "0.8");
|
$url->addChild('priority', "0.8");
|
||||||
|
|
|
||||||
|
|
@ -86,39 +86,9 @@ class PageController extends Controller
|
||||||
|
|
||||||
static function actionArticle()
|
static function actionArticle()
|
||||||
{
|
{
|
||||||
self::$layout = 'layoutPage.php';
|
|
||||||
|
|
||||||
$articleId = (int) App::getParam('id');
|
$articleId = (int) App::getParam('id');
|
||||||
if ($articleId) {
|
if ($articleId) {
|
||||||
self::addScript('/js/jquery-2.1.0.min.js');
|
App::redirect('/article/'.$articleId, 301);
|
||||||
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,
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
App::error404();
|
App::error404();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>
|
<div id="pageSmoothBackground" style="background-image: url(<?= $background ?>);"></div>
|
||||||
<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;padding-bottom: 30px;">
|
<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;padding-bottom: 30px;">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<a href="/articles/edit/id/0" class="btn btn-default" title="Добавить новую статью"><span class="glyphicon glyphicon-plus"></span> Добавить новую статью</a><br/>
|
<a href="/articles/edit/id/0" class="btn btn-default" title="Добавить новую статью"><span class="glyphicon glyphicon-plus"></span> Добавить новую статью</a><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php foreach ($articles as $article): ?>
|
<?php foreach ($articles as $article): ?>
|
||||||
<a href="/page/article/id/<?= $article->id ?>" target="_blank"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> просмотр</a> — <a href="/articles/edit/id/<?= $article->id ?>">#<?= $article->id ?> <?= $article->title ? $article->title : 'НАЗВАНИЕ НЕ ЗАДАНО!' ?></a><br/>
|
<a href="/article/<?= $article->id ?>" target="_blank"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> просмотр</a> — <a href="/articles/edit/id/<?= $article->id ?>">#<?= $article->id ?> <?= $article->title ? $article->title : 'НАЗВАНИЕ НЕ ЗАДАНО!' ?></a><br/>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ if (App::$user) {
|
||||||
<span id="boxClose" onclick="closeBox();">×</span>
|
<span id="boxClose" onclick="closeBox();">×</span>
|
||||||
<div id="boxInfo">
|
<div id="boxInfo">
|
||||||
<h3>Информация</h3>
|
<h3>Информация</h3>
|
||||||
<a href="/page/article/id/1">О проекте</a><br/>
|
<a href="/article/1">О проекте</a><br/>
|
||||||
<a onclick="showArticle(2);" href="#">Как пользоваться</a><br/>
|
<a onclick="showArticle(2);" href="#">Как пользоваться</a><br/>
|
||||||
<a onclick="$('#categoriesModal').modal('show');" href="#">Легенда</a><br/>
|
<a onclick="$('#categoriesModal').modal('show');" href="#">Легенда</a><br/>
|
||||||
<a href="/page/points">Список точек</a><br/>
|
<a href="/page/points">Список точек</a><br/>
|
||||||
|
|
@ -108,6 +108,7 @@ if (App::$user) {
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div id="boxUser">
|
<div id="boxUser">
|
||||||
<h3>Профиль</h3>
|
<h3>Профиль</h3>
|
||||||
|
<a href="/user/">Информация</a><br/><br/>
|
||||||
<a class="btn btn-default" type="button" href="/index/logout"><span class="glyphicon glyphicon-ban-circle"></span> Выйти</a>
|
<a class="btn btn-default" type="button" href="/index/logout"><span class="glyphicon glyphicon-ban-circle"></span> Выйти</a>
|
||||||
<hr/>
|
<hr/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
<h2>Статьи: </h2>
|
<h2>Статьи: </h2>
|
||||||
<?php if ($articles): foreach ($articles as $article): ?>
|
<?php if ($articles): foreach ($articles as $article): ?>
|
||||||
<b><a href="/page/article/id/<?= $article->id ?>" target="_blank"><?= $article->title ?></a></b><br/>
|
<b><a href="/article/<?= $article->id ?>" target="_blank"><?= $article->title ?></a></b><br/>
|
||||||
<?php endforeach;
|
<?php endforeach;
|
||||||
else: ?>
|
else: ?>
|
||||||
Пока нет статей.
|
Пока нет статей.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue