Commit 78072abe0ebea2a2f70f2336f20955c2feeca998

Authored by Conrad Vermeulen
1 parent bc6c5313

KTS-673

"The search algorithm needs some work"
Implemented. Index is cleared out when document is expunged.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7187 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/storage/ondiskhashedstoragemanager.inc.php
@@ -288,7 +288,8 @@ class KTOnDiskHashedStorageManager extends KTStorageManager { @@ -288,7 +288,8 @@ class KTOnDiskHashedStorageManager extends KTStorageManager {
288 * return boolean true on successful expunge 288 * return boolean true on successful expunge
289 */ 289 */
290 function expunge($oDocument) { 290 function expunge($oDocument) {
291 - $oConfig =& KTConfig::getSingleton(); 291 + parent::expunge($oDocument);
  292 + $oConfig =& KTConfig::getSingleton();
292 $sCurrentPath = $this->getPath($oDocument); 293 $sCurrentPath = $this->getPath($oDocument);
293 294
294 $sDocumentRoot = $oConfig->get('urls/documentRoot'); 295 $sDocumentRoot = $oConfig->get('urls/documentRoot');
lib/storage/ondiskpathstoragemanager.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * path on-disk as in the repository. 6 * path on-disk as in the repository.
7 * 7 *
8 * WARNING: 8 * WARNING:
9 - * 9 + *
10 * This storage manager is _not_ transaction-safe, as on-disk paths need 10 * This storage manager is _not_ transaction-safe, as on-disk paths need
11 * to update when the repository position changes, and this operation 11 * to update when the repository position changes, and this operation
12 * and the repository change in combination can't be atomic, even if 12 * and the repository change in combination can't be atomic, even if
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 * License Version 1.1.2 ("License"); You may not use this file except in 16 * License Version 1.1.2 ("License"); You may not use this file except in
17 * compliance with the License. You may obtain a copy of the License at 17 * compliance with the License. You may obtain a copy of the License at
18 * http://www.knowledgetree.com/KPL 18 * http://www.knowledgetree.com/KPL
19 - * 19 + *
20 * Software distributed under the License is distributed on an "AS IS" 20 * Software distributed under the License is distributed on an "AS IS"
21 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 21 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
22 * See the License for the specific language governing rights and 22 * See the License for the specific language governing rights and
@@ -27,9 +27,9 @@ @@ -27,9 +27,9 @@
27 * (ii) the KnowledgeTree copyright notice 27 * (ii) the KnowledgeTree copyright notice
28 * in the same form as they appear in the distribution. See the License for 28 * in the same form as they appear in the distribution. See the License for
29 * requirements. 29 * requirements.
30 - * 30 + *
31 * The Original Code is: KnowledgeTree Open Source 31 * The Original Code is: KnowledgeTree Open Source
32 - * 32 + *
33 * The Initial Developer of the Original Code is The Jam Warehouse Software 33 * The Initial Developer of the Original Code is The Jam Warehouse Software
34 * (Pty) Ltd, trading as KnowledgeTree. 34 * (Pty) Ltd, trading as KnowledgeTree.
35 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright 35 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
@@ -97,7 +97,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -97,7 +97,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
97 function freeTemporaryFile($sPath) { 97 function freeTemporaryFile($sPath) {
98 return; 98 return;
99 } 99 }
100 - 100 +
101 function download($oDocument) { 101 function download($oDocument) {
102 //get the path to the document on the server 102 //get the path to the document on the server
103 $oConfig =& KTConfig::getSingleton(); 103 $oConfig =& KTConfig::getSingleton();
@@ -148,7 +148,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -148,7 +148,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
148 $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $oFolder->generateFolderPath($oFolder->getID())); 148 $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $oFolder->generateFolderPath($oFolder->getID()));
149 KTUtil::deleteDirectory($sPath); 149 KTUtil::deleteDirectory($sPath);
150 } 150 }
151 - 151 +
152 function downloadVersion($oDocument, $iVersionId) { 152 function downloadVersion($oDocument, $iVersionId) {
153 //get the document 153 //get the document
154 $oContentVersion = KTDocumentContentVersion::get($iVersionId); 154 $oContentVersion = KTDocumentContentVersion::get($iVersionId);
@@ -170,7 +170,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -170,7 +170,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
170 return false; 170 return false;
171 } 171 }
172 } 172 }
173 - 173 +
174 /** 174 /**
175 * Move a document to a new folder 175 * Move a document to a new folder
176 * 176 *
@@ -200,7 +200,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -200,7 +200,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
200 } 200 }
201 return true; 201 return true;
202 } 202 }
203 - 203 +
204 /** 204 /**
205 * Move a file 205 * Move a file
206 * 206 *
@@ -220,7 +220,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -220,7 +220,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
220 } 220 }
221 } else { 221 } else {
222 return false; 222 return false;
223 - } 223 + }
224 } 224 }
225 225
226 function moveFolder($oFolder, $oDestFolder) { 226 function moveFolder($oFolder, $oDestFolder) {
@@ -248,7 +248,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -248,7 +248,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
248 if (PEAR::isError($res)) { 248 if (PEAR::isError($res)) {
249 return $res; 249 return $res;
250 } 250 }
251 - 251 +
252 $oConfig =& KTConfig::getSingleton(); 252 $oConfig =& KTConfig::getSingleton();
253 $sSrc = sprintf("%s/%s", 253 $sSrc = sprintf("%s/%s",
254 $oConfig->get('urls/documentRoot'), 254 $oConfig->get('urls/documentRoot'),
@@ -261,7 +261,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -261,7 +261,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
261 ); 261 );
262 return KTUtil::moveDirectory($sSrc, $sDst); 262 return KTUtil::moveDirectory($sSrc, $sDst);
263 } 263 }
264 - 264 +
265 function renameFolder($oFolder, $sNewName) { 265 function renameFolder($oFolder, $sNewName) {
266 $table = "document_content_version"; 266 $table = "document_content_version";
267 $sQuery = "UPDATE $table SET storage_path = CONCAT(?, SUBSTRING(storage_path FROM ?)) WHERE storage_path LIKE ?"; 267 $sQuery = "UPDATE $table SET storage_path = CONCAT(?, SUBSTRING(storage_path FROM ?)) WHERE storage_path LIKE ?";
@@ -283,7 +283,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -283,7 +283,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
283 if (PEAR::isError($res)) { 283 if (PEAR::isError($res)) {
284 return $res; 284 return $res;
285 } 285 }
286 - 286 +
287 $oConfig =& KTConfig::getSingleton(); 287 $oConfig =& KTConfig::getSingleton();
288 $sSrc = sprintf("%s/%s", 288 $sSrc = sprintf("%s/%s",
289 $oConfig->get('urls/documentRoot'), 289 $oConfig->get('urls/documentRoot'),
@@ -294,59 +294,59 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -294,59 +294,59 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
294 $sDestFolderPath 294 $sDestFolderPath
295 ); 295 );
296 $res = @rename($sSrc, $sDst); 296 $res = @rename($sSrc, $sDst);
297 - if (PEAR::isError($res) || ($res == false)) { 297 + if (PEAR::isError($res) || ($res == false)) {
298 print '<br /> -- unable to move ' . $sSrc . ' to ' . $sDst . ' '; 298 print '<br /> -- unable to move ' . $sSrc . ' to ' . $sDst . ' ';
299 return false; 299 return false;
300 - // return PEAR::raiseError('unable to move directory to ' . $sDst);  
301 - }  
302 - 300 + // return PEAR::raiseError('unable to move directory to ' . $sDst);
  301 + }
  302 +
303 return true; 303 return true;
304 - }  
305 - 304 + }
  305 +
306 /** 306 /**
307 * Perform any storage changes necessary to account for a copied 307 * Perform any storage changes necessary to account for a copied
308 * document object. 308 * document object.
309 */ 309 */
310 function copy($oSrcDocument, &$oNewDocument) { 310 function copy($oSrcDocument, &$oNewDocument) {
311 - // we get the Folder object 311 + // we get the Folder object
312 $oVersion = $oNewDocument->_oDocumentContentVersion; 312 $oVersion = $oNewDocument->_oDocumentContentVersion;
313 $oConfig =& KTConfig::getSingleton(); 313 $oConfig =& KTConfig::getSingleton();
314 $sDocumentRoot = $oConfig->get('urls/documentRoot'); 314 $sDocumentRoot = $oConfig->get('urls/documentRoot');
315 - 315 +
316 $sNewPath = $this->generateStoragePath($oNewDocument); 316 $sNewPath = $this->generateStoragePath($oNewDocument);
317 $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $this->generateStoragePath($oSrcDocument)); 317 $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $this->generateStoragePath($oSrcDocument));
318 $sFullNewPath = sprintf("%s/%s", $sDocumentRoot, $sNewPath); 318 $sFullNewPath = sprintf("%s/%s", $sDocumentRoot, $sNewPath);
319 - 319 +
320 $res = KTUtil::copyFile($sFullOldPath, $sFullNewPath); 320 $res = KTUtil::copyFile($sFullOldPath, $sFullNewPath);
321 if (PEAR::isError($res)) { return $res; } 321 if (PEAR::isError($res)) { return $res; }
322 $oVersion->setStoragePath($sNewPath); 322 $oVersion->setStoragePath($sNewPath);
323 - $oVersion->update(); 323 + $oVersion->update();
324 } 324 }
325 - 325 +
326 /** 326 /**
327 * Perform any storage changes necessary to account for a renamed 327 * Perform any storage changes necessary to account for a renamed
328 * document object. 328 * document object.
329 * someone else _must_ call the update on $oDocument 329 * someone else _must_ call the update on $oDocument
330 */ 330 */
331 function renameDocument(&$oDocument, $oOldContentVersion, $sNewFilename) { 331 function renameDocument(&$oDocument, $oOldContentVersion, $sNewFilename) {
332 - // we get the Folder object  
333 - $oVersion =& $oDocument->_oDocumentContentVersion; 332 + // we get the Folder object
  333 + $oVersion =& $oDocument->_oDocumentContentVersion;
334 $oConfig =& KTConfig::getSingleton(); 334 $oConfig =& KTConfig::getSingleton();
335 $sDocumentRoot = $oConfig->get('urls/documentRoot'); 335 $sDocumentRoot = $oConfig->get('urls/documentRoot');
336 - 336 +
337 $sOldPath = sprintf("%s/%s-%s", Folder::generateFolderPath($oDocument->getFolderID()), $oOldContentVersion->getId(), $oOldContentVersion->getFileName()); 337 $sOldPath = sprintf("%s/%s-%s", Folder::generateFolderPath($oDocument->getFolderID()), $oOldContentVersion->getId(), $oOldContentVersion->getFileName());
338 $sNewPath = sprintf("%s/%s-%s", Folder::generateFolderPath($oDocument->getFolderID()), $oDocument->_oDocumentContentVersion->getId(), $sNewFilename); 338 $sNewPath = sprintf("%s/%s-%s", Folder::generateFolderPath($oDocument->getFolderID()), $oDocument->_oDocumentContentVersion->getId(), $sNewFilename);
339 $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $sOldPath); 339 $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $sOldPath);
340 $sFullNewPath = sprintf("%s/%s", $sDocumentRoot, $sNewPath); 340 $sFullNewPath = sprintf("%s/%s", $sDocumentRoot, $sNewPath);
341 - 341 +
342 $res = KTUtil::copyFile($sFullOldPath, $sFullNewPath); 342 $res = KTUtil::copyFile($sFullOldPath, $sFullNewPath);
343 if (PEAR::isError($res)) { return $res; } 343 if (PEAR::isError($res)) { return $res; }
344 - 344 +
345 $oVersion->setStoragePath($sNewPath); 345 $oVersion->setStoragePath($sNewPath);
346 // someone else _must_ call the update. 346 // someone else _must_ call the update.
347 return true; // RES ?= PEAR::raiseError('.'); 347 return true; // RES ?= PEAR::raiseError('.');
348 } 348 }
349 - 349 +
350 /** 350 /**
351 * Deletes a document- moves it to the Deleted/ folder 351 * Deletes a document- moves it to the Deleted/ folder
352 * 352 *
@@ -355,7 +355,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -355,7 +355,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
355 function delete($oDocument) { 355 function delete($oDocument) {
356 $oConfig =& KTConfig::getSingleton(); 356 $oConfig =& KTConfig::getSingleton();
357 $sCurrentPath = $this->getPath($oDocument); 357 $sCurrentPath = $this->getPath($oDocument);
358 - 358 +
359 // check if the deleted folder exists and create it if not 359 // check if the deleted folder exists and create it if not
360 $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot')); 360 $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot'));
361 if (!file_exists($sDeletedPrefix)) { 361 if (!file_exists($sDeletedPrefix)) {
@@ -379,11 +379,12 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -379,11 +379,12 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
379 * Completely remove a document from the Deleted/ folder 379 * Completely remove a document from the Deleted/ folder
380 * 380 *
381 * return boolean true on successful expunge 381 * return boolean true on successful expunge
382 - */ 382 + */
383 function expunge($oDocument) { 383 function expunge($oDocument) {
  384 + parent::expunge($oDocument);
384 $oConfig =& KTConfig::getSingleton(); 385 $oConfig =& KTConfig::getSingleton();
385 $sCurrentPath = $this->getPath($oDocument); 386 $sCurrentPath = $this->getPath($oDocument);
386 - 387 +
387 // check if the deleted folder exists and create it if not 388 // check if the deleted folder exists and create it if not
388 $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot')); 389 $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot'));
389 $sDocumentRoot = $oConfig->get('urls/documentRoot'); 390 $sDocumentRoot = $oConfig->get('urls/documentRoot');
@@ -398,16 +399,16 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -398,16 +399,16 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
398 } 399 }
399 return true; 400 return true;
400 } 401 }
401 - 402 +
402 /** 403 /**
403 * Restore a document from the Deleted/ folder to the specified folder 404 * Restore a document from the Deleted/ folder to the specified folder
404 * 405 *
405 * return boolean true on successful move, false otherwhise 406 * return boolean true on successful move, false otherwhise
406 - */ 407 + */
407 function restore($oDocument) { 408 function restore($oDocument) {
408 $oConfig =& KTConfig::getSingleton(); 409 $oConfig =& KTConfig::getSingleton();
409 $sCurrentPath = $this->getPath($oDocument); 410 $sCurrentPath = $this->getPath($oDocument);
410 - 411 +
411 // check if the deleted folder exists and create it if not 412 // check if the deleted folder exists and create it if not
412 $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot')); 413 $sDeletedPrefix = sprintf("%s/Deleted", $oConfig->get('urls/documentRoot'));
413 $sDocumentRoot = $oConfig->get('urls/documentRoot'); 414 $sDocumentRoot = $oConfig->get('urls/documentRoot');
@@ -422,12 +423,12 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -422,12 +423,12 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
422 $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $sOldPath); 423 $sFullOldPath = sprintf("%s/%s", $sDocumentRoot, $sOldPath);
423 KTUtil::moveFile($sFullOldPath, $sFullNewPath); 424 KTUtil::moveFile($sFullOldPath, $sFullNewPath);
424 $oVersion->update(); 425 $oVersion->update();
425 - 426 +
426 } 427 }
427 return true; 428 return true;
428 } 429 }
429 -  
430 - 430 +
  431 +
