В список моих статей добавлен статус статьи. Доработано сохранение - уже опубликованную статью нельзя отправить в черновики.
This commit is contained in:
parent
e1cce75c1d
commit
756e8e6f1e
|
|
@ -92,6 +92,10 @@ class ArticleController extends Controller
|
|||
App::error404();
|
||||
}
|
||||
|
||||
if (!$article->id) {
|
||||
$article->status = 'draft';
|
||||
}
|
||||
|
||||
App::setConfig('title', 'Редактирование статьи – ' . $article->title . ' – wikipoints.ru');
|
||||
|
||||
self::render('articles/edit.php', array(
|
||||
|
|
@ -129,6 +133,7 @@ class ArticleController extends Controller
|
|||
|
||||
if ($id == 0) {
|
||||
$article->author = App::$user->id;
|
||||
$article->status = 'draft';
|
||||
}
|
||||
|
||||
if (isset($_POST['save']) && $_POST['save'] == 'published') {
|
||||
|
|
@ -136,14 +141,11 @@ class ArticleController extends Controller
|
|||
$article->pubDate = time();
|
||||
}
|
||||
$article->status = 'published';
|
||||
} else {
|
||||
$article->status = 'draft';
|
||||
}
|
||||
|
||||
$article->title = $title ? $title : 'Без названия';
|
||||
$article->text = $text;
|
||||
$article->html = $html;
|
||||
$article->status = (isset($_POST['save']) && $_POST['save'] == 'published') ? 'published' : 'draft';
|
||||
$article->photoId = Helper::getFirstImg($text);
|
||||
$article->allowComments = $allowComments;
|
||||
$article->save();
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
</div>
|
||||
<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>
|
||||
<button type="submit" id="submitButton" class="btn btn-sm btn-success" name="save" value="draft" title="Сохранить черновик"><span class="glyphicon glyphicon-floppy-disk"></span> сохранить черновик</button>
|
||||
<?php if ($article->status == 'draft') : ?>
|
||||
<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 class="btn-group" role="group" aria-label="...">
|
||||
<button type="button" class="btn btn-default btn-sm" title="Жирый" onclick="markBold()"><b>Ж</b></button>
|
||||
|
|
|
|||
|
|
@ -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="topDiv">
|
||||
Персональный блог пользователя
|
||||
|
|
@ -32,7 +40,7 @@
|
|||
<?php endif; ?>
|
||||
</a>
|
||||
<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') ?>…
|
||||
<?php if ($imAuthor) : ?>
|
||||
<br/>
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ function markdown()
|
|||
$('#articleText').keyup(function () {
|
||||
clearTimeout(monitorTimeout);
|
||||
monitorTimeout = setTimeout(function () {
|
||||
$('#submitButton').addClass('btn-info');
|
||||
$('#submitButton').removeClass('btn-default').addClass('btn-info');
|
||||
markdown();
|
||||
}, 200);
|
||||
}).keydown(function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue