OSDN Git Service

Simplify. Renive unused global, shrink, rename internal vars...
[pukiwiki/pukiwiki.git] / plugin / recent.inc.php
index 08e5c73..9087d0b 100644 (file)
@@ -4,37 +4,43 @@
  *
  * CopyRight 2002 Y.MASUI GPL2
  * http://masui.net/pukiwiki/ masui@masui.net
- * 
+ *
  * Êѹ¹ÍúÎò:
  *  2002.04.08: pat¤µ¤ó¡¢¤ß¤Î¤ë¤µ¤ó¤Î»ØŦ¤Ë¤è¤ê¡¢¥ê¥ó¥¯À褬ÆüËܸì¤Î¾ì¹ç¤Ë
  *              ²½¤±¤ë¤Î¤ò½¤Àµ
- * 
+ *
  *  2002.06.17: plugin_recent_init()¤òÀßÄê
  *  2002.07.02: <ul>¤Ë¤è¤ë½ÐÎϤËÊѹ¹¤·¹½Â¤²½
  *
- * $id$
+ * $Id: recent.inc.php,v 1.11 2004/07/31 03:09:20 henoheno Exp $
  */
 
 function plugin_recent_convert()
 {
-       global $script,$BracketName,$whatsnew,$date_format;
+       global $script,$BracketName,$date_format;
        global $_recent_plugin_frame;
-       
+
        $recent_lines = 10;
-       if (func_num_args())
-               list($recent_lines) = func_get_args();
-       
+       if (func_num_args()) {
+               $args = func_get_args();
+               if (is_numeric($args[0])) {
+                       $recent_lines = $args[0];
+               }
+       }
+
        $date = $items = '';
-       $lines = array_splice(preg_grep('/^\/\//',get_source($whatsnew)),0,$recent_lines);
-       foreach($lines as $line) {
-               if (!preg_match("/^\/\/(\d+)\s($BracketName)$/",$line,$match))
-                       continue; // fatal error, die?
-               
-               $page = $match[2];
-               $_date = get_date($date_format,$match[1]);
+       if (!file_exists(CACHE_DIR.'recent.dat')) {
+               return '';
+       }
+       $recent = file(CACHE_DIR.'recent.dat');
+       $lines = array_splice($recent,0,$recent_lines);
+       foreach ($lines as $line) {
+               list($time,$page) = explode("\t",rtrim($line));
+               $_date = get_date($date_format,$time);
                if ($date != $_date) {
-                       if ($date != '')
+                       if ($date != '') {
                                $items .= '</ul>';
+                       }
                        $date = $_date;
                        $items .= "<strong>$date</strong>\n<ul class=\"recent_list\">";
                }