* Add feed widget * add feed render * Add CommentPage widget * New theme (#1390) * 调整忽略目录 * add theme * fix theme scss build Co-authored-by: fen <f3nb0x@gmail.com> * s/is_writeable/is_writable/g * New upgrade method * merge new fixes from master * add pgsql ssl mode support (ref #1600) (#1623) * Feat/code refactor (#1626) * remove all magic methods, add type for class properties * refactor codes * fix all * refactor code * fix type * fix all * fix request is method * fix all * fix router * fix get page * fix 1.3.0 upgrade * [feat] support high resolution avatar * fix types in i18n component * Implement Ctrl+S or Command+S for save draft (#1628) * Implement Ctrl+S or Command+S for save draft * rename * add Typecho.savePost * fix upload file size * add new uploader * replace new uploader * fix textarea change * fix preview * refactor post edit * fix issue * fix page edit --------- Co-authored-by: joyqi <joyqi@segmentfault.com> Co-authored-by: joyqi <magike.net@gmail.com> * fix #1632 * Add svg to image types * Feat/tree pages (#1646) * add tree trait * finish category tree trait * support select fields * fix select fields * refactor admin trait * fix draft status * Add new contents type "revision" * minor refactor * add more tree view abstracts * add tree trait to pages * get ready for tree view pages * improve page edit * fix revision * fix slug * add router params delegate * fix params delegate * fix * fix * fix all * fix all * fix tree * fix page link * fix feed * fix page * fix permalink * fix permalink input * fix offset query * Support IDN (#1629) * Support IDN * use js * Optimize code * Optimize code * fix URL script * remove unnecessary use --------- Co-authored-by: joyqi <joyqi@segmentfault.com> * fix input element * fix #1651, close #1653 * Use json instead of serialize (#1624) * Use json instead of serialize * Fix Upgrade code * add tree trait * finish category tree trait * support select fields * fix select fields * refactor admin trait * fix draft status * Add new contents type "revision" * minor refactor * add more tree view abstracts * add tree trait to pages * get ready for tree view pages * improve page edit * fix revision * fix slug * add router params delegate * fix params delegate * fix * fix * fix all * fix all * fix tree * fix page link * fix feed * fix page * fix permalink * fix permalink input * fix offset query * Fix typo * remove proxy methods * remove unnecessary useage --------- Co-authored-by: joyqi <joyqi@segmentfault.com> Co-authored-by: joyqi <magike.net@gmail.com> * Fix Prevent XSS vulnerability in default theme (#1654) * Fix Prevent XSS vulnerability in default theme * Update var/Typecho/Db/Adapter/Pdo.php * fix the getter --------- Co-authored-by: joyqi <joyqi@segmentfault.com> * add throwCallback to widget response * fix: cut down fields when selecting recent posts * fix typo errors * fix typo errors * fix http client cookie * add throw finish * fix theme lang * fix default theme * fix query * add open graph and twitter card support add canonical link * fix canonical link meta * fix theme classic-22 * remove unnecessary scss file when packaging * init plugin signal * improve: remove feather-icon js file * fix: typo * improve: post detail layout * fix tags saving * improve: nav search * fix: theme screenshot * fix: theme page layout * remove php 7.2/7.3 env --------- Co-authored-by: fen <f3nb0x@gmail.com> Co-authored-by: Lu Fei <52o@qq52o.cn>
213 lines
13 KiB
PHP
213 lines
13 KiB
PHP
<?php
|
|
include 'common.php';
|
|
include 'header.php';
|
|
include 'menu.php';
|
|
|
|
$post = \Widget\Contents\Post\Edit::alloc()->prepare();
|
|
?>
|
|
<div class="main">
|
|
<div class="body container">
|
|
<?php include 'page-title.php'; ?>
|
|
<div class="row typecho-page-main typecho-post-area" role="form">
|
|
<form action="<?php $security->index('/action/contents-post-edit'); ?>" method="post" name="write_post">
|
|
<div class="col-mb-12 col-tb-9" role="main">
|
|
<?php if ($post->draft): ?>
|
|
<?php if ($post->draft['cid'] != $post->cid): ?>
|
|
<?php $postModifyDate = new \Typecho\Date($post->draft['modified']); ?>
|
|
<cite
|
|
class="edit-draft-notice"><?php _e('你正在编辑的是保存于 %s 的修订版, 你也可以 <a href="%s">删除它</a>', $postModifyDate->word(),
|
|
$security->getIndex('/action/contents-post-edit?do=deleteDraft&cid=' . $post->cid)); ?></cite>
|
|
<?php else: ?>
|
|
<cite class="edit-draft-notice"><?php _e('当前正在编辑的是未发布的草稿'); ?></cite>
|
|
<?php endif; ?>
|
|
<input name="draft" type="hidden" value="<?php echo $post->draft['cid'] ?>"/>
|
|
<?php endif; ?>
|
|
|
|
<p class="title">
|
|
<label for="title" class="sr-only"><?php _e('标题'); ?></label>
|
|
<input type="text" id="title" name="title" autocomplete="off" value="<?php $post->title(); ?>"
|
|
placeholder="<?php _e('标题'); ?>" class="w-100 text title"/>
|
|
</p>
|
|
<?php $permalink = \Typecho\Common::url($options->routingTable['post']['url'], $options->index);
|
|
[$scheme, $permalink] = explode(':', $permalink, 2);
|
|
$permalink = ltrim($permalink, '/');
|
|
$permalink = preg_replace("/\[([_a-z0-9-]+)[^\]]*\]/i", "{\\1}", $permalink);
|
|
if ($post->have()) {
|
|
$permalink = str_replace([
|
|
'{cid}', '{category}', '{year}', '{month}', '{day}'
|
|
], [
|
|
$post->cid, $post->category, $post->year, $post->month, $post->day
|
|
], $permalink);
|
|
}
|
|
$input = '<input type="text" id="slug" name="slug" autocomplete="off" value="' . htmlspecialchars($post->slug ?? '') . '" class="mono" />';
|
|
?>
|
|
<p class="mono url-slug">
|
|
<label for="slug" class="sr-only"><?php _e('网址缩略名'); ?></label>
|
|
<?php echo preg_replace("/\{slug\}/i", $input, $permalink); ?>
|
|
</p>
|
|
<p>
|
|
<label for="text" class="sr-only"><?php _e('文章内容'); ?></label>
|
|
<textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text"
|
|
name="text" class="w-100 mono"><?php echo htmlspecialchars($post->text); ?></textarea>
|
|
</p>
|
|
|
|
<?php include 'custom-fields.php'; ?>
|
|
|
|
<p class="submit clearfix">
|
|
<span class="left">
|
|
<button type="button" id="btn-cancel-preview" class="btn"><i
|
|
class="i-caret-left"></i> <?php _e('取消预览'); ?></button>
|
|
</span>
|
|
<span class="right">
|
|
<input type="hidden" name="do" value="publish" />
|
|
<input type="hidden" name="cid" value="<?php $post->cid(); ?>"/>
|
|
<button type="button" id="btn-preview" class="btn"><i
|
|
class="i-exlink"></i> <?php _e('预览文章'); ?></button>
|
|
<button type="submit" name="do" value="save" id="btn-save"
|
|
class="btn"><?php _e('保存草稿'); ?></button>
|
|
<button type="submit" name="do" value="publish" class="btn primary"
|
|
id="btn-submit"><?php _e('发布文章'); ?></button>
|
|
<?php if ($options->markdown && (!$post->have() || $post->isMarkdown)): ?>
|
|
<input type="hidden" name="markdown" value="1"/>
|
|
<?php endif; ?>
|
|
</span>
|
|
</p>
|
|
|
|
<?php \Typecho\Plugin::factory('admin/write-post.php')->call('content', $post); ?>
|
|
</div>
|
|
|
|
<div id="edit-secondary" class="col-mb-12 col-tb-3" role="complementary">
|
|
<ul class="typecho-option-tabs clearfix">
|
|
<li class="active w-50"><a href="#tab-advance"><?php _e('选项'); ?></a></li>
|
|
<li class="w-50"><a href="#tab-files" id="tab-files-btn"><?php _e('附件'); ?></a></li>
|
|
</ul>
|
|
|
|
|
|
<div id="tab-advance" class="tab-content">
|
|
<section class="typecho-post-option" role="application">
|
|
<label for="date" class="typecho-label"><?php _e('发布日期'); ?></label>
|
|
<p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off"
|
|
value="<?php $post->have() && $post->created > 0 ? $post->date('Y-m-d H:i') : ''; ?>"/>
|
|
</p>
|
|
</section>
|
|
|
|
<section class="typecho-post-option category-option">
|
|
<label class="typecho-label"><?php _e('分类'); ?></label>
|
|
<?php \Widget\Metas\Category\Rows::alloc()->to($category); ?>
|
|
<ul>
|
|
<?php $categories = $post->categories->toArray('mid'); ?>
|
|
<?php while ($category->next()): ?>
|
|
<li><?php echo str_repeat(' ', $category->levels); ?><input
|
|
type="checkbox" id="category-<?php $category->mid(); ?>"
|
|
value="<?php $category->mid(); ?>" name="category[]"
|
|
<?php if (in_array($category->mid, $categories)): ?>checked="true"<?php endif; ?>/>
|
|
<label
|
|
for="category-<?php $category->mid(); ?>"><?php $category->name(); ?></label>
|
|
</li>
|
|
<?php endwhile; ?>
|
|
</ul>
|
|
</section>
|
|
|
|
<section class="typecho-post-option">
|
|
<label for="token-input-tags" class="typecho-label"><?php _e('标签'); ?></label>
|
|
<p><input id="tags" name="tags" type="text" value="<?php $post->have() ? $post->tags(',', false) : ''; ?>"
|
|
class="w-100 text"/></p>
|
|
</section>
|
|
|
|
<?php \Typecho\Plugin::factory('admin/write-post.php')->call('option', $post); ?>
|
|
|
|
<button type="button" id="advance-panel-btn" class="btn btn-xs"><?php _e('高级选项'); ?> <i
|
|
class="i-caret-down"></i></button>
|
|
<div id="advance-panel">
|
|
<?php if ($user->pass('editor', true)): ?>
|
|
<section class="typecho-post-option visibility-option">
|
|
<label for="visibility" class="typecho-label"><?php _e('公开度'); ?></label>
|
|
<p>
|
|
<select id="visibility" name="visibility">
|
|
<?php if ($user->pass('editor', true)): ?>
|
|
<option
|
|
value="publish"<?php if (($post->status == 'publish' && !$post->password) || !$post->status): ?> selected<?php endif; ?>><?php _e('公开'); ?></option>
|
|
<option
|
|
value="hidden"<?php if ($post->status == 'hidden'): ?> selected<?php endif; ?>><?php _e('隐藏'); ?></option>
|
|
<option
|
|
value="password"<?php if (strlen($post->password ?? '') > 0): ?> selected<?php endif; ?>><?php _e('密码保护'); ?></option>
|
|
<option
|
|
value="private"<?php if ($post->status == 'private'): ?> selected<?php endif; ?>><?php _e('私密'); ?></option>
|
|
<?php endif; ?>
|
|
<option
|
|
value="waiting"<?php if (!$user->pass('editor', true) || $post->status == 'waiting'): ?> selected<?php endif; ?>><?php _e('待审核'); ?></option>
|
|
</select>
|
|
</p>
|
|
<p id="post-password"<?php if (strlen($post->password ?? '') == 0): ?> class="hidden"<?php endif; ?>>
|
|
<label for="protect-pwd" class="sr-only">内容密码</label>
|
|
<input type="text" name="password" id="protect-pwd" class="text-s"
|
|
value="<?php $post->password(); ?>" size="16"
|
|
placeholder="<?php _e('内容密码'); ?>" autocomplete="off"/>
|
|
</p>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<section class="typecho-post-option allow-option">
|
|
<label class="typecho-label"><?php _e('权限控制'); ?></label>
|
|
<ul>
|
|
<li><input id="allowComment" name="allowComment" type="checkbox" value="1"
|
|
<?php if ($post->allow('comment')): ?>checked="true"<?php endif; ?> />
|
|
<label for="allowComment"><?php _e('允许评论'); ?></label></li>
|
|
<li><input id="allowPing" name="allowPing" type="checkbox" value="1"
|
|
<?php if ($post->allow('ping')): ?>checked="true"<?php endif; ?> />
|
|
<label for="allowPing"><?php _e('允许被引用'); ?></label></li>
|
|
<li><input id="allowFeed" name="allowFeed" type="checkbox" value="1"
|
|
<?php if ($post->allow('feed')): ?>checked="true"<?php endif; ?> />
|
|
<label for="allowFeed"><?php _e('允许在聚合中出现'); ?></label></li>
|
|
</ul>
|
|
</section>
|
|
|
|
<section class="typecho-post-option">
|
|
<label for="trackback" class="typecho-label"><?php _e('引用通告'); ?></label>
|
|
<p><textarea id="trackback" class="w-100 mono" name="trackback" rows="2"></textarea></p>
|
|
<p class="description"><?php _e('每一行一个引用地址, 用回车隔开'); ?></p>
|
|
</section>
|
|
|
|
<?php \Typecho\Plugin::factory('admin/write-post.php')->call('advanceOption', $post); ?>
|
|
</div><!-- end #advance-panel -->
|
|
|
|
<?php if ($post->have()): ?>
|
|
<?php $modified = new \Typecho\Date($post->modified); ?>
|
|
<section class="typecho-post-option">
|
|
<p class="description">
|
|
<br>—<br>
|
|
<?php _e('本文由 <a href="%s">%s</a> 撰写',
|
|
\Typecho\Common::url('manage-posts.php?uid=' . $post->author->uid, $options->adminUrl), $post->author->screenName); ?>
|
|
<br>
|
|
<?php _e('最后更新于 %s', $modified->word()); ?>
|
|
</p>
|
|
</section>
|
|
<?php endif; ?>
|
|
</div><!-- end #tab-advance -->
|
|
|
|
<div id="tab-files" class="tab-content hidden">
|
|
<?php include 'file-upload.php'; ?>
|
|
</div><!-- end #tab-files -->
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
include 'copyright.php';
|
|
include 'common-js.php';
|
|
include 'form-js.php';
|
|
include 'write-js.php';
|
|
|
|
\Typecho\Plugin::factory('admin/write-post.php')->trigger($plugged)->call('richEditor', $post);
|
|
if (!$plugged) {
|
|
include 'editor-js.php';
|
|
}
|
|
|
|
include 'file-upload-js.php';
|
|
include 'custom-fields-js.php';
|
|
\Typecho\Plugin::factory('admin/write-post.php')->call('bottom', $post);
|
|
include 'footer.php';
|
|
?>
|