Revisão | 6c0563312311d3b114446e9c28dc434f09bab035 (tree) |
---|---|
Hora | 2004-09-04 23:16:30 |
Autor | henoheno <henoheno> |
Commiter | henoheno |
Just a cleanup. Add two \n
@@ -12,46 +12,46 @@ | ||
12 | 12 | * 2002.06.17: plugin_recent_init()を設定 |
13 | 13 | * 2002.07.02: <ul>による出力に変更し構造化 |
14 | 14 | * |
15 | - * $Id: recent.inc.php,v 1.11 2004/07/31 03:09:20 henoheno Exp $ | |
15 | + * $Id: recent.inc.php,v 1.12 2004/09/04 14:16:30 henoheno Exp $ | |
16 | 16 | */ |
17 | 17 | |
18 | +// RecentChangesのキャッシュ | |
19 | +define('PLUGIN_RECENT_CACHE', CACHE_DIR . 'recent.dat'); | |
20 | + | |
18 | 21 | function plugin_recent_convert() |
19 | 22 | { |
20 | - global $script,$BracketName,$date_format; | |
23 | + global $script, $date_format; | |
21 | 24 | global $_recent_plugin_frame; |
22 | 25 | |
26 | + if (! file_exists(PLUGIN_RECENT_CACHE)) return ''; | |
27 | + | |
23 | 28 | $recent_lines = 10; |
24 | 29 | if (func_num_args()) { |
25 | 30 | $args = func_get_args(); |
26 | - if (is_numeric($args[0])) { | |
31 | + if (is_numeric($args[0])) | |
27 | 32 | $recent_lines = $args[0]; |
28 | - } | |
29 | 33 | } |
30 | 34 | |
35 | + // 先頭のN件(行)を取り出す | |
36 | + $lines = array_splice(file(PLUGIN_RECENT_CACHE), 0, $recent_lines); | |
37 | + | |
31 | 38 | $date = $items = ''; |
32 | - if (!file_exists(CACHE_DIR.'recent.dat')) { | |
33 | - return ''; | |
34 | - } | |
35 | - $recent = file(CACHE_DIR.'recent.dat'); | |
36 | - $lines = array_splice($recent,0,$recent_lines); | |
37 | 39 | foreach ($lines as $line) { |
38 | - list($time,$page) = explode("\t",rtrim($line)); | |
39 | - $_date = get_date($date_format,$time); | |
40 | + list($time, $page) = explode("\t", rtrim($line)); | |
41 | + $_date = get_date($date_format, $time); | |
40 | 42 | if ($date != $_date) { |
41 | - if ($date != '') { | |
42 | - $items .= '</ul>'; | |
43 | - } | |
43 | + if ($date != '') $items .= '</ul>'; | |
44 | 44 | $date = $_date; |
45 | - $items .= "<strong>$date</strong>\n<ul class=\"recent_list\">"; | |
45 | + $items .= "<strong>$date</strong>\n" . | |
46 | + "<ul class=\"recent_list\">\n"; | |
46 | 47 | } |
47 | 48 | $s_page = htmlspecialchars($page); |
48 | 49 | $r_page = rawurlencode($page); |
49 | - $pg_passage = get_pg_passage($page,FALSE); | |
50 | + $pg_passage = get_pg_passage($page, FALSE); | |
50 | 51 | $items .=" <li><a href=\"$script?$r_page\" title=\"$s_page $pg_passage\">$s_page</a></li>\n"; |
51 | 52 | } |
52 | - if (count($lines)) { | |
53 | - $items .='</ul>'; | |
54 | - } | |
55 | - return sprintf($_recent_plugin_frame,count($lines),$items); | |
53 | + if (! empty($lines)) $items .= "</ul>\n"; | |
54 | + | |
55 | + return sprintf($_recent_plugin_frame, count($lines), $items); | |
56 | 56 | } |
57 | 57 | ?> |