From 2708dd01ee780ed65814efd1d0920b2c4737b779 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 4 Sep 2019 11:26:09 +0200 Subject: [PATCH] LSsearch : Add nbObjectsByPageChoices parameter --- doc/conf/LSobject/LSsearch.docbook | 9 ++++++ .../LSobjects/config.LSobjects.LSpeople.php | 2 ++ public_html/css/default/base.css | 23 ++++++++++----- public_html/includes/class/class.LSsearch.php | 29 +++++++++++++++++++ public_html/templates/default/viewSearch.tpl | 14 +++++++++ 5 files changed, 69 insertions(+), 8 deletions(-) diff --git a/doc/conf/LSobject/LSsearch.docbook b/doc/conf/LSobject/LSsearch.docbook index 92ac00fd..563108ba 100644 --- a/doc/conf/LSobject/LSsearch.docbook +++ b/doc/conf/LSobject/LSsearch.docbook @@ -34,6 +34,7 @@ configuration des &LSobjects;, dans la variable LSsearch // Paramètre d'affichage 'displayFormat' => [LSformat], 'nbObjectsByPage' => [integer], + 'nbObjectsByPageChoices' => array([integer], [integer], ...), 'nbPageLinkByPage' => [integer], 'validPatternRegex' => '[regex]' ), @@ -234,6 +235,14 @@ contexte dans lequel cette recherche est effectuée. + + nbObjectsByPageChoices + + Tableau des choix proposés à l'utilisateur pour le nombre d'objets maximum affichés dans une page + de résultat de la recherche. + + + nbPageLinkByPage diff --git a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php index 8cb1ddd0..7284d6d0 100644 --- a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php +++ b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php @@ -181,6 +181,8 @@ $GLOBALS['LSobjects']['LSpeople'] = array ( ), 'params' => array ( 'recursive' => true, + 'nbObjectsByPage' => 5, + 'nbObjectsByPageChoices' => array(5, 10, 15), ), 'predefinedFilters' => array ( '(jpegPhoto=*)' => 'With photo', diff --git a/public_html/css/default/base.css b/public_html/css/default/base.css index 983f3116..6172f3f5 100644 --- a/public_html/css/default/base.css +++ b/public_html/css/default/base.css @@ -236,27 +236,34 @@ td.LSobject-list-names { */ p.LSobject-list-page { text-align: center; - margin: 0.5em; + margin: auto; + margin-top: 0.5em; + max-width: 20em; } -a.LSobject-list-page { +a.LSobject-list-page, a.LSobject-list-nb-by-page { color: #0072b8; text-decoration: none; } -a.LSobject-list-page:hover { +a.LSobject-list-page:hover, a.LSobject-list-nb-by-page:hover { color: #0072b8; } -strong.LSobject-list-page { +strong.LSobject-list-page, strong.LSobject-list-nb-by-page { color: #0072b8; } +#LSobject_list_nbresult, p.LSobject-list-nb-by-page { + float: right; + clear: both; + color: #333; + font-style: italic; + margin: 0; + margin-right: 20px; +} + #LSobject_list_nbresult { - float: right; - color: #333; - font-style: italic; - margin-right: 20px; text-transform: lowercase; } diff --git a/public_html/includes/class/class.LSsearch.php b/public_html/includes/class/class.LSsearch.php index d429ba90..6c5c9c30 100644 --- a/public_html/includes/class/class.LSsearch.php +++ b/public_html/includes/class/class.LSsearch.php @@ -58,6 +58,7 @@ class LSsearch { 'displaySubDn' => NULL, 'displayFormat' => NULL, 'nbObjectsByPage' => NB_LSOBJECT_LIST, + 'nbObjectsByPageChoices' => array(25, 50, 75, 100), 'nbPageLinkByPage' => 10, 'customInfos' => array(), 'withoutCache' => false, @@ -333,6 +334,34 @@ class LSsearch { $OK=false; } } + + // nbObjectsByPageChoices + if (isset($params['nbObjectsByPageChoices'])) { + if (is_array($params['nbObjectsByPageChoices'])) { + $choices = array(); + $choiceError = false; + foreach($params['nbObjectsByPageChoices'] as $choice) { + if (is_int($choice) && !in_array($choice, $choices)) { + $choices[] = $choice; + } + else { + $choiceError = true; + break; + } + } + if (!empty($choices) && !$choiceError) { + $this -> params['nbObjectsByPageChoices'] = $choices; + } + else { + LSerror :: addErrorCode('LSsearch_03','nbObjectsByPageChoices'); + $OK = false; + } + } + else { + LSerror :: addErrorCode('LSsearch_03','nbObjectsByPageChoices'); + $OK = false; + } + } // Sort Limit if (isset($params['sortlimit'])) { diff --git a/public_html/templates/default/viewSearch.tpl b/public_html/templates/default/viewSearch.tpl index 4a680047..68da34d5 100644 --- a/public_html/templates/default/viewSearch.tpl +++ b/public_html/templates/default/viewSearch.tpl @@ -113,7 +113,21 @@ {/foreach} + {$LSsearch->label_total|escape:"htmlall"} +{if !empty($page.list)} +

+ {tr msg='Nb / page :'} + {foreach from=$LSsearch->getParam('nbObjectsByPageChoices') item=choice} + {if $LSsearch->getParam('nbObjectsByPage') == $choice} + {$choice} + {else} + {$choice} + {/if} + {/foreach} +

+{/if} + {if $page.nbPages > 1}