OSDN Git Service

Convert character code of the source code to UTF-8 from EUC-JP
[pukiwiki/pukiwiki.git] / plugin / versionlist.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: versionlist.inc.php,v 1.17 2007/05/12 08:37:38 henoheno Exp $
4 // Copyright (C)
5 //       2002-2006 PukiWiki Developers Team
6 //       2002      S.YOSHIMURA GPL2 yosimura@excellence.ac.jp
7 // License: GPL v2
8 //
9 // Listing cvs revisions of files
10
11 function plugin_versionlist_action()
12 {
13         global $_title_versionlist;
14
15         if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this');
16
17         return array(
18                 'msg' => $_title_versionlist,
19                 'body' => plugin_versionlist_convert());
20 }
21
22 function plugin_versionlist_convert()
23 {
24         if (PKWK_SAFE_MODE) return ''; // Show nothing
25         
26         /* 探索ディレクトリ設定 */
27         $SCRIPT_DIR = array('./');
28         if (LIB_DIR   != './') array_push($SCRIPT_DIR, LIB_DIR);
29         if (DATA_HOME != './' && DATA_HOME != LIB_DIR) array_push($SCRIPT_DIR, DATA_HOME);
30         array_push($SCRIPT_DIR, PLUGIN_DIR, SKIN_DIR);
31
32         $comments = array();
33
34         foreach ($SCRIPT_DIR as $sdir)
35         {
36                 if (!$dir = @dir($sdir))
37                 {
38                         // die_message('directory '.$sdir.' is not found or not readable.');
39                         continue;
40                 }
41                 while($file = $dir->read())
42                 {
43                         if (!preg_match("/\.(php|lng|css|js)$/i",$file))
44                         {
45                                 continue;
46                         }
47                         $data = join('',file($sdir.$file));
48                         $comment = array('file'=>htmlsc($sdir.$file),'rev'=>'','date'=>'');
49                         if (preg_match('/\$'.'Id: (.+),v (\d+\.\d+) (\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2})/',$data,$matches))
50                         {
51 //                              $comment['file'] = htmlsc($sdir.$matches[1]);
52                                 $comment['rev'] = htmlsc($matches[2]);
53                                 $comment['date'] = htmlsc($matches[3]);
54                         }
55                         $comments[$sdir.$file] = $comment;
56                 }
57                 $dir->close();
58         }
59         if (count($comments) == 0)
60         {
61                 return '';
62         }
63         ksort($comments, SORT_STRING);
64         $retval = '';
65         foreach ($comments as $comment)
66         {
67                 $retval .= <<<EOD
68
69   <tr>
70    <td>{$comment['file']}</td>
71    <td align="right">{$comment['rev']}</td>
72    <td>{$comment['date']}</td>
73   </tr>
74 EOD;
75         }
76         $retval = <<<EOD
77 <table border="1">
78  <thead>
79   <tr>
80    <th>filename</th>
81    <th>revision</th>
82    <th>date</th>
83   </tr>
84  </thead>
85  <tbody>
86 $retval
87  </tbody>
88 </table>
89 EOD;
90         return $retval;
91 }
92 ?>