diff --git a/views/bootstrap/class.Indexer.php b/views/bootstrap/class.Indexer.php index a28cffd5f..e0934f963 100644 --- a/views/bootstrap/class.Indexer.php +++ b/views/bootstrap/class.Indexer.php @@ -18,6 +18,76 @@ */ 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 "
".$folder->getFolderPathPlain()."
"; + foreach($documents as $document) { + echo "
".$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 " getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting').""; + /* + 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 "getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_document_unchanged').""; + } else { + $this->index->delete($hit->id); + echo " getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting').""; + /* + 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 "
"; + } + } + } /* }}} */ +} /* }}} */ + /** * Class which outputs the html page for Indexer view * @@ -205,6 +275,9 @@ $(document).ready( function() { ?>