В список моих статей добавлен статус статьи. Доработано сохранение - уже опубликованную статью нельзя отправить в черновики.

This commit is contained in:
Krivchikov Dmitry 2015-10-03 11:33:27 +03:00
parent e1cce75c1d
commit 756e8e6f1e
4 changed files with 20 additions and 8 deletions

View File

@ -92,6 +92,10 @@ class ArticleController extends Controller
App::error404(); App::error404();
} }
if (!$article->id) {
$article->status = 'draft';
}
App::setConfig('title', 'Редактирование статьи ' . $article->title . ' wikipoints.ru'); App::setConfig('title', 'Редактирование статьи ' . $article->title . ' wikipoints.ru');
self::render('articles/edit.php', array( self::render('articles/edit.php', array(
@ -129,6 +133,7 @@ class ArticleController extends Controller
if ($id == 0) { if ($id == 0) {
$article->author = App::$user->id; $article->author = App::$user->id;
$article->status = 'draft';
} }
if (isset($_POST['save']) && $_POST['save'] == 'published') { if (isset($_POST['save']) && $_POST['save'] == 'published') {
@ -136,14 +141,11 @@ class ArticleController extends Controller
$article->pubDate = time(); $article->pubDate = time();
} }
$article->status = 'published'; $article->status = 'published';
} else {
$article->status = 'draft';
} }
$article->title = $title ? $title : 'Без названия'; $article->title = $title ? $title : 'Без названия';
$article->text = $text; $article->text = $text;
$article->html = $html; $article->html = $html;
$article->status = (isset($_POST['save']) && $_POST['save'] == 'published') ? 'published' : 'draft';
$article->photoId = Helper::getFirstImg($text); $article->photoId = Helper::getFirstImg($text);
$article->allowComments = $allowComments; $article->allowComments = $allowComments;
$article->save(); $article->save();

View File

@ -22,8 +22,10 @@
<a href="/user/" class="btn btn-sm btn-danger" onclick="return confirm('Выйти без сохранения изменений?')" title="Выйти без сохранения"><span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span> выйти не сохраняя</a> <a href="/user/" class="btn btn-sm btn-danger" onclick="return confirm('Выйти без сохранения изменений?')" title="Выйти без сохранения"><span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span> выйти не сохраняя</a>
</div> </div>
<div class="btn-group" role="group" aria-label="..."> <div class="btn-group" role="group" aria-label="...">
<button type="submit" class="btn btn-sm btn-default" name="save" value="published" title="Сохранить"><span class="glyphicon glyphicon-floppy-saved"></span> опубликовать</button> <?php if ($article->status == 'draft') : ?>
<button type="submit" id="submitButton" class="btn btn-sm btn-success" name="save" value="draft" title="Сохранить черновик"><span class="glyphicon glyphicon-floppy-disk"></span> сохранить черновик</button> <button type="submit" class="btn btn-sm btn-default" name="save" value="published" title="Сохранить"><span class="glyphicon glyphicon-floppy-saved"></span> сохранить и опубликовать</button>
<?php endif; ?>
<button type="submit" id="submitButton" class="btn btn-sm btn-default" name="save" value="save" title="Сохранить изменения"><span class="glyphicon glyphicon-floppy-disk"></span> сохранить<?= ($article->status == 'draft') ? ' черновик' : '' ?></button>
</div> </div>
<div class="btn-group" role="group" aria-label="..."> <div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default btn-sm" title="Жирый" onclick="markBold()"><b>Ж</b></button> <button type="button" class="btn btn-default btn-sm" title="Жирый" onclick="markBold()"><b>Ж</b></button>

View File

@ -1,4 +1,12 @@
<div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div> <?php
$statuses = array(
'draft' => 'Черновик',
'published' => 'Опублована',
'system' => 'Системная',
'moderation' => 'На модерации',
'del' => 'Удалена',
);
?><div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>
<div class="container darkHeader"> <div class="container darkHeader">
<div class="topDiv"> <div class="topDiv">
Персональный блог пользователя Персональный блог пользователя
@ -32,7 +40,7 @@
<?php endif; ?> <?php endif; ?>
</a> </a>
<div class="pull-right date"><?= date('H:i | d.m.Y',$article->pubDate) ?></div> <div class="pull-right date"><?= date('H:i | d.m.Y',$article->pubDate) ?></div>
<a href="/article/<?= $article->id ?>" target="_blank" class="h"><?= $article->title ?></a> <a href="/article/<?= $article->id ?>" target="_blank" class="h"><?= $article->title ?><?= $article->status != 'published' ? ' - ['.$statuses[$article->status].']' : '' ?></a>
<?= mb_substr(Markdown::getClear(str_replace('"', 'ʺ', $article->text)), 0, 250, 'UTF-8') ?> <?= mb_substr(Markdown::getClear(str_replace('"', 'ʺ', $article->text)), 0, 250, 'UTF-8') ?>
<?php if ($imAuthor) : ?> <?php if ($imAuthor) : ?>
<br/> <br/>

View File

@ -100,7 +100,7 @@ function markdown()
$('#articleText').keyup(function () { $('#articleText').keyup(function () {
clearTimeout(monitorTimeout); clearTimeout(monitorTimeout);
monitorTimeout = setTimeout(function () { monitorTimeout = setTimeout(function () {
$('#submitButton').addClass('btn-info'); $('#submitButton').removeClass('btn-default').addClass('btn-info');
markdown(); markdown();
}, 200); }, 200);
}).keydown(function () { }).keydown(function () {