ADD articles - первая реализация
This commit is contained in:
parent
db6676d2f1
commit
20c00aeb4e
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
class Article extends Model
|
||||
{
|
||||
function __construct($fromArray = array())
|
||||
{
|
||||
$this->_tableName_ = 'articles';
|
||||
parent::__construct($fromArray);
|
||||
$this->setRelation('authorUser', 'author', 'User', 'id', self::TO_ONE);
|
||||
}
|
||||
|
||||
static function model()
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>
|
||||
<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;padding-bottom: 30px;">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1 style="text-align: right;"><?= $article->title ?></h1>
|
||||
<div class="coords-container">
|
||||
Вернуться <a href="/<?= $point->id ?>">на карту</a>.
|
||||
</div>
|
||||
|
||||
<div style="text-align: justify;">
|
||||
<?php
|
||||
print $article->text;
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<a href="/page/point/id/<?= $randomPoint->id ?>" style="float: left; margin: 0 20px 0 0;"><img src="<?= $randomPoint->getImg() ?>" style="width: 200px;"/></a>
|
||||
<h3 style="margin-top: 0;">Это интересно: <?= $randomPoint->name ?></h3>
|
||||
<p>
|
||||
<?= mb_substr($randomPoint->description, 0, 400, 'UTF-8') ?>...
|
||||
<a class="" href="/page/point/id/<?= $randomPoint->id ?>" role="button"><nobr> читать далее »</nobr></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
</head>
|
||||
<body style="padding: 10px 25px; overflow-y: scroll;">
|
||||
<div class="header">
|
||||
<a href="/"><img src="/img/logo_page.png" title="WIKIPOINTS.RU" /></a>
|
||||
<a href="/"><img src="/img/logo.png" title="WIKIPOINTS.RU" /></a>
|
||||
</div>
|
||||
<?= isset($content) && !empty($content) ? $content : 'No content =(' ?>
|
||||
<?= self::renderPartial('modals/about.php', array(), true) ?>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ div.infoCard h3 {text-align: center; margin-top: 0;}
|
|||
div.infoCard img {width: 200px; float: left; margin: 0 10px 5px 0; cursor: pointer;}
|
||||
div.infoCard .photosCount {position: absolute;margin: 3px;color: white;background-color: black;border-radius: 3px;padding: 2px 4px;opacity: 0.5;}
|
||||
div.header {display: block; position: absolute; top: 0px; left: 40px; z-index: 1000; background-color: rgba(255,255,255,0.7); padding: 5px 10px; border-radius: 0 0 5px 5px;}
|
||||
div.header img {height: 99px;}
|
||||
div.header img {height: 89px;}
|
||||
div.add {cursor: pointer;}
|
||||
|
||||
.fotorama {display: inline-block;}
|
||||
|
|
|
|||
Loading…
Reference in New Issue