[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 require ('./bb-load.php'); 3 4 // Determine the type of feed and the id of the object 5 if ( isset($_GET['view']) || bb_get_path() == 'view' ) { 6 7 // View 8 $feed = 'view'; 9 $feed_id = isset($_GET['view']) ? $_GET['view'] : bb_get_path(2); 10 11 } elseif ( isset($_GET['topic']) || bb_get_path() == 'topic' ) { 12 13 // Topic 14 $feed = 'topic'; 15 $topic = get_topic(isset($_GET['topic']) ? $_GET['topic'] : bb_get_path(2)); 16 $feed_id = $topic->topic_id; 17 18 } elseif ( isset($_GET['profile']) || bb_get_path() == 'profile' ) { 19 20 // Profile 21 $feed = 'profile'; 22 $feed_id = isset($_GET['profile']) ? $_GET['profile'] : bb_get_path(2); 23 24 } elseif ( isset($_GET['tag']) || bb_get_path() == 'tags' ) { 25 26 if ( isset($_GET['topics']) || bb_get_path(3) == 'topics' ) { 27 // Tag recent topics 28 $feed = 'tag-topics'; 29 } else { 30 // Tag recent posts 31 $feed = 'tag-posts'; 32 } 33 $feed_id = isset($_GET['tag']) ? $_GET['tag'] : bb_get_path(2); 34 35 } elseif ( isset($_GET['forum']) || bb_get_path() == 'forum' ) { 36 37 if ( isset($_GET['topics']) || bb_get_path(3) == 'topics' ) { 38 // Forum recent topics 39 $feed = 'forum-topics'; 40 } else { 41 // Forum recent posts 42 $feed = 'forum-posts'; 43 } 44 $forum = bb_get_forum(isset($_GET['forum']) ? $_GET['forum'] : bb_get_path(2)); 45 $feed_id = $forum->forum_id; 46 47 } elseif ( isset($_GET['topics']) || bb_get_path() == 'topics' ) { 48 49 // Recent topics 50 $feed = 'all-topics'; 51 52 } else { 53 54 // Recent posts 55 $feed = 'all-posts'; 56 57 } 58 59 // Initialise the override variable 60 $bb_db_override = false; 61 do_action( 'bb_rss.php_pre_db' ); 62 63 if ( !$bb_db_override ) { 64 65 // Get the posts and the title for the given feed 66 switch ($feed) { 67 case 'view': 68 if ( !isset($bb_views[$feed_id]) ) 69 die(); 70 if ( !$bb_views[$feed_id]['feed'] ) 71 die(); 72 if ( !$topics_object = new BB_Query( 'topic', $bb_views[$feed_id]['query'], "bb_view_$feed_id" ) ) 73 die(); 74 75 $topics = $topics_object->results; 76 77 $posts = array(); 78 foreach ( (array) $topics as $topic ) { 79 $posts[] = bb_get_first_post($topic->topic_id); 80 } 81 82 $title = sprintf( __( '%1$s » View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] ); 83 $link = get_view_link($feed_id); 84 $link_self = bb_get_view_rss_link($feed_id); 85 break; 86 87 case 'topic': 88 if ( !$topic = get_topic ( $feed_id ) ) 89 die(); 90 if ( !$posts = get_thread( $feed_id, 0, 1 ) ) 91 die(); /* Should die here, as the topic posts aren't there, so the topic is most probably deleted/empty */ 92 $title = sprintf( __( '%1$s » Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() ); 93 $link = get_topic_link($feed_id); 94 $link_self = get_topic_rss_link($feed_id); 95 break; 96 97 case 'profile': 98 if ( bb_get_option( 'mod_rewrite' ) === 'slugs') { 99 if ( !$user = bb_get_user_by_nicename( $feed_id ) ) 100 $user = bb_get_user( $feed_id ); 101 } else { 102 if ( !$user = bb_get_user( $feed_id ) ) 103 $user = bb_get_user_by_nicename( $feed_id ); 104 } 105 if ( !$user ) { 106 die(); 107 } 108 $posts = get_user_favorites( $user->ID ); 109 110 $title = sprintf( __( '%1$s » User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename ); 111 $link = get_user_profile_link($feed_id); 112 $link_self = get_favorites_rss_link($feed_id); 113 break; 114 115 case 'tag-topics': 116 if ( !$tag = bb_get_tag( $feed_id ) ) 117 die(); 118 $topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ); 119 120 $posts = array(); 121 foreach ( (array) $topics as $topic ) { 122 $posts[] = bb_get_first_post($topic->topic_id); 123 } 124 125 $title = sprintf( __( '%1$s » Tag: %2$s - Recent Topics' ), bb_get_option( 'name' ), bb_get_tag_name() ); 126 $link = bb_get_tag_link($feed_id); 127 $link_self = bb_get_tag_topics_rss_link($feed_id); 128 break; 129 130 case 'tag-posts': 131 if ( !$tag = bb_get_tag( $feed_id ) ) 132 die(); 133 $posts = get_tagged_topic_posts( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ); 134 $title = sprintf( __( '%1$s » Tag: %2$s - Recent Posts' ), bb_get_option( 'name' ), bb_get_tag_name() ); 135 $link = bb_get_tag_link($feed_id); 136 $link_self = bb_get_tag_posts_rss_link($feed_id); 137 break; 138 139 case 'forum-topics': 140 $topics = get_latest_topics( $feed_id ); 141 142 $posts = array(); 143 foreach ( (array) $topics as $topic) { 144 $posts[] = bb_get_first_post($topic->topic_id); 145 } 146 147 $title = sprintf( __( '%1$s » Forum: %2$s - Recent Topics' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ); 148 $link = get_forum_link($feed_id); 149 $link_self = bb_get_forum_topics_rss_link($feed_id); 150 break; 151 152 case 'forum-posts': 153 $posts = bb_get_latest_forum_posts( $feed_id ); 154 $title = sprintf( __( '%1$s » Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ); 155 $link = get_forum_link($feed_id); 156 $link_self = bb_get_forum_posts_rss_link($feed_id); 157 break; 158 159 // Get just the first post from the latest topics 160 case 'all-topics': 161 $topics = get_latest_topics(); 162 163 $posts = array(); 164 foreach ( (array) $topics as $topic ) { 165 $posts[] = bb_get_first_post($topic->topic_id); 166 } 167 168 $title = sprintf( __( '%1$s » Recent Topics' ), bb_get_option( 'name' ) ); 169 $link = bb_get_uri(); 170 $link_self = bb_get_topics_rss_link(); 171 break; 172 173 // Get latest posts by default 174 case 'all-posts': 175 default: 176 $posts = bb_get_latest_posts( 35 ); 177 $title = sprintf( __( '%1$s » Recent Posts' ), bb_get_option( 'name' ) ); 178 $link = bb_get_uri(); 179 $link_self = bb_get_posts_rss_link(); 180 break; 181 } 182 } 183 184 if ( !$posts ) /* We do typecasting in the template, but all themes don't have that! */ 185 $posts = array(); 186 else /* Only send 304 if there are posts */ 187 bb_send_304( gmdate('D, d M Y H:i:s \G\M\T', strtotime( $posts[0]->post_time ) ) ); 188 189 if (!$description = bb_get_option( 'description' ) ) { 190 $description = $title; 191 } 192 $title = apply_filters( 'bb_title_rss', $title, $feed ); 193 $description = apply_filters( 'bb_description_rss', $description, $feed ); 194 $posts = apply_filters( 'bb_posts_rss', $posts, $feed ); 195 $link_self = apply_filters( 'bb_link_self_rss', $link_self, $feed ); 196 197 bb_load_template( 'rss2.php', array('bb_db_override', 'title', 'description', 'link', 'link_self'), $feed ); 198
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 7 01:01:35 2017 | Cross-referenced by PHPXref 0.7.1 |