From b354e965d477616d2e9a3a7d7a0a59a23d35a623 Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 28 Oct 2013 21:37:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=BB=98=E8=AE=A4=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=20=E6=9B=B4=E6=94=B9=E5=8E=9F=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5archiveTitle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/themes/default/archive.php | 7 ++++- usr/themes/default/author.php | 30 --------------------- usr/themes/default/category.php | 31 ---------------------- usr/themes/default/search.php | 31 ---------------------- usr/themes/default/tag.php | 31 ---------------------- var/Typecho/Common.php | 2 +- var/Widget/Archive.php | 47 ++++++++++++++++++--------------- 7 files changed, 32 insertions(+), 147 deletions(-) delete mode 100644 usr/themes/default/author.php delete mode 100644 usr/themes/default/category.php delete mode 100644 usr/themes/default/search.php delete mode 100644 usr/themes/default/tag.php diff --git a/usr/themes/default/archive.php b/usr/themes/default/archive.php index 0f811157..19b313c6 100644 --- a/usr/themes/default/archive.php +++ b/usr/themes/default/archive.php @@ -1,7 +1,12 @@ need('header.php'); ?>
-

archiveTitle('', '', ''); ?>

+

archiveTitle(array( + 'category' => _t('分类 %s 下的文章'), + 'search' => _t('包含关键字 %s 的文章'), + 'tag' => _t('标签 %s 下的文章'), + 'author' => _t('%s 发布的文章') + ), '', ''); ?>

have()): ?> next()): ?>
diff --git a/usr/themes/default/author.php b/usr/themes/default/author.php deleted file mode 100644 index 248e6ea8..00000000 --- a/usr/themes/default/author.php +++ /dev/null @@ -1,30 +0,0 @@ -need('header.php'); ?> - -
-

archiveTitle('', '', ''); _e(' 发布的文章:'); ?>

- - have()): ?> - next()): ?> -
-

title() ?>

- -
- content('- 阅读剩余部分 -'); ?> -
-
- - -
-

-
- - - pageNav('« 前一页', '后一页 »'); ?> -
- - need('sidebar.php'); ?> - need('footer.php'); ?> diff --git a/usr/themes/default/category.php b/usr/themes/default/category.php deleted file mode 100644 index 8d38a15c..00000000 --- a/usr/themes/default/category.php +++ /dev/null @@ -1,31 +0,0 @@ -need('header.php'); ?> - -
-

archiveTitle('', '', ''); _e(' 分类下的文章:'); ?>

- - have()): ?> - next()): ?> - - - -
-

-
- - - pageNav('« 前一页', '后一页 »'); ?> -
- - need('sidebar.php'); ?> - need('footer.php'); ?> diff --git a/usr/themes/default/search.php b/usr/themes/default/search.php deleted file mode 100644 index 89f8232e..00000000 --- a/usr/themes/default/search.php +++ /dev/null @@ -1,31 +0,0 @@ -need('header.php'); ?> - -
-

archiveTitle('', '', ''); _e(' 相关的搜索结果:'); ?>

- - have()): ?> - next()): ?> - - - -
-

-
- - - pageNav('« 前一页', '后一页 »'); ?> -
- - need('sidebar.php'); ?> - need('footer.php'); ?> diff --git a/usr/themes/default/tag.php b/usr/themes/default/tag.php deleted file mode 100644 index b3075030..00000000 --- a/usr/themes/default/tag.php +++ /dev/null @@ -1,31 +0,0 @@ -need('header.php'); ?> - -
-

archiveTitle('', '', ''); _e(' 标签下的文章:'); ?>

- - have()): ?> - next()): ?> - - - -
-

