]> git.mxchange.org Git - friendica.git/commitdiff
Add node-wide default items per page config
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 16 Feb 2020 18:04:26 +0000 (13:04 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 16 Feb 2020 18:04:26 +0000 (13:04 -0500)
mod/network.php
mod/notes.php
mod/settings.php
src/Model/Contact.php
src/Module/BaseSearch.php
src/Module/Conversation/Community.php
src/Module/Profile/Status.php
src/Module/Search/Index.php
static/defaults.config.php

index 31cafb5a86206b223f5b8b6fc4408d1b3fcd4cb5..6c63753d9114de8f9dd8b412a204c24795822744 100644 (file)
@@ -228,14 +228,12 @@ function networkPager(App $a, Pager $pager, $update)
                return ' LIMIT 100';
        }
 
-       //  check if we serve a mobile device and get the user settings
-       //  accordingly
        if (DI::mode()->isMobile()) {
-               $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network');
-               $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
+               $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                       DI::config()->get('system', 'itemspage_network_mobile'));
        } else {
-               $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network');
-               $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 40);
+               $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                       DI::config()->get('system', 'itemspage_network'));
        }
 
        //  now that we have the user settings, see if the theme forces
index 602514a54ac2139bdafd094871cbcd10cf9703be..67f8fcab29f08b9bedd2acf7f0d73335c90a4805 100644 (file)
@@ -69,7 +69,15 @@ function notes_content(App $a, $update = false)
        $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
                'contact-id'=> $a->contact['id']];
 
-       $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 40);
+       if (DI::mode()->isMobile()) {
+               $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                       DI::config()->get('system', 'itemspage_network_mobile'));
+       } else {
+               $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                       DI::config()->get('system', 'itemspage_network'));
+       }
+
+       $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
 
        $params = ['order' => ['created' => true],
                'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
index 6fc8c8b1eb9a76b86d6dbb54fdeb1a9859518960..94aed74ad499d3fa54faa2c98d19f92394621aba 100644 (file)
@@ -356,11 +356,15 @@ function settings_post(App $a)
                        }
                }
 
-               $itemspage_network = !empty($_POST['itemspage_network'])  ? intval($_POST['itemspage_network'])  : 40;
+               $itemspage_network = !empty($_POST['itemspage_network']) ?
+                       intval($_POST['itemspage_network']) :
+                       DI::config()->get('system', 'itemspage_network');
                if ($itemspage_network > 100) {
                        $itemspage_network = 100;
                }
-               $itemspage_mobile_network = !empty($_POST['itemspage_mobile_network']) ? intval($_POST['itemspage_mobile_network']) : 20;
+               $itemspage_mobile_network = !empty($_POST['itemspage_mobile_network']) ?
+                       intval($_POST['itemspage_mobile_network']) :
+                       DI::config()->get('system', 'itemspage_network_mobile');
                if ($itemspage_mobile_network > 100) {
                        $itemspage_mobile_network = 100;
                }
@@ -938,9 +942,9 @@ function settings_content(App $a)
                }
 
                $itemspage_network = intval(DI::pConfig()->get(local_user(), 'system', 'itemspage_network'));
-               $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items
+               $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : DI::config()->get('system', 'itemspage_network'));
                $itemspage_mobile_network = intval(DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network'));
-               $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : 20); // default if not set: 20 items
+               $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : DI::config()->get('system', 'itemspage_network_mobile'));
 
                $nosmile = DI::pConfig()->get(local_user(), 'system', 'no_smilies', 0);
                $first_day_of_week = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
index f1fec640a84e788ba419f8076d66048125c54b6f..adc686f7052f660f79f367f6276ed3db64a21f48 100644 (file)
@@ -1805,7 +1805,15 @@ class Contact
                                $cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
                }
 
-               $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
+               if (DI::mode()->isMobile()) {
+                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                               DI::config()->get('system', 'itemspage_network_mobile'));
+               } else {
+                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                               DI::config()->get('system', 'itemspage_network'));
+               }
+
+               $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
 
                $params = ['order' => ['received' => true],
                        'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
index e1bb3ebb0af1ea101cb970efcdeac73f577d764b..e67d3c3c93819234cb7ca0d85cea73a088426c42 100644 (file)
@@ -81,7 +81,15 @@ class BaseSearch extends BaseModule
                        $header = DI::l10n()->t('Forum Search - %s', $search);
                }
 
-               $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
+               if (DI::mode()->isMobile()) {
+                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                               DI::config()->get('system', 'itemspage_network_mobile'));
+               } else {
+                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                               DI::config()->get('system', 'itemspage_network'));
+               }
+
+               $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
 
                if ($localSearch && empty($results)) {
                        $pager->setItemsPerPage(80);
index a5f663139d41d0ba8da31a6dcfd2572bcd2fe047..58af38eb16d72f11d5cb715a0ea919bc92571f39 100644 (file)
@@ -195,11 +195,12 @@ class Community extends BaseModule
                        }
                }
 
-               // check if we serve a mobile device and get the user settings accordingly
                if (DI::mode()->isMobile()) {
-                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', 20);
+                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                               DI::config()->get('system', 'itemspage_network_mobile'));
                } else {
-                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', 40);
+                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                               DI::config()->get('system', 'itemspage_network'));
                }
 
                // now that we have the user settings, see if the theme forces
@@ -272,6 +273,7 @@ class Community extends BaseModule
         * @param $itemspage
         * @return array
         * @throws \Exception
+        * @TODO Move to repository/factory
         */
        private static function selectItems($since_id, $max_id, $itemspage)
        {
index bd2898fa632a624525847a6a35e34de351bd7bac..abd5736c9aa089fd7a7acdbf99161a925cf93e92 100644 (file)
@@ -166,12 +166,12 @@ class Status extends BaseProfile
                        $sql_extra3 = "";
                }
 
-               //  check if we serve a mobile device and get the user settings
-               //  accordingly
                if (DI::mode()->isMobile()) {
-                       $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', 10);
+                       $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                               DI::config()->get('system', 'itemspage_network_mobile'));
                } else {
-                       $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', 20);
+                       $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                               DI::config()->get('system', 'itemspage_network'));
                }
 
                //  now that we have the user settings, see if the theme forces
index 2b7bb5c8a1be35fa639b14daf860db212559779b..44407623e9704e19aea77c40f8f923792af8e633 100644 (file)
@@ -137,7 +137,15 @@ class Index extends BaseSearch
                // OR your own posts if you are a logged in member
                // No items will be shown if the member has a blocked profile wall.
 
-               $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
+               if (DI::mode()->isMobile()) {
+                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                               DI::config()->get('system', 'itemspage_network_mobile'));
+               } else {
+                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                               DI::config()->get('system', 'itemspage_network'));
+               }
+
+               $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
 
                if ($tag) {
                        Logger::info('Start tag search.', ['q' => $search]);
index f9eda841f26b8149db68ccd191b8e1a58dcd5283..ab47eef19ce40e0ca90f85e5c0cba30bb9892968 100644 (file)
@@ -227,6 +227,15 @@ return [
                // If set true registration is only possible after a current member of the node has send an invitation.
                'invitation_only' => false,
 
+               // itemspage_network (Integer)
+               // default number of items per page in stream pages (network, community, profile/contact statuses, search)
+               'itemspage_network' => 40,
+
+               // itemspage_network_mobile (Integer)
+               // default number of items per page in stream pages (network, community, profile/contact statuses, search)
+               // on detected mobile devices
+               'itemspage_network_mobile' => 20,
+
                // like_no_comment (Boolean)
                // Don't update the "commented" value of an item when it is liked.
                'like_no_comment' => false,