From 1c839fd26ba4be13976549baad4ea5e9f73af61c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 24 Jun 2021 09:26:17 +0200 Subject: [PATCH 1/5] pass depth of iterator to callback function --- inc/inc.Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index 64633ad8a..c89782f66 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -1018,7 +1018,7 @@ class SeedDMS_FolderTree { /* {{{ */ $iter = new \SeedDMS\RecursiveFolderIterator($folder); $iter2 = new RecursiveIteratorIterator($iter, RecursiveIteratorIterator:: SELF_FIRST); foreach($iter2 as $ff) { - call_user_func($callback, $ff); + call_user_func($callback, $ff, $iter2->getDepth()); // echo $ff->getID().': '.$ff->getFolderPathPlain().'-'.$ff->getName()."
"; } } /* }}} */ From ec46d40194f558e07c24f34ed0dd8c00c33d9e70 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 24 Jun 2021 09:26:37 +0200 Subject: [PATCH 2/5] indent folders, place folder icon in front of folder name --- views/bootstrap/class.Indexer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.Indexer.php b/views/bootstrap/class.Indexer.php index 99dc859dc..75e8b8110 100644 --- a/views/bootstrap/class.Indexer.php +++ b/views/bootstrap/class.Indexer.php @@ -35,9 +35,9 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */ $this->numdocs = $this->fulltextservice->Indexer()->count(); } /* }}} */ - public function process($folder) { /* {{{ */ + public function process($folder, $depth=0) { /* {{{ */ $lucenesearch = $this->fulltextservice->Search(); - echo "
".$folder->getId().":".htmlspecialchars($folder->getFolderPathPlain()); + echo "
".$folder->getId().":".htmlspecialchars($folder->getFolderPathPlain()); /* If the document wasn't indexed before then just add it */ if(($this->numdocs == 0) || !($hit = $lucenesearch->getFolder($folder->getId()))) { echo " getID()."\" class=\"indexme indexstatus\" data-docid=\"F".$folder->getID()."\">".getMLText('index_waiting').""; @@ -65,7 +65,7 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */ if($documents) { // echo "
".htmlspecialchars($folder->getFolderPathPlain())."
"; foreach($documents as $document) { - echo "
".$document->getId().":".htmlspecialchars($document->getName()); + echo "
".$document->getId().":".htmlspecialchars($document->getName()); /* If the document wasn't indexed before then just add it */ if(($this->numdocs == 0) || !($hit = $lucenesearch->getDocument($document->getId()))) { echo " getID()."\" class=\"indexme indexstatus\" data-docid=\"D".$document->getID()."\">".getMLText('index_waiting').""; @@ -246,7 +246,7 @@ div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;} "; $index->commit(); From 50e8c8493267b05d9bdd7dc467f1ebfff8078c30 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 24 Jun 2021 11:38:04 +0200 Subject: [PATCH 3/5] use findById instead of find in getDocument() and getFolder() --- SeedDMS_SQLiteFTS/SQLiteFTS/Search.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php b/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php index 77b3993f6..20381d1a8 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php @@ -45,23 +45,23 @@ class SeedDMS_SQliteFTS_Search { /** * Get document from index * - * @param int $id real document id + * @param int $id id of seeddms document * @return object instance of SeedDMS_SQliteFTS_QueryHit or false */ function getDocument($id) { /* {{{ */ - $hits = $this->index->find('D'.$id); - return $hits['hits'] ? $hits['hits'][0] : false; + $hits = $this->index->findById('D'.$id); + return $hits ? $hits[0] : false; } /* }}} */ /** * Get folder from index * - * @param int $id real folder id + * @param int $id id of seeddms folder * @return object instance of SeedDMS_SQliteFTS_QueryHit or false */ function getFolder($id) { /* {{{ */ - $hits = $this->index->find('F'.$id); - return $hits['hits'] ? $hits['hits'][0] : false; + $hits = $this->index->findById('F'.$id); + return $hits ? $hits[0] : false; } /* }}} */ /** From 04c494eaaaeddbe9c94733ecb5920a9a812a04be Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 24 Jun 2021 11:39:13 +0200 Subject: [PATCH 4/5] set documentid in findById(), getDocument returns content, take out getFolder() --- SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php b/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php index cc5b39119..bb77b9835 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php @@ -165,7 +165,7 @@ class SeedDMS_SQLiteFTS_Indexer { * @param string $query * @param array $limit array with elements 'limit' and 'offset' * @return boolean false in case of an error, otherwise array with elements - * 'count', 'hits', 'facets' + * 'count', 'hits', 'facets'. 'hits' is an array of SeedDMS_SQLiteFTS_QueryHit */ public function find($query, $limit=array()) { /* {{{ */ if(!$this->_conn) @@ -206,20 +206,21 @@ class SeedDMS_SQLiteFTS_Indexer { /** * Get a single document from index * - * @param integer $id id of document + * @param string $id id of document * @return boolean false in case of an error, otherwise true */ public function findById($id) { /* {{{ */ if(!$this->_conn) return false; - $sql = "SELECT ".$this->_rawid." FROM docs WHERE ".$this->_rawid."=".(int) $id; + $sql = "SELECT ".$this->_rawid.", documentid FROM docs WHERE documentid=".$this->_conn->quote($id); $res = $this->_conn->query($sql); $hits = array(); if($res) { while($rec = $res->fetch(PDO::FETCH_ASSOC)) { $hit = new SeedDMS_SQLiteFTS_QueryHit($this); $hit->id = $rec[$this->_rawid]; + $hit->documentid = $rec['documentid']; $hits[] = $hit; } } @@ -232,11 +233,11 @@ class SeedDMS_SQLiteFTS_Indexer { * @param integer $id id of index record * @return boolean false in case of an error, otherwise true */ - public function getDocument($id) { /* {{{ */ + public function getDocument($id, $content=true) { /* {{{ */ if(!$this->_conn) return false; - $sql = "SELECT ".$this->_rawid.", documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path FROM docs WHERE documentid='D".$id."'"; + $sql = "SELECT ".$this->_rawid.", documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path".($content ? ", content" : "")." FROM docs WHERE ".$this->_rawid."='".$id."'"; $res = $this->_conn->query($sql); $doc = false; if($res) { @@ -255,6 +256,8 @@ class SeedDMS_SQLiteFTS_Indexer { $doc->addField('users', $rec['users']); $doc->addField('status', $rec['status']); $doc->addField('path', $rec['path']); + if($content) + $doc->addField('content', $rec['content']); } return $doc; } /* }}} */ @@ -265,7 +268,7 @@ class SeedDMS_SQLiteFTS_Indexer { * @param integer $id id of folder * @return boolean false in case of an error, otherwise true */ - public function getFolder($id) { /* {{{ */ + public function __getFolder($id) { /* {{{ */ if(!$this->_conn) return false; From 1ee2744256437d233e30fdf5906edf26fe9a74b7 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 24 Jun 2021 11:39:46 +0200 Subject: [PATCH 5/5] index current folder before tree --- views/bootstrap/class.Indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.Indexer.php b/views/bootstrap/class.Indexer.php index 75e8b8110..743e108c6 100644 --- a/views/bootstrap/class.Indexer.php +++ b/views/bootstrap/class.Indexer.php @@ -245,8 +245,8 @@ div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
"; $index->commit();