Commit b3b8774ba5ba5212c8a24a3c7e21de3f2e90a9cd
1 parent
512087a6
Add updateSearchableText, which creates a single full-text indexed
string based on document contents, field values, and transaction history. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3928 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
26 additions
and
0 deletions
lib/documentmanagement/documentutil.inc.php
| @@ -462,6 +462,32 @@ class KTDocumentUtil { | @@ -462,6 +462,32 @@ class KTDocumentUtil { | ||
| 462 | return DBUtil::autoInsert($sTable, $aInsert, array('noid' => true)); | 462 | return DBUtil::autoInsert($sTable, $aInsert, array('noid' => true)); |
| 463 | } | 463 | } |
| 464 | // }}} | 464 | // }}} |
| 465 | + // | ||
| 466 | + // {{{ updateSearchableText | ||
| 467 | + function updateSearchableText($oDocument) { | ||
| 468 | + $iDocumentId = KTUtil::getId($oDocument); | ||
| 469 | + $sTable = KTUtil::getTableName('document_transaction_text'); | ||
| 470 | + $aQuery = array("SELECT document_text FROM $sTable WHERE | ||
| 471 | + document_id = ?", array($iDocumentId)); | ||
| 472 | + $sAllComments = DBUtil::getOneResultKey($aQuery, 'document_text'); | ||
| 473 | + $sTable = KTUtil::getTableName('document_text'); | ||
| 474 | + $aQuery = array("SELECT document_text FROM $sTable WHERE | ||
| 475 | + document_id = ?", array($iDocumentId)); | ||
| 476 | + $sAllDocumentText = DBUtil::getOneResultKey($aQuery, 'document_text'); | ||
| 477 | + $aFieldLinks = DocumentFieldLink::getByDocument($iDocumentId); | ||
| 478 | + $aFieldValues = array(); | ||
| 479 | + foreach ($aFieldLinks as $oFieldLink) { | ||
| 480 | + $aFieldValues[] = $oFieldLink->getValue(); | ||
| 481 | + } | ||
| 482 | + $sAllFieldText = join(" ", $aFieldValues); | ||
| 483 | + $sSearchableText = $sAllDocumentText . " " . $sAllFieldText . " " . $sAllComments; | ||
| 484 | + $sTable = KTUtil::getTableName('document_searchable_text'); | ||
| 485 | + $aInsert = array( | ||
| 486 | + "document_id" => $iDocumentId, | ||
| 487 | + "document_text" => $sSearchableText, | ||
| 488 | + ); | ||
| 489 | + return DBUtil::autoInsert($sTable, $aInsert, array('noid' => true)); | ||
| 490 | + } | ||
| 465 | } | 491 | } |
| 466 | 492 | ||
| 467 | class KTMetadataValidationError extends PEAR_Error { | 493 | class KTMetadataValidationError extends PEAR_Error { |