OSDN Git Service

reimyさんによるHTML適正化
[pukiwiki/pukiwiki.git] / plugin / recent.inc.php
1 <?
2 /*
3  * PukiWiki ºÇ¿·¤Î?·ï¤òɽ¼¨¤¹¤ë¥×¥é¥°¥¤¥ó
4  *
5  * CopyRight 2002 Y.MASUI GPL2
6  * http://masui.net/pukiwiki/ masui@masui.net
7  * 
8  * Êѹ¹ÍúÎò:
9  *  2002.04.08: pat¤µ¤ó¡¢¤ß¤Î¤ë¤µ¤ó¤Î»ØŦ¤Ë¤è¤ê¡¢¥ê¥ó¥¯À褬ÆüËܸì¤Î¾ì¹ç¤Ë
10  *              ²½¤±¤ë¤Î¤ò½¤Àµ
11  * 
12  *  2002.06.17: plugin_recent_init()¤òÀßÄê
13  *
14  * $Id: recent.inc.php,v 1.3 2002/07/01 07:08:57 masui Exp $
15  */
16
17 function plugin_recent_init()
18 {
19   $_plugin_recent_messages = array(
20     '_recent_plugin_li'=>'¡¦',
21     '_recent_plugin_frame '=>'<h5 class="side_label">ºÇ¿·¤Î%d·ï</h5><span class="small">%s</span>');
22   set_plugin_messages($_plugin_recent_messages);
23 }
24
25 function plugin_recent_convert()
26 {
27         global $_recent_plugin_li,$_recent_plugin_frame;
28         global $WikiName,$BracketName,$script,$whatsnew;
29         
30         $recent_lines = 10;
31         if(func_num_args()>0) {
32                 $array = func_get_args();
33                 $recent_lines = $array[0];
34         }
35         
36         $lines = file(get_filename(encode($whatsnew)));
37         $date = $items = "";
38         $cnt = 0;
39         foreach($lines as $line)
40         {
41                 if($cnt > $recent_lines - 1) break;
42                 if(preg_match("/(($WikiName)|($BracketName))/",$line,$match))
43                 {
44                         $name = $match[1];
45                         if($match[2])
46                         {
47                                 $title = $match[1];
48                         }
49                         else
50                         {
51                                 $title = strip_bracket($match[1]);
52                         }
53                         if(preg_match("/([0-9]{4}-[0-9]{2}-[0-9]{2})/",$line,$match)) {
54                                 if($date != $match[0]) {
55                                         if($date != '') {
56                                                 $items .= "<br />";
57                                         }
58                                         $items .= "<strong>".$match[0]."</strong><br />";
59                                         $date = $match[0];
60                                 }
61                         }
62                         $title = htmlspecialchars($title);
63                         $items .= $_recent_plugin_li."<a href=\"".$script."?".rawurlencode($name)."\" title=\"$title ".get_pg_passage($name,false)."\">".$title."</a><br />\n";
64                         $cnt++;
65                 }
66         }
67         return sprintf($_recent_plugin_frame,$cnt,$items);
68 }
69 ?>