]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
Merge pull request #4312 from zeroadam/feature/L10n
[friendica.git] / mod / network.php
index f9a5488ebefef26962402b8607d28ce88f6af260..1d64fcbde5ddb6cbf243ac099a28ae2f45f0fedd 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\Content\ForumManager;
 use Friendica\Content\Nav;
 use Friendica\Content\Widget;
 use Friendica\Core\Addon;
+use Friendica\Core\L10n;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
@@ -25,7 +26,7 @@ require_once 'include/acl_selectors.php';
 function network_init(App $a)
 {
        if (!local_user()) {
-               notice(t('Permission denied.') . EOL);
+               notice(L10n::t('Permission denied.') . EOL);
                return;
        }
 
@@ -56,8 +57,6 @@ function network_init(App $a)
                $group_id = 0;
        }
 
-       PConfig::set(local_user(), 'network.view', 'group.selected', $group_id);
-
        if ($a->argc > 1) {
                for ($x = 1; $x < $a->argc; $x ++) {
                        if (is_a_date_arg($a->argv[$x])) {
@@ -75,23 +74,17 @@ function network_init(App $a)
 
        // fetch last used network view and redirect if needed
        if (!$is_a_date_query) {
+               $sel_nets = defaults($_GET, 'nets', false);
                $sel_tabs = network_query_get_sel_tab($a);
-               $sel_nets = network_query_get_sel_net();
                $sel_groups = network_query_get_sel_group($a);
                $last_sel_tabs = PConfig::get(local_user(), 'network.view', 'tab.selected');
-               $last_sel_nets = PConfig::get(local_user(), 'network.view', 'net.selected');
-               $last_sel_groups = PConfig::get(local_user(), 'network.view', 'group.selected');
 
                $remember_tab = ($sel_tabs[0] === 'active' && is_array($last_sel_tabs) && $last_sel_tabs[0] !== 'active');
-               $remember_net = ($sel_nets === false && $last_sel_nets && $last_sel_nets !== 'all');
-               $remember_group = ($sel_groups === false && $last_sel_groups && $last_sel_groups != 0);
 
                $net_baseurl = '/network';
                $net_args = [];
 
-               if ($remember_group) {
-                       $net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection
-               } elseif ($sel_groups !== false) {
+               if ($sel_groups !== false) {
                        $net_baseurl .= '/' . $sel_groups;
                }
 
@@ -132,18 +125,13 @@ function network_init(App $a)
                        } else {
                                $remember_tab = false;
                        }
-               } elseif ($sel_tabs[4] === 'active') {
-                       // The '/new' tab is selected
-                       $remember_group = false;
                }
 
-               if ($remember_net) {
-                       $net_args['nets'] = $last_sel_nets;
-               } elseif ($sel_nets !== false) {
+               if ($sel_nets !== false) {
                        $net_args['nets'] = $sel_nets;
                }
 
-               if ($remember_tab || $remember_net || $remember_group) {
+               if ($remember_tab) {
                        $net_args = array_merge($query_array, $net_args);
                        $net_queries = build_querystring($net_args);
 
@@ -200,15 +188,15 @@ function saved_searches($search)
                        'id'          => $rr['id'],
                        'term'        => $rr['term'],
                        'encodedterm' => urlencode($rr['term']),
-                       'delete'      => t('Remove term'),
+                       'delete'      => L10n::t('Remove term'),
                        'selected'    => ($search == $rr['term']),
                ];
        }
 
        $tpl = get_markup_template('saved_searches_aside.tpl');
        $o = replace_macros($tpl, [
-               '$title'     => t('Saved Searches'),
-               '$add'       => t('add'),
+               '$title'     => L10n::t('Saved Searches'),
+               '$add'       => L10n::t('add'),
                '$searchbox' => search($search, 'netsearch-box', $srchurl, true),
                '$saved'     => $saved,
        ]);
@@ -276,21 +264,6 @@ function network_query_get_sel_tab(App $a)
        return [$no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active];
 }
 
-/**
- * @brief Return selected network from query
- * @return string Name of the selected network
- */
-function network_query_get_sel_net()
-{
-       $network = false;
-
-       if (x($_GET, 'nets')) {
-               $network = $_GET['nets'];
-       }
-
-       return $network;
-}
-
 function network_query_get_sel_group(App $a)
 {
        $group = false;
@@ -437,8 +410,6 @@ function networkFlatView(App $a, $update = 0)
 
        $file = ((x($_GET, 'file')) ? $_GET['file'] : '');
 
-       PConfig::set(local_user(), 'network.view', 'net.selected', 'all');
-
        if (!$update && !$rawmode) {
                $tabs = network_tabs($a);
                $o .= $tabs;
@@ -563,7 +534,6 @@ function networkThreadedView(App $a, $update = 0)
                        $def_acl = ['allow_cid' => $str];
                }
        }
-       PConfig::set(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
 
        if (!$update && !$rawmode) {
                $tabs = network_tabs($a);
@@ -571,9 +541,10 @@ function networkThreadedView(App $a, $update = 0)
 
                if ($gid) {
                        if (($t = Contact::getOStatusCountByGroupId($gid)) && !PConfig::get(local_user(), 'system', 'nowarn_insecure')) {
-                               notice(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
-                                               "Warning: This group contains %s members from a network that doesn't allow non public messages.", $t) . EOL);
-                               notice(t("Messages in this group won't be send to these receivers.") . EOL);
+                               notice(L10n::tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
+                                               "Warning: This group contains %s members from a network that doesn't allow non public messages.",
+                                               $t) . EOL);
+                               notice(L10n::t("Messages in this group won't be send to these receivers.").EOL);
                        }
                }
 
@@ -641,7 +612,7 @@ function networkThreadedView(App $a, $update = 0)
                        if ($update) {
                                killme();
                        }
-                       notice(t('No such group') . EOL);
+                       notice(L10n::t('No such group') . EOL);
                        goaway('network/0');
                        // NOTREACHED
                }
@@ -662,11 +633,11 @@ function networkThreadedView(App $a, $update = 0)
                        $sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '" . protect_sprintf('%<' . intval($gid) . '>%') . "' AND `temp1`.`private`))";
                } else {
                        $sql_extra3 .= " AND false ";
-                       info(t('Group is empty'));
+                       info(L10n::t('Group is empty'));
                }
 
                $o = replace_macros(get_markup_template('section_title.tpl'), [
-                       '$title' => t('Group: %s', $group['name'])
+                       '$title' => L10n::t('Group: %s', $group['name'])
                ]) . $o;
        } elseif ($cid) {
                $fields = ['id', 'name', 'network', 'writable', 'nurl',
@@ -691,12 +662,11 @@ function networkThreadedView(App $a, $update = 0)
                                'id' => 'network',
                        ]) . $o;
 