431 /** 432 /**
432 * View a document using an inline viewer 433 * View a document using an inline viewer
433 * 434 *
@@ -439,7 +440,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -439,7 +440,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
439 */ 440 */
440 function inlineViewPhysicalDocument($iDocumentID) { 441 function inlineViewPhysicalDocument($iDocumentID) {
441 //get the document 442 //get the document
442 - $oDocument = & Document::get($iDocumentID); 443 + $oDocument = & Document::get($iDocumentID);
443 //get the path to the document on the server 444 //get the path to the document on the server
444 $sDocumentFileSystemPath = $oDocument->getPath(); 445 $sDocumentFileSystemPath = $oDocument->getPath();
445 if (file_exists($sDocumentFileSystemPath)) { 446 if (file_exists($sDocumentFileSystemPath)) {
@@ -456,7 +457,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -456,7 +457,7 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
456 return false; 457 return false;
457 } 458 }
458 } 459 }
459 - 460 +
460 /** 461 /**
461 * Get the uploaded file information and place it into a document object 462 * Get the uploaded file information and place it into a document object
462 * 463 *
@@ -466,9 +467,9 @@ class KTOnDiskPathStorageManager extends KTStorageManager { @@ -466,9 +467,9 @@ class KTOnDiskPathStorageManager extends KTStorageManager {
466 * @return Document Document object containing uploaded file information 467 * @return Document Document object containing uploaded file information
467 */ 468 */
468 function & createDocumentFromUploadedFile($aFileArray, $iFolderID) { 469 function & createDocumentFromUploadedFile($aFileArray, $iFolderID) {
469 - //get the uploaded document information and put it into a document object  
470 - $oDocument = & new Document($aFileArray['name'], $aFileArray['name'], $aFileArray['size'], $_SESSION["userID"], PhysicalDocumentManager::getMimeTypeID($aFileArray['type'], $aFileArray['name']), $iFolderID);  
471 - return $oDocument; 470 + //get the uploaded document information and put it into a document object
  471 + $oDocument = new Document($aFileArray['name'], $aFileArray['name'], $aFileArray['size'], $_SESSION["userID"], PhysicalDocumentManager::getMimeTypeID($aFileArray['type'], $aFileArray['name']), $iFolderID);
  472 + return $oDocument;
472 } 473 }
473 } 474 }
474 475
lib/storage/storagemanager.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * License Version 1.1.2 ("License"); You may not use this file except in 6 * License Version 1.1.2 ("License"); You may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at 7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.knowledgetree.com/KPL 8 * http://www.knowledgetree.com/KPL
9 - * 9 + *
10 * Software distributed under the License is distributed on an "AS IS" 10 * Software distributed under the License is distributed on an "AS IS"
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12 * See the License for the specific language governing rights and 12 * See the License for the specific language governing rights and
@@ -17,9 +17,9 @@ @@ -17,9 +17,9 @@
17 * (ii) the KnowledgeTree copyright notice 17 * (ii) the KnowledgeTree copyright notice
18 * in the same form as they appear in the distribution. See the License for 18 * in the same form as they appear in the distribution. See the License for
19 * requirements. 19 * requirements.
20 - * 20 + *
21 * The Original Code is: KnowledgeTree Open Source 21 * The Original Code is: KnowledgeTree Open Source
22 - * 22 + *
23 * The Initial Developer of the Original Code is The Jam Warehouse Software 23 * The Initial Developer of the Original Code is The Jam Warehouse Software
24 * (Pty) Ltd, trading as KnowledgeTree. 24 * (Pty) Ltd, trading as KnowledgeTree.
25 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright 25 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
@@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
34 * The Document Manager may only use setDiskPath on the oDocument 34 * The Document Manager may only use setDiskPath on the oDocument
35 * object, and should not update the document object. 35 * object, and should not update the document object.
36 */ 36 */
  37 +require_once(KT_DIR . '/search2/indexing/indexerCore.inc.php');
