Commit 83646f1e2cbbd97ed32cdcd9d7d9f7d89d0256b1

Authored by Megan
1 parent 8b99c1c5

SUP-1555 Added a dropdown to select if documents or folders are displayed first …

…in the search results.

Committed by: Megan Watson
Reviewed by: Kevin Cyster
search2.php
@@ -467,10 +467,39 @@ class SearchDispatcher extends KTStandardDispatcher { @@ -467,10 +467,39 @@ class SearchDispatcher extends KTStandardDispatcher {
467 467
468 // NOTE: sorting results (when it is implemented) might have to be done per section, as it is done with the browse view 468 // NOTE: sorting results (when it is implemented) might have to be done per section, as it is done with the browse view
469 469
470 - $resultArray = $results['docs'];  
471 - foreach($results['folders'] as $f) $resultArray[] = $f;  
472 - foreach($results['shortdocs'] as $d) $resultArray[] = $d;  
473 - foreach($results['shortfolders'] as $f) $resultArray[] = $f; 470 + // Get the order of display - folders first / documents first
  471 +
  472 + // Get the display order of the results - documents / folders first
  473 + $_SESSION['display_order'] = isset($_POST['display_order']) ? $_POST['display_order'] : $_SESSION['display_order'];
  474 +
  475 + $display_order = $_SESSION['display_order'];
  476 + $selected_order = array('f' => '', 'd' => '', 's' => '');
  477 +
  478 + switch ($display_order){
  479 + case 's':
  480 + $selected_order['s'] = 'selected';
  481 + $resultArray = $results['shortfolders'];
  482 + foreach($results['shortdocs'] as $f) $resultArray[] = $f;
  483 + foreach($results['folders'] as $d) $resultArray[] = $d;
  484 + foreach($results['docs'] as $f) $resultArray[] = $f;
  485 + break;
  486 +
  487 + case 'd':
  488 + $selected_order['d'] = 'selected';
  489 + $resultArray = $results['docs'];
  490 + foreach($results['folders'] as $f) $resultArray[] = $f;
  491 + foreach($results['shortdocs'] as $d) $resultArray[] = $d;
  492 + foreach($results['shortfolders'] as $f) $resultArray[] = $f;
  493 + break;
  494 +
  495 + case 'f':
  496 + default:
  497 + $selected_order['f'] = 'selected';
  498 + $resultArray = $results['folders'];
  499 + foreach($results['docs'] as $f) $resultArray[] = $f;
  500 + foreach($results['shortfolders'] as $d) $resultArray[] = $d;
  501 + foreach($results['shortdocs'] as $f) $resultArray[] = $f;
  502 + }
474 503
475 $results = $resultArray; 504 $results = $resultArray;
476 505
@@ -536,6 +565,7 @@ class SearchDispatcher extends KTStandardDispatcher { @@ -536,6 +565,7 @@ class SearchDispatcher extends KTStandardDispatcher {
536 565
537 $aTemplateData = array( 566 $aTemplateData = array(
538 "context" => $this, 567 "context" => $this,
  568 + 'selected_order' => $selected_order,
539 'bulkactions'=>$aBulkActions, 569 'bulkactions'=>$aBulkActions,
540 'firstRec'=>$firstRec, 570 'firstRec'=>$firstRec,
541 'lastRec'=>$lastRec, 571 'lastRec'=>$lastRec,
templates/ktcore/search2/search_results.smarty
@@ -131,6 +131,17 @@ function onShowAll(showall) @@ -131,6 +131,17 @@ function onShowAll(showall)
131 131
132 {else} 132 {else}
133 133
  134 + <form method=post action="{$rootUrl}/search2.php?action=searchResults">
  135 +
  136 + <select name='display_order' onChange="submit();">
  137 + <option value='f' {$selected_order.f}>Show folders first</option>
  138 + <option value='d' {$selected_order.d}>Show documents first</option>
  139 + <option value='s' {$selected_order.s}>Show shortcuts first</option>
  140 + </select>
  141 +
  142 + </form>
  143 + <br /><br />
  144 +
134 <form method=post action="{$rootUrl}/action.php"> 145 <form method=post action="{$rootUrl}/action.php">
135 <table border=0 cellpadding="1" cellspacing="1" width="100%" align=center> 146 <table border=0 cellpadding="1" cellspacing="1" width="100%" align=center>
136 {assign var=cbid value=0} 147 {assign var=cbid value=0}