]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Widget.php
Copy functions from include/tags to src
[friendica.git] / src / Content / Widget.php
index e019de9638b3916a4eee8e1edb7824e301039524..c66a4ea9db0bb1c99b06da6d329ca356dd141a36 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
 {
@@ -312,4 +313,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']);
+
+                       if (!$owner_id) {
+                               return '';
+                       }
+                       return Widget\TagCloud::getHTML($a->profile['profile_uid'], $limit, $owner_id, 'wall');
+               }
+
+               return '';
+       }
 }