OSDN Git Service

[[pukiwiki:BugTrack/60]] recentプラグインを構造化 - reimy
[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  *  2002.07.02: <ul>¤Ë¤è¤ë½ÐÎϤËÊѹ¹¤·¹½Â¤²½
14  *
15  * $id$
16  */
17
18 function plugin_recent_init()
19 {
20   $_plugin_recent_messages = array(
21     '_recent_plugin_frame '=>'<h5 class="side_label" style="margin:auto;margin-top:0px;margin-bottom:.5em">ºÇ¿·¤Î%d·ï</h5><div class="small" style="margin-left:.8em;margin-right:.8em">%s</div>');
22   set_plugin_messages($_plugin_recent_messages);
23 }
24
25 function plugin_recent_convert()
26 {
27         global $_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 .= "</ul>";
57                                         }
58                                         $items .= "<strong>".$match[0]."</strong><ul class=\"recent_list\">";
59                                         $date = $match[0];
60                                 }
61                         }
62                         $title = htmlspecialchars($title);
63                         $items .="<li><a href=\"".$script."?".rawurlencode($name)."\" title=\"$title ".get_pg_passage($name,false)."\">".$title."</a></li>\n";
64                         $cnt++;
65                 }
66         }
67         $items .="</ul>";
68         return sprintf($_recent_plugin_frame,$cnt,$items);
69 }
70 ?>