• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revisiona264b6477de87f44b6c1ffa6cae25e54689bf7b5 (tree)
Time2016-02-04 23:35:29
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/377 Filter template pages for sites that have many pages

* Template list page: ':config/Templates'

  • Show the list as template pages

* Anothor rule: Page whose name have 'template' keyward is template

Change Summary

Incremental Difference

--- a/lib/html.php
+++ b/lib/html.php
@@ -1,8 +1,8 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone.
3-// $Id: html.php,v 1.66 2011/01/25 15:01:01 henoheno Exp $
3+// html.php
44 // Copyright (C)
5-// 2002-2006 PukiWiki Developers Team
5+// 2002-2016 PukiWiki Development Team
66 // 2001-2002 Originally written by yu-ji
77 // License: GPL v2 or (at your option) any later version
88 //
@@ -183,6 +183,7 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
183183 global $_btn_preview, $_btn_repreview, $_btn_update, $_btn_cancel, $_msg_help;
184184 global $whatsnew, $_btn_template, $_btn_load, $load_template_func;
185185 global $notimeupdate;
186+ global $_title_list;
186187
187188 // Newly generate $digest or not
188189 if ($digest === FALSE) $digest = md5(join('', get_source($page)));
@@ -203,20 +204,54 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
203204 }
204205
205206 if($load_template_func && $b_template) {
206- $pages = array();
207+ $tpage_names = array(); // Pages marked as template
208+ $template_page = ':config/Templates';
209+ $page_max = 100;
210+ foreach(get_source($template_page) as $_templates) {
211+ $m = array();
212+ if (! preg_match('#\-\s*\[\[([^\[\]]+)\]\]#', $_templates, $m)) continue;
213+ $tpage = preg_replace('#^./#', "$template_page/", $m[1]);
214+ if (! is_page($tpage)) continue;
215+ $tpage_names[] = $tpage;
216+ }
217+ $page_names = array();
207218 foreach(get_existpages() as $_page) {
208219 if ($_page == $whatsnew || check_non_list($_page))
209220 continue;
210- $s_page = htmlsc($_page);
211- $pages[$_page] = ' <option value="' . $s_page . '">' .
212- $s_page . '</option>';
221+ if (preg_match('/template/i', $_page)) {
222+ $tpage_names[] = $_page;
223+ } else {
224+ if (count($page_names) >= $page_max) continue;
225+ $page_names[] = $_page;
226+ }
227+ }
228+ $tpage_names2 = array_values(array_unique($tpage_names));
229+ natcasesort($tpage_names2);
230+ natcasesort($page_names);
231+ $tpages = array(); // Template pages
232+ $npages = array(); // Normal pages
233+ foreach($tpage_names2 as $p) {
234+ $ps = htmlsc($p);
235+ $tpages[] = ' <option value="' . $ps . '">' . $ps . '</option>';
236+ }
237+ foreach($page_names as $p) {
238+ $ps = htmlsc($p);
239+ $npages[] = ' <option value="' . $ps . '">' . $ps . '</option>';
213240 }
214- ksort($pages, SORT_STRING);
215- $s_pages = join("\n", $pages);
241+ if (count($page_names) === $page_max) {
242+ $npages[] = ' <option value="">...</option>';
243+ }
244+ $s_tpages = join("\n", $tpages);
245+ $s_npages = join("\n", $npages);
216246 $template = <<<EOD
217247 <select name="template_page">
218248 <option value="">-- $_btn_template --</option>
219-$s_pages
249+ <optgroup label="$_btn_template">
250+$s_tpages
251+ </optgroup>
252+ <optgroup label="$_title_list">
253+$s_npages
254+ </optgroup>
220255 </select>
221256 <input type="submit" name="template" value="$_btn_load" accesskey="r" />
222257 <br />
@@ -559,4 +594,3 @@ function pkwk_output_dtd($pkwk_dtd = PKWK_DTD_XHTML_1_1, $charset = CONTENT_CHAR
559594 return '<meta http-equiv="content-type" content="text/html; charset=' . $charset . '" />' . "\n";
560595 }
561596 }
562-
Show on old repository browser