Commit MetaInfo

修订版42273401ea905161ea5a41caf536b39e8756466d (tree)
时间2020-03-05 00:50:13
作者umorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack/2505 Fix calendar_viewer Year-Month filter

更改概述

差异

--- a/plugin/calendar_viewer.inc.php
+++ b/plugin/calendar_viewer.inc.php
@@ -1,7 +1,7 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone
33 // calendar_viewer.inc.php
4-// Copyright 2002-2017 PukiWiki Development Team
4+// Copyright 2002-2020 PukiWiki Development Team
55 // License: GPL v2 or (at your option) any later version
66 //
77 // Calendar viewer plugin - List pages that calendar/calnedar2 plugin created
@@ -115,10 +115,14 @@ function plugin_calendar_viewer_convert()
115115 return "#calendar_viewer(): Exceeded the limit of show count: $s_page<br />";
116116 }
117117 // page name pattern
118- $pagepattern = strip_bracket($pagename) . '/';
118+ $simple_pagename = strip_bracket($pagename);
119119 if ($pagename === '') {
120120 // Support non-pagename yyyy-mm-dd pattern
121- $pagepattern = '';
121+ $pagepattern = $page_YM;
122+ $page_datestart_idx = 0;
123+ } else {
124+ $pagepattern = $simple_pagename . '/' . $page_YM;
125+ $page_datestart_idx = strlen($simple_pagename) + 1;
122126 }
123127 $pagepattern_len = strlen($pagepattern);
124128 // Get pagelist
@@ -126,7 +130,7 @@ function plugin_calendar_viewer_convert()
126130 $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd');
127131 foreach (get_existpages() as $page) {
128132 if (strncmp($page, $pagepattern, $pagepattern_len) !== 0) continue;
129- $page_date = substr($page, $pagepattern_len);
133+ $page_date = substr($page, $page_datestart_idx);
130134 // Verify the $page_date pattern (Default: yyyy-mm-dd).
131135 // Past-mode hates the future, and
132136 // Future-mode hates the past.
@@ -194,8 +198,6 @@ function plugin_calendar_viewer_convert()
194198
195199 // ここで、前後のリンクを表示
196200 // ?plugin=calendar_viewer&file=ページ名&date=yyyy-mm
197- $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1));
198-
199201 if ($page_YM != '') {
200202 // 年月表示時
201203 $date_sep_len = strlen($date_sep);
@@ -252,7 +254,8 @@ function plugin_calendar_viewer_convert()
252254 $s_date_sep = htmlsc($date_sep);
253255 $left_link = $right_link = '';
254256 $link = $script . '?plugin=calendar_viewer&amp;mode=' . $mode .
255- '&amp;file=' . $enc_pagename . '&amp;date_sep=' . $s_date_sep . '&amp;';
257+ '&amp;file=' . rawurlencode($simple_pagename) .
258+ '&amp;date_sep=' . $s_date_sep . '&amp;';
256259 if ($left_YM != '')
257260 $left_link = '<a href="' . $link .
258261 'date=' . $left_YM . '">' . $left_text . '</a>';
Show on old repository browser