]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Widget.php
Add support for legacy $lang config in App->loadConfig
[friendica.git] / src / Content / Widget.php
index e019de9638b3916a4eee8e1edb7824e301039524..ba575201244205548276e11d591bb197c64b22d3 100644 (file)
@@ -12,12 +12,13 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Model\Profile;
-
 use dba;
 
 require_once 'boot.php';
+require_once 'include/dba.php';
 
 class Widget
 {
@@ -50,23 +51,28 @@ class Widget
                        if ($x || is_site_admin()) {
                                $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
                                        . L10n::tt('%d invitation available', '%d invitations available', $x)
-                                       . '</div>' . $inv;
+                                       . '</div>';
                        }
                }
 
-               return replace_macros(get_markup_template('peoplefind.tpl'), array(
-                       '$findpeople' => L10n::t('Find People'),
-                       '$desc' => L10n::t('Enter name or interest'),
-                       '$label' => L10n::t('Connect/Follow'),
-                       '$hint' => L10n::t('Examples: Robert Morgenstein, Fishing'),
-                       '$findthem' => L10n::t('Find'),
-                       '$suggest' => L10n::t('Friend Suggestions'),
-                       '$similar' => L10n::t('Similar Interests'),
-                       '$random' => L10n::t('Random Profile'),
-                       '$inv' => L10n::t('Invite Friends'),
-                       '$directory' => L10n::t('View Global Directory'),
-                       '$global_dir' => $global_dir
-               ));
+               $nv = [];
+               $nv['findpeople'] = L10n::t('Find People');
+               $nv['desc'] = L10n::t('Enter name or interest');
+               $nv['label'] = L10n::t('Connect/Follow');
+               $nv['hint'] = L10n::t('Examples: Robert Morgenstein, Fishing');
+               $nv['findthem'] = L10n::t('Find');
+               $nv['suggest'] = L10n::t('Friend Suggestions');
+               $nv['similar'] = L10n::t('Similar Interests');
+               $nv['random'] = L10n::t('Random Profile');
+               $nv['inv'] = L10n::t('Invite Friends');
+               $nv['directory'] = L10n::t('Global Directory');
+               $nv['global_dir'] = $global_dir;
+               $nv['local_directory'] = L10n::t('Local Directory');
+
+               $aside = [];
+               $aside['$nv'] = $nv;
+
+               return replace_macros(get_markup_template('peoplefind.tpl'), $aside);
        }
 
        /**
@@ -258,7 +264,7 @@ class Widget
 
                $cid = $zcid = 0;
 
-               if (is_array($_SESSION['remote'])) {
+               if (!empty($_SESSION['remote'])) {
                        foreach ($_SESSION['remote'] as $visitor) {
                                if ($visitor['uid'] == $profile_uid) {
                                        $cid = $visitor['cid'];
@@ -312,4 +318,31 @@ class Widget
                        '$items' => $r)
                );
        }
+
+       /**
+        * Insert a tag cloud widget for the present profile.
+        *
+        * @brief Insert a tag cloud widget for the present profile.
+        * @param int     $limit Max number of displayed tags.
+        * @return string HTML formatted output.
+        */
+       public static function tagCloud($limit = 50)
+       {
+               $a = get_app();
+
+               if (!$a->profile['profile_uid'] || !$a->profile['url']) {
+                       return '';
+               }
+
+               if (Feature::isEnabled($a->profile['profile_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 '';
+       }
 }