From 41c1112c231fbdeae4130ee2e48d734310806efb Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 08:39:18 +0800 Subject: [PATCH 1/7] fixed #119 --- var/Widget/Archive.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index d558d2b0..5c90456b 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -605,13 +605,17 @@ class Widget_Archive extends Widget_Abstract_Contents return; } - $value = array( - 'page' => $this->_currentPage - ); - $value = array_merge($this->_archiveSingle ? $this->row : $this->_pageRow, $value); + if ($this->_archiveSingle) { + $permalink = $this->permalink; + } else { + $value = array_merge($this->_pageRow, array( + 'page' => $this->_currentPage + )); + + $path = Typecho_Router::url($type, $value); + $permalink = Typecho_Common::url($path, $this->options->index); + } - $path = Typecho_Router::url($type, $value); - $permalink = Typecho_Common::url($path, $this->options->index); $requestUrl = $this->request->getRequestUrl(); $src = parse_url($permalink); @@ -875,7 +879,9 @@ class Widget_Archive extends Widget_Abstract_Contents ->where('table.contents.type = ?', 'post'); /** 设置分页 */ - $this->_pageRow = $category; + $this->_pageRow = array_merge($category, array( + 'slug' => urlencode($category['slug']) + )); /** 设置关键词 */ $this->_keywords = $category['name']; @@ -941,7 +947,9 @@ class Widget_Archive extends Widget_Abstract_Contents ->where('table.contents.type = ?', 'post'); /** 设置分页 */ - $this->_pageRow = $tag; + $this->_pageRow = array_merge($tag, array( + 'slug' => urlencode($tag['slug']) + )); /** 设置关键词 */ $this->_keywords = $tag['name']; From b20e12f63cee49a842f9172853640b58b167cc74 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 15:54:58 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E9=9B=86=E6=88=90=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..1a316658 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: php +php: + - 5.5 + - 5.4 + - 5.3 + - 5.2 From c869721cca829564b5b6843b52181b59d05da321 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 16:02:22 +0800 Subject: [PATCH 3/7] fix travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a316658..23902b4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,3 @@ php: - 5.5 - 5.4 - 5.3 - - 5.2 From 355301df67a5f068fb964bf5db65db97c11bb4f5 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 16:06:26 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B9=B2=E6=8E=89=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 23902b4d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: php -php: - - 5.5 - - 5.4 - - 5.3 From 17fb8ffd6439fcd140b486936900410a58787ac3 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 17:41:45 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E6=AD=A3iis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Typecho/Request.php | 86 ++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 31 deletions(-) diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php index f77b4fcb..e11e8d48 100644 --- a/var/Typecho/Request.php +++ b/var/Typecho/Request.php @@ -39,6 +39,14 @@ class Typecho_Request */ private $_server = array(); + /** + * _requestUri + * + * @var string + * @access private + */ + private $_requestUri = NULL; + /** * 客户端ip地址 * @@ -306,7 +314,52 @@ class Typecho_Request public function getRequestUrl() { $scheme = $this->isSecure() ? 'https' : 'http'; - return $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + return $scheme . '://' . $_SERVER['HTTP_HOST'] . $this->getRequestUri(); + } + + /** + * 获取请求地址 + * + * @access public + * @return string + */ + public function getRequestUri() + { + if (!empty($this->_requestUri)) { + return $this->_requestUri; + } + + //处理requestUri + $requestUri = '/'; + + if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch + $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; + } elseif ( + // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) + isset($_SERVER['IIS_WasUrlRewritten']) + && $_SERVER['IIS_WasUrlRewritten'] == '1' + && isset($_SERVER['UNENCODED_URL']) + && $_SERVER['UNENCODED_URL'] != '' + ) { + $requestUri = $_SERVER['UNENCODED_URL']; + } elseif (isset($_SERVER['REQUEST_URI'])) { + $requestUri = $_SERVER['REQUEST_URI']; + if (isset($_SERVER['HTTP_HOST']) && strstr($requestUri, $_SERVER['HTTP_HOST'])) { + $parts = @parse_url($requestUri); + + if (false !== $parts) { + $requestUri = (empty($parts['path']) ? '' : $parts['path']) + . ((empty($parts['query'])) ? '' : '?' . $parts['query']); + } + } + } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI + $requestUri = $_SERVER['ORIG_PATH_INFO']; + if (!empty($_SERVER['QUERY_STRING'])) { + $requestUri .= '?' . $_SERVER['QUERY_STRING']; + } + } + + return $this->_requestUri = $requestUri; } /** @@ -364,36 +417,7 @@ class Typecho_Request $pathInfo = NULL; //处理requestUri - $requestUri = NULL; - - if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch - $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; - } elseif ( - // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem) - isset($_SERVER['IIS_WasUrlRewritten']) - && $_SERVER['IIS_WasUrlRewritten'] == '1' - && isset($_SERVER['UNENCODED_URL']) - && $_SERVER['UNENCODED_URL'] != '' - ) { - $requestUri = $_SERVER['UNENCODED_URL']; - } elseif (isset($_SERVER['REQUEST_URI'])) { - $requestUri = $_SERVER['REQUEST_URI']; - if (isset($_SERVER['HTTP_HOST']) && strstr($requestUri, $_SERVER['HTTP_HOST'])) { - $parts = @parse_url($requestUri); - - if (false !== $parts) { - $requestUri = (empty($parts['path']) ? '' : $parts['path']) - . ((empty($parts['query'])) ? '' : '?' . $parts['query']); - } - } - } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI - $requestUri = $_SERVER['ORIG_PATH_INFO']; - if (!empty($_SERVER['QUERY_STRING'])) { - $requestUri .= '?' . $_SERVER['QUERY_STRING']; - } - } else { - return $this->_pathInfo = '/'; - } + $requestUri = $this->getRequestUri(); //处理baseUrl $filename = (isset($_SERVER['SCRIPT_FILENAME'])) ? basename($_SERVER['SCRIPT_FILENAME']) : ''; From 6825bb69d94e870c983135d5e45210ec9784c00c Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 22:45:48 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3header=E7=9A=84plugin?= =?UTF-8?q?=E4=BC=9A=E5=86=B2=E6=8E=89=E5=A4=B4=E9=83=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Widget/Archive.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 5c90456b..9d2c4a9d 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -1564,6 +1564,8 @@ class Widget_Archive extends Widget_Abstract_Contents $allows = array_merge($allows, $rules); } + $allows = $this->pluginHandle()->headerOptions($allows, $this); + $header = ''; if (!empty($allows['description'])) { $header .= '' . "\n"; @@ -1687,7 +1689,7 @@ var TypechoComment = { } /** 插件支持 */ - $header = $this->pluginHandle()->header($header, $this); + $this->pluginHandle()->header($header, $this); /** 输出header */ echo $header; From 7e06a9cc2ed3bbb4e154f41304630b897ff85317 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 11 Dec 2013 22:51:17 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BB=A5=E6=9F=90?= =?UTF-8?q?=E4=B8=AApage=E4=BD=9C=E4=B8=BA=E9=A6=96=E9=A1=B5=E6=97=B6descr?= =?UTF-8?q?iption=E5=92=8Ckeywords=E4=BC=9A=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Widget/Archive.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 9d2c4a9d..508ecf89 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -796,12 +796,6 @@ class Widget_Archive extends Widget_Abstract_Contents } } - /** 设置关键词 */ - $this->_keywords = implode(',', Typecho_Common::arrayFlatten($this->tags, 'name')); - - /** 设置描述 */ - $this->_description = $this->description; - /** 设置模板 */ if ($this->template) { /** 应用自定义模板 */ @@ -823,6 +817,12 @@ class Widget_Archive extends Widget_Abstract_Contents /** 设置标题 */ $this->_archiveTitle = $this->title; + + /** 设置关键词 */ + $this->_keywords = implode(',', Typecho_Common::arrayFlatten($this->tags, 'name')); + + /** 设置描述 */ + $this->_description = $this->description; } /** 设置归档类型 */