diff --git a/admin/manage-pages.php b/admin/manage-pages.php
index 2821fe24..adfa1d8a 100644
--- a/admin/manage-pages.php
+++ b/admin/manage-pages.php
@@ -64,6 +64,8 @@ $stat = Typecho_Widget::widget('Widget_Stat');
hasSaved || 'page_draft' == $pages->type) {
echo '' . _t('草稿') . '';
+ } else if ('hidden' == $pages->status) {
+ echo '' . _t('隐藏') . '';
} else if ('waiting' == $pages->status) {
echo '' . _t('待审核') . '';
} else if ('private' == $pages->status) {
diff --git a/admin/manage-posts.php b/admin/manage-posts.php
index f1f8e18f..ee95ba04 100644
--- a/admin/manage-posts.php
+++ b/admin/manage-posts.php
@@ -74,6 +74,8 @@ $stat = Typecho_Widget::widget('Widget_Stat');
hasSaved || 'post_draft' == $posts->type) {
echo '' . _t('草稿') . '';
+ } else if ('hidden' == $posts->status) {
+ echo '' . _t('隐藏') . '';
} else if ('waiting' == $posts->status) {
echo '' . _t('待审核') . '';
} else if ('private' == $posts->status) {
diff --git a/admin/write-post.php b/admin/write-post.php
index 6427f2fd..6db21f34 100644
--- a/admin/write-post.php
+++ b/admin/write-post.php
@@ -96,10 +96,11 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php
index 3a0c2390..5645ba4a 100644
--- a/var/Widget/Archive.php
+++ b/var/Widget/Archive.php
@@ -1202,11 +1202,22 @@ class Widget_Archive extends Widget_Abstract_Contents
/** 定时发布功能 */
if (!$selectPlugged) {
- if ($this->user->hasLogin()) {
- $select = $this->select()->where('table.contents.status = ? OR
- (table.contents.status = ? AND table.contents.authorId = ?)', 'publish', 'private', $this->user->uid);
+ if ('post' == $this->parameter->type) {
+ if ($this->user->hasLogin()) {
+ $select = $this->select()->where('table.contents.status = ? OR table.contents.status = ? OR
+ (table.contents.status = ? AND table.contents.authorId = ?)',
+ 'publish', 'hidden', 'private', $this->user->uid);
+ } else {
+ $select = $this->select()->where('table.contents.status = ? OR table.contents.status',
+ 'publish', 'hidden');
+ }
} else {
- $select = $this->select()->where('table.contents.status = ?', 'publish');
+ if ($this->user->hasLogin()) {
+ $select = $this->select()->where('table.contents.status = ? OR
+ (table.contents.status = ? AND table.contents.authorId = ?)', 'publish', 'private', $this->user->uid);
+ } else {
+ $select = $this->select()->where('table.contents.status = ?', 'publish');
+ }
}
$select->where('table.contents.created < ?', $this->options->gmtTime);
}
diff --git a/var/Widget/Contents/Post/Edit.php b/var/Widget/Contents/Post/Edit.php
index ec7c96eb..71ac5103 100644
--- a/var/Widget/Contents/Post/Edit.php
+++ b/var/Widget/Contents/Post/Edit.php
@@ -180,7 +180,7 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
if ($this->user->pass('editor', true)) {
if (empty($contents['visibility'])) {
$contents['status'] = 'publish';
- } else if ('password' == $contents['visibility'] || !in_array($contents['visibility'], array('private', 'waiting', 'publish'))) {
+ } else if ('password' == $contents['visibility'] || !in_array($contents['visibility'], array('private', 'waiting', 'publish', 'hidden'))) {
if (empty($contents['password']) || 'password' != $contents['visibility']) {
$contents['password'] = '';
}
@@ -253,7 +253,7 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
if ($this->user->pass('editor', true)) {
if (empty($contents['visibility'])) {
$contents['status'] = 'publish';
- } else if ('password' == $contents['visibility'] || !in_array($contents['visibility'], array('private', 'waiting', 'publish'))) {
+ } else if ('password' == $contents['visibility'] || !in_array($contents['visibility'], array('private', 'waiting', 'publish', 'hidden'))) {
if (empty($contents['password']) || 'password' != $contents['visibility']) {
$contents['password'] = '';
}
@@ -558,7 +558,7 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
public function writePost()
{
$contents = $this->request->from('password', 'allowComment',
- 'allowPing', 'allowFeed', 'slug', 'category', 'tags', 'text', 'do', 'visibility');
+ 'allowPing', 'allowFeed', 'slug', 'category', 'tags', 'text', 'visibility');
$contents['title'] = $this->request->get('title', _t('未命名文档'));
$contents['created'] = $this->getCreated();
diff --git a/var/Widget/Options/Permalink.php b/var/Widget/Options/Permalink.php
index 31d1190d..70c611cc 100644
--- a/var/Widget/Options/Permalink.php
+++ b/var/Widget/Options/Permalink.php
@@ -29,8 +29,8 @@ class Widget_Options_Permalink extends Widget_Abstract_Options implements Widget
*/
private function encodeRule($rule)
{
- return str_replace(array('{cid}', '{slug}', '{category}', '{year}', '{month}', '{day}'),
- array('[cid:digital]', '[slug]', '[category]', '[year:digital:4]', '[month:digital:2]', '[day:digital:2]'), $rule);
+ return str_replace(array('{cid}', '{slug}', '{category}', '{year}', '{month}', '{day}', '{mid}'),
+ array('[cid:digital]', '[slug]', '[category]', '[year:digital:4]', '[month:digital:2]', '[day:digital:2]', '[mid:digital]'), $rule);
}
/**
@@ -93,6 +93,18 @@ class Widget_Options_Permalink extends Widget_Abstract_Options implements Widget
return strpos($value, '{slug}') !== false || strpos($value, '{cid}') !== false;
}
+ /**
+ * 检查categoryPattern里是否含有必要参数
+ *
+ * @param mixed $value
+ * @access public
+ * @return void
+ */
+ public function checkCategoryPattern($value)
+ {
+ return strpos($value, '{slug}') !== false || strpos($value, '{mid}') !== false;
+ }
+
/**
* 检测是否可以rewrite
*
@@ -241,6 +253,11 @@ RewriteRule . {$basePath}index.php [L]
$pagePattern->input->setAttribute('class', 'mono w-60');
$form->addInput($pagePattern->addRule(array($this, 'checkPagePattern'), _t('独立页面路径中没有包含 {cid} 或者 {slug} ')));
+ /** 分类页面 */
+ $categoryPattern = new Typecho_Widget_Helper_Form_Element_Text('categoryPattern', NULL, $this->decodeRule($this->options->routingTable['category']['url']), _t('分类路径'), _t('可用参数: {mid} 分类 ID、{slug} 分类缩略名
请在路径中至少包含上述的一项参数.'));
+ $categoryPattern->input->setAttribute('class', 'mono w-60');
+ $form->addInput($categoryPattern->addRule(array($this, 'checkCategoryPattern'), _t('分类路径中没有包含 {mid} 或者 {slug} ')));
+
/** 提交按钮 */
$submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置'));
$submit->input->setAttribute('class', 'primary');
@@ -275,6 +292,8 @@ RewriteRule . {$basePath}index.php [L]
$routingTable = $this->options->routingTable;
$routingTable['post']['url'] = $this->request->postPattern;
$routingTable['page']['url'] = '/' . ltrim($this->encodeRule($this->request->pagePattern), '/');
+ $routingTable['category']['url'] = '/' . ltrim($this->encodeRule($this->request->categoryPattern), '/');
+ $routingTable['category_page']['url'] = rtrim($routingTable['category']['url'], '/') . '/[page:digital]';
if (isset($routingTable[0])) {
unset($routingTable[0]);