-
- - - pageNav('« 前一页', '后一页 »'); ?> -
- - need('sidebar.php'); ?> - need('footer.php'); ?> diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php index 0928d118..74277402 100644 --- a/var/Typecho/Common.php +++ b/var/Typecho/Common.php @@ -710,7 +710,7 @@ EOF; */ public static function filterSearchQuery($query) { - return str_replace(array('%', '?', '*', '/', '{', '}'), '', $query); + return str_replace('-', ' ', self::slugName($query)); } /** diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 81e6ee85..53ecabd5 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -12,7 +12,6 @@ * 定义的css类 * p.more:阅读全文链接所属段落 * - * TODO 增加feed支持 * @package Widget */ class Widget_Archive extends Widget_Abstract_Contents @@ -157,9 +156,9 @@ class Widget_Archive extends Widget_Abstract_Contents * 归档标题 * * @access private - * @var array + * @var string */ - private $_archiveTitle = array(); + private $_archiveTitle = NULL; /** * 归档类型 @@ -648,7 +647,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->response->setStatus(404); /** 设置标题 */ - $this->_archiveTitle[] = _t('页面没找到'); + $this->_archiveTitle = _t('页面没找到'); /** 设置归档类型 */ $this->_archiveType = 'archive'; @@ -783,7 +782,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_feedAtomUrl = $this->feedAtomUrl; /** 设置标题 */ - $this->_archiveTitle[] = $this->title; + $this->_archiveTitle = $this->title; } /** 设置归档类型 */ @@ -859,7 +858,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_feedAtomUrl = $category['feedAtomUrl']; /** 设置标题 */ - $this->_archiveTitle[] = $category['name']; + $this->_archiveTitle = $category['name']; /** 设置归档类型 */ $this->_archiveType = 'category'; @@ -925,7 +924,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_feedAtomUrl = $tag['feedAtomUrl']; /** 设置标题 */ - $this->_archiveTitle[] = $tag['name']; + $this->_archiveTitle = $tag['name']; /** 设置归档类型 */ $this->_archiveType = 'tag'; @@ -980,7 +979,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_feedAtomUrl = $author['feedAtomUrl']; /** 设置标题 */ - $this->_archiveTitle[] = $author['screenName']; + $this->_archiveTitle = $author['screenName']; /** 设置归档类型 */ $this->_archiveType = 'author'; @@ -1017,9 +1016,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_archiveSlug = 'day'; /** 设置标题 */ - $this->_archiveTitle[] = $year; - $this->_archiveTitle[] = $month; - $this->_archiveTitle[] = $day; + $this->_archiveTitle = _t('%d年%d月%d日', $year, $month, $day); } else if (!empty($year) && !empty($month)) { /** 如果按月归档 */ @@ -1030,8 +1027,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_archiveSlug = 'month'; /** 设置标题 */ - $this->_archiveTitle[] = $year; - $this->_archiveTitle[] = $month; + $this->_archiveTitle = _t('%d年%d月', $year, $month); } else if (!empty($year)) { /** 如果按年归档 */ @@ -1042,7 +1038,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_archiveSlug = 'year'; /** 设置标题 */ - $this->_archiveTitle[] = $year; + $this->_archiveTitle = _t('%d年', $year); } $select->where('table.contents.created >= ?', $from - $this->options->timezone + $this->options->serverTimezone) @@ -1115,7 +1111,7 @@ class Widget_Archive extends Widget_Abstract_Contents $this->_feedAtomUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedAtomUrl); /** 设置标题 */ - $this->_archiveTitle[] = $keywords; + $this->_archiveTitle = $keywords; /** 设置归档类型 */ $this->_archiveType = 'search'; @@ -1228,7 +1224,7 @@ class Widget_Archive extends Widget_Abstract_Contents $handles = array( 'index' => 'indexHandle', 'index_page' => 'indexHandle', - 404 => 'error404Handle', + 404 => 'error404Handle', 'page' => 'singleHandle', 'post' => 'singleHandle', 'attachment' => 'singleHandle', @@ -1658,15 +1654,22 @@ var TypechoComment = { /** * 输出归档标题 - * + * + * @param mixed $defines + * @param string $before + * @param string $end * @access public - * @param string $split * @return void */ - public function archiveTitle($split = ' » ', $before = ' » ', $end = '') + public function archiveTitle($defines = NULL, $before = ' » ', $end = '') { if ($this->_archiveTitle) { - echo $before . implode($split, $this->_archiveTitle) . $end; + $define = '%s'; + if (is_array($defines) && !empty($defines[$this->_archiveType])) { + $define = $defines[$this->_archiveType]; + } + + echo $before . sprintf($define, $this->_archiveTitle) . $end; } } @@ -1810,7 +1813,7 @@ var TypechoComment = { if ($this->is('single') || 'comments' == $this->parameter->type) { $this->_feed->setTitle(_t('%s 的评论', - $this->options->title . ($this->_archiveTitle ? ' - ' . implode(' - ', $this->_archiveTitle) : NULL))); + $this->options->title . ($this->_archiveTitle ? ' - ' . $this->_archiveTitle : NULL))); if ('comments' == $this->parameter->type) { $comments = $this->widget('Widget_Comments_Recent', 'pageSize=10'); @@ -1839,7 +1842,7 @@ var TypechoComment = { )); } } else { - $this->_feed->setTitle($this->options->title . ($this->_archiveTitle ? ' - ' . implode(' - ', $this->_archiveTitle) : NULL)); + $this->_feed->setTitle($this->options->title . ($this->_archiveTitle ? ' - ' . $this->_archiveTitle : NULL)); while ($this->next()) { $suffix = $this->pluginHandle()->trigger($plugged)->feedItem($this->_feedType, $this);