Commit a6f9c7efc4cc1e39b3c17e3f72617ab7fc230e30

Authored by Jonathan Byrne
1 parent 9f2d5f28

KTS-2601

"Create indexer administration page"
Implemented. Added all search & indexing administration/reporting pages.

Committed By: Jonathan Byrne
Reviewed By: Conrad Vermeulen

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7941 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/mime.inc.php
... ... @@ -207,6 +207,44 @@ class KTMime {
207 207 function stripAllButExtension($sFileName) {
208 208 return strtolower(substr($sFileName, strrpos($sFileName, ".")+1, strlen($sFileName) - strrpos($sFileName, ".")));
209 209 }
  210 +
  211 + /**
  212 + * getAllMimeTypesInformation is a staic function used to get a fuller set of
  213 + * information on the mime types held in the database.
  214 + *
  215 + */
  216 + function getAllMimeTypesInformation()
  217 + {
  218 + $sTable = KTUtil::getTableName('mimetypes');
  219 + $aQuery = array('SELECT MT.id, MT.filetypes, MT.mimetypes, MT.icon_path, MT.friendly_name, ME.name as extractor FROM '
  220 + . $sTable .' MT LEFT JOIN mime_extractors ME ON(MT.extractor_id = ME.id) ORDER BY MT.filetypes', array());
  221 + $res = DBUtil::getResultArray($aQuery);
  222 + return $res;
  223 + }
  224 +
  225 + /**
  226 + * get all information on all the extractors in the database
  227 + *
  228 + */
  229 + function getMimeExtractorInformation()
  230 + {
  231 + $aQuery = array('SELECT id, name, active FROM mime_extractors ORDER BY name', array());
  232 + $res = DBUtil::getResultArray($aQuery);
  233 + return $res;
  234 + }
  235 +
  236 + /**
  237 + *give the mimetype name and get the friendly names and the extensions
  238 + *
  239 + */
  240 + function getFriendlyNameAndExtension($sMimeType)
  241 + {
  242 + $sTable = KTUtil::getTableName('mimetypes');
  243 + $sQuery = "SELECT friendly_name, filetypes FROM " . $sTable . " WHERE mimetypes = ?";
  244 + $aQuery = array($sQuery, array($sMimeType));
  245 + $res = DBUtil::getResultArray($aQuery);
  246 + return $res;
  247 + }
210 248 }
211 249  
212 250 $_KT_icon_path_cache = array();
... ...
plugins/ktcore/KTCorePlugin.php
... ... @@ -232,6 +232,8 @@ class KTCorePlugin extends KTPlugin {
232 232 _kt('Manage checked-out, archived and deleted documents.'));
233 233 $this->registerAdminCategory('documents', _kt('Document Metadata and Workflow Configuration'),
234 234 _kt('Configure the document metadata: Document Types, Document Fieldsets, Link Types and Workflows.'));
  235 + $this->registerAdminCategory('search', _kt('Search and Indexing'),
  236 + _kt('Search and Indexing Settings'));
235 237 $this->registerAdminCategory('misc', _kt('Miscellaneous'),
236 238 _kt('Various settings which do not fit into the other categories, including managing help and saved searches.'));
237 239  
... ... @@ -289,7 +291,26 @@ class KTCorePlugin extends KTPlugin {
289 291 _kt('Restore or Expunge Deleted Documents'), _kt('Restore previously deleted documents, or permanently expunge them.'),
290 292 'admin/deletedDocuments.php', null);
291 293  
292   -
  294 + //Search and Indexing
  295 + $this->registerAdminPage('managemimetypes', 'ManageMimeTypesDispatcher', 'search',
  296 + _kt('Mime Types'), _kt('Mime type information.'),
  297 + '../search2/reporting/ManageMimeTypes.php', null);
  298 +
  299 + $this->registerAdminPage('extractorinfo', 'ExtractorInfoDispatcher', 'search',
  300 + _kt('Extractor Information'), _kt('Extractor information.'),
  301 + '../search2/reporting/ExtractorInfo.php', null);
  302 +
  303 + $this->registerAdminPage('indexerrors', 'IndexErrorsDispatcher', 'search',
  304 + _kt('Document Indexing Diagnostics'), _kt('Document Indexing Diagnostics'),
  305 + '../search2/reporting/IndexErrors.php', null);
  306 +
  307 + $this->registerAdminPage('pendingdocuments', 'PendingDocumentsDispatcher', 'search',
  308 + _kt('Pending Documents Indexing Queue'), _kt('Pending Documents Indexing Information'),
  309 + '../search2/reporting/PendingDocuments.php', null);
  310 +
  311 + $this->registerAdminPage('reschedulealldocuments', 'RescheduleDocumentsDispatcher', 'search',
  312 + _kt('Reschedule all documents'), _kt('Reschedule all documents'),
  313 + '../search2/reporting/RescheduleDocuments.php', null);
