Commit ee390a84266376aa85fdea16a773ca31f454e268

Authored by Megan Watson
1 parent c635afc3

Fixed paging on pending documents list and error list

PT: 1799020

Committed by: Megan Watson
plugins/search2/reporting/IndexErrors.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -54,6 +54,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { @@ -54,6 +54,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher {
54 54
55 //Number of items on a page 55 //Number of items on a page
56 $itemsPerPage = 50; 56 $itemsPerPage = 50;
  57 + $pageNum = 1;
  58 +
  59 + if(isset($_REQUEST['itemsPerPage'])){
  60 + $itemsPerPage = $_REQUEST['itemsPerPage'];
  61 + }
57 62
58 //registerTypes registers the mime types and populates the needed tables. 63 //registerTypes registers the mime types and populates the needed tables.
59 $indexer = Indexer::get(); 64 $indexer = Indexer::get();
@@ -128,6 +133,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { @@ -128,6 +133,11 @@ class IndexErrorsDispatcher extends KTAdminDispatcher {
128 if(isset($_REQUEST['pageValue'])) 133 if(isset($_REQUEST['pageValue']))
129 { 134 {
130 $pageNum = (int)$_REQUEST['pageValue']; 135 $pageNum = (int)$_REQUEST['pageValue'];
  136 +
  137 + if($pageNum > $pages){
  138 + $pageNum = $pages;
  139 + }
  140 +
131 $start = (($pageNum-1)*$itemsPerPage)-1; 141 $start = (($pageNum-1)*$itemsPerPage)-1;
132 $limit = $start+$itemsPerPage; 142 $limit = $start+$itemsPerPage;
133 for($i = $start; $i <= $limit; $i++){ 143 for($i = $start; $i <= $limit; $i++){
@@ -145,13 +155,18 @@ class IndexErrorsDispatcher extends KTAdminDispatcher { @@ -145,13 +155,18 @@ class IndexErrorsDispatcher extends KTAdminDispatcher {
145 } 155 }
146 } 156 }
147 157
  158 + $config = KTConfig::getSingleton();
  159 + $rootUrl = $config->get('KnowledgeTree/rootUrl');
  160 +
148 $oTemplate->setData(array( 161 $oTemplate->setData(array(
149 'context' => $this, 162 'context' => $this,
150 'pageList' => $aPages, 163 'pageList' => $aPages,
151 'pageCount' => $pages, 164 'pageCount' => $pages,
  165 + 'pageNum' => $pageNum,
152 'itemCount' => $items, 166 'itemCount' => $items,
153 'itemsPerPage' => $itemsPerPage, 167 'itemsPerPage' => $itemsPerPage,
154 - 'indexErrors' => $aIndexList 168 + 'indexErrors' => $aIndexList,
  169 + 'root_url' => $rootUrl
155 170
156 )); 171 ));
157 return $oTemplate; 172 return $oTemplate;
plugins/search2/reporting/PendingDocuments.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
@@ -51,6 +51,14 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher @@ -51,6 +51,14 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher
51 51
52 function do_main() { 52 function do_main() {
53 53
  54 + //Number of items on a page
  55 + $itemsPerPage = 50;
  56 + $pageNum = 1;
  57 +
  58 + if(isset($_REQUEST['itemsPerPage'])){
  59 + $itemsPerPage = $_REQUEST['itemsPerPage'];
  60 + }
  61 +
54 //registerTypes registers the mime types and populates the needed tables. 62 //registerTypes registers the mime types and populates the needed tables.
55 $indexer = Indexer::get(); 63 $indexer = Indexer::get();
56 $indexer->registerTypes(); 64 $indexer->registerTypes();
@@ -68,6 +76,51 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher @@ -68,6 +76,51 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher
68 $aPendingDocs[$key] = $doc; 76 $aPendingDocs[$key] = $doc;
69 } 77 }
70 78
  79 + $aPendingList = array();
  80 +
  81 + //creating page variables and loading the items for the current page
  82 + if(!empty($aPendingDocs)){
  83 + $items = count($aPendingDocs);
  84 +
  85 + if(fmod($items, $itemsPerPage) > 0){
  86 + $pages = floor($items/$itemsPerPage)+1;
  87 + }else{
  88 + $pages = ($items/$itemsPerPage);
  89 + }
  90 + for($i=1; $i<=$pages; $i++){
  91 + $aPages[] = $i;
  92 + }
  93 + if($items < $itemsPerPage){
  94 + $limit = $items-1;
  95 + }else{
  96 + $limit = $itemsPerPage-1;
  97 + }
  98 +
  99 + if(isset($_REQUEST['pageValue']))
  100 + {
  101 + $pageNum = (int)$_REQUEST['pageValue'];
  102 +
  103 + if($pageNum > $pages){
  104 + $pageNum = $pages;
  105 + }
  106 +
  107 + $start = (($pageNum-1)*$itemsPerPage)-1;
  108 + $limit = $start+$itemsPerPage;
  109 + for($i = $start; $i <= $limit; $i++){
  110 + if(isset($aPendingDocs[$i]))
  111 + {
  112 + $aPendingList[] = $aPendingDocs[$i];
  113 + }
  114 + }
  115 + }
  116 + else
  117 + {
  118 + for($i = 0; $i <= $limit; $i++){
  119 + $aPendingList[] = $aPendingDocs[$i];
  120 + }
  121 + }
  122 + }
  123 +
71 $oTemplating =& KTTemplating::getSingleton(); 124 $oTemplating =& KTTemplating::getSingleton();
72 $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments'); 125 $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments');
73 126
@@ -76,7 +129,12 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher @@ -76,7 +129,12 @@ class PendingDocumentsDispatcher extends KTAdminDispatcher
76 129
77 $oTemplate->setData(array( 130 $oTemplate->setData(array(
78 'context' => $this, 131 'context' => $this,
79 - 'pending_docs' => $aPendingDocs, 132 + 'pageList' => $aPages,
  133 + 'pageCount' => $pages,
  134 + 'pageNum' => $pageNum,
  135 + 'itemCount' => $items,
  136 + 'itemsPerPage' => $itemsPerPage,
  137 + 'pending_docs' => $aPendingList,
80 'root_url' => $rootUrl 138 'root_url' => $rootUrl
81 )); 139 ));
82 return $oTemplate; 140 return $oTemplate;
templates/ktcore/search2/reporting/indexerrors.smarty
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 {foreach key=key from=$indexErrors item=indexError} 40 {foreach key=key from=$indexErrors item=indexError}
41 <tr> 41 <tr>
42 <td class="centered"><input type="checkbox" name="index_error[{$indexError.document_id}]" value="1"/></td> 42 <td class="centered"><input type="checkbox" name="index_error[{$indexError.document_id}]" value="1"/></td>
43 - <td><a href="/view.php?fDocumentId={$indexError.document_id}">{$indexError.filename|truncate:40:'...'}</a></td> 43 + <td><a href="{$root_url}/view.php?fDocumentId={$indexError.document_id}">{$indexError.filename|truncate:40:'...'}</a></td>
44 <td>{if $indexError.extractor}{$indexError.extractor}{else}<p><font color="#FF9933">{i18n}n/a{/i18n}</font></p>{/if}</td> 44 <td>{if $indexError.extractor}{$indexError.extractor}{else}<p><font color="#FF9933">{i18n}n/a{/i18n}</font></p>{/if}</td>
45 <td>{$indexError.indexdate}</td> 45 <td>{$indexError.indexdate}</td>
46 46
@@ -57,18 +57,31 @@ @@ -57,18 +57,31 @@
57 <tfoot> 57 <tfoot>
58 <tr> 58 <tr>
59 <td colspan="4"> 59 <td colspan="4">
60 -<div align="center">  
61 -{foreach item=page from=$pageList}  
62 -<a id="pageButton{$page}" href="#" onclick="nextSearchPage({$page});">{$page}</a>  
63 -{/foreach}  
64 -</div>  
65 -</td>  
66 -</tr>  
67 -<tr>  
68 -<td colspan="4">  
69 -<div> {$itemCount} items, {$itemsPerPage} items per page.</div> 60 + <div align="center">
  61 + {foreach item=page from=$pageList}
  62 + {if $pageNum == $page}
  63 + {$page}&nbsp;
  64 + {else}
  65 + <a id="pageButton{$page}" href="#" onclick="nextSearchPage({$page});">{$page}</a>&nbsp;
  66 + {/if}
  67 + {/foreach}
  68 + </div>
70 </td> 69 </td>
71 </tr> 70 </tr>
  71 + <tr>
  72 + <td colspan="2">
  73 + <div> {$itemCount} {i18n}items{/i18n}, {$itemsPerPage} {i18n}items per page{/i18n}.</div>
  74 + </td>
  75 + <td align="right">
  76 + <select name="itemsPerPage">
  77 + <option value='10' {if $itemsPerPage == 10}selected='true'{/if} onclick="nextSearchPage({$pageNum});" >10</option>
  78 + <option value='20' {if $itemsPerPage == 20}selected='true'{/if} onclick="nextSearchPage({$pageNum});">20</option>
  79 + <option value='50' {if $itemsPerPage == 50}selected='true'{/if} onclick="nextSearchPage({$pageNum});">50</option>
  80 + <option value='100' {if $itemsPerPage == 100}selected='true'{/if} onclick="nextSearchPage({$pageNum});">100</option>
  81 + </select>
  82 + {i18n}items per page{/i18n}
  83 + </td>
  84 + </tr>
72 </tfoot> 85 </tfoot>
73 </table> 86 </table>
74 87
templates/ktcore/search2/reporting/pendingdocuments.smarty
  1 +{literal}
  2 +<script type="text/javascript">
  3 + function nextSearchPage(value)
  4 + {
  5 + var hiddenPageVal = document.getElementById("pageValue");
  6 + hiddenPageVal.value = value;
  7 + document.pendingQueueForm.submit();
  8 + }
  9 +</script>
  10 +{/literal}
1 <h2>{i18n}Pending Documents Indexing Queue{/i18n}</h2> 11 <h2>{i18n}Pending Documents Indexing Queue{/i18n}</h2>
2 -{i18n}This report lists documents that are waiting to be indexed.{/i18n}  
3 -<br><br> 12 +<p class="descriptiveText">{i18n}This report lists documents that are waiting to be indexed.{/i18n}</p>
  13 +<br>
4 {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} 14 {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}
5 <br><br> 15 <br><br>
6 16
@@ -11,6 +21,9 @@ @@ -11,6 +21,9 @@
11 {else} 21 {else}
12 22
13 23
  24 +<form name="pendingQueueForm" action="{$smarty.server.PHP_SELF}" method="POST">
  25 +<input type="hidden" name="pageValue" id="pageValue" value="" />
  26 +
14 <table class=kt_collection> 27 <table class=kt_collection>
15 28
16 <thead> 29 <thead>
@@ -33,6 +46,40 @@ @@ -33,6 +46,40 @@
33 46
34 </tbody> 47 </tbody>
35 48
  49 +<tfoot>
  50 + <tr>
  51 + <td colspan="3">
  52 + <div align="center">
  53 + {foreach item=page from=$pageList}
  54 + {if $pageNum == $page}
  55 + {$page}&nbsp;
  56 + {else}
  57 + <a id="pageButton{$page}" href="#" onclick="nextSearchPage({$page});">{$page}</a>&nbsp;
  58 + {/if}
  59 + {/foreach}
  60 + </div>
  61 + </td>
  62 + </tr>
  63 + <tr>
  64 + <td colspan="2">
  65 + <div> {$itemCount} {i18n}items{/i18n},
  66 + {$itemsPerPage} {i18n}items per page{/i18n}.
  67 + </div>
  68 + </td>
  69 + <td align="right">
  70 + <select name="itemsPerPage">
  71 + <option value='10' {if $itemsPerPage == 10}selected='true'{/if} onclick="nextSearchPage({$pageNum});" >10</option>
  72 + <option value='20' {if $itemsPerPage == 20}selected='true'{/if} onclick="nextSearchPage({$pageNum});">20</option>
  73 + <option value='50' {if $itemsPerPage == 50}selected='true'{/if} onclick="nextSearchPage({$pageNum});">50</option>
  74 + <option value='100' {if $itemsPerPage == 100}selected='true'{/if} onclick="nextSearchPage({$pageNum});">100</option>
  75 + </select>
  76 + {i18n}items per page{/i18n}
  77 + </td>
  78 + </tr>
  79 +</tfoot>
  80 +
36 </table> 81 </table>
37 82
  83 +</form>
  84 +
38 {/if} 85 {/if}