当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_Activity_Activity::generate_action_strings方法代码示例

本文整理汇总了PHP中BP_Activity_Activity::generate_action_strings方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Activity_Activity::generate_action_strings方法的具体用法?PHP BP_Activity_Activity::generate_action_strings怎么用?PHP BP_Activity_Activity::generate_action_strings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Activity_Activity的用法示例。


在下文中一共展示了BP_Activity_Activity::generate_action_strings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get


//.........这里部分代码省略.........
      *
      * @param bool                 $value Whether to use legacy structure or not.
      * @param BP_Activity_Activity $value Current method being called.
      * @param array                $r     Parsed arguments passed into method.
      */
     if (apply_filters('bp_use_legacy_activity_query', false, __METHOD__, $r)) {
         // Legacy queries joined against the user table.
         $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
         $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
         if (!empty($page) && !empty($per_page)) {
             $pag_sql = $wpdb->prepare("LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page);
             /** This filter is documented in bp-activity/bp-activity-classes.php */
             $activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
         } else {
             $pag_sql = '';
             /**
              * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
              *
              * @since 1.5.0
              *
              * @param string $value      Concatenated MySQL statement pieces to be query results with for legacy query.
              * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
              * @param string $from_sql   Final FROM MySQL statement portion for legacy query.
              * @param string $where_sql  Final WHERE MySQL statement portion for legacy query.
              * @param string $sort       Final sort direction for legacy query.
              */
             $activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
         }
     } else {
         // Query first for activity IDs.
         $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
         if (!empty($per_page) && !empty($page)) {
             // We query for $per_page + 1 items in order to
             // populate the has_more_items flag.
             $activity_ids_sql .= $wpdb->prepare(" LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page + 1);
         }
         /**
          * Filters the paged activities MySQL statement.
          *
          * @since 2.0.0
          *
          * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
          * @param array  $r                Array of arguments passed into method.
          */
         $activity_ids_sql = apply_filters('bp_activity_paged_activities_sql', $activity_ids_sql, $r);
         $activity_ids = $wpdb->get_col($activity_ids_sql);
         $retval['has_more_items'] = !empty($per_page) && count($activity_ids) > $per_page;
         // If we've fetched more than the $per_page value, we
         // can discard the extra now.
         if (!empty($per_page) && count($activity_ids) === $per_page + 1) {
             array_pop($activity_ids);
         }
         if ('ids' === $r['fields']) {
             $activities = array_map('intval', $activity_ids);
         } else {
             $activities = self::get_activity_data($activity_ids);
         }
     }
     if ('ids' !== $r['fields']) {
         // Get the fullnames of users so we don't have to query in the loop.
         $activities = self::append_user_fullnames($activities);
         // Get activity meta.
         $activity_ids = array();
         foreach ((array) $activities as $activity) {
             $activity_ids[] = $activity->id;
         }
         if (!empty($activity_ids) && $r['update_meta_cache']) {
             bp_activity_update_meta_cache($activity_ids);
         }
         if ($activities && $r['display_comments']) {
             $activities = BP_Activity_Activity::append_comments($activities, $r['spam']);
         }
         // Pre-fetch data associated with activity users and other objects.
         BP_Activity_Activity::prefetch_object_data($activities);
         // Generate action strings.
         $activities = BP_Activity_Activity::generate_action_strings($activities);
     }
     $retval['activities'] = $activities;
     // If $max is set, only return up to the max results.
     if (!empty($r['count_total'])) {
         /**
          * Filters the total activities MySQL statement.
          *
          * @since 1.5.0
          *
          * @param string $value     MySQL statement used to query for total activities.
          * @param string $where_sql MySQL WHERE statement portion.
          * @param string $sort      Sort direction for query.
          */
         $total_activities_sql = apply_filters('bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort);
         $total_activities = $wpdb->get_var($total_activities_sql);
         if (!empty($r['max'])) {
             if ((int) $total_activities > (int) $r['max']) {
                 $total_activities = $r['max'];
             }
         }
         $retval['total'] = $total_activities;
     }
     return $retval;
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:class-bp-activity-activity.php

示例2: get


//.........这里部分代码省略.........
     // the activity.
     if (false === $display_comments || 'threaded' === $display_comments) {
         $excluded_types[] = 'activity_comment';
     }
     // Exclude 'last_activity' items unless the 'action' filter has
     // been explicitly set
     if (empty($filter['object'])) {
         $excluded_types[] = 'last_activity';
     }
     // Exclude 'new_member' items if xprofile component is not active
     if (!bp_is_active('xprofile')) {
         $excluded_types[] = 'new_member';
     }
     // Build the excluded type sql part
     if (!empty($excluded_types)) {
         $not_in = "'" . implode("', '", esc_sql($excluded_types)) . "'";
         $where_conditions['excluded_types'] = "a.type NOT IN ({$not_in})";
     }
     // Filter the where conditions
     $where_conditions = apply_filters('bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql);
     // Join the where conditions together
     $where_sql = 'WHERE ' . join(' AND ', $where_conditions);
     // Define the preferred order for indexes
     $indexes = apply_filters('bp_activity_preferred_index_order', array('user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam'));
     foreach ($indexes as $key => $index) {
         if (false !== strpos($where_sql, $index)) {
             $the_index = $index;
             break;
             // Take the first one we find
         }
     }
     if (!empty($the_index)) {
         $index_hint_sql = "USE INDEX ({$the_index})";
     } else {
         $index_hint_sql = '';
     }
     // Sanitize page and per_page parameters
     $page = absint($page);
     $per_page = absint($per_page);
     $retval = array('activities' => null, 'total' => null, 'has_more_items' => null);
     // Filter and return true to use the legacy query structure (not recommended)
     if (apply_filters('bp_use_legacy_activity_query', false, __METHOD__, $r)) {
         // Legacy queries joined against the user table
         $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
         $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
         if (!empty($page) && !empty($per_page)) {
             $pag_sql = $wpdb->prepare("LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page);
             $activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql));
         } else {
             $activities = $wpdb->get_results(apply_filters('bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort));
         }
     } else {
         // Query first for activity IDs
         $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
         if (!empty($per_page) && !empty($page)) {
             // We query for $per_page + 1 items in order to
             // populate the has_more_items flag
             $activity_ids_sql .= $wpdb->prepare(" LIMIT %d, %d", absint(($page - 1) * $per_page), $per_page + 1);
         }
         $activity_ids_sql = apply_filters('bp_activity_paged_activities_sql', $activity_ids_sql, $r);
         $activity_ids = $wpdb->get_col($activity_ids_sql);
         $retval['has_more_items'] = !empty($per_page) && count($activity_ids) > $per_page;
         // If we've fetched more than the $per_page value, we
         // can discard the extra now
         if (!empty($per_page) && count($activity_ids) === $per_page + 1) {
             array_pop($activity_ids);
         }
         $activities = self::get_activity_data($activity_ids);
     }
     // Get the fullnames of users so we don't have to query in the loop
     $activities = self::append_user_fullnames($activities);
     // Get activity meta
     $activity_ids = array();
     foreach ((array) $activities as $activity) {
         $activity_ids[] = $activity->id;
     }
     if (!empty($activity_ids) && $update_meta_cache) {
         bp_activity_update_meta_cache($activity_ids);
     }
     if ($activities && $display_comments) {
         $activities = BP_Activity_Activity::append_comments($activities, $spam);
     }
     // Pre-fetch data associated with activity users and other objects
     BP_Activity_Activity::prefetch_object_data($activities);
     // Generate action strings
     $activities = BP_Activity_Activity::generate_action_strings($activities);
     $retval['activities'] = $activities;
     // If $max is set, only return up to the max results
     if (!empty($r['count_total'])) {
         $total_activities_sql = apply_filters('bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort);
         $total_activities = $wpdb->get_var($total_activities_sql);
         if (!empty($max)) {
             if ((int) $total_activities > (int) $max) {
                 $total_activities = $max;
             }
         }
         $retval['total'] = $total_activities;
     }
     return $retval;
 }
开发者ID:eresyyl,项目名称:mk,代码行数:101,代码来源:bp-activity-classes.php


注:本文中的BP_Activity_Activity::generate_action_strings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。