]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
Move Temporal::convert() to DateTimeFormat::convert()
[friendica.git] / mod / network.php
index 5b7cf83a8e64acd8d93e237ea29c6fd96285a56e..c2f05fd8e7e22a14a17a4b9b06c306eb28dc4fa8 100644 (file)
@@ -3,6 +3,7 @@
 /**
  * @file mod/network.php
  */
+
 use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Content\ForumManager;
@@ -10,6 +11,7 @@ use Friendica\Content\Nav;
 use Friendica\Content\Widget;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
+use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
@@ -17,6 +19,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Model\Profile;
 use Friendica\Module\Login;
+use Friendica\Util\DateTimeFormat;
 
 require_once 'include/conversation.php';
 require_once 'include/items.php';
@@ -25,7 +28,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;
        }
 
@@ -187,15 +190,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,
        ]);
@@ -540,9 +543,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);
                        }
                }
 
@@ -610,7 +614,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
                }
@@ -631,11 +635,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',
@@ -660,12 +664,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
                }
@@ -678,11 +681,11 @@ function networkThreadedView(App $a, $update = 0)
 
        if ($datequery) {
                $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ",
-                               dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
+                               dbesc(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
        }
        if ($datequery2) {
                $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ",
-                               dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
+                               dbesc(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
        }
 
        $sql_order = '';
@@ -782,13 +785,13 @@ function networkThreadedView(App $a, $update = 0)
        }
 
        // Only show it when unfiltered (no groups, no networks, ...)
-       if (Config::get('system', 'comment_public') && in_array($nets, ['', NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
+       if (in_array($nets, ['', NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
                if (DBM::is_result($r)) {
                        $top_limit = current($r)['order_date'];
                        $bottom_limit = end($r)['order_date'];
                } else {
-                       $top_limit = datetime_convert();
-                       $bottom_limit = datetime_convert();
+                       $top_limit = DateTimeFormat::utcNow();
+                       $bottom_limit = DateTimeFormat::utcNow();
                }
 
                // When checking for updates we need to fetch from the newest date to the newest date before
@@ -801,7 +804,7 @@ function networkThreadedView(App $a, $update = 0)
                        $top_limit = $last_date;
                } elseif ($a->pager['page'] == 1) {
                        // Highest possible top limit when we are on the first page
-                       $top_limit = datetime_convert();
+                       $top_limit = DateTimeFormat::utcNow();
                }
 
                $items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item`
@@ -908,18 +911,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',
                ],
@@ -927,10 +930,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',
                ];
@@ -938,10 +941,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',
                ];
@@ -949,10 +952,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',
                ];
@@ -960,10 +963,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',
                ];