mirror of
https://github.com/typecho/typecho.git
synced 2025-04-14 06:41:53 +02:00
fix options
This commit is contained in:
parent
ecd21c2557
commit
7bd37f7d8c
@ -1,10 +1,12 @@
|
||||
<?php if(!defined('__TYPECHO_ADMIN__')) exit; ?>
|
||||
<?php if (!defined('__TYPECHO_ADMIN__')) exit; ?>
|
||||
<?php
|
||||
$fields = isset($post) ? $post->getFieldItems() : $page->getFieldItems();
|
||||
$defaultFields = isset($post) ? $post->getDefaultFieldItems() : $page->getDefaultFieldItems();
|
||||
?>
|
||||
<section id="custom-field" class="typecho-post-option<?php if (empty($defaultFields) && empty($fields)): ?> fold<?php endif; ?>">
|
||||
<label id="custom-field-expand" class="typecho-label"><a href="##"><i class="i-caret-right"></i> <?php _e('自定义字段'); ?></a></label>
|
||||
<section id="custom-field"
|
||||
class="typecho-post-option<?php if (empty($defaultFields) && empty($fields)): ?> fold<?php endif; ?>">
|
||||
<label id="custom-field-expand" class="typecho-label"><a href="##"><i
|
||||
class="i-caret-right"></i> <?php _e('自定义字段'); ?></a></label>
|
||||
<table class="typecho-list-table mono">
|
||||
<colgroup>
|
||||
<col width="25%"/>
|
||||
@ -13,7 +15,7 @@ $defaultFields = isset($post) ? $post->getDefaultFieldItems() : $page->getDefaul
|
||||
<col width="10%"/>
|
||||
</colgroup>
|
||||
<?php foreach ($defaultFields as $field): ?>
|
||||
<?php list ($label, $input) = $field; ?>
|
||||
<?php [$label, $input] = $field; ?>
|
||||
<tr>
|
||||
<td><?php $label->render(); ?></td>
|
||||
<td colspan="3"><?php $input->render(); ?></td>
|
||||
@ -23,19 +25,24 @@ $defaultFields = isset($post) ? $post->getDefaultFieldItems() : $page->getDefaul
|
||||
<tr>
|
||||
<td>
|
||||
<label for="fieldname" class="sr-only"><?php _e('字段名称'); ?></label>
|
||||
<input type="text" name="fieldNames[]" value="<?php echo htmlspecialchars($field['name']); ?>" id="fieldname" class="text-s w-100">
|
||||
<input type="text" name="fieldNames[]" value="<?php echo htmlspecialchars($field['name']); ?>"
|
||||
id="fieldname" class="text-s w-100">
|
||||
</td>
|
||||
<td>
|
||||
<label for="fieldtype" class="sr-only"><?php _e('字段类型'); ?></label>
|
||||
<select name="fieldTypes[]" id="fieldtype">
|
||||
<option value="str"<?php if ('str' == $field['type']): ?> selected<?php endif; ?>><?php _e('字符'); ?></option>
|
||||
<option value="int"<?php if ('int' == $field['type']): ?> selected<?php endif; ?>><?php _e('整数'); ?></option>
|
||||
<option value="float"<?php if ('float' == $field['type']): ?> selected<?php endif; ?>><?php _e('小数'); ?></option>
|
||||
<option
|
||||
value="str"<?php if ('str' == $field['type']): ?> selected<?php endif; ?>><?php _e('字符'); ?></option>
|
||||
<option
|
||||
value="int"<?php if ('int' == $field['type']): ?> selected<?php endif; ?>><?php _e('整数'); ?></option>
|
||||
<option
|
||||
value="float"<?php if ('float' == $field['type']): ?> selected<?php endif; ?>><?php _e('小数'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label for="fieldvalue" class="sr-only"><?php _e('字段值'); ?></label>
|
||||
<textarea name="fieldValues[]" id="fieldvalue" class="text-s w-100" rows="2"><?php echo htmlspecialchars($field[$field['type'] . '_value']); ?></textarea>
|
||||
<textarea name="fieldValues[]" id="fieldvalue" class="text-s w-100"
|
||||
rows="2"><?php echo htmlspecialchars($field[$field['type'] . '_value']); ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs"><?php _e('删除'); ?></button>
|
||||
@ -46,7 +53,8 @@ $defaultFields = isset($post) ? $post->getDefaultFieldItems() : $page->getDefaul
|
||||
<tr>
|
||||
<td>
|
||||
<label for="fieldname" class="sr-only"><?php _e('字段名称'); ?></label>
|
||||
<input type="text" name="fieldNames[]" placeholder="<?php _e('字段名称'); ?>" id="fieldname" class="text-s w-100">
|
||||
<input type="text" name="fieldNames[]" placeholder="<?php _e('字段名称'); ?>" id="fieldname"
|
||||
class="text-s w-100">
|
||||
</td>
|
||||
<td>
|
||||
<label for="fieldtype" class="sr-only"><?php _e('字段类型'); ?></label>
|
||||
@ -58,7 +66,8 @@ $defaultFields = isset($post) ? $post->getDefaultFieldItems() : $page->getDefaul
|
||||
</td>
|
||||
<td>
|
||||
<label for="fieldvalue" class="sr-only"><?php _e('字段值'); ?></label>
|
||||
<textarea name="fieldValues[]" placeholder="<?php _e('字段值'); ?>" id="fieldvalue" class="text-s w-100" rows="2"></textarea>
|
||||
<textarea name="fieldValues[]" placeholder="<?php _e('字段值'); ?>" id="fieldvalue"
|
||||
class="text-s w-100" rows="2"></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-xs"><?php _e('删除'); ?></button>
|
||||
|
@ -8,6 +8,6 @@ if (!isset($panelTable['file']) || !in_array(urlencode($panel), $panelTable['fil
|
||||
throw new \Typecho\Plugin\Exception(_t('页面不存在'), 404);
|
||||
}
|
||||
|
||||
list ($pluginName, $file) = explode('/', trim($panel, '/'), 2);
|
||||
[$pluginName, $file] = explode('/', trim($panel, '/'), 2);
|
||||
|
||||
require_once $options->pluginDir($pluginName) . '/' . $panel;
|
||||
|
@ -13,20 +13,22 @@ include 'menu.php';
|
||||
<?php if ($page->draft): ?>
|
||||
<?php if ($page->draft['cid'] != $page->cid): ?>
|
||||
<?php $pageModifyDate = new \Typecho\Date($page->draft['modified']); ?>
|
||||
<cite class="edit-draft-notice"><?php _e('当前正在编辑的是保存于%s的草稿, 你可以<a href="%s">删除它</a>', $pageModifyDate->word(),
|
||||
<cite
|
||||
class="edit-draft-notice"><?php _e('当前正在编辑的是保存于%s的草稿, 你可以<a href="%s">删除它</a>', $pageModifyDate->word(),
|
||||
$security->getIndex('/action/contents-page-edit?do=deleteDraft&cid=' . $page->cid)); ?></cite>
|
||||
<?php else: ?>
|
||||
<cite class="edit-draft-notice"><?php _e('当前正在编辑的是未发布的草稿'); ?></cite>
|
||||
<?php endif; ?>
|
||||
<input name="draft" type="hidden" value="<?php echo $page->draft['cid'] ?>" />
|
||||
<input name="draft" type="hidden" value="<?php echo $page->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 $page->title(); ?>" placeholder="<?php _e('标题'); ?>" class="w-100 text title" />
|
||||
<input type="text" id="title" name="title" autocomplete="off" value="<?php $page->title(); ?>"
|
||||
placeholder="<?php _e('标题'); ?>" class="w-100 text title"/>
|
||||
</p>
|
||||
<?php $permalink = \Typecho\Common::url($options->routingTable['page']['url'], $options->index);
|
||||
list ($scheme, $permalink) = explode(':', $permalink, 2);
|
||||
[$scheme, $permalink] = explode(':', $permalink, 2);
|
||||
$permalink = ltrim($permalink, '/');
|
||||
$permalink = preg_replace("/\[([_a-z0-9-]+)[^\]]*\]/i", "{\\1}", $permalink);
|
||||
if ($page->have()) {
|
||||
@ -40,25 +42,30 @@ include 'menu.php';
|
||||
</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($page->text); ?></textarea>
|
||||
<textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text"
|
||||
name="text" class="w-100 mono"><?php echo htmlspecialchars($page->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>
|
||||
<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="cid" value="<?php $page->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>
|
||||
<input type="hidden" name="cid" value="<?php $page->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 && (!$page->have() || $page->isMarkdown)): ?>
|
||||
<input type="hidden" name="markdown" value="1" />
|
||||
<input type="hidden" name="markdown" value="1"/>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
|
||||
<?php \Typecho\Plugin::factory('admin/write-page.php')->content($page); ?>
|
||||
</div>
|
||||
<div id="edit-secondary" class="col-mb-12 col-tb-3" role="complementary">
|
||||
@ -68,68 +75,80 @@ include 'menu.php';
|
||||
</ul>
|
||||
|
||||
<div id="tab-advance" class="tab-content">
|
||||
<section class="typecho-post-option" role="application">
|
||||
<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 $page->have() && $page->created > 0 ? $page->date('Y-m-d H:i') : ''; ?>" /></p>
|
||||
<p><input class="typecho-date w-100" type="text" name="date" id="date" autocomplete="off"
|
||||
value="<?php $page->have() && $page->created > 0 ? $page->date('Y-m-d H:i') : ''; ?>"/>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="typecho-post-option">
|
||||
<label for="order" class="typecho-label"><?php _e('页面顺序'); ?></label>
|
||||
<p><input type="text" id="order" name="order" value="<?php $page->order(); ?>" class="w-100" /></p>
|
||||
<p><input type="text" id="order" name="order" value="<?php $page->order(); ?>"
|
||||
class="w-100"/></p>
|
||||
<p class="description"><?php _e('为你的自定义页面设定一个序列值以后, 能够使得它们按此值从小到大排列'); ?></p>
|
||||
</section>
|
||||
|
||||
<section class="typecho-post-option">
|
||||
<section class="typecho-post-option">
|
||||
<label for="template" class="typecho-label"><?php _e('自定义模板'); ?></label>
|
||||
<p>
|
||||
<select name="template" id="template">
|
||||
<option value=""><?php _e('不选择'); ?></option>
|
||||
<?php $templates = $page->getTemplates(); foreach ($templates as $template => $name): ?>
|
||||
<option value="<?php echo $template; ?>"<?php if($template == $page->template): ?> selected="true"<?php endif; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</p>
|
||||
<p class="description"><?php _e('如果你为此页面选择了一个自定义模板, 系统将按照你选择的模板文件展现它'); ?></p>
|
||||
<p>
|
||||
<select name="template" id="template">
|
||||
<option value=""><?php _e('不选择'); ?></option>
|
||||
<?php $templates = $page->getTemplates();
|
||||
foreach ($templates as $template => $name): ?>
|
||||
<option
|
||||
value="<?php echo $template; ?>"<?php if ($template == $page->template): ?> selected="true"<?php endif; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</p>
|
||||
<p class="description"><?php _e('如果你为此页面选择了一个自定义模板, 系统将按照你选择的模板文件展现它'); ?></p>
|
||||
</section>
|
||||
|
||||
<?php \Typecho\Plugin::factory('admin/write-page.php')->option($page); ?>
|
||||
|
||||
<button type="button" id="advance-panel-btn" class="btn btn-xs"><?php _e('高级选项'); ?> <i class="i-caret-down"></i></button>
|
||||
<button type="button" id="advance-panel-btn" class="btn btn-xs"><?php _e('高级选项'); ?> <i
|
||||
class="i-caret-down"></i></button>
|
||||
<div id="advance-panel">
|
||||
<section class="typecho-post-option visibility-option">
|
||||
<label for="visibility" class="typecho-label"><?php _e('公开度'); ?></label>
|
||||
<p>
|
||||
<select id="visibility" name="visibility">
|
||||
<option value="publish"<?php if ($page->status == 'publish' || !$page->status): ?> selected<?php endif; ?>><?php _e('公开'); ?></option>
|
||||
<option value="hidden"<?php if ($page->status == 'hidden'): ?> selected<?php endif; ?>><?php _e('隐藏'); ?></option>
|
||||
</select>
|
||||
<select id="visibility" name="visibility">
|
||||
<option
|
||||
value="publish"<?php if ($page->status == 'publish' || !$page->status): ?> selected<?php endif; ?>><?php _e('公开'); ?></option>
|
||||
<option
|
||||
value="hidden"<?php if ($page->status == 'hidden'): ?> selected<?php endif; ?>><?php _e('隐藏'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<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($page->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($page->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($page->allow('feed')): ?>checked="true"<?php endif; ?> />
|
||||
<label for="allowFeed"><?php _e('允许在聚合中出现'); ?></label></li>
|
||||
<li><input id="allowComment" name="allowComment" type="checkbox" value="1"
|
||||
<?php if ($page->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 ($page->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 ($page->allow('feed')): ?>checked="true"<?php endif; ?> />
|
||||
<label for="allowFeed"><?php _e('允许在聚合中出现'); ?></label></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
<?php \Typecho\Plugin::factory('admin/write-page.php')->advanceOption($page); ?>
|
||||
</div>
|
||||
<?php if($page->have()): ?>
|
||||
<?php $modified = new \Typecho\Date($page->modified); ?>
|
||||
<section class="typecho-post-option">
|
||||
<p class="description">
|
||||
<br>—<br>
|
||||
<?php _e('本页面由 <a href="%s">%s</a> 创建',
|
||||
\Typecho\Common::url('manage-pages.php?uid=' . $page->author->uid, $options->adminUrl), $page->author->screenName); ?><br>
|
||||
<?php _e('最后更新于 %s', $modified->word()); ?>
|
||||
</p>
|
||||
</section>
|
||||
<?php if ($page->have()): ?>
|
||||
<?php $modified = new \Typecho\Date($page->modified); ?>
|
||||
<section class="typecho-post-option">
|
||||
<p class="description">
|
||||
<br>—<br>
|
||||
<?php _e('本页面由 <a href="%s">%s</a> 创建',
|
||||
\Typecho\Common::url('manage-pages.php?uid=' . $page->author->uid, $options->adminUrl), $page->author->screenName); ?>
|
||||
<br>
|
||||
<?php _e('最后更新于 %s', $modified->word()); ?>
|
||||
</p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div><!-- end #tab-advance -->
|
||||
|
||||
|
@ -13,28 +13,30 @@ include 'menu.php';
|
||||
<?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(),
|
||||
<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'] ?>" />
|
||||
<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" />
|
||||
<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);
|
||||
list ($scheme, $permalink) = explode(':', $permalink, 2);
|
||||
[$scheme, $permalink] = explode(':', $permalink, 2);
|
||||
$permalink = ltrim($permalink, '/');
|
||||
$permalink = preg_replace("/\[([_a-z0-9-]+)[^\]]*\]/i", "{\\1}", $permalink);
|
||||
if ($post->have()) {
|
||||
$permalink = str_replace(array(
|
||||
$permalink = str_replace([
|
||||
'{cid}', '{category}', '{year}', '{month}', '{day}'
|
||||
), array(
|
||||
], [
|
||||
$post->cid, $post->category, $post->year, $post->month, $post->day
|
||||
), $permalink);
|
||||
], $permalink);
|
||||
}
|
||||
$input = '<input type="text" id="slug" name="slug" autocomplete="off" value="' . htmlspecialchars($post->slug) . '" class="mono" />';
|
||||
?>
|
||||
@ -44,22 +46,27 @@ include 'menu.php';
|
||||
</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>
|
||||
<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>
|
||||
<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="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>
|
||||
<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" />
|
||||
<input type="hidden" name="markdown" value="1"/>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</p>
|
||||
@ -77,7 +84,9 @@ include 'menu.php';
|
||||
<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>
|
||||
<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">
|
||||
@ -88,58 +97,75 @@ include 'menu.php';
|
||||
if ($post->have()) {
|
||||
$categories = array_column($post->categories, 'mid');
|
||||
} else {
|
||||
$categories = array();
|
||||
$categories = [];
|
||||
}
|
||||
?>
|
||||
<?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 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->tags(',', false); ?>" class="w-100 text" /></p>
|
||||
<p><input id="tags" name="tags" type="text" value="<?php $post->tags(',', false); ?>"
|
||||
class="w-100 text"/></p>
|
||||
</section>
|
||||
|
||||
<?php \Typecho\Plugin::factory('admin/write-post.php')->option($post); ?>
|
||||
|
||||
<button type="button" id="advance-panel-btn" class="btn btn-xs"><?php _e('高级选项'); ?> <i class="i-caret-down"></i></button>
|
||||
<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 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>
|
||||
<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>
|
||||
@ -149,16 +175,17 @@ include 'menu.php';
|
||||
<?php \Typecho\Plugin::factory('admin/write-post.php')->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 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 -->
|
||||
|
||||
|
@ -4,10 +4,11 @@ $langs = [];
|
||||
|
||||
/**
|
||||
* output lang
|
||||
*
|
||||
*
|
||||
* @param string $str
|
||||
*/
|
||||
function output_lang($str) {
|
||||
function output_lang(string $str)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$key = md5($str);
|
||||
@ -19,19 +20,20 @@ function output_lang($str) {
|
||||
|
||||
/**
|
||||
* get all files
|
||||
*
|
||||
*
|
||||
* @param string $dir
|
||||
* @param string $pattern
|
||||
* @return array
|
||||
*/
|
||||
function all_files($dir, $pattern = '*') {
|
||||
$result = array();
|
||||
function all_files(string $dir, string $pattern = '*'): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$items = glob($dir . '/' . $pattern, GLOB_BRACE);
|
||||
foreach ($items as $item) {
|
||||
if (is_file($item)) {
|
||||
$result[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items = glob($dir . '/*', GLOB_ONLYDIR);
|
||||
@ -46,11 +48,12 @@ function all_files($dir, $pattern = '*') {
|
||||
|
||||
/**
|
||||
* get msgid
|
||||
*
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
function get_msgid($value) {
|
||||
function get_msgid(string $value): string
|
||||
{
|
||||
if ($value[0] == '"') {
|
||||
return $value;
|
||||
} else {
|
||||
@ -61,22 +64,22 @@ function get_msgid($value) {
|
||||
|
||||
/**
|
||||
* get pot from file
|
||||
*
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
function get_pot($file) {
|
||||
function get_pot(string $file)
|
||||
{
|
||||
$source = file_get_contents($file);
|
||||
$matched = null;
|
||||
$plural = [];
|
||||
|
||||
foreach (token_get_all($source) as $token) {
|
||||
if (is_array($token)) {
|
||||
list ($type, $value) = $token;
|
||||
[$type, $value] = $token;
|
||||
|
||||
if ($type == T_STRING && in_array($value, ['_t', '_e', '_n'])) {
|
||||
$matched = $value;
|
||||
} else if ($type == T_CONSTANT_ENCAPSED_STRING && $matched) {
|
||||
} elseif ($type == T_CONSTANT_ENCAPSED_STRING && $matched) {
|
||||
$key = md5($value);
|
||||
|
||||
if ($matched == '_n') {
|
||||
@ -85,7 +88,7 @@ function get_pot($file) {
|
||||
output_lang('msgid ' . get_msgid($value) . "\nmsgstr \"\"\n\n");
|
||||
$matched = null;
|
||||
}
|
||||
} else if ($type != T_WHITESPACE) {
|
||||
} elseif ($type != T_WHITESPACE) {
|
||||
$matched = null;
|
||||
|
||||
if (!empty($plural)) {
|
||||
@ -102,16 +105,13 @@ function get_pot($file) {
|
||||
$plural = [];
|
||||
}
|
||||
}
|
||||
} else if ($token != ',' && $token != '(') {
|
||||
} elseif ($token != ',' && $token != '(') {
|
||||
$matched = null;
|
||||
$plural = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../var/Typecho/Common.php';
|
||||
|
||||
|
||||
echo <<<EOF
|
||||
# Copyright (C) Typecho
|
||||
# This file is distributed under the same license as the Typecho Project.
|
||||
|
@ -27,7 +27,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
|
||||
* @property int $logged
|
||||
* @property string $group
|
||||
* @property string $authCode
|
||||
* @property-read Config $options
|
||||
* @property-read Config $personalOptions
|
||||
* @property-read string $permalink
|
||||
* @property-read string $feedUrl
|
||||
* @property-read string $feedRssUrl
|
||||
@ -216,12 +216,12 @@ class Users extends Base implements QueryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* ___options
|
||||
* personalOptions
|
||||
*
|
||||
* @return Config
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function ___options(): Config
|
||||
protected function ___personalOptions(): Config
|
||||
{
|
||||
$rows = $this->db->fetchAll($this->db->select()
|
||||
->from('table.options')->where('user = ?', $this->uid));
|
||||
|
@ -63,14 +63,13 @@ class Upgrade extends BaseOptions implements ActionInterface
|
||||
|
||||
/** 执行升级脚本 */
|
||||
try {
|
||||
$result = call_user_func(['Upgrade', $package], $this->db, $options);
|
||||
$result = call_user_func([\Utils\Upgrade::class, $package], $this->db, $options);
|
||||
if (!empty($result)) {
|
||||
$message[] = $result;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Notice::alloc()->set($e->getMessage(), 'error');
|
||||
$this->response->goBack();
|
||||
return;
|
||||
}
|
||||
|
||||
/** 更新版本号 */
|
||||
|
@ -68,11 +68,18 @@ class User extends Users
|
||||
if ($this->hasLogin()) {
|
||||
$this->push($this->currentUser);
|
||||
|
||||
//更新最后活动时间
|
||||
// update last activated time
|
||||
$this->db->query($this->db
|
||||
->update('table.users')
|
||||
->rows(['activated' => $this->options->time])
|
||||
->where('uid = ?', $this->currentUser['uid']));
|
||||
|
||||
// merge personal options
|
||||
$options = $this->personalOptions->toArray();
|
||||
|
||||
foreach ($options as $key => $val) {
|
||||
$this->options->{$key} = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user