]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Widget.php
Merge pull request #10657 from annando/self-unfollow
[friendica.git] / src / Content / Widget.php
index 032b9e7534d3f8a3e05a12ab1c1b067697a5b463..a899644c3ce5a80c27ad2de9e13667e0dce320e4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -334,7 +334,7 @@ class Widget
        {
                $a = DI::app();
 
-               $uid = intval($a->profile['uid']);
+               $uid = intval($a->getProfileOwner());
 
                if (!Feature::isEnabled($uid, 'categories')) {
                        return '';
@@ -416,23 +416,20 @@ class Widget
        /**
         * Insert a tag cloud widget for the present profile.
         *
+        * @param int $uid   User ID
         * @param int $limit Max number of displayed tags.
         * @return string HTML formatted output.
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function tagCloud($limit = 50)
+       public static function tagCloud(int $uid, int $limit = 50)
        {
-               $a = DI::app();
-
-               $uid = intval($a->profile['uid']);
-
-               if (!$uid || !$a->profile['url']) {
+               if (empty($uid)) {
                        return '';
                }
 
                if (Feature::isEnabled($uid, 'tagadelic')) {
-                       $owner_id = Contact::getIdForURL($a->profile['url'], 0, false);
+                       $owner_id = Contact::getPublicIdByUserId($uid);
 
                        if (!$owner_id) {
                                return '';
@@ -463,7 +460,7 @@ class Widget
 
                $cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall;
                $dthen = DI::cache()->get($cachekey);
-               if (!empty($dthen)) {
+               if (empty($dthen)) {
                        $dthen = Item::firstPostDate($uid, $wall);
                        DI::cache()->set($cachekey, $dthen, Duration::HOUR);
                }