]> git.mxchange.org Git - friendica.git/commitdiff
tags: possibility to filter posts for tags and profile owner (profile)
authorrabuzarus <>
Wed, 22 Nov 2017 23:59:20 +0000 (00:59 +0100)
committerrabuzarus <>
Wed, 22 Nov 2017 23:59:20 +0000 (00:59 +0100)
include/tags.php
mod/profile.php
view/templates/tagblock_widget.tpl

index fb3315441c1336807e40f4e58fb6b22a1f7930e6..8a6b3ba7468a8ef5efc908f81e71c79477cd2337 100644 (file)
@@ -151,7 +151,7 @@ function update_items() {
        dba::close($messages);
 }
 
-function tagadelic($uid, $count = 0, $owner = 0, $flags = 0, $type = TERM_HASHTAG) {
+function tagadelic($uid, $count = 0, $owner_id = 0, $flags = 0, $type = TERM_HASHTAG) {
        require_once('include/security.php');
 
        $item_condition = item_condition();
@@ -163,8 +163,8 @@ function tagadelic($uid, $count = 0, $owner = 0, $flags = 0, $type = TERM_HASHTA
                }
        }
 
-       if ($owner) {
-               $sql_options .= " AND `item`.`owner-id` = ".intval($owner)." ";
+       if ($owner_id) {
+               $sql_options .= " AND `item`.`owner-id` = ".intval($owner_id)." ";
        }
 
        // Fetch tags
@@ -186,13 +186,21 @@ function tagadelic($uid, $count = 0, $owner = 0, $flags = 0, $type = TERM_HASHTA
        return tag_calc($r);
 }
 
-function wtagblock($uid, $count = 0,$owner = 0, $flags = 0, $type = TERM_HASHTAG) {
+function wtagblock($uid, $count = 0,$owner_id = 0, $flags = 0, $type = TERM_HASHTAG) {
        $o = '';
-       $r = tagadelic($uid, $count, $owner, $flags, $type);
-       if($r) {
+       $r = tagadelic($uid, $count, $owner_id, $flags, $type);
+       if($r && $owner_id) {
+               $contact = dba::select(
+                       "contact",
+                       array("url"),
+                       array("id" => $owner_id),
+                       array("limit" => 1)
+               );
+               $url = System::removedBaseUrl($contact['url']);
+
                foreach ($r as $rr) {
                        $tag['level'] = $rr[2];
-                       $tag['url'] = urlencode($rr[0]);
+                       $tag['url'] = $url."?tag=".urlencode($rr[0]);
                        $tag['name'] = $rr[0];
 
                        $tags[] = $tag;
index 9ad24ccd1779d2f8c155e54da11ee5141e6b8c0c..59835bd4cbf5b3bf85b78818b7f1809c41de0363 100644 (file)
@@ -98,6 +98,8 @@ function profile_content(App $a, $update = 0) {
                $category = ((x($_GET,'category')) ? $_GET['category'] : '');
        }
 
+       $hashtags = (x($_GET, 'tag') ? $_GET['tag'] : '');
+
        if (Config::get('system','block_public') && (! local_user()) && (! remote_user())) {
                return login();
        }
@@ -255,6 +257,11 @@ function profile_content(App $a, $update = 0) {
                        //$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
                }
 
+               if (x($hashtags)) {
+                       $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
+                               dbesc(protect_sprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['profile_uid']));
+               }
+
                if ($datequery) {
                        $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
                }
index 602d762aa534dc75b2d92f5eaa7ba464548a6211..114d32290bc4c1dee73147f886d8c0b529a60121 100644 (file)
@@ -5,7 +5,7 @@
        <div class="tag-cloud">
                {{foreach $tags as $tag}}
                <span class="tags">
-                       <span class="tag{{$tag.level}}">#</span><a href="search?f=&tag={{$tag.url}}" class="tag{{$tag.level}}">{{$tag.name}}</a>
+                       <span class="tag{{$tag.level}}">#</span><a href="{{$tag.url}}" class="tag{{$tag.level}}">{{$tag.name}}</a>
                </span>
                {{/foreach}}
        </div>