d87add40a72f2516e0b92e137da8e8c36590a221
[atutor.git] / mods / wiki / plugins / module / tour.php
1 <?php
2
3 /*
4    Provides a fancy "quick view" (fragments) of the current and all
5    associated (linked and backlinked) pages.
6
7    - idea borought from a PhpWiki: discussion.
8    - obviously needs improvement (all links should be tour:Links ?)
9 */
10
11
12
13 $ewiki_plugins["action"]["tour"] = "ewiki_tour";
14 $ewiki_config["action_links"]["view"]["tour"] = "PageTour";
15 $ewiki_config["action_links"]["tour"]["view"] = "ViewFullPage";
16 $ewiki_config["action_links"]["tour"]["links"] = "BACKLINKS";
17 $ewiki_config["action_links"]["tour"]["info"] = "PAGEHISTORY";
18
19 function ewiki_tour($id, &$data, $action) {
20
21    $o = "\n";
22
23    $page_lists = array(
24       array($id),
25       explode("\n", trim($data["refs"])),
26       ewiki_get_backlinks($id),
27    );
28
29    foreach ($page_lists as $pages) {
30       foreach ($pages as $page) {
31
32          $row = ewiki_db::GET($page);
33          if (EWIKI_DB_F_TEXT == $row["flags"] & EWIKI_DB_F_TYPE) {
34
35             $add = substr($row["content"], 0, 333);
36             $add = substr($add, 0, strrpos($add, " "));
37             $add = preg_replace("/^[!*#-:;>]+/m", "", $add);
38             $add = strtr($add, "\n\t", "  ");
39
40             $o .= "!!! [tour:{$row[id]}]\n"
41                 . "@@tour-page-fragment $add ...\n\n";
42          }
43       }
44
45    }
46
47    $o = ewiki_format($o);
48    $o .= ewiki_control_links($id, $data, $action);
49    return($o);
50 }
51
52
53 ?>