mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
c369950458
|
@ -205,6 +205,7 @@
|
||||||
- add filter function to notification service
|
- add filter function to notification service
|
||||||
- reindex document after it was edited
|
- reindex document after it was edited
|
||||||
- show preview images in drop folder menu after mouse over
|
- show preview images in drop folder menu after mouse over
|
||||||
|
- add support for indexing folders
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
Changes in version 5.1.20
|
Changes in version 5.1.20
|
||||||
|
|
|
@ -2880,6 +2880,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$groupIDs = "";
|
$groupIDs = "";
|
||||||
$defAccess = $this->getDefaultAccess();
|
$defAccess = $this->getDefaultAccess();
|
||||||
|
|
||||||
|
/* Check if the default access is < read access or >= read access.
|
||||||
|
* If default access is less than read access, then create a list
|
||||||
|
* of users and groups with read access.
|
||||||
|
* If default access is equal or greater then read access, then
|
||||||
|
* create a list of users and groups without read access.
|
||||||
|
*/
|
||||||
if ($defAccess<M_READ) {
|
if ($defAccess<M_READ) {
|
||||||
// Get the list of all users and groups that are listed in the ACL as
|
// Get the list of all users and groups that are listed in the ACL as
|
||||||
// having read access to the document.
|
// having read access to the document.
|
||||||
|
@ -2890,9 +2896,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
// to the document.
|
// to the document.
|
||||||
$tmpList = $this->getAccessList(M_NONE, O_LTEQ);
|
$tmpList = $this->getAccessList(M_NONE, O_LTEQ);
|
||||||
}
|
}
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $groupAccess */
|
||||||
foreach ($tmpList["groups"] as $groupAccess) {
|
foreach ($tmpList["groups"] as $groupAccess) {
|
||||||
$groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $groupAccess->getGroupID();
|
$groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $groupAccess->getGroupID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_UserAccess $userAccess */
|
||||||
foreach ($tmpList["users"] as $userAccess) {
|
foreach ($tmpList["users"] as $userAccess) {
|
||||||
$user = $userAccess->getUser();
|
$user = $userAccess->getUser();
|
||||||
if (!$listadmin && $user->isAdmin()) continue;
|
if (!$listadmin && $user->isAdmin()) continue;
|
||||||
|
@ -2924,7 +2933,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
(strlen($userIDs) == 0 ? "" : " OR (`tblUsers`.`id` IN (". $userIDs ."))").
|
(strlen($userIDs) == 0 ? "" : " OR (`tblUsers`.`id` IN (". $userIDs ."))").
|
||||||
") ORDER BY `login`";
|
") ORDER BY `login`";
|
||||||
}
|
}
|
||||||
/* If default access is equal or greater then M_READ, $userIDs and
|
/* If default access is equal or greater than M_READ, $userIDs and
|
||||||
* $groupIDs contains a list of user without read access
|
* $groupIDs contains a list of user without read access
|
||||||
*/
|
*/
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1784,11 +1784,12 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* administrators and the owner of the folder unless $listadmin resp.
|
* administrators and the owner of the folder unless $listadmin resp.
|
||||||
* $listowner is set to true.
|
* $listowner is set to true.
|
||||||
*
|
*
|
||||||
* @param bool|int $listadmin if set to true any admin will be listed too
|
* @param boolean $listadmin if set to true any admin will be listed too
|
||||||
* @param bool|int $listowner if set to true the owner will be listed too
|
* @param boolean $listowner if set to true the owner will be listed too
|
||||||
|
* @param boolean $listguest if set to true any guest will be listed too
|
||||||
* @return array list of users and groups
|
* @return array list of users and groups
|
||||||
*/
|
*/
|
||||||
function getReadAccessList($listadmin=0, $listowner=0) { /* {{{ */
|
function getReadAccessList($listadmin=0, $listowner=0, $listguest=0) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if (!isset($this->_readAccessList)) {
|
if (!isset($this->_readAccessList)) {
|
||||||
|
@ -1823,7 +1824,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
$user = $userAccess->getUser();
|
$user = $userAccess->getUser();
|
||||||
if (!$listadmin && $user->isAdmin()) continue;
|
if (!$listadmin && $user->isAdmin()) continue;
|
||||||
if (!$listowner && $user->getID() == $this->_ownerID) continue;
|
if (!$listowner && $user->getID() == $this->_ownerID) continue;
|
||||||
if ($user->isGuest()) continue;
|
if (!$listguest && $user->isGuest()) continue;
|
||||||
$userIDs .= (strlen($userIDs)==0 ? "" : ", ") . $userAccess->getUserID();
|
$userIDs .= (strlen($userIDs)==0 ? "" : ", ") . $userAccess->getUserID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1850,7 +1851,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
(strlen($userIDs) == 0 ? "" : " OR (`tblUsers`.`id` IN (". $userIDs ."))").
|
(strlen($userIDs) == 0 ? "" : " OR (`tblUsers`.`id` IN (". $userIDs ."))").
|
||||||
") ORDER BY `login`";
|
") ORDER BY `login`";
|
||||||
}
|
}
|
||||||
/* If default access is equal or greate then read, $userIDs and
|
/* If default access is equal or greater than M_READ, $userIDs and
|
||||||
* $groupIDs contains a list of user without read access
|
* $groupIDs contains a list of user without read access
|
||||||
*/
|
*/
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -91,7 +91,7 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
* Constructor. Creates our indexable document and adds all
|
* Constructor. Creates our indexable document and adds all
|
||||||
* necessary fields to it using the passed in document
|
* necessary fields to it using the passed in document
|
||||||
* @param SeedDMS_Core_DMS $dms
|
* @param SeedDMS_Core_DMS $dms
|
||||||
* @param SeedDMS_Core_Document $document
|
* @param SeedDMS_Core_Document|Folder $document
|
||||||
* @param null $convcmd
|
* @param null $convcmd
|
||||||
* @param bool $nocontent
|
* @param bool $nocontent
|
||||||
* @param int $timeout
|
* @param int $timeout
|
||||||
|
@ -100,44 +100,8 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
$this->errormsg = '';
|
$this->errormsg = '';
|
||||||
$this->cmd = '';
|
$this->cmd = '';
|
||||||
$this->mimetype = '';
|
$this->mimetype = '';
|
||||||
$_convcmd = array(
|
|
||||||
'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'',
|
|
||||||
'application/postscript' => 'ps2pdf14 %s - | pdftotext -enc UTF-8 -nopgbrk - - | sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'',
|
|
||||||
'application/msword' => 'catdoc %s',
|
|
||||||
'application/vnd.ms-excel' => 'ssconvert -T Gnumeric_stf:stf_csv -S %s fd://1',
|
|
||||||
'audio/mp3' => "id3 -l -R %s | egrep '(Title|Artist|Album)' | sed 's/^[^:]*: //g'",
|
|
||||||
'audio/mpeg' => "id3 -l -R %s | egrep '(Title|Artist|Album)' | sed 's/^[^:]*: //g'",
|
|
||||||
'text/plain' => 'cat %s',
|
|
||||||
);
|
|
||||||
if($convcmd) {
|
|
||||||
$_convcmd = $convcmd;
|
|
||||||
}
|
|
||||||
|
|
||||||
$version = $document->getLatestContent();
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Keyword('document_id', $document->getID()));
|
|
||||||
if($version) {
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Keyword('mimetype', $version->getMimeType()));
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Keyword('origfilename', $version->getOriginalFileName(), 'utf-8'));
|
|
||||||
if(!$nocontent)
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $version->getDate()));
|
|
||||||
if($attributes = $version->getAttributes()) {
|
|
||||||
foreach($attributes as $attribute) {
|
|
||||||
$attrdef = $attribute->getAttributeDefinition();
|
|
||||||
if($attrdef->getValueSet() != '')
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Keyword('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue(), 'utf-8'));
|
|
||||||
else
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue(), 'utf-8'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('title', $document->getName(), 'utf-8'));
|
$this->addField(Zend_Search_Lucene_Field::Text('title', $document->getName(), 'utf-8'));
|
||||||
if($categories = $document->getCategories()) {
|
|
||||||
$names = array();
|
|
||||||
foreach($categories as $cat) {
|
|
||||||
$names[] = $cat->getName();
|
|
||||||
}
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('category', implode(' ', $names), 'utf-8'));
|
|
||||||
}
|
|
||||||
if($acllist = $document->getReadAccessList(1, 1, 1)) {
|
if($acllist = $document->getReadAccessList(1, 1, 1)) {
|
||||||
$allu = [];
|
$allu = [];
|
||||||
foreach($acllist['users'] as $u)
|
foreach($acllist['users'] as $u)
|
||||||
|
@ -159,15 +123,41 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue(), 'utf-8'));
|
$this->addField(Zend_Search_Lucene_Field::Text('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue(), 'utf-8'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = $document->getOwner();
|
$owner = $document->getOwner();
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('owner', $owner->getLogin(), 'utf-8'));
|
$this->addField(Zend_Search_Lucene_Field::Text('owner', $owner->getLogin(), 'utf-8'));
|
||||||
if($keywords = $document->getKeywords()) {
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('keywords', $keywords, 'utf-8'));
|
|
||||||
}
|
|
||||||
if($comment = $document->getComment()) {
|
if($comment = $document->getComment()) {
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('comment', $comment, 'utf-8'));
|
$this->addField(Zend_Search_Lucene_Field::Text('comment', $comment, 'utf-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($document->isType('document')) {
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Keyword('document_id', 'D'.$document->getID()));
|
||||||
|
$version = $document->getLatestContent();
|
||||||
|
if($version) {
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Keyword('mimetype', $version->getMimeType()));
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Keyword('origfilename', $version->getOriginalFileName(), 'utf-8'));
|
||||||
|
if(!$nocontent)
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $version->getDate()));
|
||||||
|
if($attributes = $version->getAttributes()) {
|
||||||
|
foreach($attributes as $attribute) {
|
||||||
|
$attrdef = $attribute->getAttributeDefinition();
|
||||||
|
if($attrdef->getValueSet() != '')
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Keyword('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue(), 'utf-8'));
|
||||||
|
else
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Text('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue(), 'utf-8'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($categories = $document->getCategories()) {
|
||||||
|
$names = array();
|
||||||
|
foreach($categories as $cat) {
|
||||||
|
$names[] = $cat->getName();
|
||||||
|
}
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Text('category', implode(' ', $names), 'utf-8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($keywords = $document->getKeywords()) {
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Text('keywords', $keywords, 'utf-8'));
|
||||||
|
}
|
||||||
if($version) {
|
if($version) {
|
||||||
$status = $version->getStatus();
|
$status = $version->getStatus();
|
||||||
$this->addField(Zend_Search_Lucene_Field::Keyword('status', $status['status'], 'utf-8'));
|
$this->addField(Zend_Search_Lucene_Field::Keyword('status', $status['status'], 'utf-8'));
|
||||||
|
@ -180,12 +170,12 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
$this->mimetype = $mimetype;
|
$this->mimetype = $mimetype;
|
||||||
$cmd = '';
|
$cmd = '';
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
if(isset($_convcmd[$mimetype])) {
|
if(isset($convcmd[$mimetype])) {
|
||||||
$cmd = sprintf($_convcmd[$mimetype], $path);
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
|
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
||||||
$cmd = sprintf($_convcmd[$mimetype], $path);
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
} elseif(isset($_convcmd['*'])) {
|
} elseif(isset($convcmd['*'])) {
|
||||||
$cmd = sprintf($_convcmd[$mimetype], $path);
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
}
|
}
|
||||||
if($cmd) {
|
if($cmd) {
|
||||||
$this->cmd = $cmd;
|
$this->cmd = $cmd;
|
||||||
|
@ -202,6 +192,10 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif($document->isType('folder')) {
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Keyword('document_id', 'F'.$document->getID()));
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $document->getDate()));
|
||||||
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
public function getErrorMsg() { /* {{{ */
|
public function getErrorMsg() { /* {{{ */
|
||||||
|
|
|
@ -49,7 +49,18 @@ class SeedDMS_Lucene_Search {
|
||||||
* @return object instance of SeedDMS_Lucene_Document of false
|
* @return object instance of SeedDMS_Lucene_Document of false
|
||||||
*/
|
*/
|
||||||
function getDocument($id) { /* {{{ */
|
function getDocument($id) { /* {{{ */
|
||||||
$hits = $this->index->find('document_id:'.$id);
|
$hits = $this->index->find('document_id:D'.$id);
|
||||||
|
return $hits ? $hits[0] : false;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get folder from index
|
||||||
|
*
|
||||||
|
* @param object $index lucene index
|
||||||
|
* @return object instance of SeedDMS_Lucene_Document of false
|
||||||
|
*/
|
||||||
|
function getFolder($id) { /* {{{ */
|
||||||
|
$hits = $this->index->find('document_id:F'.$id);
|
||||||
return $hits ? $hits[0] : false;
|
return $hits ? $hits[0] : false;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
<email>uwe@steinmann.cx</email>
|
<email>uwe@steinmann.cx</email>
|
||||||
<active>yes</active>
|
<active>yes</active>
|
||||||
</lead>
|
</lead>
|
||||||
<date>2020-09-10</date>
|
<date>2020-12-12</date>
|
||||||
<time>08:55:43</time>
|
<time>08:55:43</time>
|
||||||
<version>
|
<version>
|
||||||
<release>1.1.15</release>
|
<release>1.1.16</release>
|
||||||
<api>1.1.15</api>
|
<api>1.1.16</api>
|
||||||
</version>
|
</version>
|
||||||
<stability>
|
<stability>
|
||||||
<release>stable</release>
|
<release>stable</release>
|
||||||
|
@ -23,12 +23,7 @@
|
||||||
</stability>
|
</stability>
|
||||||
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
<notes>
|
<notes>
|
||||||
- add searching for document status
|
- add indexing of folders
|
||||||
- better error handling if opening index fails
|
|
||||||
- parameters for SeedDMS_Lucene_Search::search() has changed
|
|
||||||
- SeedDMS_Lucene_Search::search() returns array of hits, count and facets
|
|
||||||
- pass config array instead of index directory to SeedDMS_Lucene_Indexer::create()
|
|
||||||
and SeedDMS_Lucene_Indexer::open()
|
|
||||||
</notes>
|
</notes>
|
||||||
<contents>
|
<contents>
|
||||||
<dir baseinstalldir="SeedDMS" name="/">
|
<dir baseinstalldir="SeedDMS" name="/">
|
||||||
|
@ -336,5 +331,26 @@ IndexedDocument() remembers cmd and mimetype
|
||||||
Index users with at least read access on the document
|
Index users with at least read access on the document
|
||||||
</notes>
|
</notes>
|
||||||
</release>
|
</release>
|
||||||
|
<release>
|
||||||
|
<date>2020-09-10</date>
|
||||||
|
<time>08:55:43</time>
|
||||||
|
<version>
|
||||||
|
<release>1.1.15</release>
|
||||||
|
<api>1.1.15</api>
|
||||||
|
</version>
|
||||||
|
<stability>
|
||||||
|
<release>stable</release>
|
||||||
|
<api>stable</api>
|
||||||
|
</stability>
|
||||||
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
|
<notes>
|
||||||
|
- add searching for document status
|
||||||
|
- better error handling if opening index fails
|
||||||
|
- parameters for SeedDMS_Lucene_Search::search() has changed
|
||||||
|
- SeedDMS_Lucene_Search::search() returns array of hits, count and facets
|
||||||
|
- pass config array instead of index directory to SeedDMS_Lucene_Indexer::create()
|
||||||
|
and SeedDMS_Lucene_Indexer::open()
|
||||||
|
</notes>
|
||||||
|
</release>
|
||||||
</changelog>
|
</changelog>
|
||||||
</package>
|
</package>
|
||||||
|
|
|
@ -44,7 +44,8 @@ class SeedDMS_SQLiteFTS_Document {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
public function addField($key, $value) { /* {{{ */
|
public function addField($key, $value) { /* {{{ */
|
||||||
if($key == 'document_id') {
|
//if($key == 'document_id') {
|
||||||
|
if($key == 'docid') {
|
||||||
$this->id = $this->fields[$key] = (int) $value;
|
$this->id = $this->fields[$key] = (int) $value;
|
||||||
} else {
|
} else {
|
||||||
if(isset($this->fields[$key]))
|
if(isset($this->fields[$key]))
|
||||||
|
|
|
@ -94,21 +94,38 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
$this->errormsg = '';
|
$this->errormsg = '';
|
||||||
$this->cmd = '';
|
$this->cmd = '';
|
||||||
$this->mimetype = '';
|
$this->mimetype = '';
|
||||||
$_convcmd = array(
|
|
||||||
'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'',
|
$this->addField('title', $document->getName());
|
||||||
'application/postscript' => 'ps2pdf14 %s - | pdftotext -enc UTF-8 -nopgbrk - - | sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'',
|
if($acllist = $document->getReadAccessList(1, 1, 1)) {
|
||||||
'application/msword' => 'catdoc %s',
|
$allu = [];
|
||||||
'application/vnd.ms-excel' => 'ssconvert -T Gnumeric_stf:stf_csv -S %s fd://1',
|
foreach($acllist['users'] as $u)
|
||||||
'audio/mp3' => "id3 -l -R %s | egrep '(Title|Artist|Album)' | sed 's/^[^:]*: //g'",
|
$allu[] = $u->getLogin();
|
||||||
'audio/mpeg' => "id3 -l -R %s | egrep '(Title|Artist|Album)' | sed 's/^[^:]*: //g'",
|
$this->addField('users', implode(' ', $allu));
|
||||||
'text/plain' => 'cat %s',
|
/*
|
||||||
);
|
$allg = [];
|
||||||
if($convcmd) {
|
foreach($acllist['groups'] as $g)
|
||||||
$_convcmd = $convcmd;
|
$allg[] = $g->getName();
|
||||||
|
$this->addField('groups', implode(' ', $allg));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
if($attributes = $document->getAttributes()) {
|
||||||
|
foreach($attributes as $attribute) {
|
||||||
|
$attrdef = $attribute->getAttributeDefinition();
|
||||||
|
if($attrdef->getValueSet() != '')
|
||||||
|
$this->addField('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue());
|
||||||
|
else
|
||||||
|
$this->addField('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$owner = $document->getOwner();
|
||||||
|
$this->addField('owner', $owner->getLogin());
|
||||||
|
if($comment = $document->getComment()) {
|
||||||
|
$this->addField('comment', $comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($document->isType('document')) {
|
||||||
|
$this->addField('document_id', 'D'.$document->getID());
|
||||||
$version = $document->getLatestContent();
|
$version = $document->getLatestContent();
|
||||||
$this->addField('document_id', $document->getID());
|
|
||||||
if($version) {
|
if($version) {
|
||||||
$this->addField('mimetype', $version->getMimeType());
|
$this->addField('mimetype', $version->getMimeType());
|
||||||
$this->addField('origfilename', $version->getOriginalFileName());
|
$this->addField('origfilename', $version->getOriginalFileName());
|
||||||
|
@ -124,7 +141,6 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->addField('title', $document->getName());
|
|
||||||
if($categories = $document->getCategories()) {
|
if($categories = $document->getCategories()) {
|
||||||
$names = array();
|
$names = array();
|
||||||
foreach($categories as $cat) {
|
foreach($categories as $cat) {
|
||||||
|
@ -132,36 +148,9 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
}
|
}
|
||||||
$this->addField('category', implode(' ', $names));
|
$this->addField('category', implode(' ', $names));
|
||||||
}
|
}
|
||||||
if($attributes = $document->getAttributes()) {
|
|
||||||
foreach($attributes as $attribute) {
|
|
||||||
$attrdef = $attribute->getAttributeDefinition();
|
|
||||||
if($attrdef->getValueSet() != '')
|
|
||||||
$this->addField('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue());
|
|
||||||
else
|
|
||||||
$this->addField('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$owner = $document->getOwner();
|
|
||||||
$this->addField('owner', $owner->getLogin());
|
|
||||||
if($keywords = $document->getKeywords()) {
|
if($keywords = $document->getKeywords()) {
|
||||||
$this->addField('keywords', $keywords);
|
$this->addField('keywords', $keywords);
|
||||||
}
|
}
|
||||||
if($comment = $document->getComment()) {
|
|
||||||
$this->addField('comment', $comment);
|
|
||||||
}
|
|
||||||
if($acllist = $document->getReadAccessList(1, 1, 1)) {
|
|
||||||
$allu = [];
|
|
||||||
foreach($acllist['users'] as $u)
|
|
||||||
$allu[] = $u->getLogin();
|
|
||||||
$this->addField('users', implode(' ', $allu));
|
|
||||||
/*
|
|
||||||
$allg = [];
|
|
||||||
foreach($acllist['groups'] as $g)
|
|
||||||
$allg[] = $g->getName();
|
|
||||||
$this->addField('groups', implode(' ', $allg));
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
if($version) {
|
if($version) {
|
||||||
$status = $version->getStatus();
|
$status = $version->getStatus();
|
||||||
$this->addField('status', $status['status']+10);
|
$this->addField('status', $status['status']+10);
|
||||||
|
@ -174,12 +163,12 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
$this->mimetype = $mimetype;
|
$this->mimetype = $mimetype;
|
||||||
$cmd = '';
|
$cmd = '';
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
if(isset($_convcmd[$mimetype])) {
|
if(isset($convcmd[$mimetype])) {
|
||||||
$cmd = sprintf($_convcmd[$mimetype], $path);
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
} elseif(isset($_convcmd[$mimeparts[0].'/*'])) {
|
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
||||||
$cmd = sprintf($_convcmd[$mimetype], $path);
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
} elseif(isset($_convcmd['*'])) {
|
} elseif(isset($convcmd['*'])) {
|
||||||
$cmd = sprintf($_convcmd[$mimetype], $path);
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
}
|
}
|
||||||
if($cmd) {
|
if($cmd) {
|
||||||
$this->cmd = $cmd;
|
$this->cmd = $cmd;
|
||||||
|
@ -196,6 +185,9 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif($document->isType('folder')) {
|
||||||
|
$this->addField('document_id', 'F'.$document->getID());
|
||||||
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
public function getErrorMsg() { /* {{{ */
|
public function getErrorMsg() { /* {{{ */
|
||||||
|
|
|
@ -63,9 +63,9 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
*/
|
*/
|
||||||
$version = SQLite3::version();
|
$version = SQLite3::version();
|
||||||
if($version['versionNumber'] >= 3008000)
|
if($version['versionNumber'] >= 3008000)
|
||||||
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, notindexed=created, matchinfo=fts3)';
|
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, notindexed=created, matchinfo=fts3)';
|
||||||
else
|
else
|
||||||
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, matchinfo=fts3)';
|
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, matchinfo=fts3)';
|
||||||
$res = $index->_conn->exec($sql);
|
$res = $index->_conn->exec($sql);
|
||||||
if($res === false) {
|
if($res === false) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -96,7 +96,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
if(!$this->_conn)
|
if(!$this->_conn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = "INSERT INTO docs (docid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status) VALUES(".$doc->getFieldValue('document_id').", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($doc->getFieldValue('comment')).", ".$this->_conn->quote($doc->getFieldValue('keywords')).", ".$this->_conn->quote($doc->getFieldValue('category')).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($doc->getFieldValue('content')).", ".$this->_conn->quote($doc->getFieldValue('mimetype')).", ".$this->_conn->quote($doc->getFieldValue('origfilename')).", ".(int)$doc->getFieldValue('created').", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($doc->getFieldValue('status'))/*time()*/.")";
|
$sql = "INSERT INTO docs (documentid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($doc->getFieldValue('comment')).", ".$this->_conn->quote($doc->getFieldValue('keywords')).", ".$this->_conn->quote($doc->getFieldValue('category')).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($doc->getFieldValue('content')).", ".$this->_conn->quote($doc->getFieldValue('mimetype')).", ".$this->_conn->quote($doc->getFieldValue('origfilename')).", ".(int)$doc->getFieldValue('created').", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($doc->getFieldValue('status'))/*time()*/.")";
|
||||||
$res = $this->_conn->exec($sql);
|
$res = $this->_conn->exec($sql);
|
||||||
if($res === false) {
|
if($res === false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -150,7 +150,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
$res = $this->_conn->query($sql);
|
$res = $this->_conn->query($sql);
|
||||||
$row = $res->fetch();
|
$row = $res->fetch();
|
||||||
|
|
||||||
$sql = "SELECT docid FROM docs";
|
$sql = "SELECT docid, documentid FROM docs";
|
||||||
if($query)
|
if($query)
|
||||||
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
|
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
|
||||||
$res = $this->_conn->query($sql);
|
$res = $this->_conn->query($sql);
|
||||||
|
@ -164,6 +164,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
foreach($res as $rec) {
|
foreach($res as $rec) {
|
||||||
$hit = new SeedDMS_SQLiteFTS_QueryHit($this);
|
$hit = new SeedDMS_SQLiteFTS_QueryHit($this);
|
||||||
$hit->id = $rec['docid'];
|
$hit->id = $rec['docid'];
|
||||||
|
$hit->documentid = $rec['documentid'];
|
||||||
$hits[] = $hit;
|
$hits[] = $hit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,19 +197,21 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
/**
|
/**
|
||||||
* Get a single document from index
|
* Get a single document from index
|
||||||
*
|
*
|
||||||
* @param integer $id id of document
|
* @param integer $id id of index record
|
||||||
* @return boolean false in case of an error, otherwise true
|
* @return boolean false in case of an error, otherwise true
|
||||||
*/
|
*/
|
||||||
public function getDocument($id) { /* {{{ */
|
public function getDocument($id) { /* {{{ */
|
||||||
if(!$this->_conn)
|
if(!$this->_conn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = "SELECT title, comment, owner, keywords, category, mimetype, origfilename, created, users, status FROM docs WHERE docid=".(int) $id;
|
$sql = "SELECT docid, documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status FROM docs WHERE docid=".$id;
|
||||||
$res = $this->_conn->query($sql);
|
$res = $this->_conn->query($sql);
|
||||||
$doc = false;
|
$doc = false;
|
||||||
if($res) {
|
if($res) {
|
||||||
$rec = $res->fetch(PDO::FETCH_ASSOC);
|
$rec = $res->fetch(PDO::FETCH_ASSOC);
|
||||||
$doc = new SeedDMS_SQLiteFTS_Document();
|
$doc = new SeedDMS_SQLiteFTS_Document();
|
||||||
|
$doc->addField('docid', $rec['docid']);
|
||||||
|
$doc->addField('document_id', $rec['documentid']);
|
||||||
$doc->addField('title', $rec['title']);
|
$doc->addField('title', $rec['title']);
|
||||||
$doc->addField('comment', $rec['comment']);
|
$doc->addField('comment', $rec['comment']);
|
||||||
$doc->addField('keywords', $rec['keywords']);
|
$doc->addField('keywords', $rec['keywords']);
|
||||||
|
@ -223,6 +226,33 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
return $doc;
|
return $doc;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a single folder from index
|
||||||
|
*
|
||||||
|
* @param integer $id id of folder
|
||||||
|
* @return boolean false in case of an error, otherwise true
|
||||||
|
*/
|
||||||
|
public function getFolder($id) { /* {{{ */
|
||||||
|
if(!$this->_conn)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$sql = "SELECT docid, documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status FROM docs WHERE documentid='F".$id."'";
|
||||||
|
$res = $this->_conn->query($sql);
|
||||||
|
$doc = false;
|
||||||
|
if($res) {
|
||||||
|
$rec = $res->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$doc = new SeedDMS_SQLiteFTS_Document();
|
||||||
|
$doc->addField('docid', $rec['docid']);
|
||||||
|
$doc->addField('document_id', $rec['documentid']);
|
||||||
|
$doc->addField('title', $rec['title']);
|
||||||
|
$doc->addField('comment', $rec['comment']);
|
||||||
|
$doc->addField('owner', $rec['owner']);
|
||||||
|
$doc->addField('created', $rec['created']);
|
||||||
|
$doc->addField('users', $rec['users']);
|
||||||
|
}
|
||||||
|
return $doc;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of terms in index
|
* Return list of terms in index
|
||||||
*
|
*
|
||||||
|
|
|
@ -37,11 +37,17 @@ class SeedDMS_SQLiteFTS_QueryHit {
|
||||||
protected $_document;
|
protected $_document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var integer $id id of document
|
* @var integer $id id of index document
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $id;
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var integer $id id of real document
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public $documentid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,14 +43,25 @@ class SeedDMS_SQliteFTS_Search {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get hit from index
|
* Get document from index
|
||||||
*
|
*
|
||||||
* @param object $index lucene index
|
* @param int $id real document id
|
||||||
* @return object instance of SeedDMS_Lucene_Document of false
|
* @return object instance of SeedDMS_SQliteFTS_QueryHit or false
|
||||||
*/
|
*/
|
||||||
function getDocument($id) { /* {{{ */
|
function getDocument($id) { /* {{{ */
|
||||||
$hits = $this->index->findById((int) $id);
|
$hits = $this->index->find('D'.$id);
|
||||||
return $hits ? $hits[0] : false;
|
return $hits['hits'] ? $hits['hits'][0] : false;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get folder from index
|
||||||
|
*
|
||||||
|
* @param int $id real folder id
|
||||||
|
* @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;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +113,7 @@ class SeedDMS_SQliteFTS_Search {
|
||||||
$result = $this->index->find($querystr, $limit);
|
$result = $this->index->find($querystr, $limit);
|
||||||
$recs = array();
|
$recs = array();
|
||||||
foreach($result["hits"] as $hit) {
|
foreach($result["hits"] as $hit) {
|
||||||
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->id);
|
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->documentid);
|
||||||
}
|
}
|
||||||
return array('count'=>$result['count'], 'hits'=>$recs, 'facets'=>array());
|
return array('count'=>$result['count'], 'hits'=>$recs, 'facets'=>array());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -48,17 +48,18 @@ class SeedDMS_SQLiteFTS_Term {
|
||||||
public function __construct($term, $col, $occurrence) { /* {{{ */
|
public function __construct($term, $col, $occurrence) { /* {{{ */
|
||||||
$this->text = $term;
|
$this->text = $term;
|
||||||
$fields = array(
|
$fields = array(
|
||||||
0 => 'title',
|
0 => 'documentid',
|
||||||
1 => 'comment',
|
1 => 'title',
|
||||||
2 => 'keywords',
|
2 => 'comment',
|
||||||
3 => 'category',
|
3 => 'keywords',
|
||||||
4 => 'mimetype',
|
4 => 'category',
|
||||||
5 => 'origfilename',
|
5 => 'mimetype',
|
||||||
6 => 'owner',
|
6 => 'origfilename',
|
||||||
7 => 'content',
|
7 => 'owner',
|
||||||
8 => 'created',
|
8 => 'content',
|
||||||
9 => 'user',
|
9 => 'created',
|
||||||
10 => 'status'
|
10 => 'user',
|
||||||
|
11 => 'status'
|
||||||
);
|
);
|
||||||
$this->field = $fields[$col];
|
$this->field = $fields[$col];
|
||||||
$this->_occurrence = $occurrence;
|
$this->_occurrence = $occurrence;
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
<email>uwe@steinmann.cx</email>
|
<email>uwe@steinmann.cx</email>
|
||||||
<active>yes</active>
|
<active>yes</active>
|
||||||
</lead>
|
</lead>
|
||||||
<date>2020-09-11</date>
|
<date>2020-12-12</date>
|
||||||
<time>08:57:44</time>
|
<time>08:57:44</time>
|
||||||
<version>
|
<version>
|
||||||
<release>1.0.14</release>
|
<release>1.0.15</release>
|
||||||
<api>1.0.14</api>
|
<api>1.0.15</api>
|
||||||
</version>
|
</version>
|
||||||
<stability>
|
<stability>
|
||||||
<release>stable</release>
|
<release>stable</release>
|
||||||
|
@ -23,12 +23,7 @@
|
||||||
</stability>
|
</stability>
|
||||||
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
<notes>
|
<notes>
|
||||||
- add searching for document status
|
- add indexing folders
|
||||||
- search even if query is empty (will find all documents)
|
|
||||||
- parameters for SeedDMS_SQLiteFTS_Search::search() has changed
|
|
||||||
- SeedDMS_Lucene_Search::search() returns array of hits, count and facets
|
|
||||||
- pass config array instead of index directory to SeedDMS_Lucene_Indexer::create()
|
|
||||||
and SeedDMS_Lucene_Indexer::open()
|
|
||||||
</notes>
|
</notes>
|
||||||
<contents>
|
<contents>
|
||||||
<dir baseinstalldir="SeedDMS" name="/">
|
<dir baseinstalldir="SeedDMS" name="/">
|
||||||
|
@ -296,5 +291,26 @@ Index users with at least read access on a document
|
||||||
add user to list of terms
|
add user to list of terms
|
||||||
</notes>
|
</notes>
|
||||||
</release>
|
</release>
|
||||||
|
<release>
|
||||||
|
<date>2020-09-11</date>
|
||||||
|
<time>08:57:44</time>
|
||||||
|
<version>
|
||||||
|
<release>1.0.14</release>
|
||||||
|
<api>1.0.14</api>
|
||||||
|
</version>
|
||||||
|
<stability>
|
||||||
|
<release>stable</release>
|
||||||
|
<api>stable</api>
|
||||||
|
</stability>
|
||||||
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
|
<notes>
|
||||||
|
- add searching for document status
|
||||||
|
- search even if query is empty (will find all documents)
|
||||||
|
- parameters for SeedDMS_SQLiteFTS_Search::search() has changed
|
||||||
|
- SeedDMS_Lucene_Search::search() returns array of hits, count and facets
|
||||||
|
- pass config array instead of index directory to SeedDMS_Lucene_Indexer::create()
|
||||||
|
and SeedDMS_Lucene_Indexer::open()
|
||||||
|
</notes>
|
||||||
|
</release>
|
||||||
</changelog>
|
</changelog>
|
||||||
</package>
|
</package>
|
||||||
|
|
|
@ -66,7 +66,10 @@ class SeedDMS_FulltextService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function IndexedDocument($document, $forceupdate=false) {
|
public function IndexedDocument($document, $forceupdate=false) {
|
||||||
|
if($document->isType('document'))
|
||||||
$nocontent = ($document->getLatestContent()->getFileSize() > $this->maxsize) && !$forceupdate;
|
$nocontent = ($document->getLatestContent()->getFileSize() > $this->maxsize) && !$forceupdate;
|
||||||
|
else
|
||||||
|
$nocontent = true;
|
||||||
return new $this->services[0]['IndexedDocument']($document->getDMS(), $document, $this->converters, $nocontent, $this->cmdtimeout);
|
return new $this->services[0]['IndexedDocument']($document->getDMS(), $document, $this->converters, $nocontent, $this->cmdtimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -990,19 +990,28 @@ switch($command) {
|
||||||
break; /* }}} */
|
break; /* }}} */
|
||||||
|
|
||||||
case 'indexdocument': /* {{{ */
|
case 'indexdocument': /* {{{ */
|
||||||
|
case 'indexfolder': /* {{{ */
|
||||||
if($user && $user->isAdmin()) {
|
if($user && $user->isAdmin()) {
|
||||||
if($fulltextservice) {
|
if($fulltextservice) {
|
||||||
$document = $dms->getDocument($_REQUEST['id']);
|
if($command == 'indexdocument') {
|
||||||
if($document) {
|
$hook = 'indexDocument';
|
||||||
|
$object = $dms->getDocument($_REQUEST['id']);
|
||||||
|
$prefix = 'D';
|
||||||
|
} else {
|
||||||
|
$hook = 'indexFolder';
|
||||||
|
$object = $dms->getFolder($_REQUEST['id']);
|
||||||
|
$prefix = 'F';
|
||||||
|
}
|
||||||
|
if($object) {
|
||||||
if($index = $fulltextservice->Indexer()) {
|
if($index = $fulltextservice->Indexer()) {
|
||||||
$idoc = $fulltextservice->IndexedDocument($document, true);
|
$idoc = $fulltextservice->IndexedDocument($object, true);
|
||||||
$error = $idoc->getErrorMsg();
|
$error = $idoc->getErrorMsg();
|
||||||
if(!$error) {
|
if(!$error) {
|
||||||
$ires = null;
|
$ires = null;
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS'][$hook])) {
|
||||||
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
|
foreach($GLOBALS['SEEDDMS_HOOKS'][$hook] as $hookObj) {
|
||||||
if (method_exists($hookObj, 'preIndexDocument')) {
|
if (method_exists($hookObj, 'pre'.ucfirst($hook))) {
|
||||||
$ires = $hookObj->preIndexDocument(null, $document, $idoc);
|
$ires = $hookObj->preIndexDocument(null, $object, $idoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1010,17 +1019,17 @@ switch($command) {
|
||||||
$ires = $index->addDocument($idoc);
|
$ires = $index->addDocument($idoc);
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if(false === $ires) {
|
if(false === $ires) {
|
||||||
echo json_encode(array('success'=>false, 'message'=>getMLText('error_document_indexed'), 'data'=>$document->getID()));
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_document_indexed'), 'data'=>$prefix.$object->getID()));
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_indexed'), 'data'=>$document->getID(), 'cmd'=>$idoc->getCmd()));
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_indexed'), 'data'=>$prefix.$object->getID(), 'cmd'=>$idoc->getCmd()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode(array('success'=>false, 'message'=>$error, 'data'=>$document->getID(), 'mimetype'=>$idoc->getMimeType(), 'cmd'=>$idoc->getCmd()));
|
echo json_encode(array('success'=>false, 'message'=>$error, 'data'=>$object->getID(), 'mimetype'=>$idoc->getMimeType(), 'cmd'=>$idoc->getCmd()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode(array('success'=>false, 'message'=>getMLText('error_occured'), 'data'=>$document->getID()));
|
echo json_encode(array('success'=>false, 'message'=>getMLText('error_occured'), 'data'=>$prefix.$object->getID()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
|
@ -195,22 +195,31 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
|
||||||
} else {
|
} else {
|
||||||
$entries = array();
|
$entries = array();
|
||||||
$facets = $searchresult['facets'];
|
$facets = $searchresult['facets'];
|
||||||
$dcount = $searchresult['count']; //0;
|
$dcount = 0;
|
||||||
$fcount = 0;
|
$fcount = 0;
|
||||||
if($searchresult) {
|
if($searchresult) {
|
||||||
foreach($searchresult['hits'] as $hit) {
|
foreach($searchresult['hits'] as $hit) {
|
||||||
if($tmp = $dms->getDocument($hit['document_id'])) {
|
if($hit['document_id'][0] == 'D') {
|
||||||
if($tmp->getAccessMode($user) >= M_READ) {
|
if($tmp = $dms->getDocument(substr($hit['document_id'], 1))) {
|
||||||
|
// if($tmp->getAccessMode($user) >= M_READ) {
|
||||||
$tmp->verifyLastestContentExpriry();
|
$tmp->verifyLastestContentExpriry();
|
||||||
$entries[] = $tmp;
|
$entries[] = $tmp;
|
||||||
// $dcount++;
|
$dcount++;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
} elseif($hit['document_id'][0] == 'F') {
|
||||||
|
if($tmp = $dms->getFolder(substr($hit['document_id'], 1))) {
|
||||||
|
// if($tmp->getAccessMode($user) >= M_READ) {
|
||||||
|
$entries[] = $tmp;
|
||||||
|
$fcount++;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($pageNumber != 'all' && $dcount > $limit) {
|
if($pageNumber != 'all' && $searchresult['count'] > $limit) {
|
||||||
$totalPages = (int) ($dcount/$limit);
|
$totalPages = (int) ($searchresult['count']/$limit);
|
||||||
if($dcount%$limit)
|
if($searchresult['count']%$limit)
|
||||||
$totalPages++;
|
$totalPages++;
|
||||||
// if($limit > 0)
|
// if($limit > 0)
|
||||||
// $entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
// $entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
|
||||||
|
|
|
@ -72,6 +72,7 @@ if ($document->checkForDueRevisionWorkflow($user)){
|
||||||
}
|
}
|
||||||
|
|
||||||
if($view) {
|
if($view) {
|
||||||
|
$view->setParam('fulltextservice', $fulltextservice);
|
||||||
$view->setParam('folder', $folder);
|
$view->setParam('folder', $folder);
|
||||||
$view->setParam('document', $document);
|
$view->setParam('document', $document);
|
||||||
$view->setParam('showtree', showtree());
|
$view->setParam('showtree', showtree());
|
||||||
|
|
|
@ -96,39 +96,85 @@ $(document).ready( function() {
|
||||||
}
|
}
|
||||||
}); /* }}} */
|
}); /* }}} */
|
||||||
|
|
||||||
/* The typeahead functionality useѕ the rest api */
|
/* The typeahead functionality useѕ the modified version of
|
||||||
|
* bootstrap-typeahead, which is able to set the render function.
|
||||||
|
* This was needed because the search function return json objects
|
||||||
|
* for each hit and render could only process strings.
|
||||||
|
* */
|
||||||
$("#searchfield").typeahead({ /* {{{ */
|
$("#searchfield").typeahead({ /* {{{ */
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
|
items: 100, /* the query will limit the number of hits */
|
||||||
source: function(query, process) {
|
source: function(query, process) {
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var pastYear = d.getFullYear() - 1;
|
var pastYear = d.getFullYear() - 1;
|
||||||
d.setFullYear(pastYear);
|
d.setFullYear(pastYear);
|
||||||
console.log(d.toISOString().split('T')[0]);
|
// console.log(d.toISOString().split('T')[0]);
|
||||||
|
|
||||||
$.get('../restapi/index.php/search', { query: query, limit: 8, mode: 'typeahead' }, function(data) {
|
// $.get('../restapi/index.php/search', { query: query, limit: 8, mode: 'typeahead' }, function(data) {
|
||||||
// $.get('../out/out.Search.php', { query: query, limit: 8, creationdate: 1, createstart: d.toISOString().split('T')[0], action: 'typeahead' }, function(data) {
|
var data = {
|
||||||
|
query: query,
|
||||||
|
limit: 18,
|
||||||
|
// fullsearch: 1,
|
||||||
|
// creationdate: 1,
|
||||||
|
// createstart: d.toISOString().split('T')[0],
|
||||||
|
action: 'typeahead'
|
||||||
|
};
|
||||||
|
/* Return a list of json objects, each containing
|
||||||
|
* type: type of object (D=doc, F=folder, S=searchterm)
|
||||||
|
* name: name of object
|
||||||
|
*/
|
||||||
|
$.get('../out/out.Search.php', data, function(data) {
|
||||||
process(data);
|
process(data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* updater is called when the item in the list is clicked. It is
|
/* updater is called when the item in the list is clicked. It is
|
||||||
* actually provided to update the input field, but here we use
|
* actually provided to update the input field, but here we use
|
||||||
* it to set the document location. */
|
* it to set the document location. The passed value is the string
|
||||||
|
* set in data-value of the list items. */
|
||||||
updater: function (item) {
|
updater: function (item) {
|
||||||
document.location = "../out/out.Search.php?query=" + encodeURIComponent(item.substring(1));
|
console.log(item);
|
||||||
|
document.location = "../out/out.Search.php?query=" + encodeURIComponent(item);
|
||||||
return item;
|
return item;
|
||||||
},
|
},
|
||||||
/* Set a matcher that allows any returned value */
|
sorter: function(items) {
|
||||||
|
return items;
|
||||||
|
},
|
||||||
|
/* matcher will always return true, because the initial search returns
|
||||||
|
* matches only
|
||||||
|
*/
|
||||||
matcher : function (item) {
|
matcher : function (item) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
highlighter : function (item) {
|
highlighter : function (item) {
|
||||||
if(item.charAt(0) == 'D')
|
if(item.type.charAt(0) == 'D')
|
||||||
return '<i class="fa fa-file"></i> ' + item.substring(1).replace(/</g, '<');
|
return '<i class="fa fa-file"></i> ' + item.name.replace(/</g, '<');
|
||||||
else if(item.charAt(0) == 'F')
|
else if(item.type.charAt(0) == 'F')
|
||||||
return '<i class="fa fa-folder-o"></i> ' + item.substring(1).replace(/</g, '<');
|
return '<i class="fa fa-folder-o"></i> ' + item.name.replace(/</g, '<');
|
||||||
else
|
else
|
||||||
return '<i class="fa fa-search"></i> ' + item.substring(1).replace(/</g, '<');
|
return '<i class="fa fa-search"></i> ' + item.name.replace(/</g, '<');
|
||||||
|
},
|
||||||
|
/* This only works with a modified version of bootstrap typeahead located
|
||||||
|
* in boostrap-typeahead.js Search for 'render'
|
||||||
|
* The line
|
||||||
|
* this.render = this.options.render || this.render
|
||||||
|
* was added to bootstrap-typeahead.js
|
||||||
|
* The following function is a copy of the original render function but
|
||||||
|
* access item.name instead of item
|
||||||
|
*/
|
||||||
|
render : function (items) {
|
||||||
|
var that = this
|
||||||
|
|
||||||
|
items = $(items).map(function (i, item) {
|
||||||
|
i = $(that.options.item).attr('data-value', item.name)
|
||||||
|
i.find('a').html(that.highlighter(item))
|
||||||
|
return i[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
items.first().addClass('active')
|
||||||
|
this.$menu.html(items)
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
}); /* }}} */
|
}); /* }}} */
|
||||||
|
|
||||||
/* Document chooser */
|
/* Document chooser */
|
||||||
|
|
338
styles/bootstrap/bootstrap/js/bootstrap-typeahead.js
vendored
Normal file
338
styles/bootstrap/bootstrap/js/bootstrap-typeahead.js
vendored
Normal file
|
@ -0,0 +1,338 @@
|
||||||
|
/* =============================================================
|
||||||
|
* bootstrap-typeahead.js v2.3.2
|
||||||
|
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
||||||
|
* =============================================================
|
||||||
|
* Copyright 2012 Twitter, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ============================================================ */
|
||||||
|
|
||||||
|
/* THIS IS A MODIFIED VERSION FOR SEEDDMS WHICH IS ABLE TO OVERRIDE THE render FUNCTION */
|
||||||
|
|
||||||
|
!function($){
|
||||||
|
|
||||||
|
"use strict"; // jshint ;_;
|
||||||
|
|
||||||
|
|
||||||
|
/* TYPEAHEAD PUBLIC CLASS DEFINITION
|
||||||
|
* ================================= */
|
||||||
|
|
||||||
|
var Typeahead = function (element, options) {
|
||||||
|
this.$element = $(element)
|
||||||
|
this.options = $.extend({}, $.fn.typeahead.defaults, options)
|
||||||
|
this.matcher = this.options.matcher || this.matcher
|
||||||
|
this.render = this.options.render || this.render
|
||||||
|
this.sorter = this.options.sorter || this.sorter
|
||||||
|
this.highlighter = this.options.highlighter || this.highlighter
|
||||||
|
this.updater = this.options.updater || this.updater
|
||||||
|
this.source = this.options.source
|
||||||
|
this.$menu = $(this.options.menu)
|
||||||
|
this.shown = false
|
||||||
|
this.listen()
|
||||||
|
}
|
||||||
|
|
||||||
|
Typeahead.prototype = {
|
||||||
|
|
||||||
|
constructor: Typeahead
|
||||||
|
|
||||||
|
, select: function () {
|
||||||
|
var val = this.$menu.find('.active').attr('data-value')
|
||||||
|
this.$element
|
||||||
|
.val(this.updater(val))
|
||||||
|
.change()
|
||||||
|
return this.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
, updater: function (item) {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
, show: function () {
|
||||||
|
var pos = $.extend({}, this.$element.position(), {
|
||||||
|
height: this.$element[0].offsetHeight
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$menu
|
||||||
|
.insertAfter(this.$element)
|
||||||
|
.css({
|
||||||
|
top: pos.top + pos.height
|
||||||
|
, left: pos.left
|
||||||
|
})
|
||||||
|
.show()
|
||||||
|
|
||||||
|
this.shown = true
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
, hide: function () {
|
||||||
|
this.$menu.hide()
|
||||||
|
this.shown = false
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
, lookup: function (event) {
|
||||||
|
var items
|
||||||
|
|
||||||
|
this.query = this.$element.val()
|
||||||
|
|
||||||
|
if (!this.query || this.query.length < this.options.minLength) {
|
||||||
|
return this.shown ? this.hide() : this
|
||||||
|
}
|
||||||
|
|
||||||
|
items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
|
||||||
|
|
||||||
|
return items ? this.process(items) : this
|
||||||
|
}
|
||||||
|
|
||||||
|
, process: function (items) {
|
||||||
|
var that = this
|
||||||
|
|
||||||
|
items = $.grep(items, function (item) {
|
||||||
|
return that.matcher(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
items = this.sorter(items)
|
||||||
|
|
||||||
|
if (!items.length) {
|
||||||
|
return this.shown ? this.hide() : this
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.render(items.slice(0, this.options.items)).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
, matcher: function (item) {
|
||||||
|
return ~item.toLowerCase().indexOf(this.query.toLowerCase())
|
||||||
|
}
|
||||||
|
|
||||||
|
, sorter: function (items) {
|
||||||
|
var beginswith = []
|
||||||
|
, caseSensitive = []
|
||||||
|
, caseInsensitive = []
|
||||||
|
, item
|
||||||
|
|
||||||
|
while (item = items.shift()) {
|
||||||
|
if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
|
||||||
|
else if (~item.indexOf(this.query)) caseSensitive.push(item)
|
||||||
|
else caseInsensitive.push(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
return beginswith.concat(caseSensitive, caseInsensitive)
|
||||||
|
}
|
||||||
|
|
||||||
|
, highlighter: function (item) {
|
||||||
|
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
|
||||||
|
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
|
||||||
|
return '<strong>' + match + '</strong>'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
, render: function (items) {
|
||||||
|
var that = this
|
||||||
|
|
||||||
|
items = $(items).map(function (i, item) {
|
||||||
|
i = $(that.options.item).attr('data-value', item)
|
||||||
|
i.find('a').html(that.highlighter(item))
|
||||||
|
return i[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
items.first().addClass('active')
|
||||||
|
this.$menu.html(items)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
, next: function (event) {
|
||||||
|
var active = this.$menu.find('.active').removeClass('active')
|
||||||
|
, next = active.next()
|
||||||
|
|
||||||
|
if (!next.length) {
|
||||||
|
next = $(this.$menu.find('li')[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
next.addClass('active')
|
||||||
|
}
|
||||||
|
|
||||||
|
, prev: function (event) {
|
||||||
|
var active = this.$menu.find('.active').removeClass('active')
|
||||||
|
, prev = active.prev()
|
||||||
|
|
||||||
|
if (!prev.length) {
|
||||||
|
prev = this.$menu.find('li').last()
|
||||||
|
}
|
||||||
|
|
||||||
|
prev.addClass('active')
|
||||||
|
}
|
||||||
|
|
||||||
|
, listen: function () {
|
||||||
|
this.$element
|
||||||
|
.on('focus', $.proxy(this.focus, this))
|
||||||
|
.on('blur', $.proxy(this.blur, this))
|
||||||
|
.on('keypress', $.proxy(this.keypress, this))
|
||||||
|
.on('keyup', $.proxy(this.keyup, this))
|
||||||
|
|
||||||
|
if (this.eventSupported('keydown')) {
|
||||||
|
this.$element.on('keydown', $.proxy(this.keydown, this))
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$menu
|
||||||
|
.on('click', $.proxy(this.click, this))
|
||||||
|
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
||||||
|
.on('mouseleave', 'li', $.proxy(this.mouseleave, this))
|
||||||
|
}
|
||||||
|
|
||||||
|
, eventSupported: function(eventName) {
|
||||||
|
var isSupported = eventName in this.$element
|
||||||
|
if (!isSupported) {
|
||||||
|
this.$element.setAttribute(eventName, 'return;')
|
||||||
|
isSupported = typeof this.$element[eventName] === 'function'
|
||||||
|
}
|
||||||
|
return isSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
, move: function (e) {
|
||||||
|
if (!this.shown) return
|
||||||
|
|
||||||
|
switch(e.keyCode) {
|
||||||
|
case 9: // tab
|
||||||
|
case 13: // enter
|
||||||
|
case 27: // escape
|
||||||
|
e.preventDefault()
|
||||||
|
break
|
||||||
|
|
||||||
|
case 38: // up arrow
|
||||||
|
e.preventDefault()
|
||||||
|
this.prev()
|
||||||
|
break
|
||||||
|
|
||||||
|
case 40: // down arrow
|
||||||
|
e.preventDefault()
|
||||||
|
this.next()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
, keydown: function (e) {
|
||||||
|
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
|
||||||
|
this.move(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
, keypress: function (e) {
|
||||||
|
if (this.suppressKeyPressRepeat) return
|
||||||
|
this.move(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
, keyup: function (e) {
|
||||||
|
switch(e.keyCode) {
|
||||||
|
case 40: // down arrow
|
||||||
|
case 38: // up arrow
|
||||||
|
case 16: // shift
|
||||||
|
case 17: // ctrl
|
||||||
|
case 18: // alt
|
||||||
|
break
|
||||||
|
|
||||||
|
case 9: // tab
|
||||||
|
case 13: // enter
|
||||||
|
if (!this.shown) return
|
||||||
|
this.select()
|
||||||
|
break
|
||||||
|
|
||||||
|
case 27: // escape
|
||||||
|
if (!this.shown) return
|
||||||
|
this.hide()
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
this.lookup()
|
||||||
|
}
|
||||||
|
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
, focus: function (e) {
|
||||||
|
this.focused = true
|
||||||
|
}
|
||||||
|
|
||||||
|
, blur: function (e) {
|
||||||
|
this.focused = false
|
||||||
|
if (!this.mousedover && this.shown) this.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
, click: function (e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
this.select()
|
||||||
|
this.$element.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
, mouseenter: function (e) {
|
||||||
|
this.mousedover = true
|
||||||
|
this.$menu.find('.active').removeClass('active')
|
||||||
|
$(e.currentTarget).addClass('active')
|
||||||
|
}
|
||||||
|
|
||||||
|
, mouseleave: function (e) {
|
||||||
|
this.mousedover = false
|
||||||
|
if (!this.focused && this.shown) this.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* TYPEAHEAD PLUGIN DEFINITION
|
||||||
|
* =========================== */
|
||||||
|
|
||||||
|
var old = $.fn.typeahead
|
||||||
|
|
||||||
|
$.fn.typeahead = function (option) {
|
||||||
|
return this.each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
, data = $this.data('typeahead')
|
||||||
|
, options = typeof option == 'object' && option
|
||||||
|
if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
|
||||||
|
if (typeof option == 'string') data[option]()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn.typeahead.defaults = {
|
||||||
|
source: []
|
||||||
|
, items: 8
|
||||||
|
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
||||||
|
, item: '<li><a href="#"></a></li>'
|
||||||
|
, minLength: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn.typeahead.Constructor = Typeahead
|
||||||
|
|
||||||
|
|
||||||
|
/* TYPEAHEAD NO CONFLICT
|
||||||
|
* =================== */
|
||||||
|
|
||||||
|
$.fn.typeahead.noConflict = function () {
|
||||||
|
$.fn.typeahead = old
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* TYPEAHEAD DATA-API
|
||||||
|
* ================== */
|
||||||
|
|
||||||
|
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
|
||||||
|
var $this = $(this)
|
||||||
|
if ($this.data('typeahead')) return
|
||||||
|
$this.typeahead($this.data())
|
||||||
|
})
|
||||||
|
|
||||||
|
}(window.jQuery);
|
||||||
|
|
|
@ -59,19 +59,65 @@ include($myincpath."/inc/inc.Init.php");
|
||||||
include($myincpath."/inc/inc.Extension.php");
|
include($myincpath."/inc/inc.Extension.php");
|
||||||
include($myincpath."/inc/inc.DBInit.php");
|
include($myincpath."/inc/inc.DBInit.php");
|
||||||
|
|
||||||
function tree($dms, $fulltextservice, $folder, $indent='') { /* {{{ */
|
function tree($dms, $fulltextservice, $folder, $indent='', $numdocs) { /* {{{ */
|
||||||
global $settings, $themes;
|
global $settings, $themes;
|
||||||
echo $themes->black($indent."D ".$folder->getName()).PHP_EOL;
|
|
||||||
$subfolders = $folder->getSubFolders();
|
|
||||||
foreach($subfolders as $subfolder) {
|
|
||||||
tree($dms, $fulltextservice, $subfolder, $indent.' ');
|
|
||||||
}
|
|
||||||
$documents = $folder->getDocuments();
|
|
||||||
$index = $fulltextservice->Indexer();
|
$index = $fulltextservice->Indexer();
|
||||||
$lucenesearch = $fulltextservice->Search();
|
$lucenesearch = $fulltextservice->Search();
|
||||||
|
|
||||||
|
// echo $themes->black($indent."D ".$folder->getName()).PHP_EOL;
|
||||||
|
echo $themes->black($indent."D ".$folder->getId().":".$folder->getName()." ");
|
||||||
|
if(($numdocs == 0) || !($hit = $lucenesearch->getFolder($folder->getId()))) {
|
||||||
|
try {
|
||||||
|
$idoc = $fulltextservice->IndexedDocument($folder, true);
|
||||||
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexFolder'])) {
|
||||||
|
foreach($GLOBALS['SEEDDMS_HOOKS']['indexFolder'] as $hookObj) {
|
||||||
|
if (method_exists($hookObj, 'preIndexFolder')) {
|
||||||
|
$hookObj->preIndexDocument(null, $folder, $idoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$index->addDocument($idoc);
|
||||||
|
echo $themes->green(" (Folder added)").PHP_EOL;
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo $themes->error(" (Timeout)").PHP_EOL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$created = (int) $hit->getDocument()->getFieldValue('created');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$created = 0;
|
||||||
|
}
|
||||||
|
if($created >= $folder->getDate()) {
|
||||||
|
echo $themes->italic(" (Folder unchanged)").PHP_EOL;
|
||||||
|
} else {
|
||||||
|
$index->delete($hit->id);
|
||||||
|
try {
|
||||||
|
$idoc = $fulltextservice->IndexedDocument($folder, true);
|
||||||
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
|
||||||
|
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
|
||||||
|
if (method_exists($hookObj, 'preIndexDocument')) {
|
||||||
|
$hookObj->preIndexDocument(null, $folder, $idoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$index->addDocument($idoc);
|
||||||
|
echo $themes->green(" (Folder updated)").PHP_EOL;
|
||||||
|
} catch(Exception $e) {
|
||||||
|
echo $themes->error(" (Timeout)").PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$subfolders = $folder->getSubFolders();
|
||||||
|
foreach($subfolders as $subfolder) {
|
||||||
|
tree($dms, $fulltextservice, $subfolder, $indent.' ', $numdocs);
|
||||||
|
}
|
||||||
|
|
||||||
|
$documents = $folder->getDocuments();
|
||||||
foreach($documents as $document) {
|
foreach($documents as $document) {
|
||||||
echo $themes->black($indent." ".$document->getId().":".$document->getName()." ");
|
echo $themes->black($indent." ".$document->getId().":".$document->getName()." ");
|
||||||
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
|
if(($numdocs == 0) || !($hit = $lucenesearch->getDocument($document->getId()))) {
|
||||||
try {
|
try {
|
||||||
$idoc = $fulltextservice->IndexedDocument($document, true);
|
$idoc = $fulltextservice->IndexedDocument($document, true);
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
|
||||||
|
@ -124,8 +170,12 @@ if(!$index) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$numdocs = $fulltextservice->Indexer()->count();
|
||||||
$folder = $dms->getFolder($settings->_rootFolderID);
|
$folder = $dms->getFolder($settings->_rootFolderID);
|
||||||
tree($dms, $fulltextservice, $folder);
|
/* if numdocs is 0, then there is no need to check if a document/folder is already
|
||||||
|
* indexed. That speeds up the indexing.
|
||||||
|
*/
|
||||||
|
tree($dms, $fulltextservice, $folder,'', $numdocs);
|
||||||
|
|
||||||
$index->commit();
|
$index->commit();
|
||||||
$index->optimize();
|
$index->optimize();
|
||||||
|
|
|
@ -177,6 +177,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '<script src="../styles/'.$this->theme.'/bootstrap/js/bootstrap.min.js"></script>'."\n";
|
echo '<script src="../styles/'.$this->theme.'/bootstrap/js/bootstrap.min.js"></script>'."\n";
|
||||||
|
echo '<script src="../styles/'.$this->theme.'/bootstrap/js/bootstrap-typeahead.js"></script>'."\n";
|
||||||
echo '<script src="../views/'.$this->theme.'/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>'."\n";
|
echo '<script src="../views/'.$this->theme.'/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>'."\n";
|
||||||
foreach(array('de', 'es', 'ar', 'el', 'bg', 'ru', 'hr', 'hu', 'ko', 'pl', 'ro', 'sk', 'tr', 'uk', 'ca', 'nl', 'fi', 'cs', 'it', 'fr', 'sv', 'sl', 'pt-BR', 'zh-CN', 'zh-TW') as $lang)
|
foreach(array('de', 'es', 'ar', 'el', 'bg', 'ru', 'hr', 'hu', 'ko', 'pl', 'ro', 'sk', 'tr', 'uk', 'ca', 'nl', 'fi', 'cs', 'it', 'fr', 'sv', 'sl', 'pt-BR', 'zh-CN', 'zh-TW') as $lang)
|
||||||
echo '<script src="../views/'.$this->theme.'/vendors/bootstrap-datepicker/locales/bootstrap-datepicker.'.$lang.'.min.js"></script>'."\n";
|
echo '<script src="../views/'.$this->theme.'/vendors/bootstrap-datepicker/locales/bootstrap-datepicker.'.$lang.'.min.js"></script>'."\n";
|
||||||
|
|
|
@ -32,18 +32,43 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
|
||||||
public function __construct($fulltextservice, $forceupdate) { /* {{{ */
|
public function __construct($fulltextservice, $forceupdate) { /* {{{ */
|
||||||
$this->fulltextservice = $fulltextservice;
|
$this->fulltextservice = $fulltextservice;
|
||||||
$this->forceupdate = $forceupdate;
|
$this->forceupdate = $forceupdate;
|
||||||
|
$this->numdocs = $this->fulltextservice->Indexer()->count();
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
public function process($folder) { /* {{{ */
|
public function process($folder) { /* {{{ */
|
||||||
|
$lucenesearch = $this->fulltextservice->Search();
|
||||||
|
echo "<div class=\"folder\">".$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 " <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
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
if($created >= $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);
|
||||||
|
echo " <span id=\"status_F".$folder->getID()."\" class=\"indexme indexstatus\" data-docid=\"F".$folder->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
|
||||||
$documents = $folder->getDocuments();
|
$documents = $folder->getDocuments();
|
||||||
if($documents) {
|
if($documents) {
|
||||||
$lucenesearch = $this->fulltextservice->Search();
|
// echo "<div class=\"folder\">".htmlspecialchars($folder->getFolderPathPlain())."</div>";
|
||||||
echo "<div class=\"folder\">".$folder->getFolderPathPlain()."</div>";
|
|
||||||
foreach($documents as $document) {
|
foreach($documents as $document) {
|
||||||
echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
|
echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
|
||||||
/* If the document wasn't indexed before then just add it */
|
/* If the document wasn't indexed before then just add it */
|
||||||
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
|
if(($this->numdocs == 0) || !($hit = $lucenesearch->getDocument($document->getId()))) {
|
||||||
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
echo " <span id=\"status_D".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"D".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
} else {
|
} else {
|
||||||
/* Check if the attribute created is set or has a value older
|
/* Check if the attribute created is set or has a value older
|
||||||
* than the lastet content. Documents without such an attribute
|
* than the lastet content. Documents without such an attribute
|
||||||
|
@ -57,10 +82,10 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
|
||||||
}
|
}
|
||||||
$content = $document->getLatestContent();
|
$content = $document->getLatestContent();
|
||||||
if($created >= $content->getDate() && !$this->forceupdate) {
|
if($created >= $content->getDate() && !$this->forceupdate) {
|
||||||
echo "<span id=\"status_".$document->getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
|
echo "<span id=\"status_D".$document->getID()."\" class=\"indexstatus\" data-docid=\"D".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
|
||||||
} else {
|
} else {
|
||||||
$this->fulltextservice->Indexer()->delete($hit->id);
|
$this->fulltextservice->Indexer()->delete($hit->id);
|
||||||
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
echo " <span id=\"status_D".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"D".$document->getID()."\">".getMLText('index_waiting')."</span>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
@ -105,12 +130,18 @@ function check_queue() {
|
||||||
if(funcArray.length == 0) {
|
if(funcArray.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var command = '';
|
||||||
docid = funcArray.pop();
|
docid = funcArray.pop();
|
||||||
$('#status_'+docid).html('Processsing ...');
|
$('#status_'+docid).html('Processsing ...');
|
||||||
|
if(docid[0] == 'F') {
|
||||||
|
command = 'indexfolder';
|
||||||
|
} else {
|
||||||
|
command = 'indexdocument';
|
||||||
|
}
|
||||||
$.ajax({url: '../op/op.Ajax.php',
|
$.ajax({url: '../op/op.Ajax.php',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {command: 'indexdocument', id: docid},
|
data: {command: command, id: docid.substring(1)},
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
queue_count++; // Add request to the counter
|
queue_count++; // Add request to the counter
|
||||||
$('.queue-bar').css('width', (queue_count*100/MAX_REQUESTS)+'%');
|
$('.queue-bar').css('width', (queue_count*100/MAX_REQUESTS)+'%');
|
||||||
|
|
|
@ -121,13 +121,15 @@ $(document).ready( function() {
|
||||||
if($entries) {
|
if($entries) {
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
if($entry->isType('document')) {
|
if($entry->isType('document')) {
|
||||||
$recs[] = 'D'.$entry->getName();
|
// $recs[] = 'D'.$entry->getName();
|
||||||
|
$recs[] = array('type'=>'D', 'name'=>$entry->getName());
|
||||||
} elseif($entry->isType('folder')) {
|
} elseif($entry->isType('folder')) {
|
||||||
$recs[] = 'F'.$entry->getName();
|
// $recs[] = 'F'.$entry->getName();
|
||||||
|
$recs[] = array('type'=>'F', 'name'=>$entry->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
array_unshift($recs, ' '.$query);
|
array_unshift($recs, array('type'=>'S', 'name'=>$query));
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($recs);
|
echo json_encode($recs);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user