]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Profile.php
show pinned items
[friendica.git] / src / Module / Profile.php
index cb710b10ba97bee752cc13cd3dcf7aab7156603c..ac345fad243047ba589e9bf944263d8b6c262f8e 100644 (file)
@@ -33,7 +33,7 @@ class Profile extends BaseModule
        public static $which = '';
        public static $profile = 0;
 
-       public static function init()
+       public static function init(array $parameters = [])
        {
                $a = self::getApp();
 
@@ -51,7 +51,7 @@ class Profile extends BaseModule
                }
        }
 
-       public static function rawContent()
+       public static function rawContent(array $parameters = [])
        {
                if (ActivityPub::isRequest()) {
                        $user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);
@@ -75,7 +75,7 @@ class Profile extends BaseModule
                }
        }
 
-       public static function content($update = 0)
+       public static function content(array $parameters = [], $update = 0)
        {
                $a = self::getApp();
 
@@ -102,7 +102,7 @@ class Profile extends BaseModule
 
                        // site block
                        if (!$blocked && !$userblock) {
-                               $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], defaults($a->profile, 'pub_keywords', ''));
+                               $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
                                if (strlen($keywords)) {
                                        $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
                                }
@@ -131,9 +131,12 @@ class Profile extends BaseModule
 
                $category = $datequery = $datequery2 = '';
 
+               /** @var DateTimeFormat $dtFormat */
+               $dtFormat = self::getClass(DateTimeFormat::class);
+
                if ($a->argc > 2) {
                        for ($x = 2; $x < $a->argc; $x ++) {
-                               if (is_a_date_arg($a->argv[$x])) {
+                               if ($dtFormat->isYearMonth($a->argv[$x])) {
                                        if ($datequery) {
                                                $datequery2 = Strings::escapeHtml($a->argv[$x]);
                                        } else {
@@ -146,10 +149,10 @@ class Profile extends BaseModule
                }
 
                if (empty($category)) {
-                       $category = defaults($_GET, 'category', '');
+                       $category = $_GET['category'] ?? '';
                }
 
-               $hashtags = defaults($_GET, 'tag', '');
+               $hashtags = $_GET['tag'] ?? '';
 
                if (Config::get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['profile_uid'])) {
                        return Login::form();
@@ -174,7 +177,7 @@ class Profile extends BaseModule
                }
 
                if (!$update) {
-            $tab = Strings::escapeTags(trim(defaults($_GET, 'tab', '')));
+                       $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
 
                        $o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
 
@@ -346,6 +349,12 @@ class Profile extends BaseModule
 
                $items = DBA::toArray($items_stmt);
 
+               if ($pager->getStart() == 0) {
+                       $pinned_items = Item::selectPinned($a->profile['profile_uid'], ['uri']);
+                       $pinned = Item::inArray($pinned_items);
+                       $items = array_merge($items, $pinned);
+               }
+
                $o .= conversation($a, $items, $pager, 'profile', $update, false, 'received', $a->profile['profile_uid']);
 
                if (!$update) {