OSDN Git Service

href="...&ls=..." -> href="...&=...." by reimy
[pukiwiki/pukiwiki.git] / plugin / ls.inc.php
1 <?
2 /*
3  * PukiWiki ls¥×¥é¥°¥¤¥ó
4  *
5  * CopyRight 2002 Y.MASUI GPL2
6  * http://masui.net/pukiwiki/ masui@masui.net
7  */
8
9 function plugin_ls_convert()
10 {
11         global $vars, $script;
12         
13         if(func_num_args())
14                 $aryargs = func_get_args();
15         else
16                 $aryargs = array();
17
18         $with_title = FALSE;
19         if(array_search('title',$aryargs)!==FALSE) {
20           $with_title = TRUE;
21         }
22         $ls = $comment = '';
23         $filepattern = encode('[['.strip_bracket($vars["page"]).'/');
24         $filepattern_len = strlen($filepattern);
25         if ($dir = @opendir(DATA_DIR))
26         {
27                 while($file = readdir($dir))
28                 {
29                         if($file == ".." || $file == ".") continue;
30                         if(substr($file,0,$filepattern_len)!=$filepattern) continue; 
31                         $page = decode(trim(preg_replace("/\.txt$/"," ",$file)));
32                         if($with_title) {
33                           $comment = '';
34                           $fd = fopen(DATA_DIR . $file,'r');
35                           if(!feof ($fd)) {
36                             $comment = ereg_replace("^[-*]+",'',fgets($fd,1024));
37                             $comment = ereg_replace("[~\r\n]+$",'',$comment);
38                             $comment = trim($comment);
39                           }
40                           if($comment != '' && substr($comment,0,1) != '#') {
41                             $comment = " - " . convert_html($comment);
42                           }
43                           else {
44                             $comment = '';
45                           }
46                           fclose($fd);
47                         }
48                         $url = rawurlencode($page);
49                         $name = strip_bracket($page);
50                         $title = $name ." " .get_pg_passage($page,false);
51                         $ls .= "<li><a href=\"$script?cmd=read&amp;page=$url\" title=\"$title\">$name</a>$comment\n";
52                 }
53                 closedir($dir);
54         }
55         
56         if($ls=='') {
57           return '';
58         }
59         
60         return "<ul>$ls</ul>";
61 }
62 ?>