]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Widget.php
Merge pull request #7674 from annando/fix-magic-again
[friendica.git] / src / Content / Widget.php
index 066c17413a3a8db9b56da401f1b5e481a339cb08..90974427965538d5425637361e7c437a21bad759 100644 (file)
@@ -52,7 +52,7 @@ class Widget
                $global_dir = Config::get('system', 'directory');
 
                if (Config::get('system', 'invitation_only')) {
-                       $x = PConfig::get(local_user(), 'system', 'invites_remaining');
+                       $x = intval(PConfig::get(local_user(), 'system', 'invites_remaining'));
                        if ($x || is_site_admin()) {
                                $a->page['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
                                        . L10n::tt('%d invitation available', '%d invitations available', $x)
@@ -256,7 +256,7 @@ class Widget
         * @param string $baseurl  baseurl
         * @param string $selected optional, default empty
         * @return string|void
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \Exception
         */
        public static function fileAs($baseurl, $selected = '')
        {
@@ -269,15 +269,9 @@ class Widget
                        return;
                }
 
-               $matches = [];
-               $terms = array();
-               $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
-               if ($cnt) {
-                       foreach ($matches as $mtch)
-                       {
-                               $unescaped = XML::escape(FileTag::decode($mtch[1]));
-                               $terms[] = ['ref' => $unescaped, 'name' => $unescaped];
-                       }
+               $terms = [];
+               foreach (FileTag::fileToArray($saved) as $savedFolderName) {
+                       $terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
                }
 
                return self::filter(
@@ -303,24 +297,20 @@ class Widget
        {
                $a = \get_app();
 
-               if (!Feature::isEnabled($a->profile['profile_uid'], 'categories')) {
+               $uid = intval($a->profile['profile_uid']);
+
+               if (!Feature::isEnabled($uid, 'categories')) {
                        return '';
                }
 
-               $saved = PConfig::get($a->profile['profile_uid'], 'system', 'filetags');
+               $saved = PConfig::get($uid, 'system', 'filetags');
                if (!strlen($saved)) {
                        return;
                }
 
-               $matches = [];
                $terms = array();
-               $cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
-
-               if ($cnt) {
-                       foreach ($matches as $mtch) {
-                               $unescaped = XML::escape(FileTag::decode($mtch[1]));
-                               $terms[] = ['ref' => $unescaped, 'name' => $unescaped];
-                       }
+               foreach (FileTag::fileToArray($saved, 'category') as $savedFolderName) {
+                       $terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
                }
 
                return self::filter(
@@ -347,16 +337,9 @@ class Widget
                        return;
                }
 
-               $cid = $zcid = 0;
+               $zcid = 0;
 
-               if (!empty($_SESSION['remote'])) {
-                       foreach ($_SESSION['remote'] as $visitor) {
-                               if ($visitor['uid'] == $profile_uid) {
-                                       $cid = $visitor['cid'];
-                                       break;
-                               }
-                       }
-               }
+               $cid = remote_user($profile_uid);
 
                if (!$cid) {
                        if (Profile::getMyURL()) {
@@ -432,17 +415,19 @@ class Widget
        {
                $a = \get_app();
 
-               if (!$a->profile['profile_uid'] || !$a->profile['url']) {
+               $uid = intval($a->profile['profile_uid']);
+
+               if (!$uid || !$a->profile['url']) {
                        return '';
                }
 
-               if (Feature::isEnabled($a->profile['profile_uid'], 'tagadelic')) {
+               if (Feature::isEnabled($uid, 'tagadelic')) {
                        $owner_id = Contact::getIdForURL($a->profile['url'], 0, true);
 
                        if (!$owner_id) {
                                return '';
                        }
-                       return Widget\TagCloud::getHTML($a->profile['profile_uid'], $limit, $owner_id, 'wall');
+                       return Widget\TagCloud::getHTML($uid, $limit, $owner_id, 'wall');
                }
 
                return '';