Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2022-12-15 12:45:04 +01:00
commit 9e9c0c8ac5
6 changed files with 30 additions and 24 deletions

View File

@ -149,8 +149,9 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
if($version) {
$this->addField(Zend_Search_Lucene_Field::Keyword('mimetype', $version->getMimeType()));
$this->addField(Zend_Search_Lucene_Field::Keyword('origfilename', $version->getOriginalFileName(), 'utf-8'));
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $version->getDate()));
if(!$nocontent)
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $version->getDate()));
$this->addField(Zend_Search_Lucene_Field::UnIndexed('indexed', time()));
if($attributes = $version->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();

View File

@ -151,8 +151,9 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
if($version) {
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('mimetype', $version->getMimeType()));
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('origfilename', $version->getOriginalFileName()));
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('created', $version->getDate(), 'unindexed'));
if(!$nocontent)
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('created', $version->getDate(), 'unindexed'));
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('indexed', time(), 'unindexed'));
if($attributes = $version->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();
@ -226,6 +227,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('document_id', 'F'.$document->getID()));
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('record_type', 'folder'));
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('created', $document->getDate(), 'unindexed'));
$this->addField(SeedDMS_SQLiteFTS_Field::Keyword('indexed', time(), 'unindexed'));
}
} /* }}} */

View File

