mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-15 06:01:19 +00:00
use new class SeedDMS_FolderTree for iterating over all folders
This commit is contained in:
parent
b6ac58eb3d
commit
487950c37c
|
@ -18,6 +18,76 @@
|
||||||
*/
|
*/
|
||||||
require_once("class.Bootstrap.php");
|
require_once("class.Bootstrap.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for processing a single folder
|
||||||
|
*
|
||||||
|
* SeedDMS_View_Indexer_Process_Folder::process() is used as a callable when
|
||||||
|
* iterating over all folders recursively.
|
||||||
|
*/
|
||||||
|
class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
|
||||||
|
protected $forceupdate;
|
||||||
|
|
||||||
|
protected $index;
|
||||||
|
|
||||||
|
protected $indexconf;
|
||||||
|
|
||||||
|
public function __construct($index, $indexconf, $forceupdate) { /* {{{ */
|
||||||
|
$this->index = $index;
|
||||||
|
$this->indexconf = $indexconf;
|
||||||
|
$this->forceupdate = $forceupdate;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function process($folder) { /* {{{ */
|
||||||
|
$documents = $folder->getDocuments();
|
||||||
|
if($documents) {
|
||||||
|
echo "<div class=\"folder\">".$folder->getFolderPathPlain()."</div>";
|
||||||
|
foreach($documents as $document) {
|
||||||
|
echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
|
||||||
|
/* If the document wasn't indexed before then just add it */
|
||||||
|
$lucenesearch = new $this->indexconf['Search']($this->index);
|
||||||
|
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
|
||||||
|
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
|
||||||
|
echo "(document added)";
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo $indent."(adding document failed '".$e->getMessage()."')";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
/* Check if the attribute created is set or has a value older
|
||||||
|
* than the lastet content. Documents without such an attribute
|
||||||
|
* where added when a new document was added to the dms. In such
|
||||||
|
* a case the document content wasn't indexed.
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
$created = (int) $hit->getDocument()->getFieldValue('created');
|
||||||
|
} catch (/* Zend_Search_Lucene_ */Exception $e) {
|
||||||
|
$created = 0;
|
||||||
|
}
|
||||||
|
$content = $document->getLatestContent();
|
||||||
|
if($created >= $content->getDate() && !$this->forceupdate) {
|
||||||
|
echo "<span id=\"status_".$document->getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
|
||||||
|
} else {
|
||||||
|
$this->index->delete($hit->id);
|
||||||
|
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
|
||||||
|
echo $indent."(document updated)";
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo $indent."(updating document failed)";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which outputs the html page for Indexer view
|
* Class which outputs the html page for Indexer view
|
||||||
*
|
*
|
||||||
|
@ -205,6 +275,9 @@ $(document).ready( function() {
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
li {line-height: 20px;}
|
li {line-height: 20px;}
|
||||||
|
div.document {line-height: 20px;}
|
||||||
|
div.document:hover {background-color: #eee;}
|
||||||
|
div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
|
||||||
.nav-header {line-height: 19px; margin-bottom: 0px;}
|
.nav-header {line-height: 19px; margin-bottom: 0px;}
|
||||||
.nav-list {padding-right: 0px;}
|
.nav-list {padding-right: 0px;}
|
||||||
.nav-list>li.document:hover {background-color: #eee;}
|
.nav-list>li.document:hover {background-color: #eee;}
|
||||||
|
@ -226,7 +299,10 @@ li {line-height: 20px;}
|
||||||
<div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div>
|
<div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$this->tree($dms, $index, $indexconf, $folder);
|
$folderprocess = new SeedDMS_View_Indexer_Process_Folder($index, $indexconf, $forceupdate);
|
||||||
|
$tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process'));
|
||||||
|
call_user_func(array($folderprocess, 'process'), $folder);
|
||||||
|
// $this->tree($dms, $index, $indexconf, $folder);
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
||||||
$index->commit();
|
$index->commit();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user