OSDN Git Service

BugTrack/2256 edit: Handle template loading button
[pukiwiki/pukiwiki.git] / plugin / recent.inc.php
index 075122d..5936879 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-// $Id: recent.inc.php,v 1.17 2005/10/02 16:15:06 henoheno Exp $
+// $Id: recent.inc.php,v 1.27 2011/01/25 15:01:01 henoheno Exp $
 // Copyright (C)
-//   2002-2005 PukiWiki Developers Team
+//   2002-2007 PukiWiki Developers Team
 //   2002      Y.MASUI http://masui.net/pukiwiki/ masui@masui.net
 // License: GPL version 2
 //
@@ -24,7 +24,7 @@ define('PLUGIN_RECENT_CACHE', CACHE_DIR . 'recent.dat');
 
 function plugin_recent_convert()
 {
-       global $vars, $date_format, $_recent_plugin_frame;
+       global $vars, $date_format, $_recent_plugin_frame, $show_passage;
        static $exec_count = 1;
 
        $recent_lines = PLUGIN_RECENT_DEFAULT_LINES;
@@ -44,15 +44,17 @@ function plugin_recent_convert()
                ++$exec_count;
        }
 
-       // Get latest N changes
-       if (file_exists(PLUGIN_RECENT_CACHE)) {
-               // Only variables can be passed by reference from PHP 5.0.5
-               $file_array = file(PLUGIN_RECENT_CACHE); // with array_splice()
-               $lines      = array_splice($file_array, 0, $recent_lines);
-       } else {
-               return '#recent(): Cache file of RecentChanges not found' . '<br />';
+       if (! file_exists(PLUGIN_RECENT_CACHE)) {
+               put_lastmodified();
+               if (! file_exists(PLUGIN_RECENT_CACHE)) {
+                       return '#recent(): Cache file of RecentChanges not found' . '<br />';
+               }
        }
 
+       // Get latest N changes
+       $lines = file_head(PLUGIN_RECENT_CACHE, $recent_lines);
+       if ($lines == FALSE) return '#recent(): File can not open' . '<br />' . "\n";
+
        $script = get_script_uri();
        $date = $items = '';
        foreach ($lines as $line) {
@@ -69,15 +71,16 @@ function plugin_recent_convert()
                                '<ul class="recent_list">' . "\n";
                }
 
-               $s_page = htmlspecialchars($page);
-               if($page == $vars['page']) {
-                       // No need to link to the page now you read, notifies where you just read
+               $s_page = htmlsc($page);
+
+               if ($page === $vars['page']) {
+                       // No need to link to the page you just read, or notify where you just read
                        $items .= ' <li>' . $s_page . '</li>' . "\n";
                } else {
-                       $r_page = rawurlencode($page);
-                       $pg_passage = get_pg_passage($page, FALSE);
-                       $items .= ' <li><a href="' . $script . '?' . $r_page . '" title="' .
-                               $s_page . ' ' . $pg_passage . '">' . $s_page . '</a></li>' . "\n";
+                       $r_page = pagename_urlencode($page);
+                       $passage = $show_passage ? ' ' . get_passage($time) : '';
+                       $items .= ' <li><a href="' . $script . '?' . $r_page . '"' . 
+                               ' title="' . $s_page . $passage . '">' . $s_page . '</a></li>' . "\n";
                }
        }
        // End of the day
@@ -85,4 +88,4 @@ function plugin_recent_convert()
 
        return sprintf($_recent_plugin_frame, count($lines), $items);
 }
-?>
+