diff --git a/plugins/search2/reporting/IndexErrors.php b/plugins/search2/reporting/IndexErrors.php index 0ccca13..5171bdf 100644 --- a/plugins/search2/reporting/IndexErrors.php +++ b/plugins/search2/reporting/IndexErrors.php @@ -5,7 +5,7 @@ * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008, 2009 KnowledgeTree Inc. - * + * * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the @@ -54,6 +54,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { //Number of items on a page $itemsPerPage = 50; + $pageNum = 1; + + if(isset($_REQUEST['itemsPerPage'])){ + $itemsPerPage = $_REQUEST['itemsPerPage']; + } //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); @@ -128,6 +133,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { if(isset($_REQUEST['pageValue'])) { $pageNum = (int)$_REQUEST['pageValue']; + + if($pageNum > $pages){ + $pageNum = $pages; + } + $start = (($pageNum-1)*$itemsPerPage)-1; $limit = $start+$itemsPerPage; for($i = $start; $i <= $limit; $i++){ @@ -145,13 +155,18 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { } } + $config = KTConfig::getSingleton(); + $rootUrl = $config->get('KnowledgeTree/rootUrl'); + $oTemplate->setData(array( 'context' => $this, 'pageList' => $aPages, 'pageCount' => $pages, + 'pageNum' => $pageNum, 'itemCount' => $items, 'itemsPerPage' => $itemsPerPage, - 'indexErrors' => $aIndexList + 'indexErrors' => $aIndexList, + 'root_url' => $rootUrl )); return $oTemplate; diff --git a/plugins/search2/reporting/PendingDocuments.php b/plugins/search2/reporting/PendingDocuments.php index 8198b5e..386bb40 100644 --- a/plugins/search2/reporting/PendingDocuments.php +++ b/plugins/search2/reporting/PendingDocuments.php @@ -5,7 +5,7 @@ * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008, 2009 KnowledgeTree Inc. - * + * * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the @@ -51,6 +51,14 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher function do_main() { + //Number of items on a page + $itemsPerPage = 50; + $pageNum = 1; + + if(isset($_REQUEST['itemsPerPage'])){ + $itemsPerPage = $_REQUEST['itemsPerPage']; + } + //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); @@ -68,6 +76,51 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher $aPendingDocs[$key] = $doc; } + $aPendingList = array(); + + //creating page variables and loading the items for the current page + if(!empty($aPendingDocs)){ + $items = count($aPendingDocs); + + if(fmod($items, $itemsPerPage) > 0){ + $pages = floor($items/$itemsPerPage)+1; + }else{ + $pages = ($items/$itemsPerPage); + } + for($i=1; $i<=$pages; $i++){ + $aPages[] = $i; + } + if($items < $itemsPerPage){ + $limit = $items-1; + }else{ + $limit = $itemsPerPage-1; + } + + if(isset($_REQUEST['pageValue'])) + { + $pageNum = (int)$_REQUEST['pageValue']; + + if($pageNum > $pages){ + $pageNum = $pages; + } + + $start = (($pageNum-1)*$itemsPerPage)-1; + $limit = $start+$itemsPerPage; + for($i = $start; $i <= $limit; $i++){ + if(isset($aPendingDocs[$i])) + { + $aPendingList[] = $aPendingDocs[$i]; + } + } + } + else + { + for($i = 0; $i <= $limit; $i++){ + $aPendingList[] = $aPendingDocs[$i]; + } + } + } + $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments'); @@ -76,7 +129,12 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher $oTemplate->setData(array( 'context' => $this, - 'pending_docs' => $aPendingDocs, + 'pageList' => $aPages, + 'pageCount' => $pages, + 'pageNum' => $pageNum, + 'itemCount' => $items, + 'itemsPerPage' => $itemsPerPage, + 'pending_docs' => $aPendingList, 'root_url' => $rootUrl )); return $oTemplate; diff --git a/templates/ktcore/search2/reporting/indexerrors.smarty b/templates/ktcore/search2/reporting/indexerrors.smarty index 5cd2280..f479102 100644 --- a/templates/ktcore/search2/reporting/indexerrors.smarty +++ b/templates/ktcore/search2/reporting/indexerrors.smarty @@ -40,7 +40,7 @@ {foreach key=key from=$indexErrors item=indexError}
{i18n}n/a{/i18n}
{/if}{i18n}This report lists documents that are waiting to be indexed.{/i18n}
+