-                       if ($contact['network'] === NETWORK_OSTATUS && $contact['writable'] && !PConfig::get(local_user(), 'system',
-                                       'nowarn_insecure')) {
-                               notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
+                       if ($contact['network'] === NETWORK_OSTATUS && $contact['writable'] && !PConfig::get(local_user(),'system','nowarn_insecure')) {
+                               notice(L10n::t('Private messages to this person are at risk of public disclosure.') . EOL);
                        }
                } else {
-                       notice(t('Invalid contact.') . EOL);
+                       notice(L10n::t('Invalid contact.') . EOL);
                        goaway('network');
                        // NOTREACHED
                }
@@ -846,7 +816,7 @@ function networkThreadedView(App $a, $update = 0)
 
                if (count($data) > 0) {
                        logger('Tagged items: ' . count($data) . ' - ' . $bottom_limit . ' - ' . $top_limit . ' - ' . local_user()); //$last_date);
-                       $r = array_merge($r, $data);
+                       $r = array_merge($data, $r);
                }
        }
 
@@ -939,18 +909,18 @@ function network_tabs(App $a)
        // tabs
        $tabs = [
                [
-                       'label' => t('Commented Order'),
+                       'label' => L10n::t('Commented Order'),
                        'url'   => str_replace('/new', '', $cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
                        'sel'   => $all_active,
-                       'title' => t('Sort by Comment Date'),
+                       'title' => L10n::t('Sort by Comment Date'),
                        'id'    => 'commented-order-tab',
                        'accesskey' => 'e',
                ],
                [
-                       'label' => t('Posted Order'),
+                       'label' => L10n::t('Posted Order'),
                        'url'   => str_replace('/new', '', $cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
                        'sel'   => $postord_active,
-                       'title' => t('Sort by Post Date'),
+                       'title' => L10n::t('Sort by Post Date'),
                        'id'    => 'posted-order-tab',
                        'accesskey' => 't',
                ],
@@ -958,10 +928,10 @@ function network_tabs(App $a)
 
        if (Feature::isEnabled(local_user(), 'personal_tab')) {
                $tabs[] = [
-                       'label' => t('Personal'),
+                       'label' => L10n::t('Personal'),
                        'url'   => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
                        'sel'   => $conv_active,
-                       'title' => t('Posts that mention or involve you'),
+                       'title' => L10n::t('Posts that mention or involve you'),
                        'id'    => 'personal-tab',
                        'accesskey' => 'r',
                ];
@@ -969,10 +939,10 @@ function network_tabs(App $a)
 
        if (Feature::isEnabled(local_user(), 'new_tab')) {
                $tabs[] = [
-                       'label' => t('New'),
+                       'label' => L10n::t('New'),
                        'url'   => 'network/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
                        'sel'   => $new_active,
-                       'title' => t('Activity Stream - by date'),
+                       'title' => L10n::t('Activity Stream - by date'),
                        'id'    => 'activitiy-by-date-tab',
                        'accesskey' => 'w',
                ];
@@ -980,10 +950,10 @@ function network_tabs(App $a)
 
        if (Feature::isEnabled(local_user(), 'link_tab')) {
                $tabs[] = [
-                       'label' => t('Shared Links'),
+                       'label' => L10n::t('Shared Links'),
                        'url'   => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
                        'sel'   => $bookmarked_active,
-                       'title' => t('Interesting Links'),
+                       'title' => L10n::t('Interesting Links'),
                        'id'    => 'shared-links-tab',
                        'accesskey' => 'b',
                ];
@@ -991,10 +961,10 @@ function network_tabs(App $a)
 
        if (Feature::isEnabled(local_user(), 'star_posts')) {
                $tabs[] = [
-                       'label' => t('Starred'),
+                       'label' => L10n::t('Starred'),
                        'url'   => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
                        'sel'   => $starred_active,
-                       'title' => t('Favourite Posts'),
+                       'title' => L10n::t('Favourite Posts'),
                        'id'    => 'starred-posts-tab',
                        'accesskey' => 'm',
                ];