Changeset 9537 for trunk/src/bp-activity/bp-activity-template.php
- Timestamp:
- 02/23/2015 06:41:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-template.php
r9536 r9537 240 240 * } 241 241 */ 242 function __construct( $args ) {242 public function __construct( $args ) { 243 243 $bp = buddypress(); 244 244 … … 367 367 // Fetch parent content for activity comments so we do not have to query in the loop 368 368 foreach ( (array) $this->activities as $activity ) { 369 if ( 'activity_comment' != $activity->type ) 369 if ( 'activity_comment' != $activity->type ) { 370 370 continue; 371 } 371 372 372 373 $parent_ids[] = $activity->item_id; 373 374 } 374 375 375 if ( !empty( $parent_ids ) ) 376 if ( !empty( $parent_ids ) ) { 376 377 $activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) ); 378 } 377 379 378 380 if ( !empty( $activity_parents['activities'] ) ) { 379 foreach( $activity_parents['activities'] as $parent ) 381 foreach( $activity_parents['activities'] as $parent ) { 380 382 $this->activity_parents[$parent->id] = $parent; 383 } 381 384 382 385 unset( $activity_parents ); … … 405 408 */ 406 409 function has_activities() { 407 if ( $this->activity_count ) 410 if ( $this->activity_count ) { 408 411 return true; 412 } 409 413 410 414 return false; … … 416 420 * @return object The next activity item to iterate over. 417 421 */ 418 function next_activity() {422 public function next_activity() { 419 423 $this->current_activity++; 420 $this->activity = $this->activities[ $this->current_activity];424 $this->activity = $this->activities[ $this->current_activity ]; 421 425 422 426 return $this->activity; … … 426 430 * Rewind the posts and reset post index. 427 431 */ 428 function rewind_activities() {432 public function rewind_activities() { 429 433 $this->current_activity = -1; 430 434 if ( $this->activity_count > 0 ) { … … 445 449 * otherwise false. 446 450 */ 447 function user_activities() {448 if ( $this->current_activity + 1< $this->activity_count ) {451 public function user_activities() { 452 if ( ( $this->current_activity + 1 ) < $this->activity_count ) { 449 453 return true; 450 } elseif ( $this->current_activity + 1== $this->activity_count ) {454 } elseif ( ( $this->current_activity + 1 ) == $this->activity_count ) { 451 455 452 456 /** … … 456 460 */ 457 461 do_action( 'activity_loop_end' ); 462 458 463 // Do some cleaning up after the loop 459 464 $this->rewind_activities(); … … 461 466 462 467 $this->in_the_loop = false; 468 463 469 return false; 464 470 } … … 473 479 * @see bp_the_activity() 474 480 */ 475 function the_activity() {481 public function the_activity() { 476 482 477 483 $this->in_the_loop = true; 478 484 $this->activity = $this->next_activity(); 479 485 480 if ( is_array( $this->activity ) ) 486 if ( is_array( $this->activity ) ) { 481 487 $this->activity = (object) $this->activity; 482 483 if ( $this->current_activity == 0 ) { // loop has just started 488 } 489 490 // loop has just started 491 if ( $this->current_activity == 0 ) { 484 492 485 493 /** … … 1505 1513 1506 1514 // If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it. 1507 if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) 1515 if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) { 1508 1516 $email = $current_activity_item->user_email; 1517 } 1509 1518 1510 1519 /** … … 1745 1754 global $activities_template; 1746 1755 1747 $ defaults =array(1756 $args = wp_parse_args( $args, array( 1748 1757 'no_timestamp' => false, 1749 ); 1750 1751 $args = wp_parse_args( $args, $defaults ); 1752 extract( $args, EXTR_SKIP ); 1758 ) ); 1753 1759 1754 1760 $action = $activities_template->activity->action; … … 1763 1769 $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array( $action, &$activities_template->activity, $args ) ); 1764 1770 1765 if ( ! empty( $action ) && ! $no_timestamp )1771 if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) { 1766 1772 $action = bp_insert_activity_meta( $action ); 1773 } 1767 1774 1768 1775 /** … … 1802 1809 1803 1810 // Backwards compatibility if action is not being used 1804 if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) )1811 if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) { 1805 1812 $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content ); 1813 } 1806 1814 1807 1815 /** … … 1827 1835 global $activities_template; 1828 1836 1829 if ( ! empty( $activities_template->activity->content ) )1837 if ( ! empty( $activities_template->activity->content ) ) { 1830 1838 return true; 1839 } 1831 1840 1832 1841 return false; … … 2012 2021 * 2013 2022 * @global object $activities_template {@link BP_Activity_Template} 2014 * @uses wp_parse_args()2015 2023 * @uses apply_filters() To call the 'bp_get_activity_parent_content' hook. 2016 2024 * 2017 * @param array $args { 2018 * Array of optional arguments. 2019 * @deprecated bool $hide_user No longer used. 2020 * } 2025 * @param string $args Unused. Left over from an earlier implementation. 2026 * 2021 2027 * @return mixed False on failure, otherwise the activity parent content 2022 2028 */ … … 2024 2030 global $activities_template; 2025 2031 2026 $defaults = array( 2027 'hide_user' => false 2028 ); 2029 2030 $r = wp_parse_args( $args, $defaults ); 2031 extract( $r, EXTR_SKIP ); 2032 // Bail if no activity on no item ID 2033 if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) { 2034 return false; 2035 } 2032 2036 2033 2037 // Get the ID of the parent activity content 2034 if ( !$parent_id = $activities_template->activity->item_id ) 2038 $parent_id = (int) $activities_template->activity->item_id; 2039 2040 // Bail if no parent content 2041 if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) { 2035 2042 return false; 2036 2037 // Bail if no parent content 2038 if ( empty( $activities_template->activity_parents[$parent_id] ) ) 2043 } 2044 2045 // Bail if no action 2046 if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) { 2039 2047 return false; 2040 2041 // Bail if no action 2042 if ( empty( $activities_template->activity_parents[$parent_id]->action ) ) 2043 return false; 2048 } 2044 2049 2045 2050 // Content always includes action 2046 $content = $activities_template->activity_parents[ $parent_id]->action;2051 $content = $activities_template->activity_parents[ $parent_id ]->action; 2047 2052 2048 2053 // Maybe append activity content, if it exists 2049 if ( ! empty( $activities_template->activity_parents[$parent_id]->content ) ) 2050 $content .= ' ' . $activities_template->activity_parents[$parent_id]->content; 2054 if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) { 2055 $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content; 2056 } 2051 2057 2052 2058 // Remove the time since content for backwards compatibility … … 2089 2095 2090 2096 // Bail if no activity on no item ID 2091 if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) 2097 if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) { 2092 2098 return false; 2099 } 2093 2100 2094 2101 // Get the ID of the parent activity content 2095 if ( !$parent_id = $activities_template->activity->item_id ) 2102 $parent_id = (int) $activities_template->activity->item_id; 2103 2104 // Bail if no parent item 2105 if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) { 2096 2106 return false; 2097 2098 // Bail if no parent item 2099 if ( empty( $activities_template->activity_parents[$parent_id] ) ) 2107 } 2108 2109 // Bail if no parent user ID 2110 if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) { 2100 2111 return false; 2101 2102 // Bail if no parent user ID 2103 if ( empty( $activities_template->activity_parents[$parent_id]->user_id ) ) 2104 return false; 2105 2106 $retval = $activities_template->activity_parents[$parent_id]->user_id; 2112 } 2113 2114 $retval = $activities_template->activity_parents[ $parent_id ]->user_id; 2107 2115 2108 2116 /** … … 2157 2165 * @todo deprecate $args param 2158 2166 * 2159 * @param string $args Unused. Appears to be left over from an earlier implementation.2167 * @param array $args See {@link bp_activity_get_comments} for description. 2160 2168 */ 2161 2169 function bp_activity_comments( $args = '' ) { … … 2173 2181 * this function can probably be streamlined or removed. 2174 2182 * 2175 * @param string $args Unused. Appears to be left over from an earlier implementation.2183 * @param string $args Unused. Left over from an earlier implementation. 2176 2184 * 2177 2185 * @global object $activities_template {@link BP_Activity_Template} … … 2181 2189 global $activities_template; 2182 2190 2183 if ( !isset( $activities_template->activity->children ) || !$activities_template->activity->children )2191 if ( empty( $activities_template->activity->children ) ) { 2184 2192 return false; 2193 } 2185 2194 2186 2195 bp_activity_recurse_comments( $activities_template->activity ); … … 2203 2212 global $activities_template; 2204 2213 2205 if ( empty( $comment ) ) 2214 if ( empty( $comment ) ) { 2206 2215 return false; 2207 2208 if ( empty( $comment->children ) ) 2216 } 2217 2218 if ( empty( $comment->children ) ) { 2209 2219 return false; 2220 } 2210 2221 2211 2222 /** … … 2216 2227 * @param string $value Opening tag for the HTML markup to use. 2217 2228 */ 2218 echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );2229 echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' ); 2219 2230 foreach ( (array) $comment->children as $comment_child ) { 2231 2220 2232 // Put the comment into the global so it's available to filters 2221 2233 $activities_template->activity->current_comment = $comment_child; … … 2243 2255 * @param string $value Closing tag for the HTML markup to use. 2244 2256 */ 2245 echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>' );2257 echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>' ); 2246 2258 } 2247 2259 … … 2455 2467 global $activities_template; 2456 2468 2457 if ( empty( $activities_template->activity->current_comment->date_recorded ) ) 2469 if ( empty( $activities_template->activity->current_comment->date_recorded ) ) { 2458 2470 return false; 2471 } 2459 2472 2460 2473 $date_recorded = bp_core_time_since( $activities_template->activity->current_comment->date_recorded ); … … 2724 2737 function bp_get_activity_comment_form_nojs_display() { 2725 2738 global $activities_template; 2726 if ( isset( $_GET['ac'] ) && $_GET['ac'] == $activities_template->activity->id . '/' ) 2739 2740 if ( isset( $_GET['ac'] ) && ( $_GET['ac'] === ( $activities_template->activity->id . '/' ) ) ) { 2727 2741 return 'style="display: block"'; 2742 } 2728 2743 2729 2744 return false; … … 2998 3013 $class = ' activity-item'; 2999 3014 3000 if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) ) 3015 if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) ) { 3001 3016 $class .= ' mini'; 3002 3003 if ( bp_activity_get_comment_count() && bp_activity_can_comment() ) 3017 } 3018 3019 if ( bp_activity_get_comment_count() && bp_activity_can_comment() ) { 3004 3020 $class .= ' has-comments'; 3021 } 3005 3022 3006 3023 /** … … 3149 3166 function bp_get_activity_latest_update( $user_id = 0 ) { 3150 3167 3151 if ( empty( $user_id ) ) 3168 if ( empty( $user_id ) ) { 3152 3169 $user_id = bp_displayed_user_id(); 3153 3154 if ( bp_is_user_inactive( $user_id ) ) 3170 } 3171 3172 if ( bp_is_user_inactive( $user_id ) ) { 3155 3173 return false; 3156 3157 if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) 3174 } 3175 3176 if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) { 3158 3177 return false; 3178 } 3159 3179 3160 3180 /** … … 3220 3240 function bp_get_activity_filter_links( $args = false ) { 3221 3241 3222 $ defaults =array(3242 $r = wp_parse_args( $args, array( 3223 3243 'style' => 'list' 3224 ); 3225 3226 $r = wp_parse_args( $args, $defaults ); 3227 extract( $r, EXTR_SKIP ); 3244 ) ); 3228 3245 3229 3246 // Define local variable … … 3233 3250 $components = BP_Activity_Activity::get_recorded_components(); 3234 3251 3235 if ( empty( $components ) ) 3252 if ( empty( $components ) ) { 3236 3253 return false; 3254 } 3237 3255 3238 3256 foreach ( (array) $components as $component ) { 3239 3257 3240 3258 // Skip the activity comment filter 3241 if ( 'activity' == $component ) 3259 if ( 'activity' == $component ) { 3242 3260 continue; 3243 3244 if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) 3261 } 3262 3263 if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) { 3245 3264 $selected = ' class="selected"'; 3246 else 3247 unset($selected); 3265 } else { 3266 $selected = ''; 3267 } 3248 3268 3249 3269 $component = esc_attr( $component ); 3250 3270 3251 switch ( $ style) {3271 switch ( $r['style'] ) { 3252 3272 case 'list': 3253 3273 $tag = 'li'; … … 3285 3305 $link = remove_query_arg( 'afilter' , $link ); 3286 3306 3287 if ( isset( $_GET['afilter'] ) ) 3307 if ( isset( $_GET['afilter'] ) ) { 3288 3308 $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>'; 3309 } 3289 3310 3290 3311 /**
Note: See TracChangeset
for help on using the changeset viewer.