Пример #1
0
 function file_save($file, $body)
 {
     if (is_dir(dirname($file)) && path_under_path(dirname($file), wiki_module::get_wiki_path())) {
         // Save the file ...
         $handle = fopen($file, "w+b");
         fputs($handle, $body);
         fclose($handle);
         // Update the search index for this file, if any
         $index = Zend_Search_Lucene::open(ATTACHMENTS_DIR . 'search/wiki');
         $f = str_replace(wiki_module::get_wiki_path(), "", $file);
         $hits = $index->find('id:' . $f);
         foreach ($hits as $hit) {
             $index->delete($hit->id);
         }
         wiki_module::update_search_index_doc($index, $f);
         $index->commit();
     }
 }
Пример #2
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();