37 38
38 class KTStorageManager { 39 class KTStorageManager {
39 /** 40 /**
@@ -72,7 +73,7 @@ class KTStorageManager { @@ -72,7 +73,7 @@ class KTStorageManager {
72 73
73 /** 74 /**
74 * Performs any storage changes necessary to account for a changed 75 * Performs any storage changes necessary to account for a changed
75 - * repository path. 76 + * repository path.
76 * 77 *
77 * The info arrays must contain the following information: 78 * The info arrays must contain the following information:
78 * "names" => an array of the names of the folders in the path 79 * "names" => an array of the names of the folders in the path
@@ -93,7 +94,7 @@ class KTStorageManager { @@ -93,7 +94,7 @@ class KTStorageManager {
93 function moveFolder ($oFolder, $oDestFolder) { 94 function moveFolder ($oFolder, $oDestFolder) {
94 return PEAR::raiseError(_kt("Not implemented")); 95 return PEAR::raiseError(_kt("Not implemented"));
95 } 96 }
96 - 97 +
97 function renameFolder($oFolder, $sNewName) { 98 function renameFolder($oFolder, $sNewName) {
98 return PEAR::raiseError(_kt("Not implemented")); 99 return PEAR::raiseError(_kt("Not implemented"));
99 } 100 }
@@ -103,7 +104,7 @@ class KTStorageManager { @@ -103,7 +104,7 @@ class KTStorageManager {
103 * document object. 104 * document object.
104 */ 105 */
105 function copy ($oSrcDocument, &$oNewDocument) { 106 function copy ($oSrcDocument, &$oNewDocument) {
106 - return PEAR::raiseError(_kt("Not implemented")); 107 + return PEAR::raiseError(_kt("Not implemented"));
107 } 108 }
108 109
109 /** 110 /**
@@ -119,7 +120,9 @@ class KTStorageManager { @@ -119,7 +120,9 @@ class KTStorageManager {
119 * storage. 120 * storage.
120 */ 121 */
121 function expunge (&$oDocument) { 122 function expunge (&$oDocument) {
122 - return PEAR::raiseError(_kt("Not implemented")); 123 + $documentid = $oDocument->getId();
  124 + $indexer = Indexer::get();
  125 + $indexer->deleteDocument($documentid);
123 } 126 }
124 127
125 /** 128 /**
@@ -145,24 +148,30 @@ class KTStorageManager { @@ -145,24 +148,30 @@ class KTStorageManager {
145 function createFolder($sFolderPath) { 148 function createFolder($sFolderPath) {
146 return PEAR::raiseError(_kt("Not implemented")); 149 return PEAR::raiseError(_kt("Not implemented"));
147 } 150 }
148 - 151 +
149 function renameDocument(&$oDocument, $oOldContentVersion, $sNewFilename) { 152 function renameDocument(&$oDocument, $oOldContentVersion, $sNewFilename) {
150 return PEAR::raiseError(_kt("Not implemented")); 153 return PEAR::raiseError(_kt("Not implemented"));
151 } 154 }
152 } 155 }
153 156
154 class KTStorageManagerUtil { 157 class KTStorageManagerUtil {
155 - function &getSingleton() {  
156 - $oConfig =& KTConfig::getSingleton();  
157 - $sDefaultManager = 'KTOnDiskHashedStorageManager';  
158 - $klass = $oConfig->get('storage/manager', $sDefaultManager);  
159 - if (!class_exists($klass)) {  
160 - $klass = $sDefaultManager;  
161 - }  
162 - if (!KTUtil::arrayGet($GLOBALS, 'KTStorageManager')) {  
163 - $GLOBALS['KTStorageManager'] =& new $klass;  
164 - }  
165 - return $GLOBALS['KTStorageManager']; 158 + static function &getSingleton() {
  159 +
  160 +
  161 + static $singleton = null;
  162 +
  163 + if (is_null($singleton))
  164 + {
  165 + $oConfig =& KTConfig::getSingleton();
  166 + $sDefaultManager = 'KTOnDiskHashedStorageManager';
  167 + $klass = $oConfig->get('storage/manager', $sDefaultManager);
  168 + if (!class_exists($klass)) {
  169 + $klass = $sDefaultManager;
  170 + }
  171 + $singleton = new $klass;
  172 + }
  173 +
  174 + return $singleton;
166 } 175 }
167 } 176 }
168 177