From fc5afc23bcd9f934be08ff755437cd5ab1c17bfd Mon Sep 17 00:00:00 2001 From: joyqi Date: Sun, 17 Nov 2013 21:22:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E6=96=87=E7=AB=A0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=9A=90=E7=A7=81=E9=80=89=E9=A1=B9=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9=E8=AE=A9=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E4=B8=8D=E7=8E=B0=E5=AE=9E=E5=87=BA=E6=9D=A5=EF=BC=8C=E8=80=8C?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E9=80=9A=E8=BF=87url=E8=AE=BF=E9=97=AE=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=AF=E4=BB=A5=E8=B0=83=E6=95=B4=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=9B=BA=E5=AE=9A=E9=93=BE=E6=8E=A5=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/manage-pages.php | 2 ++ admin/manage-posts.php | 2 ++ admin/write-post.php | 7 ++++--- var/Widget/Archive.php | 19 +++++++++++++++---- var/Widget/Contents/Post/Edit.php | 6 +++--- var/Widget/Options/Permalink.php | 23 +++++++++++++++++++++-- 6 files changed, 47 insertions(+), 12 deletions(-) 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]);