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/install.php b/install.php
index 8641fc79..f8aabdad 100644
--- a/install.php
+++ b/install.php
@@ -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 5645ba4a..8ad7a9ce 100644
--- a/var/Widget/Archive.php
+++ b/var/Widget/Archive.php
@@ -1165,6 +1165,32 @@ class Widget_Archive extends Widget_Abstract_Contents
return;
}
+ $handles = array(
+ 'index' => 'indexHandle',
+ 'index_page' => 'indexHandle',
+ 'archive' => 'error404Handle',
+ 'archive_page' => 'error404Handle',
+ 404 => 'error404Handle',
+ 'page' => 'singleHandle',
+ 'post' => 'singleHandle',
+ 'attachment' => 'singleHandle',
+ 'comment_page' => 'singleHandle',
+ 'category' => 'categoryHandle',
+ 'category_page' => 'categoryHandle',
+ 'tag' => 'tagHandle',
+ 'tag_page' => 'tagHandle',
+ 'author' => 'authorHandle',
+ 'author_page' => 'authorHandle',
+ 'archive_year' => 'dateHandle',
+ 'archive_year_page' => 'dateHandle',
+ 'archive_month' => 'dateHandle',
+ 'archive_month_page' => 'dateHandle',
+ 'archive_day' => 'dateHandle',
+ 'archive_day_page' => 'dateHandle',
+ 'search' => 'searchHandle',
+ 'search_page' => 'searchHandle'
+ );
+
/** 处理搜索结果跳转 */
if (isset($this->request->s)) {
$filterKeywords = $this->request->filter('search')->s;
@@ -1177,9 +1203,8 @@ class Widget_Archive extends Widget_Abstract_Contents
}
/** 自定义首页功能 */
+ $frontPage = $this->options->frontPage;
if (!$this->_invokeByFeed && ('index' == $this->parameter->type || 'index_page' == $this->parameter->type)) {
- $frontPage = $this->options->frontPage;
-
//显示某个页面
if (0 === strpos($frontPage, 'page:')) {
// 对某些变量做hack
@@ -1193,6 +1218,12 @@ class Widget_Archive extends Widget_Abstract_Contents
}
}
+ 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;
@@ -1230,31 +1261,7 @@ class Widget_Archive extends Widget_Abstract_Contents
$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',
- 404 => 'error404Handle',
- 'page' => 'singleHandle',
- 'post' => 'singleHandle',
- 'attachment' => 'singleHandle',
- 'comment_page' => 'singleHandle',
- 'category' => 'categoryHandle',
- 'category_page' => 'categoryHandle',
- 'tag' => 'tagHandle',
- 'tag_page' => 'tagHandle',
- 'author' => 'authorHandle',
- 'author_page' => 'authorHandle',
- 'archive_year' => 'dateHandle',
- 'archive_year_page' => 'dateHandle',
- 'archive_month' => 'dateHandle',
- 'archive_month_page' => 'dateHandle',
- 'archive_day' => 'dateHandle',
- 'archive_day_page' => 'dateHandle',
- 'search' => 'searchHandle',
- 'search_page' => 'searchHandle'
- );
+ $this->_description = $this->options->description;
if (isset($handles[$this->parameter->type])) {
$handle = $handles[$this->parameter->type];
@@ -1776,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/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 70c611cc..e701e068 100644
--- a/var/Widget/Options/Permalink.php
+++ b/var/Widget/Options/Permalink.php
@@ -27,7 +27,7 @@ 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}', '{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);
}
@@ -293,7 +293,7 @@ RewriteRule . {$basePath}index.php [L]
$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]';
+ $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 . '