293 314  
294 315 // misc
295 316 $this->registerAdminPage('helpmanagement', 'ManageHelpDispatcher', 'misc',
... ...
plugins/search2/reporting/ExtractorInfo.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id:$
  4 + *
  5 + * KnowledgeTree Open Source Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
  8 + *
  9 + * This program is free software; you can redistribute it and/or modify it under
  10 + * the terms of the GNU General Public License version 3 as published by the
  11 + * Free Software Foundation.
  12 + *
  13 + * This program is distributed in the hope that it will be useful, but WITHOUT
  14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16 + * details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 + *
  21 + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
  22 + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
  23 + *
  24 + * The interactive user interfaces in modified source and object code versions
  25 + * of this program must display Appropriate Legal Notices, as required under
  26 + * Section 5 of the GNU General Public License version 3.
  27 + *
  28 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  29 + * these Appropriate Legal Notices must retain the display of the "Powered by
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
  34 + * Contributor( s): ______________________________________
  35 + *
  36 + */
  37 +
  38 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  39 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  40 +require_once(KT_LIB_DIR . '/mime.inc.php');
  41 +
  42 +class ExtractorInfoDispatcher extends KTAdminDispatcher {
  43 +
  44 +
  45 + function check() {
  46 + $this->aBreadcrumbs[] = array(
  47 + 'url' => $_SERVER['PHP_SELF'],
  48 + 'name' => _kt('Extractor Information'),
  49 + );
  50 + return parent::check();
  51 + }
  52 +
  53 + function do_main() {
  54 +
  55 + //registerTypes registers the mime types and populates the needed tables.
  56 + $indexer = Indexer::get();
  57 + $indexer->registerTypes();
  58 +
  59 + $oTemplating =& KTTemplating::getSingleton();
  60 + $oTemplating->addLocation('Extractor Information', '/plugins/search2/reporting/templates');
  61 +
  62 + $oTemplate =& $oTemplating->loadTemplate('extractorinfo');
  63 +
  64 + $aExtractorInfo = KTMime::getMimeExtractorInformation();
  65 +
  66 + if(empty($aExtractorInfo))
  67 + {
  68 + $oTemplate->setData(array(
  69 + 'context' => $this,
  70 + 'extractor_info' => $aExtractorInfo
  71 + ));
  72 +
  73 + return $oTemplate;
  74 + }
  75 +
  76 + foreach($aExtractorInfo as $key=>$info)
  77 + {
  78 + $extractorClass = $info['name'];
  79 + $extractor = $indexer->getExtractor($extractorClass);
  80 + $info['mimeTypes'] = array();
  81 + $aMimeTypes = $this->getSupportedMimeTypesDB($extractorClass);//$extractor->getSupportedMimeTypes();
  82 +
  83 +
  84 + foreach($aMimeTypes as $mimeType)
  85 + {
  86 + $sMimeInfo = KTMime::getFriendlyNameAndExtension($mimeType);
  87 +
  88 + $info['mimeTypes'][$mimeType] = array('description'=>$sMimeInfo[0]['friendly_name'], 'extensions'=>array($sMimeInfo[0]['filetypes']));
  89 +
  90 + $extensions = array();
  91 + foreach($sMimeInfo as $item)
  92 + {
  93 + $extensions[] = $item['filetypes'];
  94 + }
  95 + $info['mimeTypes'][$mimeType]['extensions'] = implode(', ', $extensions);
  96 + }
  97 +
  98 + $aExtractorInfo[$key] = $info;
  99 + }
  100 +
  101 + $oTemplate->setData(array(
  102 + 'context' => $this,
  103 + 'extractor_info' => $aExtractorInfo
  104 + ));
  105 + return $oTemplate;
  106 + }
  107 +
  108 + function getSupportedMimeTypesDB($sExtractorName)
  109 + {
  110 + $sQuery = "SELECT MT.mimetypes FROM mime_extractors as ME LEFT JOIN mime_types as MT ON " .
  111 + "(ME.id = MT.extractor_id) WHERE ME.name = ?";
  112 + $aQuery = array($sQuery, array($sExtractorName));
  113 + $aTempRes = DBUtil::getResultArray($aQuery);
  114 + $aRes = array();
  115 + for($i = 0; $i < count($aTempRes); $i++ )
  116 + {
  117 + if(!in_array($aTempRes[$i]['mimetypes'], $aRes))
  118 + {
  119 + $aRes[] = $aTempRes[$i]['mimetypes'];
  120 +
  121 + }
  122 + }
  123 + return $aRes;
  124 + }
  125 +
  126 +}
  127 +
  128 +
  129 +?>
... ...
plugins/search2/reporting/IndexErrors.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id:$
  4 + *
  5 + * KnowledgeTree Open Source Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
  8 + *
  9 + * This program is free software; you can redistribute it and/or modify it under
  10 + * the terms of the GNU General Public License version 3 as published by the
  11 + * Free Software Foundation.
  12 + *
  13 + * This program is distributed in the hope that it will be useful, but WITHOUT
  14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16 + * details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 + *
  21 + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
  22 + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
  23 + *
  24 + * The interactive user interfaces in modified source and object code versions
  25 + * of this program must display Appropriate Legal Notices, as required under
  26 + * Section 5 of the GNU General Public License version 3.
  27 + *
  28 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  29 + * these Appropriate Legal Notices must retain the display of the "Powered by
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
  34 + * Contributor( s): ______________________________________
  35 + *
  36 + */
  37 +
  38 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  39 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  40 +require_once(KT_LIB_DIR . '/mime.inc.php');
  41 +
  42 +class IndexErrorsDispatcher extends KTAdminDispatcher {
  43 +
  44 + function check() {
  45 + $this->aBreadcrumbs[] = array(
  46 + 'url' => $_SERVER['PHP_SELF'],
  47 + 'name' => _kt('Document Indexing Diagnostics'),
  48 + );
  49 + return parent::check();
  50 + }
  51 +
  52 + function do_main() {
  53 +
  54 + //registerTypes registers the mime types and populates the needed tables.
  55 + $indexer = Indexer::get();
  56 + $indexer->registerTypes();
  57 +
  58 + if($_REQUEST['rescheduleValue'] == 'reschedule')
  59 + {
  60 +
  61 + foreach(KTUtil::arrayGet($_REQUEST, 'index_error', array()) as $sDocId => $v)
  62 + {
  63 + Indexer::reindexDocument($sDocId);
  64 +
  65 + }
  66 +
  67 + }
  68 + else if($_REQUEST['rescheduleValue'] == 'rescheduleall')
  69 + {
  70 + $aIndexerValues = Indexer::getIndexingQueue();
  71 + foreach ($aIndexerValues as $sDocValues)
  72 + {
  73 + Indexer::reindexDocument($sDocValues['document_id']);
  74 + }
  75 +
  76 + }
  77 + require_once(KT_LIB_DIR . "/templating/templating.inc.php");
  78 + $oTemplating =& KTTemplating::getSingleton();
  79 + $oTemplating->addLocation('Index Errors', '/plugins/search2/reporting/templates');
  80 +
  81 + $oTemplate =& $oTemplating->loadTemplate('indexerrors');
  82 +
  83 + $aIndexerValues = Indexer::getIndexingQueue();
  84 +
  85 + $oTemplate->setData(array(
  86 + 'context' => $this,
  87 + 'index_errors' => $aIndexerValues
  88 +
  89 + ));
  90 + return $oTemplate;
  91 + }
  92 +
  93 +
  94 +
  95 +}
  96 +
  97 +
  98 +?>
... ...
plugins/search2/reporting/ManageMimeTypes.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id:$
  4 + *
  5 + * KnowledgeTree Open Source Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
  8 + *
  9 + * This program is free software; you can redistribute it and/or modify it under
  10 + * the terms of the GNU General Public License version 3 as published by the
  11 + * Free Software Foundation.
  12 + *
  13 + * This program is distributed in the hope that it will be useful, but WITHOUT
  14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16 + * details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 + *
  21 + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
  22 + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
  23 + *
  24 + * The interactive user interfaces in modified source and object code versions
  25 + * of this program must display Appropriate Legal Notices, as required under
  26 + * Section 5 of the GNU General Public License version 3.
  27 + *
  28 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  29 + * these Appropriate Legal Notices must retain the display of the "Powered by
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
  34 + * Contributor( s): ______________________________________
  35 + *
  36 + */
  37 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  38 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  39 +require_once(KT_LIB_DIR . '/mime.inc.php');
  40 +
  41 +class ManageMimeTypesDispatcher extends KTAdminDispatcher {
  42 +
  43 + function check() {
  44 + $this->aBreadcrumbs[] = array(
  45 + 'url' => $_SERVER['PHP_SELF'],
  46 + 'name' => _kt('Manage Mime Types'),
  47 + );
  48 + return parent::check();
  49 + }
  50 +
  51 + function do_main() {
  52 +
  53 + //registerTypes registers the mime types and populates the needed tables.
  54 + $indexer = Indexer::get();
  55 + $indexer->registerTypes();
  56 +
  57 + $oTemplating =& KTTemplating::getSingleton();
  58 + $oTemplating->addLocation('Manage Mime Type Plugin', '/plugins/search2/reporting/templates');
  59 +
  60 + $oTemplate =& $oTemplating->loadTemplate('managemimetypes');
  61 +
  62 + $aMimeTypes = KTMime::getAllMimeTypesInformation();
  63 +
  64 + $indexer = Indexer::get();
  65 +
  66 + $numExtensions = 0;
  67 + $numIndexedExtensions = 0;
  68 +
  69 + foreach($aMimeTypes as $key=>$mimeType)
  70 + {
  71 + $extractorClass = $mimeType['extractor'];
  72 + $numExtensions++;
  73 + if (empty($extractorClass))
  74 + {
  75 + continue;
  76 + }
  77 + $extractor = $indexer->getExtractor($extractorClass);
  78 + $aMimeTypes[$key]['extractor'] = $extractor->getDisplayName();
  79 + $numIndexedExtensions++;
  80 + }
  81 +
  82 + $indexedPercentage = 0;
  83 + if ($numExtensions > 0)
  84 + {
  85 + $indexedPercentage = number_format(($numIndexedExtensions * 100)/$numExtensions,2,'.',',');
  86 + }
  87 +
  88 + $oTemplate->setData(array(
  89 + 'context' => $this,
  90 + 'mime_types' => $aMimeTypes,
  91 + 'numExtensions'=>$numExtensions,
  92 + 'numIndexedExtensions'=>$numIndexedExtensions,
  93 + 'indexedPercentage'=>$indexedPercentage
  94 +
  95 + ));
  96 + return $oTemplate;
  97 + }
  98 +}
0 99 \ No newline at end of file
... ...
plugins/search2/reporting/PendingDocuments.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id:$
  4 + *
  5 + * KnowledgeTree Open Source Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
  8 + *
  9 + * This program is free software; you can redistribute it and/or modify it under
  10 + * the terms of the GNU General Public License version 3 as published by the
  11 + * Free Software Foundation.
  12 + *
  13 + * This program is distributed in the hope that it will be useful, but WITHOUT
  14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16 + * details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 + *
  21 + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
  22 + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
  23 + *
  24 + * The interactive user interfaces in modified source and object code versions
  25 + * of this program must display Appropriate Legal Notices, as required under
  26 + * Section 5 of the GNU General Public License version 3.
  27 + *
  28 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  29 + * these Appropriate Legal Notices must retain the display of the "Powered by
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
  34 + * Contributor( s): ______________________________________
  35 + *
  36 + */
  37 +
  38 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  39 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  40 +
  41 +class PendingDocumentsDispatcher extends KTAdminDispatcher
  42 +{
  43 + function check() {
  44 + $this->aBreadcrumbs[] = array(
  45 + 'url' => $_SERVER['PHP_SELF'],
  46 + 'name' => _kt('Pending Documents Indexing Queue'),
  47 + );
  48 + return parent::check();
  49 + }
  50 +
  51 + function do_main() {
  52 +
  53 + //registerTypes registers the mime types and populates the needed tables.
  54 + $indexer = Indexer::get();
  55 + $indexer->registerTypes();
  56 +
  57 + $aPendingDocs = Indexer::getPendingIndexingQueue();
  58 +
  59 + $oTemplating =& KTTemplating::getSingleton();
  60 + $oTemplating->addLocation('Pending Documents', '/plugins/search2/reporting/templates');
  61 + $oTemplate =& $oTemplating->loadTemplate('pendingdocuments');
  62 +
  63 + $oTemplate->setData(array(
  64 + 'context' => $this,
  65 + 'pending_docs' => $aPendingDocs
  66 +
  67 + ));
  68 + return $oTemplate;
  69 + }
  70 +
  71 +}
  72 +
  73 +
  74 +?>
... ...
plugins/search2/reporting/RescheduleDocuments.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id:$
  4 + *
  5 + * KnowledgeTree Open Source Edition
  6 + * Document Management Made Simple
  7 + * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
  8 + *
  9 + * This program is free software; you can redistribute it and/or modify it under
  10 + * the terms of the GNU General Public License version 3 as published by the
  11 + * Free Software Foundation.
  12 + *
  13 + * This program is distributed in the hope that it will be useful, but WITHOUT
  14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16 + * details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 + *
  21 + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
  22 + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
  23 + *
  24 + * The interactive user interfaces in modified source and object code versions
  25 + * of this program must display Appropriate Legal Notices, as required under
  26 + * Section 5 of the GNU General Public License version 3.
  27 + *
  28 + * In accordance with Section 7(b) of the GNU General Public License version 3,
  29 + * these Appropriate Legal Notices must retain the display of the "Powered by
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
  34 + * Contributor( s): ______________________________________
  35 + *
  36 + */
  37 +
  38 +require_once(KT_LIB_DIR . '/dispatcher.inc.php');
  39 +require_once(KT_LIB_DIR . '/templating/templating.inc.php');
  40 +
  41 +class RescheduleDocumentsDispatcher extends KTAdminDispatcher
  42 +{
  43 + function check() {
  44 + $this->aBreadcrumbs[] = array(
  45 + 'url' => $_SERVER['PHP_SELF'],
  46 + 'name' => _kt('Reschedule all documents'),
  47 + );
  48 + return parent::check();
  49 + }
  50 +
  51 + function do_main() {
  52 +
  53 + //registerTypes registers the mime types and populates the needed tables.
  54 + $indexer = Indexer::get();
  55 + $indexer->registerTypes();
  56 +
  57 + $oTemplating =& KTTemplating::getSingleton();
  58 + $oTemplating->addLocation('Reschedule Documents', '/plugins/search2/reporting/templates');
  59 +
  60 +
  61 + $oTemplate =& $oTemplating->loadTemplate('rescheduledocuments');
  62 +
  63 + if ($_REQUEST['rescheduleValue'] == 'reschedule')
  64 + {
  65 + Indexer::indexAll();
  66 + $oTemplate->setData(array(
  67 + 'context' => $this,
  68 + 'rescheduleDone' => true
  69 + ));
  70 + return $oTemplate;
  71 + }
  72 +
  73 + $oTemplate->setData(array(
  74 + 'context' => $this,
  75 + 'rescheduleDone' => false
  76 +
  77 + ));
  78 + return $oTemplate;
  79 + }
  80 +}
  81 +
  82 +?>
... ...
plugins/search2/reporting/templates/extractorinfo.smarty 0 → 100644
  1 +<h2>{i18n}Extractor Information{/i18n}</h2>
  2 +<p class="descriptiveText">{i18n}Important information about the current document extractors{/i18n}</p>
  3 +
  4 +{if $extractor_info}
  5 +
  6 +{foreach key=key from=$extractor_info item=extractor}
  7 +<br>
  8 +<dl class='panel_menu'><h3>{$extractor.name}{if $extractor.active == 1} ({i18n}Active{/i18n}){else} ({i18n}Inactive{/i18n}){/if}</h3><dl/>
  9 +
  10 +<table class=kt_collection>
  11 +
  12 +<thead>
  13 +<tr>
  14 +<th width="300">{i18n}Description{/i18n}</th>
  15 +<th width="400">{i18n}Mime Types{/i18n}</th>
  16 +<th>{i18n}Extensions{/i18n}</th>
  17 +</tr>
  18 +</thead>
  19 +
  20 +<tbody>
  21 +
  22 +{foreach from=$extractor.mimeTypes key=key item=mimeType}
  23 +<tr>
  24 + <td>{$mimeType.description}</td>
  25 + <td>{$key}</td>
  26 + <td>{$extractor.mimeTypes.$key.extensions}</td>
  27 +</tr>
  28 +{/foreach}
  29 +
  30 +</tbody>
  31 +
  32 +</table>
  33 +
  34 +{/foreach}
  35 +
  36 +{else}
  37 +<br>
  38 +<h3>{i18n}There are no extractors registered.{/i18n}</h3>
  39 +{/if}
... ...
plugins/search2/reporting/templates/indexerrors.smarty 0 → 100644
  1 +{literal}
  2 +<script type="text/javascript">
  3 + function doReschedule(rescheduleAction)
  4 + {
  5 + var hiddenVal = document.getElementById("rescheduleValue");
  6 + hiddenVal.value = rescheduleAction;
  7 + document.scheduleForm.submit();
  8 + }
  9 +
  10 +</script>
  11 +{/literal}
  12 +
  13 +<h2>{i18n}Document Indexing Diagnostics{/i18n}</h2>
  14 +<p class="descriptiveText">{i18n}This report will help to diagnose problems with document indexing.{/i18n}</p>
  15 +
  16 +<br>
  17 +{if $index_errors}
  18 +
  19 +<form name="scheduleForm" action="{$smarty.server.PHP_SELF}" method="POST">
  20 +<input type="hidden" name="rescheduleValue" id="rescheduleValue" value="" />
  21 +
  22 +<table class=kt_collection>
  23 +<thead>
  24 + <tr>
  25 + <th width="10"></th>
  26 + <th width="80"><nobr>{i18n}Document ID{/i18n}</th>
  27 + <th ><nobr>{i18n}Filename{/i18n}</th>
  28 + <th width="100"><nobr>{i18n}Extension{/i18n}</th>
  29 + <th width="100"><nobr>{i18n}Mime Type{/i18n}</th>
  30 + <th width="100"><nobr>{i18n}Extractor{/i18n}</th>
  31 + <th width="100"><nobr>{i18n}Index Date{/i18n}</th>
  32 + </tr>
  33 +</thead>
  34 +
  35 +<tbody>
  36 +{foreach key=key from=$index_errors item=indexError}
  37 +<tr>
  38 + <td class="centered"><input type="checkbox" name="index_error[{$indexError.document_id}]" value="1"/></td>
  39 + <td>{$indexError.document_id}</td>
  40 + <td>{$indexError.filename|truncate:40:'...'}</td>
  41 + <td>{$indexError.filetypes}</td>
  42 + <td>{$indexError.mimetypes}</td>
  43 + <td>{if $pendingDocs.extractor}{$indexError.extractor}{else}<p><font color="#FF9933">{i18n}n/a{/i18n}</font></p>{/if}</td>
  44 + <td>{$indexError.indexdate}</td>
  45 +
  46 +</tr>
  47 +<tr>
  48 + <td>&nbsp;</td>
  49 + <td colspan=4><pre>{$indexError.status_msg}</pre></td>
  50 +</tr>
  51 +
  52 +
  53 +{/foreach}
  54 +
  55 +</tbody>
  56 +
  57 +</table>
  58 +
  59 +<br>
  60 +<input type="button" name="Reschedule" value="{i18n}Reschedule{/i18n}" onclick="doReschedule('reschedule');"/>
  61 +<input type="button" name="Reschedule All" value="{i18n}Reschedule All{/i18n}" onclick="doReschedule('rescheduleall');"/>
  62 +{else}
  63 +<h3>{i18n}There are no indexing issues.{/i18n}</h3>
  64 +{/if}
  65 +</form>
0 66 \ No newline at end of file
... ...
plugins/search2/reporting/templates/managemimetypes.smarty 0 → 100644
  1 +<h2>{i18n}Manage Mime Types{/i18n}</h2>
  2 +<p class="descriptiveText">{i18n}Mime type information{/i18n}</p>
  3 +
  4 +
  5 +{if $mime_types}
  6 +
  7 +<table class=kt_collection>
  8 +
  9 +<thead>
  10 +<tr>
  11 +<th>Icon </th>
  12 +<th> Extension </th>
  13 +<th> Mime Type </th>
  14 +<th> Description </th>
  15 +<th> Extractor </th>
  16 +</tr>
  17 +</thead>
  18 +
  19 +<tbody>
  20 +{foreach from=$mime_types item=mimetype}
  21 +<tr>
  22 +<td><span class="contenttype {$mimetype.icon_path}"></span></td>
  23 +<td>{$mimetype.filetypes}</td>
  24 +<td>{$mimetype.mimetypes}</td>
  25 +<td>{if $mimetype.friendly_name}
  26 +{$mimetype.friendly_name}
  27 +{else}
  28 +<p><font color="#FF9933">no description</font></p>
  29 +{/if}</td>
  30 +<td>{if $mimetype.extractor}
  31 +{$mimetype.extractor}
  32 +{else}
  33 +<p><font color="#FF9933">n/a</font></p>
  34 +{/if}</td>
  35 +</tr>
  36 +{/foreach}
  37 +</tbody>
  38 +
  39 +</table>
  40 +
  41 +<table>
  42 +<tr><td>Number of Extensions<td>{$numExtensions}
  43 +<tr><td>Number of indexed extensions<td>{$numIndexedExtensions} ( {$indexedPercentage}% )
  44 +</table>
  45 +
  46 +
  47 +{/if}
  48 +
... ...
plugins/search2/reporting/templates/pendingdocuments.smarty 0 → 100644
  1 +<h2>{i18n}Pending Documents Indexing Queue{/i18n}</h2>
  2 +{i18n}This report lists documents that are waiting to be indexed.
  3 +<br><br>
  4 +If a document is not associated with an extractor, no content will be added to the index. These documents can be identified in the list by the extractor column reflecting n/a.{/i18n}
  5 +<br><br>
  6 +
  7 +{if empty($pending_docs)}
  8 +
  9 +<b>{i18n}There are no documents in the indexing queue.{/i18n}</b>
  10 +
  11 +{else}
  12 +
  13 +
  14 +<table class=kt_collection>
  15 +
  16 +<thead>
  17 +<tr>
  18 + <th width="10"><nobr>{i18n}Document ID{/i18n}</th>
  19 + <th><nobr>{i18n}Filename{/i18n}</th>
  20 + <th width="100"><nobr>{i18n}Extension{/i18n}</th>
  21 + <th width="150"><nobr>{i18n}Mime Type{/i18n}</th>
  22 + <th width="100"><nobr>{i18n}Extractor{/i18n}</th>
  23 + <th width="100"><nobr>{i18n}Index Date{/i18n}</th>
  24 +</tr>
  25 +</thead>
  26 +
  27 +<tbody>
  28 +
  29 +{foreach key=key from=$pending_docs item=pendingDocs}
  30 +<tr>
  31 + <td><a href="/view.php?fDocumentId={$pendingDocs.document_id}">{$pendingDocs.document_id}</a></td>
  32 + <td>{$pendingDocs.filename|truncate:40:'...'}</td>
  33 + <td>{$pendingDocs.filetypes}</td>
  34 + <td>{$pendingDocs.mimetypes}</td>
  35 + <td>{if $pendingDocs.extractor}{$pendingDocs.extractor}{else}<p><font color="#FF9933">{i18n}n/a{/i18n}</font></p>{/if}</td>
  36 + <td>{$pendingDocs.indexdate}</td>
  37 +</tr>
  38 +{/foreach}
  39 +
  40 +</tbody>
  41 +
  42 +</table>
  43 +
  44 +{/if}
0 45 \ No newline at end of file
... ...
plugins/search2/reporting/templates/rescheduledocuments.smarty 0 → 100644
  1 +<h2>{i18n}Reschedule All Documents{/i18n}</h2>
  2 +<p class="descriptiveText">{i18n}Reschedule all documents for indexing{/i18n}</p>
  3 +<p class="descriptiveText">{i18n}Please note that rescheduling all documents may take a long time, depending on the size if the repository{/i18n}</h3>
  4 +
  5 +<form name="rescheduleAllDocs" action="{$smarty.server.PHP_SELF}" method="POST">
  6 +<br>
  7 +{if $rescheduleDone == true}
  8 +<p>Documents Rescheduled</p>
  9 +<p>You can view the schedule queue <a href=admin.php?kt_path_info=search/pendingdocuments>here</a></p>
  10 +<br>
  11 +{/if}
  12 +<input type="submit" name="Reschedule" value="{i18n}Reschedule All{/i18n}" />
  13 +<input type="hidden" name="rescheduleValue" id="rescheduleValue" value="reschedule" />
  14 +
  15 +</form>
0 16 \ No newline at end of file
... ...
search2/indexing/indexerCore.inc.php
... ... @@ -36,6 +36,7 @@
36 36 *
37 37 */
38 38  
  39 +define('SEARCH2_INDEXER_DIR',realpath(dirname(__FILE__)) . '/');
39 40 require_once('indexing/extractorCore.inc.php');
40 41 require_once(KT_DIR . '/plugins/ktcore/scheduler/schedulerUtil.php');
41 42  
... ... @@ -492,6 +493,19 @@ abstract class Indexer
492 493 $default->log->debug("index: Queuing indexing of $document_id");
493 494 }
494 495  
  496 + public static function reindexQueue()
  497 + {
  498 + $sql = "UPDATE index_files SET processdate = null";
  499 + DBUtil::runQuery($sql);
  500 + }
  501 +
  502 + public static function reindexDocument($documentId)
  503 + {
  504 + $sql = "UPDATE index_files SET processdate=null, status_msg=null WHERE document_id=$documentId";
  505 + DBUtil::runQuery($sql);
  506 + }
  507 +
  508 +
