Esempio n. 1
0
 public static function get_list($_FORM)
 {
     global $TPL;
     $current_user =& singleton("current_user");
     $wiki_path = wiki_module::get_wiki_path();
     $files = search::get_recursive_dir_list($wiki_path);
     foreach ($files as $row) {
         $file = str_replace($wiki_path, "", $row);
         if ($_FORM["starred"] && $current_user->prefs["stars"]["wiki"][base64_encode($file)]) {
             $rows[] = array("filename" => $file);
         }
     }
     return (array) $rows;
 }
Esempio n. 2
0
 function get_recursive_dir_list($dir)
 {
     $rtn = array();
     $dir = realpath($dir) . DIRECTORY_SEPARATOR;
     $dont_search_these_dirs = array(".", "..", "CVS", ".hg", ".bzr", "_darcs", ".git");
     $files = scandir($dir);
     foreach ($files as $file) {
         if (!in_array($file, $dont_search_these_dirs)) {
             if (is_file($dir . $file) && !is_dir($dir . $file)) {
                 $rtn[] = $dir . $file;
             } else {
                 if (is_dir($dir . $file)) {
                     $rtn = array_merge((array) $rtn, (array) search::get_recursive_dir_list($dir . $file));
                 }
             }
         }
     }
     return $rtn;
 }
Esempio n. 3
0
<?php

// Create a search index for Wiki documents. This patch may take a long time to apply.
ini_set('max_execution_time', 180000);
ini_set('memory_limit', "256M");
$index = Zend_Search_Lucene::create(ATTACHMENTS_DIR . 'search/wiki');
$allowed_suffixes = array("", ".text", ".txt", ".html", ".xml", ".mdwn", ".pdf");
$files = search::get_recursive_dir_list(wiki_module::get_wiki_path());
foreach ($files as $file) {
    // check that the file is of an allowable type.
    preg_match("/(\\.\\w{3,4}\$)/", $file, $m);
    if (!in_array($m[1], $allowed_suffixes)) {
        continue;
    }
    wiki_module::update_search_index_doc($index, str_replace(wiki_module::get_wiki_path(), "", $file));
}
$index->commit();