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/options-reading.php b/admin/options-reading.php
index 67965d14..a4a378c7 100644
--- a/admin/options-reading.php
+++ b/admin/options-reading.php
@@ -19,5 +19,19 @@ include 'menu.php';
include 'copyright.php';
include 'common-js.php';
include 'form-js.php';
+?>
+
+
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/install.php b/install.php
index 8641fc79..64dde074 100644
--- a/install.php
+++ b/install.php
@@ -279,7 +279,7 @@ list($prefixVersion, $suffixVersion) = explode('/', $currentVersion);
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'rewrite', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'frontPage', 'user' => 0, 'value' => 'recent')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsRequireMail', 'user' => 0, 'value' => 1)));
- $installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsWhitelist', 'user' => 0, 'value' => 1)));
+ $installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsWhitelist', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsRequireURL', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsRequireModeration', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'plugins', 'user' => 0, 'value' => 'a:0:{}')));
@@ -315,7 +315,7 @@ list($prefixVersion, $suffixVersion) = explode('/', $currentVersion);
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsShowCommentOnly', 'user' => 0, 'value' => 0)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsAvatar', 'user' => 0, 'value' => 1)));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'commentsAvatarRating', 'user' => 0, 'value' => 'G')));
- $installDb->query($installDb->insert('table.options')->rows(array('name' => 'routingTable', 'user' => 0, 'value' => 'a:23:{s:5:"index";a:3:{s:3:"url";s:1:"/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:2:"do";a:3:{s:3:"url";s:22:"/action/[action:alpha]";s:6:"widget";s:9:"Widget_Do";s:6:"action";s:6:"action";}s:4:"post";a:3:{s:3:"url";s:24:"/archives/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"attachment";a:3:{s:3:"url";s:26:"/attachment/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"category";a:3:{s:3:"url";s:17:"/category/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:3:"tag";a:3:{s:3:"url";s:12:"/tag/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"author";a:3:{s:3:"url";s:22:"/author/[uid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"search";a:3:{s:3:"url";s:19:"/search/[keywords]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"index_page";a:3:{s:3:"url";s:21:"/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"category_page";a:3:{s:3:"url";s:32:"/category/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"tag_page";a:3:{s:3:"url";s:27:"/tag/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"author_page";a:3:{s:3:"url";s:37:"/author/[uid:digital]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"search_page";a:3:{s:3:"url";s:34:"/search/[keywords]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_year";a:3:{s:3:"url";s:18:"/[year:digital:4]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"archive_month";a:3:{s:3:"url";s:36:"/[year:digital:4]/[month:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"archive_day";a:3:{s:3:"url";s:52:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:17:"archive_year_page";a:3:{s:3:"url";s:38:"/[year:digital:4]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:18:"archive_month_page";a:3:{s:3:"url";s:56:"/[year:digital:4]/[month:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:16:"archive_day_page";a:3:{s:3:"url";s:72:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"comment_page";a:3:{s:3:"url";s:53:"[permalink:string]/comment-page-[commentPage:digital]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:4:"feed";a:3:{s:3:"url";s:20:"/feed[feed:string:0]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:4:"feed";}s:8:"feedback";a:3:{s:3:"url";s:31:"[permalink:string]/[type:alpha]";s:6:"widget";s:15:"Widget_Feedback";s:6:"action";s:6:"action";}s:4:"page";a:3:{s:3:"url";s:12:"/[slug].html";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}}')));
+ $installDb->query($installDb->insert('table.options')->rows(array('name' => 'routingTable', 'user' => 0, 'value' => 'a:25:{s:5:"index";a:3:{s:3:"url";s:1:"/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:7:"archive";a:3:{s:3:"url";s:6:"/blog/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:2:"do";a:3:{s:3:"url";s:22:"/action/[action:alpha]";s:6:"widget";s:9:"Widget_Do";s:6:"action";s:6:"action";}s:4:"post";a:3:{s:3:"url";s:24:"/archives/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"attachment";a:3:{s:3:"url";s:26:"/attachment/[cid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"category";a:3:{s:3:"url";s:17:"/category/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:3:"tag";a:3:{s:3:"url";s:12:"/tag/[slug]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"author";a:3:{s:3:"url";s:22:"/author/[uid:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:6:"search";a:3:{s:3:"url";s:19:"/search/[keywords]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:10:"index_page";a:3:{s:3:"url";s:21:"/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_page";a:3:{s:3:"url";s:26:"/blog/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"category_page";a:3:{s:3:"url";s:32:"/category/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:8:"tag_page";a:3:{s:3:"url";s:27:"/tag/[slug]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"author_page";a:3:{s:3:"url";s:37:"/author/[uid:digital]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"search_page";a:3:{s:3:"url";s:34:"/search/[keywords]/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"archive_year";a:3:{s:3:"url";s:18:"/[year:digital:4]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:13:"archive_month";a:3:{s:3:"url";s:36:"/[year:digital:4]/[month:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:11:"archive_day";a:3:{s:3:"url";s:52:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:17:"archive_year_page";a:3:{s:3:"url";s:38:"/[year:digital:4]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:18:"archive_month_page";a:3:{s:3:"url";s:56:"/[year:digital:4]/[month:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:16:"archive_day_page";a:3:{s:3:"url";s:72:"/[year:digital:4]/[month:digital:2]/[day:digital:2]/page/[page:digital]/";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:12:"comment_page";a:3:{s:3:"url";s:53:"[permalink:string]/comment-page-[commentPage:digital]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}s:4:"feed";a:3:{s:3:"url";s:20:"/feed[feed:string:0]";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:4:"feed";}s:8:"feedback";a:3:{s:3:"url";s:31:"[permalink:string]/[type:alpha]";s:6:"widget";s:15:"Widget_Feedback";s:6:"action";s:6:"action";}s:4:"page";a:3:{s:3:"url";s:12:"/[slug].html";s:6:"widget";s:14:"Widget_Archive";s:6:"action";s:6:"render";}}')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'actionTable', 'user' => 0, 'value' => 'a:0:{}')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'panelTable', 'user' => 0, 'value' => 'a:0:{}')));
$installDb->query($installDb->insert('table.options')->rows(array('name' => 'attachmentTypes', 'user' => 0, 'value' => '@image@')));
diff --git a/var/Helper.php b/var/Helper.php
index d08c3705..f9073d6a 100644
--- a/var/Helper.php
+++ b/var/Helper.php
@@ -94,20 +94,33 @@ class Helper
* @param string $url 路由路径
* @param string $widget 组件名称
* @param string $action 组件动作
+ * @param string $after 在某个路由后面
* @return void
*/
- public static function addRoute($name, $url, $widget, $action = NULL)
+ public static function addRoute($name, $url, $widget, $action = NULL, $after = NULL)
{
$routingTable = self::options()->routingTable;
if (isset($routingTable[0])) {
unset($routingTable[0]);
}
- $routingTable[$name] = array(
+ $pos = 0;
+ foreach ($routingTable as $key => $val) {
+ $pos ++;
+
+ if ($key == $after) {
+ break;
+ }
+ }
+
+ $pre = array_slice($routingTable, 0, $pos);
+ $next = array_slice($routingTable, $pos);
+
+ $routingTable = array_merge($pre, array($name => array(
'url' => $url,
'widget' => $widget,
'action' => $action
- );
+ )), $next);
self::options()->routingTable = $routingTable;
$db = Typecho_Db::get();
diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php
index e5b4837b..9179c35a 100644
--- a/var/Typecho/Common.php
+++ b/var/Typecho/Common.php
@@ -20,7 +20,7 @@
class Typecho_Common
{
/** 程序版本 */
- const VERSION = '0.9/13.10.28';
+ const VERSION = '0.9/13.11.17';
/**
* 缓存的包含路径
diff --git a/var/Upgrade.php b/var/Upgrade.php
index 2910aed4..775b6a55 100644
--- a/var/Upgrade.php
+++ b/var/Upgrade.php
@@ -987,5 +987,22 @@ Typecho_Date::setTimezoneOffset($options->timezone);
))
->where('type = ? AND status = ?', 'page', 'draft'));
}
+
+ /**
+ * v0_9r13_11_17
+ *
+ * @param mixed $db
+ * @param mixed $options
+ * @static
+ * @access public
+ * @return void
+ */
+ public static function v0_9r13_11_17($db, $options)
+ {
+ Helper::addRoute('archive', '/blog/', 'Widget_Archive', 'render', 'index');
+ Helper::addRoute('archive_page', '/blog/[page:digital]/', 'Widget_Archive', 'render', 'index_page');
+ $db->query($db->insert('table.options')
+ ->rows(array('name' => 'frontArchive', 'user' => 0, 'value' => 0)));
+ }
}
diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php
index 3a0c2390..8ad7a9ce 100644
--- a/var/Widget/Archive.php
+++ b/var/Widget/Archive.php
@@ -1165,65 +1165,11 @@ class Widget_Archive extends Widget_Abstract_Contents
return;
}
- /** 处理搜索结果跳转 */
- if (isset($this->request->s)) {
- $filterKeywords = $this->request->filter('search')->s;
-
- /** 跳转到搜索页 */
- if (NULL != $filterKeywords) {
- $this->response->redirect(Typecho_Router::url('search',
- array('keywords' => urlencode($filterKeywords)), $this->options->index));
- }
- }
-
- /** 自定义首页功能 */
- if (!$this->_invokeByFeed && ('index' == $this->parameter->type || 'index_page' == $this->parameter->type)) {
- $frontPage = $this->options->frontPage;
-
- //显示某个页面
- if (0 === strpos($frontPage, 'page:')) {
- // 对某些变量做hack
- $this->request->setParam('cid', intval(substr($frontPage, 5)));
- $this->parameter->type = 'page';
- $this->_makeSinglePageAsFrontPage = true;
- } else if (0 === strpos($frontPage, 'file:')) {
- // 显示某个文件
- $this->setThemeFile(substr($frontPage, 5));
- return;
- }
- }
-
- /** 初始化分页变量 */
- $this->_currentPage = isset($this->request->page) ? $this->request->page : 1;
- $hasPushed = false;
-
- /** select初始化 */
- $select = $this->pluginHandle()->trigger($selectPlugged)->select($this);
-
- /** 定时发布功能 */
- 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);
- } else {
- $select = $this->select()->where('table.contents.status = ?', 'publish');
- }
- $select->where('table.contents.created < ?', $this->options->gmtTime);
- }
-
- /** handle初始化 */
- $this->pluginHandle()->handleInit($this, $select);
-
- /** 初始化其它变量 */
- $this->_feedUrl = $this->options->feedUrl;
- $this->_feedRssUrl = $this->options->feedRssUrl;
- $this->_feedAtomUrl = $this->options->feedAtomUrl;
- $this->_keywords = $this->options->keywords;
- $this->_description = $this->options->description;
-
$handles = array(
'index' => 'indexHandle',
'index_page' => 'indexHandle',
+ 'archive' => 'error404Handle',
+ 'archive_page' => 'error404Handle',
404 => 'error404Handle',
'page' => 'singleHandle',
'post' => 'singleHandle',
@@ -1245,6 +1191,78 @@ class Widget_Archive extends Widget_Abstract_Contents
'search_page' => 'searchHandle'
);
+ /** 处理搜索结果跳转 */
+ if (isset($this->request->s)) {
+ $filterKeywords = $this->request->filter('search')->s;
+
+ /** 跳转到搜索页 */
+ if (NULL != $filterKeywords) {
+ $this->response->redirect(Typecho_Router::url('search',
+ array('keywords' => urlencode($filterKeywords)), $this->options->index));
+ }
+ }
+
+ /** 自定义首页功能 */
+ $frontPage = $this->options->frontPage;
+ if (!$this->_invokeByFeed && ('index' == $this->parameter->type || 'index_page' == $this->parameter->type)) {
+ //显示某个页面
+ if (0 === strpos($frontPage, 'page:')) {
+ // 对某些变量做hack
+ $this->request->setParam('cid', intval(substr($frontPage, 5)));
+ $this->parameter->type = 'page';
+ $this->_makeSinglePageAsFrontPage = true;
+ } else if (0 === strpos($frontPage, 'file:')) {
+ // 显示某个文件
+ $this->setThemeFile(substr($frontPage, 5));
+ return;
+ }
+ }
+
+ if ('recent' != $frontPage && $this->options->frontArchive) {
+ $handles['archive'] = 'indexHandle';
+ $handles['archive_page'] = 'indexHandle';
+ $this->_archiveType = 'front';
+ }
+
+ /** 初始化分页变量 */
+ $this->_currentPage = isset($this->request->page) ? $this->request->page : 1;
+ $hasPushed = false;
+
+ /** select初始化 */
+ $select = $this->pluginHandle()->trigger($selectPlugged)->select($this);
+
+ /** 定时发布功能 */
+ if (!$selectPlugged) {
+ 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 {
+ 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);
+ }
+
+ /** handle初始化 */
+ $this->pluginHandle()->handleInit($this, $select);
+
+ /** 初始化其它变量 */
+ $this->_feedUrl = $this->options->feedUrl;
+ $this->_feedRssUrl = $this->options->feedRssUrl;
+ $this->_feedAtomUrl = $this->options->feedAtomUrl;
+ $this->_keywords = $this->options->keywords;
+ $this->_description = $this->options->description;
+
if (isset($handles[$this->parameter->type])) {
$handle = $handles[$this->parameter->type];
$this->{$handle}($select, $hasPushed);
@@ -1765,7 +1783,7 @@ var TypechoComment = {
}
//~ 最后找归档路径, 比如 archive.php 或者 single.php
- if (!$validated && 'index' != $this->_archiveType) {
+ if (!$validated && 'index' != $this->_archiveType && 'front' != $this->_archiveType) {
$themeFile = $this->_archiveSingle ? 'single.php' : 'archive.php';
if (file_exists($this->_themeDir . $themeFile)) {
$this->_themeFile = $themeFile;
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/Menu.php b/var/Widget/Menu.php
index 13000cf8..1b8ec781 100644
--- a/var/Widget/Menu.php
+++ b/var/Widget/Menu.php
@@ -140,7 +140,7 @@ class Widget_Menu extends Typecho_Widget
array(
array(_t('基本'), _t('基本设置'), 'options-general.php', 'administrator'),
array(_t('评论'), _t('评论设置'), 'options-discussion.php', 'administrator'),
- array(_t('文章'), _t('阅读设置'), 'options-reading.php', 'administrator'),
+ array(_t('阅读'), _t('阅读设置'), 'options-reading.php', 'administrator'),
array(_t('永久链接'), _t('永久链接设置'), 'options-permalink.php', 'administrator'),
));
diff --git a/var/Widget/Options/Permalink.php b/var/Widget/Options/Permalink.php
index 31d1190d..e701e068 100644
--- a/var/Widget/Options/Permalink.php
+++ b/var/Widget/Options/Permalink.php
@@ -27,10 +27,10 @@ class Widget_Options_Permalink extends Widget_Abstract_Options implements Widget
* @param string $rule 待编码的路径
* @return string
*/
- private function encodeRule($rule)
+ protected 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);
}
/**
@@ -40,7 +40,7 @@ class Widget_Options_Permalink extends Widget_Abstract_Options implements Widget
* @param string $rule 待解码的路径
* @return string
*/
- private function decodeRule($rule)
+ protected function decodeRule($rule)
{
return preg_replace("/\[([_a-z0-9-]+)[^\]]*\]/i", "{\\1}", $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]);
diff --git a/var/Widget/Options/Reading.php b/var/Widget/Options/Reading.php
index 06cf0c2b..3907197b 100644
--- a/var/Widget/Options/Reading.php
+++ b/var/Widget/Options/Reading.php
@@ -18,7 +18,7 @@
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org)
* @license GNU General Public License 2.0
*/
-class Widget_Options_Reading extends Widget_Abstract_Options implements Widget_Interface_Do
+class Widget_Options_Reading extends Widget_Options_Permalink
{
/**
* 输出表单结构
@@ -49,6 +49,14 @@ class Widget_Options_Reading extends Widget_Abstract_Options implements Widget_I
'recent' => _t('显示最新发布的文章')
);
+ $frontPattern = ''
+ . 'options->frontArchive && 'recent' != $frontPageType ? ' checked' : '') .' />
+';
+
// 页面列表
$pages = $this->db->fetchAll($this->db->select('cid', 'title')
->from('table.contents')->where('type = ?', 'page')
@@ -67,6 +75,7 @@ class Widget_Options_Reading extends Widget_Abstract_Options implements Widget_I
}
$pagesSelect .= '';
$frontPageOptions['page'] = _t('使用 %s 页面作为首页', '' . $pagesSelect . '