OSDN Git Service

PukiWiki version is "1.5.4" / Year 2021
[pukiwiki/pukiwiki.git] / plugin / ls.inc.php
1 <?php
2 /*
3  * PukiWiki lsプラグイン
4  *
5  * CopyRight 2002 Y.MASUI GPL2
6  * http://masui.net/pukiwiki/ masui@masui.net
7  *
8  * $Id: ls.inc.php,v 1.9 2004/07/31 03:09:20 henoheno Exp $
9  */
10
11 function plugin_ls_convert()
12 {
13         global $vars;
14
15         $with_title = FALSE;
16
17         if (func_num_args())
18         {
19                 $args = func_get_args();
20                 $with_title = in_array('title',$args);
21         }
22
23         $prefix = $vars['page'].'/';
24
25         $pages = array();
26         foreach (get_existpages() as $page)
27         {
28                 if (strpos($page,$prefix) === 0)
29                 {
30                         $pages[] = $page;
31                 }
32         }
33         natcasesort($pages);
34
35         $ls = array();
36         foreach ($pages as $page)
37         {
38                 $comment = '';
39                 if ($with_title)
40                 {
41                         list($comment) = get_source($page);
42                         // 見出しの固有ID部を削除
43                         $comment = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/','$1$2',$comment);
44
45                         $comment = '- ' . preg_replace('/^[-*]+/','',$comment);
46                 }
47                 $ls[] = "-[[$page]] $comment";
48         }
49
50         return convert_html($ls);
51 }
52