@ -77,9 +77,9 @@ class SeedDMS_SQLiteFTS_Indexer {
$version = SQLite3::version();
if(self::ftstype == 'fts4') {
if($version['versionNumber'] >= 3008000)
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, path, notindexed=created, matchinfo=fts3)';
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created, indexed, users, status, path, notindexed=created, notindexed=indexed, matchinfo=fts3)';
else
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, path, matchinfo=fts3)';
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created, indexed, users, status, path, matchinfo=fts3)';
$res = $index->_conn->exec($sql);
if($res === false) {
return null;
@ -90,7 +90,7 @@ class SeedDMS_SQLiteFTS_Indexer {
return null;
}
} elseif(self::ftstype == 'fts5') {
$sql = 'CREATE VIRTUAL TABLE docs USING fts5(documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created unindexed, users, status, path)';
$sql = 'CREATE VIRTUAL TABLE docs USING fts5(documentid, record_type, title, comment, keywords, category, mimetype, origfilename, owner, content, created unindexed, indexed unindexed, users, status, path)';
$res = $index->_conn->exec($sql);
if($res === false) {
return null;
@ -123,7 +123,7 @@ class SeedDMS_SQLiteFTS_Indexer {
if(!$this->_conn)
return false;
foreach(array('comment', 'keywords', 'category', 'content', 'mimetype', 'origfilename', 'status', 'created') as $kk) {
foreach(array('comment', 'keywords', 'category', 'content', 'mimetype', 'origfilename', 'status', 'created', 'indexed') as $kk) {
try {
${$kk} = $doc->getFieldValue($kk);
} catch (Exception $e) {
@ -135,7 +135,7 @@ class SeedDMS_SQLiteFTS_Indexer {
if($res === false) {
return false;
}
$sql = "INSERT INTO docs (documentid, record_type, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status, path) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('record_type')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($comment).", ".$this->_conn->quote($keywords).", ".$this->_conn->quote($category).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($content).", ".$this->_conn->quote($mimetype).", ".$this->_conn->quote($origfilename).", ".(int)$created.", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($status).", ".$this->_conn->quote($doc->getFieldValue('path'))/*time()*/.")";
$sql = "INSERT INTO docs (documentid, record_type, title, comment, keywords, category, owner, content, mimetype, origfilename, created, indexed, users, status, path) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('record_type')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($comment).", ".$this->_conn->quote($keywords).", ".$this->_conn->quote($category).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($content).", ".$this->_conn->quote($mimetype).", ".$this->_conn->quote($origfilename).", ".(int)$created.", ".(int)$indexed.", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($status).", ".$this->_conn->quote($doc->getFieldValue('path'))/*time()*/.")";
$res = $this->_conn->exec($sql);
if($res === false) {
return false;
@ -324,7 +324,7 @@ class SeedDMS_SQLiteFTS_Indexer {
if(!$this->_conn)
return false;
$sql = "SELECT ".$this->_rawid.", documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path".($content ? ", content" : "")." FROM docs WHERE ".$this->_rawid."='".$id."'";
$sql = "SELECT ".$this->_rawid.", documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, indexed, users, status, path".($content ? ", content" : "")." FROM docs WHERE ".$this->_rawid."='".$id."'";
$res = $this->_conn->query($sql);
$doc = false;
if($res) {
@ -341,6 +341,7 @@ class SeedDMS_SQLiteFTS_Indexer {
$doc->addField(SeedDMS_SQLiteFTS_Field::Keyword('origfilename', $rec['origfilename']));
$doc->addField(SeedDMS_SQLiteFTS_Field::Text('owner', $rec['owner']));
$doc->addField(SeedDMS_SQLiteFTS_Field::Keyword('created', $rec['created']));
$doc->addField(SeedDMS_SQLiteFTS_Field::Keyword('indexed', $rec['indexed']));
$doc->addField(SeedDMS_SQLiteFTS_Field::Text('users', $rec['users']));
$doc->addField(SeedDMS_SQLiteFTS_Field::Keyword('status', $rec['status']));
$doc->addField(SeedDMS_SQLiteFTS_Field::Keyword('path', $rec['path']));

View File

@ -53,6 +53,7 @@ class SeedDMS_SQLiteFTS_QueryHit {
*/
public function __construct(SeedDMS_SQLiteFTS_Indexer $index) { /* {{{ */
$this->_index = $index;
$this->_document = null;
} /* }}} */
/**

View File

@ -60,7 +60,8 @@ class SeedDMS_SQLiteFTS_Term {
9 => 'created',
10 => 'user',
11 => 'status',
12 => 'path'
12 => 'path',
13 => 'indexed',
);
/* fts5 pass the column name in $col, fts4 uses an integer */
if(is_int($col))

View File

@ -42,17 +42,17 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
if(($this->numdocs == 0) || !($hit = $lucenesearch->getFolder($folder->getId()))) {
echo " <span id=\"status_F".$folder->getID()."\" class=\"indexme indexstatus\" data-docid=\"F".$folder->getID()."\">".getMLText('index_waiting')."</span>";
} else {
/* Check if the attribute created is set or has a value older
/* Check if the attribute indexed 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');
$indexed = (int) $hit->getDocument()->getFieldValue('indexed');
} catch (/* Zend_Search_Lucene_ */Exception $e) {
$created = 0;
$indexed = 0;
}
if($created >= $folder->getDate() && !$this->forceupdate) {
if($indexed >= $folder->getDate() && !$this->forceupdate) {
echo "<span id=\"status_F".$folder->getID()."\" class=\"indexstatus\" data-docid=\"F".$folder->getID()."\">".getMLText('index_document_unchanged')."</span>";
} else {
$this->fulltextservice->Indexer()->delete($hit->id);
@ -70,18 +70,18 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
if(($this->numdocs == 0) || !($hit = $lucenesearch->getDocument($document->getId()))) {
echo " <span id=\"status_D".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"D".$document->getID()."\">".getMLText('index_waiting')."</span>";
} else {
/* Check if the attribute created is set or has a value older
/* Check if the attribute indexed 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');
$indexed = (int) $hit->getDocument()->getFieldValue('indexed');
} catch (/* Zend_Search_Lucene_ */Exception $e) {
$created = 0;
$indexed = 0;
}
$content = $document->getLatestContent();
if($created >= $content->getDate() && !$this->forceupdate) {
if($indexed >= $content->getDate() && !$this->forceupdate) {
echo "<span id=\"status_D".$document->getID()."\" class=\"indexstatus\" data-docid=\"D".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
} else {
$this->fulltextservice->Indexer()->delete($hit->id);
@ -132,7 +132,7 @@ function check_queue() {
}
var command = '';
docid = funcArray.pop();
$('#status_'+docid).html('Processsing ...');
$('#status_'+docid).html('<?= getMLText('index_processing') ?>');
if(docid[0] == 'F') {
command = 'indexfolder';
} else {
@ -161,11 +161,11 @@ function check_queue() {
// console.log('success ' + data.data);
if(data.success) {
if(data.cmd)
$('#status_'+data.data).html('<?php printMLText('index_done'); ?>');
$('#status_'+data.data).html('<?= getMLText('index_done') ?>');
else
$('#status_'+data.data).html('<?= getMLText('index_done').' ('.getMLText('index_no_content').')'; ?>');
$('#status_'+data.data).html('<?= getMLText('index_done').' ('.getMLText('index_no_content').')' ?>');
} else {
$('#status_'+data.data).html('<?php printMLText('index_error'); ?>');
$('#status_'+data.data).html('<?= getMLText('index_error') ?>');
noty({
text: '<p><strong>Docid: ' + data.data + ' (' + data.mimetype + ')</strong></p>' + '<p>Cmd: ' + data.cmd + '</p>' + data.message,
type: 'error',
@ -196,7 +196,7 @@ $(document).ready( function() {
$('.indexme').each(function(index) {
var element = $(this);
var docid = element.data('docid');
element.html('<?php printMLText('index_pending'); ?>');
element.html('<?= getMLText('index_pending') ?>');
funcArray.push(docid);
});
docstoindex = funcArray.length;
@ -235,13 +235,13 @@ div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
<div class="progress">
<div class="progress-bar bar total-bar" role="progressbar" style="width: 100%;"></div>
</div>
<div class="bar-legend"><?php printMLText('overall_indexing_progress'); ?></div>
<div class="bar-legend"><?= getMLText('overall_indexing_progress') ?></div>
</div>
<div>
<div class="progress">
<div class="progress-bar bar queue-bar" role="progressbar" style="width: 100%;"></div>
</div>
<div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div>
<div class="bar-legend"><?= getMLText('indexing_tasks_in_queue') ?></div>
</div>
<?php
$folderprocess = new SeedDMS_View_Indexer_Process_Folder($fulltextservice, $forceupdate);