From ee390a84266376aa85fdea16a773ca31f454e268 Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Thu, 26 Nov 2009 16:11:02 +0200 Subject: [PATCH] Fixed paging on pending documents list and error list PT: 1799020 --- plugins/search2/reporting/IndexErrors.php | 19 +++++++++++++++++-- plugins/search2/reporting/PendingDocuments.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- templates/ktcore/search2/reporting/indexerrors.smarty | 35 ++++++++++++++++++++++++----------- templates/ktcore/search2/reporting/pendingdocuments.smarty | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 150 insertions(+), 17 deletions(-) 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} - {$indexError.filename|truncate:40:'...'} + {$indexError.filename|truncate:40:'...'} {if $indexError.extractor}{$indexError.extractor}{else}

{i18n}n/a{/i18n}

{/if} {$indexError.indexdate} @@ -57,18 +57,31 @@ -
-{foreach item=page from=$pageList} -{$page} -{/foreach} -
- - - - -
{$itemCount} items, {$itemsPerPage} items per page.
+
+ {foreach item=page from=$pageList} + {if $pageNum == $page} + {$page}  + {else} + {$page}  + {/if} + {/foreach} +
+ + +
{$itemCount} {i18n}items{/i18n}, {$itemsPerPage} {i18n}items per page{/i18n}.
+ + + + {i18n}items per page{/i18n} + + diff --git a/templates/ktcore/search2/reporting/pendingdocuments.smarty b/templates/ktcore/search2/reporting/pendingdocuments.smarty index 3cc8a52..ae6b6f3 100644 --- a/templates/ktcore/search2/reporting/pendingdocuments.smarty +++ b/templates/ktcore/search2/reporting/pendingdocuments.smarty @@ -1,6 +1,16 @@ +{literal} + +{/literal}

{i18n}Pending Documents Indexing Queue{/i18n}

-{i18n}This report lists documents that are waiting to be indexed.{/i18n} -

+

{i18n}This report lists documents that are waiting to be indexed.{/i18n}

+
{i18n}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}

@@ -11,6 +21,9 @@ {else} +
+ + @@ -33,6 +46,40 @@ + + + + + + + + + +
+
+ {foreach item=page from=$pageList} + {if $pageNum == $page} + {$page}  + {else} + {$page}  + {/if} + {/foreach} +
+
+
{$itemCount} {i18n}items{/i18n}, + {$itemsPerPage} {i18n}items per page{/i18n}. +
+
+ + {i18n}items per page{/i18n} +
+
+ {/if} -- libgit2 0.21.4