Revision | 42273401ea905161ea5a41caf536b39e8756466d (tree) |
---|---|
Time | 2020-03-05 00:50:13 |
Author | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2505 Fix calendar_viewer Year-Month filter
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | 3 | // calendar_viewer.inc.php |
4 | -// Copyright 2002-2017 PukiWiki Development Team | |
4 | +// Copyright 2002-2020 PukiWiki Development Team | |
5 | 5 | // License: GPL v2 or (at your option) any later version |
6 | 6 | // |
7 | 7 | // Calendar viewer plugin - List pages that calendar/calnedar2 plugin created |
@@ -115,10 +115,14 @@ function plugin_calendar_viewer_convert() | ||
115 | 115 | return "#calendar_viewer(): Exceeded the limit of show count: $s_page<br />"; |
116 | 116 | } |
117 | 117 | // page name pattern |
118 | - $pagepattern = strip_bracket($pagename) . '/'; | |
118 | + $simple_pagename = strip_bracket($pagename); | |
119 | 119 | if ($pagename === '') { |
120 | 120 | // 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; | |
122 | 126 | } |
123 | 127 | $pagepattern_len = strlen($pagepattern); |
124 | 128 | // Get pagelist |
@@ -126,7 +130,7 @@ function plugin_calendar_viewer_convert() | ||
126 | 130 | $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd'); |
127 | 131 | foreach (get_existpages() as $page) { |
128 | 132 | if (strncmp($page, $pagepattern, $pagepattern_len) !== 0) continue; |
129 | - $page_date = substr($page, $pagepattern_len); | |
133 | + $page_date = substr($page, $page_datestart_idx); | |
130 | 134 | // Verify the $page_date pattern (Default: yyyy-mm-dd). |
131 | 135 | // Past-mode hates the future, and |
132 | 136 | // Future-mode hates the past. |
@@ -194,8 +198,6 @@ function plugin_calendar_viewer_convert() | ||
194 | 198 | |
195 | 199 | // ここで、前後のリンクを表示 |
196 | 200 | // ?plugin=calendar_viewer&file=ページ名&date=yyyy-mm |
197 | - $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1)); | |
198 | - | |
199 | 201 | if ($page_YM != '') { |
200 | 202 | // 年月表示時 |
201 | 203 | $date_sep_len = strlen($date_sep); |
@@ -252,7 +254,8 @@ function plugin_calendar_viewer_convert() | ||
252 | 254 | $s_date_sep = htmlsc($date_sep); |
253 | 255 | $left_link = $right_link = ''; |
254 | 256 | $link = $script . '?plugin=calendar_viewer&mode=' . $mode . |
255 | - '&file=' . $enc_pagename . '&date_sep=' . $s_date_sep . '&'; | |
257 | + '&file=' . rawurlencode($simple_pagename) . | |
258 | + '&date_sep=' . $s_date_sep . '&'; | |
256 | 259 | if ($left_YM != '') |
257 | 260 | $left_link = '<a href="' . $link . |
258 | 261 | 'date=' . $left_YM . '">' . $left_text . '</a>'; |