wok view blazekiss/stuff/plugins/wkp_ToDo.php @ rev 13569

Add blazekiss
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 03 16:17:38 2012 +0100 (2012-11-03)
parents
children
line source
1 <?php # coding: utf-8
3 /** Indexe les tags {TODO ...} de pages/*.txt
4 * Accès via : ?action=todo
5 */
6 class Todo
7 {
8 public $description = "Indexe les tags {TODO ...} de la base Wiki";
10 function action($a)
11 {
12 global $CONTENT,$PAGE_TITLE,$PAGE_TITLE_link,$editable;
14 switch ($a) {
15 case "todo" :
16 $PAGE_TITLE_link = FALSE; // pas de lien sur le titre
17 $editable = FALSE; // non editable
18 $PAGE_TITLE = "To do"; // titre de la page
19 $CONTENT = '
20 <h2>{TODO ...} tags</h2>
21 ';
23 todo_index()
24 {
25 grep -l '{TODO' pages/*.txt | while read file; do
26 page=$(basename $file .txt)
27 ref="<a href=\"?page=$page#TODO\">$page</a>"
28 grep '{TODO' $file | sed "s|.*{TODO\\([^}]*\\)}.*|<p>$ref\\1</p>|"
29 done
30 }
32 if ($handle = @opendir("pages/data")) {
33 while(($item = readdir($handle)) !== false) {
34 if ($item == '..' || $item == '.') continue;
35 $CONTENT .= '<tr><td><input type=checkbox ';
36 exec('grep -qs "pages/data/'.$item.'" pages/*.txt', $tmp, $ret);
37 if ($ret == 0) $CONTENT .= 'checked=checked ';
38 $CONTENT .= 'disabled=disabled /><a href="pages/data/'.
39 $item.'">'.$item.'</a></td></tr>';
40 }
41 }
42 return TRUE;
43 }
44 return FALSE; // action non traitée
45 $CONTENT = preg_replace('#\[(.*)|(pages/.*)\]#','<a href="$1">$2</a>',$CONTENT);
46 } // action
48 function formatBegin()
49 {
50 global $CONTENT;
51 $CONTENT = preg_replace('#{TODO[^}]*}#','<a name="TODO"></a>',$CONTENT);
52 }
53 }
55 ?>