changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / page / wordindex.php
1 <?php
2
3 # Lists all used words inside WikiPageNames and shows a list of them
4 # (similar to PageIndex) - but it redirects the words to PowerSearch,
5 # which also needs to be installed therefor!
6
7
8 define("EWIKI_PAGE_WORDINDEX", "WordIndex");
9 $ewiki_plugins["page"][EWIKI_PAGE_WORDINDEX] = "ewiki_page_wordindex";
10
11
12 function ewiki_page_wordindex($id, $data, $action) {
13
14    global $ewiki_plugins;
15
16    $o = ewiki_make_title($id, $id, 2);
17
18    $src = "";
19
20    $result = ewiki_db::GETALL(array("flags"));
21    while ($row = $result->get()) {
22         if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
23             continue;
24         }   
25         if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
26             $src .= " " . $row["id"];
27         }
28    }
29
30    $src = ewiki_split_title($src, "SPLIT", 0);
31    $chars = strtr(EWIKI_CHARS_U.EWIKI_CHARS_L, "_", " ");
32    $src = preg_replace("/[^$chars]/", " ", $src);
33    $src = explode(" ", $src);
34    $src = array_unique($src);   //@ADD: word counting
35    unset($src[""]);
36
37    natcasesort($src);
38
39    $sorted = array();
40    foreach ($src as $i => $word) {
41
42       if (strlen($word) >= 2) {
43
44          $sorted[] = array(
45             EWIKI_PAGE_POWERSEARCH,
46             array("where"=>"id", "q"=>$word),
47             $word, ""          //@ADD: display word count
48          );
49
50       }
51    }
52    unset($src);
53
54    $pf_list_pages = $ewiki_plugins["list_dict"][0];
55    $o .= ewiki_list_pages($sorted, $limit=0, $vat=1, $pf_list_pages);
56
57    return($o);
58
59 }
60
61
62  ?>