]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/NotificationsManager.php
Move Temporal::convert() to DateTimeFormat::convert()
[friendica.git] / src / Core / NotificationsManager.php
index 196fd1eedc9955d281c5c686a22d35f5cb8648ab..356ed4a472e57aad7145077ecf23f3f01468199d 100644 (file)
@@ -13,6 +13,8 @@ use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\XML;
 
 require_once 'include/dba.php';
 require_once 'include/html2plain.php';
@@ -41,7 +43,7 @@ class NotificationsManager extends BaseObject
        {
                $rets = [];
                foreach ($notes as $n) {
-                       $local_time = datetime_convert('UTC', date_default_timezone_get(), $n['date']);
+                       $local_time = DateTimeFormat::local($n['date']);
                        $n['timestamp'] = strtotime($local_time);
                        $n['date_rel'] = relative_date($n['date']);
                        $n['msg_html'] = bbcode($n['msg'], false, false, false, false);
@@ -242,7 +244,7 @@ class NotificationsManager extends BaseObject
                                                $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
                                                $default_item_url = $it['url'];
                                                $default_item_text = strip_tags(bbcode($it['msg']));
-                                               $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['date'], 'r');
+                                               $default_item_when = DateTimeFormat::local($it['date'], 'r');
                                                $default_item_ago = relative_date($it['date']);
                                                break;
 
@@ -251,8 +253,8 @@ class NotificationsManager extends BaseObject
                                                $default_item_link = System::baseUrl(true) . '/display/' . $it['pguid'];
                                                $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
                                                $default_item_url = $it['author-link'];
-                                               $default_item_text = sprintf(L10n::t("%s commented on %s's post"), $it['author-name'], $it['pname']);
-                                               $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
+                                               $default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
+                                               $default_item_when = DateTimeFormat::local($it['created'], 'r');
                                                $default_item_ago = relative_date($it['created']);
                                                break;
 
@@ -262,9 +264,9 @@ class NotificationsManager extends BaseObject
                                                $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
                                                $default_item_url = $it['author-link'];
                                                $default_item_text = (($it['id'] == $it['parent'])
-                                                                       ? sprintf(L10n::t("%s created a new post"), $it['author-name'])
-                                                                       : sprintf(L10n::t("%s commented on %s's post"), $it['author-name'], $it['pname']));
-                                               $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
+                                                                       ? L10n::t("%s created a new post", $it['author-name'])
+                                                                       : L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
+                                               $default_item_when = DateTimeFormat::local($it['created'], 'r');
                                                $default_item_ago = relative_date($it['created']);
                                }
 
@@ -276,7 +278,7 @@ class NotificationsManager extends BaseObject
                                                        'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf(L10n::t("%s liked %s's post"), $it['author-name'], $it['pname']),
+                                                       'text' => L10n::t("%s liked %s's post", $it['author-name'], $it['pname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']
@@ -289,7 +291,7 @@ class NotificationsManager extends BaseObject
                                                        'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf(L10n::t("%s disliked %s's post"), $it['author-name'], $it['pname']),
+                                                       'text' => L10n::t("%s disliked %s's post", $it['author-name'], $it['pname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']
@@ -302,7 +304,7 @@ class NotificationsManager extends BaseObject
                                                        'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf(L10n::t("%s is attending %s's event"), $it['author-name'], $it['pname']),
+                                                       'text' => L10n::t("%s is attending %s's event", $it['author-name'], $it['pname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']
@@ -315,7 +317,7 @@ class NotificationsManager extends BaseObject
                                                        'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf(L10n::t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
+                                                       'text' => L10n::t("%s is not attending %s's event", $it['author-name'], $it['pname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']
@@ -328,7 +330,7 @@ class NotificationsManager extends BaseObject
                                                        'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf(L10n::t("%s may attend %s's event"), $it['author-name'], $it['pname']),
+                                                       'text' => L10n::t("%s may attend %s's event", $it['author-name'], $it['pname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']
@@ -337,7 +339,7 @@ class NotificationsManager extends BaseObject
 
                                        case ACTIVITY_FRIEND:
                                                $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
-                                               $obj = parse_xml_string($xmlhead . $it['object']);
+                                               $obj = XML::parseString($xmlhead . $it['object']);
                                                $it['fname'] = $obj->title;
 
                                                $notif = [
@@ -345,7 +347,7 @@ class NotificationsManager extends BaseObject
                                                        'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf(L10n::t("%s is now friends with %s"), $it['author-name'], $it['fname']),
+                                                       'text' => L10n::t("%s is now friends with %s", $it['author-name'], $it['fname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']