return $aryret;
}
+/**
+ * Get/Set pagelist cache enabled for get_existpages()
+ *
+ * @param $newvalue Set true when the system can cache the page list
+ * @return true if can use page list cache
+ */
+function is_pagelist_cache_enabled($newvalue = null)
+{
+ static $cache_enabled = null;
+
+ if (!is_null($newvalue)) {
+ $cache_enabled = $newvalue;
+ return; // Return nothing on setting newvalue call
+ }
+ if (is_null($cache_enabled)) {
+ return false;
+ }
+ return $cache_enabled;
+}
+
// Get a page list of this wiki
function get_existpages($dir = DATA_DIR, $ext = '.txt')
{
+ static $cached_list = null; // Cached wikitext page list
+ $use_cache = false;
+
+ if ($dir === DATA_DIR && $ext === '.txt' && is_pagelist_cache_enabled()) {
+ // Use pagelist cache for "wiki/*.txt" files
+ if (!is_null($cached_list)) {
+ return $cached_list;
+ }
+ $use_cache = true;
+ }
$aryret = array();
$pattern = '/^((?:[0-9A-F]{2})+)' . preg_quote($ext, '/') . '$/';
-
$dp = @opendir($dir) or die_message($dir . ' is not found or not readable.');
$matches = array();
while (($file = readdir($dp)) !== FALSE) {
}
}
closedir($dp);
-
+ if ($use_cache) {
+ $cached_list = $aryret;
+ }
return $aryret;
}
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: read.inc.php,v 1.9 2011/01/25 15:01:01 henoheno Exp $
+// read.inc.php
+// Copyright 2003-2017 PukiWiki Development Team
+// License: GPL v2 or (at your option) any later version
//
// Read plugin: Show a page and InterWiki
global $vars, $_title_invalidwn, $_msg_invalidiwn;
$page = isset($vars['page']) ? $vars['page'] : '';
-
if (is_page($page)) {
- // ページを表示
+ // Show this page
check_readable($page, true, true);
header_lastmod($page);
+ is_pagelist_cache_enabled(true); // Enable get_existpage() cache
return array('msg'=>'', 'body'=>'');
} else if (! PKWK_SAFE_MODE && is_interwiki($page)) {
- return do_plugin_action('interwiki'); // InterWikiNameを処理
+ return do_plugin_action('interwiki'); // Process InterWikiName
} else if (is_pagename($page)) {
$vars['cmd'] = 'edit';
- return do_plugin_action('edit'); // 存在しないので、編集フォームを表示
+ return do_plugin_action('edit'); // Page not found, then show edit form
} else {
- // 無効なページ名
+ // Invalid page name
return array(
'msg'=>$_title_invalidwn,
'body'=>str_replace('$1', htmlsc($page),
);
}
}
-?>