495 509  
496 510 public static function indexAll()
497 511 {
... ... @@ -741,6 +755,73 @@ abstract class Indexer
741 755 KTUtil::setSystemSetting('mimeTypesRegistered', true);
742 756 }
743 757  
  758 + public function getExtractor($extractorClass)
  759 + {
  760 + $includeFile = SEARCH2_INDEXER_DIR . 'extractors/' . $extractorClass . '.inc.php';
  761 + if (!file_exists($includeFile))
  762 + {
  763 + throw new Exception("Extractor file does not exist: $includeFile");
  764 + }
  765 +
  766 + require_once($includeFile);
  767 +
  768 + if (!class_exists($extractorClass))
  769 + {
  770 + throw new Exception("Extractor '$classname' not defined in file: $includeFile");
  771 + }
  772 +
  773 + $extractor = new $extractorClass();
  774 +
  775 + if (!($extractor instanceof DocumentExtractor))
  776 + {
  777 + throw new Exception("Class $classname was expected to be of type DocumentExtractor");
  778 + }
  779 +
  780 + return $extractor;
  781 + }
  782 +
  783 + public static function getIndexingQueue($problemItemsOnly=true)
  784 + {
  785 +
  786 + if ($problemItemsOnly)
  787 + {
  788 + $sql = "SELECT
  789 + iff.document_id, iff.indexdate, mt.filetypes, mt.mimetypes, me.name as extractor, iff.what, iff.status_msg, dcv.filename
  790 + FROM
  791 + index_files iff
  792 + INNER JOIN documents d ON iff.document_id=d.id
  793 + INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id
  794 + INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id
  795 + INNER JOIN mime_types mt ON dcv.mime_id=mt.id
  796 + LEFT JOIN mime_extractors me ON mt.extractor_id=me.id
  797 + WHERE
  798 + (iff.status_msg IS NOT NULL) AND dmv.status_id=1
  799 + ORDER BY indexdate ";
  800 + }
  801 + else
  802 + {
  803 + $sql = "SELECT
  804 + iff.document_id, iff.indexdate, mt.filetypes, mt.mimetypes, me.name as extractor, iff.what, iff.status_msg, dcv.filename
  805 + FROM
  806 + index_files iff
  807 + INNER JOIN documents d ON iff.document_id=d.id
  808 + INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id
  809 + INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id
  810 + INNER JOIN mime_types mt ON dcv.mime_id=mt.id
  811 + LEFT JOIN mime_extractors me ON mt.extractor_id=me.id
  812 + WHERE
  813 + (iff.status_msg IS NULL or iff.status_msg = '') AND dmv.status_id=1
  814 + ORDER BY indexdate ";
  815 + }
  816 + $aResult = DBUtil::getResultArray($sql);
  817 +
  818 + return $aResult;
  819 + }
  820 +
  821 + public static function getPendingIndexingQueue()
  822 + {
  823 + return Indexer::getIndexingQueue(false);
  824 + }
744 825  
745 826 /**
746 827 * The main function that may be called repeatedly to index documents.
... ...