viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Make rss feeds discoverable via link tags, a=chris

Chris Pollett [2020-08-04 07:Aug:th]
Make rss feeds discoverable via link tags, a=chris
Filename
src/controllers/components/SocialComponent.php
src/views/elements/GroupfeedElement.php
diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php
index 211faf893..da9f21ce6 100644
--- a/src/controllers/components/SocialComponent.php
+++ b/src/controllers/components/SocialComponent.php
@@ -1794,6 +1794,17 @@ class SocialComponent extends Component implements CrawlConstants
             if (empty($thread_start_item) ||
                 empty($thread_start_item["TITLE"])) {
                 $data['NO_POSTS_IN_THREAD'] = true;
+                if ($just_thread < 0) {
+                    $data['SUBTITLE'] = empty($pages[0][self::TITLE]) ?
+                        "" : $pages[0][self::TITLE];
+                    $data["GROUP_ID"] = -$just_thread;
+                    $group = $group_model->getGroupById(
+                        $data["GROUP_ID"], $user_id);
+                    if (!empty($group)) {
+                        $data["GROUP_NAME"] = $group["GROUP_NAME"];
+                        $data['GROUP_STATUS'] = $group['STATUS'];
+                    }
+                }
             } else {
                 $title = $thread_start_item["TITLE"];
                 $data['SUBTITLE'] = trim($title, "\- \t\n\r\0\x0B");
@@ -1853,13 +1864,19 @@ class SocialComponent extends Component implements CrawlConstants
         $this->calculateRecentFeedsAndThread($data, $user_id);
         $data['TOTAL_ROWS'] = $item_count + $groups_count;
         $data['RESULTS_PER_PAGE'] = $results_per_page;
-        $token_string = ($user_id !=  C\PUBLIC_USER_ID )? C\CSRF_TOKEN. "=".
+        $token_string = ($user_id !=  C\PUBLIC_USER_ID )? C\CSRF_TOKEN . "=".
             $this->parent->generateCSRFToken($user_id) : "";
         $data['PAGING_QUERY'] = htmlentities(B\feedsUrl($type, $type_id,
             true, $controller_name));
         $paging_query = $data['PAGING_QUERY'];
+        if (!empty($type)) {
+            $data['RSS_FEED_URL'] = $paging_query . "f=rss";
+        }
         if ($view_mode == 'ungrouped') {
-            $paging_query .= "&v=ungrouped";
+            $connector = (substr($paging_query, -1) == "?") ? "" :
+                "&";
+            $paging_query .= "{$connector}v=ungrouped";
+            $data['RSS_FEED_URL'] = $paging_query . "&f=rss";
         }
         $data['SCRIPT'] .= " let nextPage = initNextResultsPage($limit," .
             " {$data['TOTAL_ROWS']}, $results_per_page, ".
diff --git a/src/views/elements/GroupfeedElement.php b/src/views/elements/GroupfeedElement.php
index 70905f440..8beb1eaf2 100644
--- a/src/views/elements/GroupfeedElement.php
+++ b/src/views/elements/GroupfeedElement.php
@@ -185,8 +185,10 @@ class GroupfeedElement extends Element implements CrawlConstants
             -1 : $data['PAGES'][0]["GROUP_ID"]);
         $is_thread = !empty($data['JUST_THREAD']);
         $is_group = !empty($data['JUST_GROUP_ID']);
+        $is_user = !empty($data['JUST_USER_ID']);
         $is_page_with_comments = ($data['ELEMENT'] == 'wiki');
-        $is_all_feed = !$is_thread && !$is_group && !$is_page_with_comments;
+        $is_all_feed = !$is_thread && !$is_group && !$is_page_with_comments &&
+            !$is_user;
         if ($is_all_feed && !$is_api && !$is_status) {?>
             <h2 class='feed-heading'><?=
             tl('groupfeed_element_combined_feed') ?></h2><?php
@@ -200,15 +202,11 @@ class GroupfeedElement extends Element implements CrawlConstants
                 $this->drawCommentForm($parent_id, $group_id, $data);
             }
         }
-        if (!$is_api && !$is_status && isset($data['NO_POSTS_YET'])) {
+        if (!$is_api && !$is_status && !empty($data['NO_POSTS_YET'])) {
             if (isset($data['NO_POSTS_START_THREAD'])) {
                 //no read case where no posts yet
                 $this->drawStartThreadForm($data['JUST_GROUP_ID'], $data);
             }
-            ?>
-            <div class="button-group-result red medium-font" ><?=
-                tl('groupfeed_element_no_posts_yet') ?></div>
-            <?php
             if ($is_thread && !$is_page_with_comments) {
                 $this->drawCommentForm($parent_id, $group_id, $data);
             }
@@ -224,7 +222,7 @@ class GroupfeedElement extends Element implements CrawlConstants
         if (!$is_api) {?>
             <div class="result-batch" data-time='<?=time() ?>' ><?php
         }
-        if (isset($data['NO_POSTS_IN_THREAD'])) {
+        if (isset($data['NO_POSTS_IN_THREAD']) && $data['JUST_THREAD'] >= 0) {
             ?>
             <div class="button-group-result red medium-font" ><?=
             tl('groupfeed_element_thread_no_exist') ?></div>
@@ -445,7 +443,7 @@ class GroupfeedElement extends Element implements CrawlConstants
                 !$is_page_with_comments && isset($data['GROUP_STATUS']) &&
                 $data['GROUP_STATUS'] == C\ACTIVE_STATUS) {
                 $this->drawCommentForm($data['JUST_THREAD'], $data["GROUP_ID"],
-                $data);
+                    $data);
             }
         }
     }
ViewGit