X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=plugin%2Frecent.inc.php;h=f90b91645e5199c85f2c6a3b3031991e573de0f8;hb=f0e3c0f48da688dd217f7ceee034ebb4880a25d0;hp=897832a45b44594b30d0608b46d996c22eed4f56;hpb=4683d446b562736dce7a199dc9dd168f455fe168;p=pukiwiki%2Fpukiwiki.git diff --git a/plugin/recent.inc.php b/plugin/recent.inc.php index 897832a..f90b916 100644 --- a/plugin/recent.inc.php +++ b/plugin/recent.inc.php @@ -1,62 +1,89 @@ ¤Ë¤è¤ë½ÐÎϤËÊѹ¹¤·¹½Â¤²½ - * - * $Id: recent.inc.php,v 1.13 2004/09/04 14:26:52 henoheno Exp $ - */ - -// RecentChanges¤Î¥­¥ã¥Ã¥·¥å +// PukiWiki - Yet another WikiWikiWeb clone +// recent.inc.php +// Copyright +// 2002-2017 PukiWiki Development Team +// 2002 Y.MASUI http://masui.net/pukiwiki/ masui@masui.net +// License: GPL v2 or (at your option) any later version +// +// Recent plugin -- Show RecentChanges list +// * Usually used at 'MenuBar' page +// * Also used at special-page, without no #recnet at 'MenuBar' + +// Default number of 'Show latest N changes' +define('PLUGIN_RECENT_DEFAULT_LINES', 10); + +// Limit number of executions +define('PLUGIN_RECENT_EXEC_LIMIT', 2); // N times per one output + +// ---- + +define('PLUGIN_RECENT_USAGE', '#recent(number-to-show)'); + +// Place of the cache of 'RecentChanges' define('PLUGIN_RECENT_CACHE', CACHE_DIR . 'recent.dat'); function plugin_recent_convert() { - global $script, $vars, $date_format; - global $_recent_plugin_frame; - - if (! file_exists(PLUGIN_RECENT_CACHE)) return ''; + global $vars, $date_format, $_recent_plugin_frame; + static $exec_count = 1; - $recent_lines = 10; + $recent_lines = PLUGIN_RECENT_DEFAULT_LINES; if (func_num_args()) { $args = func_get_args(); - if (is_numeric($args[0])) + if (! is_numeric($args[0]) || isset($args[1])) { + return PLUGIN_RECENT_USAGE . '
'; + } else { $recent_lines = $args[0]; + } } - // ÀèƬ¤ÎN·ï(¹Ô)¤ò¼è¤ê½Ð¤¹ - $lines = array_splice(file(PLUGIN_RECENT_CACHE), 0, $recent_lines); + // Show only N times + if ($exec_count > PLUGIN_RECENT_EXEC_LIMIT) { + return '#recent(): You called me too much' . '
' . "\n"; + } else { + ++$exec_count; + } + + if (! file_exists(PLUGIN_RECENT_CACHE)) { + put_lastmodified(); + if (! file_exists(PLUGIN_RECENT_CACHE)) { + return '#recent(): Cache file of RecentChanges not found' . '
'; + } + } + // Get latest N changes + $lines = file_head(PLUGIN_RECENT_CACHE, $recent_lines); + if ($lines == FALSE) return '#recent(): File can not open' . '
' . "\n"; $date = $items = ''; foreach ($lines as $line) { list($time, $page) = explode("\t", rtrim($line)); + $_date = get_date($date_format, $time); if ($date != $_date) { - if ($date != '') $items .= ''; + // End of the day + if ($date != '') $items .= '' . "\n"; + + // New day $date = $_date; - $items .= "$date\n" . - "' . "\n"; return sprintf($_recent_plugin_frame, count($lines), $items); } -?>