]> git.agnieray.net Git - galette.git/commitdiff
Pagination on trombi (!path change!)
authorJohan Cwiklinski <johan@x-tnd.be>
Thu, 21 Feb 2019 06:23:39 +0000 (07:23 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Thu, 21 Feb 2019 06:23:39 +0000 (07:23 +0100)
Closes #1252

galette/includes/main.inc.php
galette/includes/routes/public_pages.routes.php
galette/templates/default/liste_membres.tpl
galette/templates/default/page.tpl
galette/templates/default/public_page.tpl
galette/templates/default/trombinoscope.tpl

index 36d78f481cb0ded9f29d2884b28e16b9b7d69338..88a4288390910bc38b6e0bfc3bffc15c7a2d0cd7 100644 (file)
@@ -548,9 +548,8 @@ $app->add(function ($request, $response, $next) {
 
         $missing_acls = [];
         $excluded_names = [
-            'publicMembers',
-            'filterPublicMemberslist',
-            'publicTrombinoscope'
+            'publicList',
+            'filterPublicList'
         ];
         foreach ($routes as $route) {
             $name = $route->getName();
index b7c842ee555039233f8ea8c36efbc387b4edeb44..1d8a26432dde298929ccb3c56fbdfed85b427195 100644 (file)
@@ -59,9 +59,10 @@ $showPublicPages = function ($request, $response, $next) use ($container) {
 $app->group('/public', function () {
     //public members list
     $this->get(
-        '/members[/{option:page|order}/{value:\d+}]',
+        '/{type:list|trombi}[/{option:page|order}/{value:\d+}]',
         function ($request, $response, $args) {
             $option = null;
+            $type = $args['type'];
             if (isset($args['option'])) {
                 $option = $args['option'];
             }
@@ -70,8 +71,9 @@ $app->group('/public', function () {
                 $value = $args['value'];
             }
 
-            if (isset($this->session->public_filter_members)) {
-                $filters = $this->session->public_filter_members;
+            $varname = 'public_filter_' . $type;
+            if (isset($this->session->$varname)) {
+                $filters = $this->session->$varname;
             } else {
                 $filters = new MembersList();
             }
@@ -88,9 +90,9 @@ $app->group('/public', function () {
             }
 
             $m = new Members($filters);
-            $members = $m->getPublicList(false);
+            $members = $m->getPublicList($type === 'trombi');
 
-            $this->session->public_filter_members = $filters;
+            $this->session->$varname = $filters;
 
             //assign pagination variables to the template and add pagination links
             $filters->setSmartyPagination($this->router, $this->view->getSmarty(), false);
@@ -98,9 +100,11 @@ $app->group('/public', function () {
             // display page
             $this->view->render(
                 $response,
-                'liste_membres.tpl',
+                ($type === 'list' ? 'liste_membres' : 'trombinoscope') . '.tpl',
                 array(
-                    'page_title'    => _T("Members list"),
+                    'page_title'    => ($type === 'list' ? _T("Members list") : _T('Trombinoscope')),
+                    'additionnal_html_class'    => ($type === 'list' ? '' : 'trombinoscope'),
+                    'type'          => $type,
                     'members'       => $members,
                     'nb_members'    => $m->getCount(),
                     'filters'       => $filters
@@ -108,15 +112,18 @@ $app->group('/public', function () {
             );
             return $response;
         }
-    )->setName('publicMembers');
+    )->setName('publicList');
 
     //members list filtering
     $this->post(
-        '/members/filter[/{from}]',
+        '/{type:list|trombi}/filter[/{from}]',
         function ($request, $response, $args) {
+            $type = $args['type'];
             $post = $request->getParsedBody();
-            if (isset($this->session->public_filter_members)) {
-                $filters = $this->session->public_filter_members;
+
+            $varname = 'public_filter_' . $type;
+            if (isset($this->session->$varname)) {
+                $filters = $this->session->$varname;
             } else {
                 $filters = new MembersList();
             }
@@ -131,33 +138,11 @@ $app->group('/public', function () {
                 }
             }
 
-            $this->session->public_filter_members = $filters;
+            $this->session->$varname = $filters;
 
             return $response
                 ->withStatus(301)
-                ->withHeader('Location', $this->router->pathFor('publicMembers'));
-        }
-    )->setName('filterPublicMemberslist');
-
-    //public trombinoscope
-    $this->get(
-        '/trombinoscope',
-        function ($request, $response) {
-            $m = new Members();
-            $members = $m->getPublicList(true);
-
-            // display page
-            $this->view->render(
-                $response,
-                'trombinoscope.tpl',
-                array(
-                    'page_title'                => _T("Trombinoscope"),
-                    'additionnal_html_class'    => 'trombinoscope',
-                    'members'                   => $members,
-                    'time'                      => time()
-                )
-            );
-            return $response;
+                ->withHeader('Location', $this->router->pathFor('publicList', ['type' => $type]));
         }
-    )->setName('publicTrombinoscope');
+    )->setName('filterPublicList');
 })->add($showPublicPages);
index e387b42995f72741c4faa983b2d032b7dcc87619..cc682a67c9c5ec495157d4fd8449d5c54005347d 100644 (file)
@@ -2,7 +2,7 @@
 {block name="content"}
 {if $members|@count > 0}
         <p>{_T string="This page shows only members who have choosen to be visible on the public lists and are up-to-date within their contributions. If you want your account to be visible here, edit your profile and check 'Be visible in the members list'"}</p>
-        <form action="{path_for name="filterPublicMemberslist"}" method="POST" id="filtre">
+        <form action="{path_for name="filterPublicList" data=["type" => "list"]}" method="POST" id="filtre">
         <table class="infoline">
             <tr>
                 <td class="left">{$nb_members} {if $nb_members != 1}{_T string="members"}{else}{_T string="member"}{/if}</td>
@@ -21,7 +21,7 @@
 
                 <tr>
                     <th class="left">
-                        <a href="{path_for name="publicMembers" data=["option" => "order", "value" => {Galette\Repository\Members::ORDERBY_NAME}]}" class="listing">
+                        <a href="{path_for name="publicList" data=["type" => "list", "option" => "order", "value" => {Galette\Repository\Members::ORDERBY_NAME}]}" class="listing">
                             {_T string="Name"}
                             {if $filters->orderby eq constant('Galette\Repository\Members::ORDERBY_NAME')}
                                 {if $filters->ordered eq constant('Galette\Filters\MembersList::ORDER_ASC')}
@@ -33,7 +33,7 @@
                         </a>
                     </th>
                     <th class="left">
-                        <a href="{path_for name="publicMembers" data=["option" => "order", "value" => {Galette\Repository\Members::ORDERBY_NICKNAME}]}" class="listing">
+                        <a href="{path_for name="publicList" data=["type" => "list", "option" => "order", "value" => {Galette\Repository\Members::ORDERBY_NICKNAME}]}" class="listing">
                             {_T string="Nickname"}
                             {if $filters->orderby eq constant('Galette\Repository\Members::ORDERBY_NICKNAME')}
                                 {if $filters->ordered eq constant('Galette\Filters\MembersList::ORDER_ASC')}
index cae9bdee9cabfb572542be34c38c7731a7d90766..e1cd2abe4f2e42b953a54afd7904274adc7aa52f 100644 (file)
@@ -164,8 +164,8 @@ We have to use a template file, so Smarty will do its work (like replacing varia
 {if $preferences->showPublicPages($login) eq true}
         <h1 class="nojs">{_T string="Public pages"}</h1>
         <ul>
-            <li><a href="{path_for name="publicMembers"}" title="{_T string="Members list"}">{_T string="Members list"}</a></li>
-            <li><a href="{path_for name="publicTrombinoscope"}" title="{_T string="Trombinoscope"}">{_T string="Trombinoscope"}</a></li>
+            <li><a href="{path_for name="publicList" data=["type" => "list"]}" title="{_T string="Members list"}">{_T string="Members list"}</a></li>
+            <li><a href="{path_for name="publicList" data=["type" => "trombi"]}" title="{_T string="Trombinoscope"}">{_T string="Trombinoscope"}</a></li>
             {* Include plugins menu entries *}
             {$plugins->getPublicMenus($tpl)}
         </ul>
index 311b1456fce53dd13f4ce303ba23e593b78d4e80..0125e9b0e9495e1e0d89f42b8d3d81d4bff716ad 100644 (file)
@@ -125,15 +125,15 @@ We have to use a template file, so Smarty will do its work (like replacing varia
     {/if}
     {if $preferences->showPublicPages($login) eq true}
             <a
-                href="{path_for name="publicMembers"}" title="{_T string="Members list"}"
-                class="button{if $cur_route eq "publicMembers"} selected{/if}"
+                href="{path_for name="publicList" data=["type" => "list"]}" title="{_T string="Members list"}"
+                class="button{if $cur_route eq "publicList" and $cur_subroute eq "list"} selected{/if}"
             >
                 <i class="fas fa-address-book"></i>
                 {_T string="Members list"}
             </a>
             <a
-                class="button{if $cur_route eq "publicTrombinoscope"} selected{/if}"
-                href="{path_for name="publicTrombinoscope"}" title="{_T string="Trombinoscope"}"
+                class="button{if $cur_route eq "publicList" and $cur_subroute eq "trombi"} selected{/if}"
+                href="{path_for name="publicList" data=["type" => "trombi"]}" title="{_T string="Trombinoscope"}"
             >
                 <i class="fas fa-user-friends"></i>
                 {_T string="Trombinoscope"}
index 9676eae4d1484bea1027500ad7afb28cfff0ea5d..cdf054f03c92cd29d6bf397bbd7c936e4ef7aeed 100644 (file)
@@ -1,5 +1,20 @@
 {extends file="public_page.tpl"}
+
 {block name="content"}
+<form action="{path_for name="filterPublicList" data=["type" => "trombi"]}" method="POST" id="filtre">
+    <table class="infoline">
+        <tr>
+            <td class="left">{$nb_members} {if $nb_members != 1}{_T string="members"}{else}{_T string="member"}{/if}</td>
+            <td class="right">
+                <label for="nbshow">{_T string="Records per page:"}</label>
+                <select name="nbshow" id="nbshow">
+                    {html_options options=$nbshow_options selected=$numrows}
+                </select>
+                <noscript> <span><input type="submit" value="{_T string="Change"}" /></span></noscript>
+            </td>
+        </tr>
+    </table>
+</form>
 {foreach from=$members item=member}
         <div class="trombino">
             {assign var="mid" value=$member->id}
@@ -9,4 +24,21 @@
 {foreachelse}
         <div id="infobox">{_T string="No member to show"}</div>
 {/foreach}
+
+<div class="center cright">
+    {_T string="Pages:"}<br/>
+    <ul class="pages">{$pagination}</ul>
+</div>
+{/block}
+
+{block name="javascripts"}
+    {if $members|@count > 0}
+        <script type="text/javascript">
+            $(function(){
+                $('#nbshow').change(function() {
+                    this.form.submit();
+                });
+            });
+        </script>
+    {/if}
 {/block}