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


PHP Pool::get_pool_posts_from_posts方法代码示例

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


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

示例1: batch_api_data

 /**
  * MI: Accept "fake_sample_url" option, passed only in
  * post#index. It will set a flag that will be read by PostFileMethods::sample_url()
  */
 public static function batch_api_data(array $posts, $options = array())
 {
     self::$create_fake_sample_url = !empty($options['fake_sample_url']);
     foreach ($posts as $post) {
         $result['posts'][] = $post->api_attributes();
     }
     if (empty($options['exclude_pools'])) {
         $result['pools'] = $result['pool_posts'] = [];
         $pool_posts = Pool::get_pool_posts_from_posts($posts);
         $pools = Pool::get_pools_from_pool_posts($pool_posts);
         foreach ($pools as $p) {
             $result['pools'][] = $p->api_attributes();
         }
         foreach ($pool_posts as $pp) {
             $result['pool_posts'][] = $pp->api_attributes();
         }
     }
     if (empty($options['exclude_tags'])) {
         $result['tags'] = Tag::batch_get_tag_types_for_posts($posts);
     }
     if (!empty($options['user'])) {
         $user = $options['user'];
     } else {
         $user = current_user();
     }
     # Allow loading votes along with the posts.
     #
     # The post data is cachable and vote data isn't, so keep this data separate from the
     # main post data to make it easier to cache API output later.
     if (empty($options['exclude_votes'])) {
         $vote_map = array();
         if ($posts) {
             $post_ids = array();
             foreach ($posts as $p) {
                 $post_ids[] = $p->id;
             }
             if ($post_ids) {
                 $post_ids = implode(',', $post_ids);
                 $sql = sprintf("SELECT v.* FROM post_votes v WHERE v.user_id = %d AND v.post_id IN (%s)", $user->id, $post_ids);
                 $votes = PostVote::findBySql($sql);
                 foreach ($votes as $v) {
                     $vote_map[$v->post_id] = $v->score;
                 }
             }
         }
         $result['votes'] = $vote_map;
     }
     self::$create_fake_sample_url = false;
     return $result;
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:54,代码来源:ApiMethods.php


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