예제 #1
0
 public function show()
 {
     $this->helper('Avatar');
     try {
         if ($this->params()->cache) {
             $this->response()->headers()->add("Cache-Control", "max-age=300");
         }
         $this->cache = $this->params()->cache;
         # temporary
         $this->body_only = (int) $this->params()->body == 1;
         if ($this->params()->md5) {
             if (!($this->post = Post::where(['md5' => strtolower($this->params())])->first())) {
                 throw Rails\ActiveRecord\Exception\RecordNotFoundException();
             }
         } else {
             $this->post = Post::find($this->params()->id);
         }
         $this->pools = Pool::where("pools_posts.post_id = {$this->post->id} AND pools_posts.active")->joins("JOIN pools_posts ON pools_posts.pool_id = pools.id")->order("pools.name")->select("pools.name, pools.id")->take();
         if ($this->params()->pool_id) {
             $this->following_pool_post = PoolPost::where("pool_id = ? AND post_id = ?", $this->params()->pool_id, $this->post->id)->first();
         } else {
             $this->following_pool_post = PoolPost::where("post_id = ?", $this->post->id)->first();
         }
         $this->tags = array('include' => $this->post->tags());
         $this->include_tag_reverse_aliases = true;
         $this->set_title(str_replace('_', ' ', $this->post->title_tags()));
         $this->respondTo(['html']);
     } catch (Rails\ActiveRecord\Exception\RecordNotFoundException $e) {
         $this->respondTo(['html' => function () {
             $this->render(array('action' => 'show_empty', 'status' => 404));
         }]);
     }
 }
예제 #2
0
    ?>

  <?php 
    if ($this->post->has_children) {
        ?>
    <?php 
        $children = $this->post->children;
        $s = $this;
        ?>
    <div class="status-notice">
      <?php 
        echo $this->t(['.parent.has_child_html', 'child' => $this->linkTo($children->size() == 1 ? $this->t('.parent.child') : $this->t('.parent.children'), array('#index', 'tags' => 'parent:' . $this->post->id))]);
        ?>
 (<?php 
        echo $this->t(['.parent.child_post_html', 'child' => implode(', ', array_map(function ($child) {
            return $this->linkTo($child->id, array('#show', 'id' => $child->id));
        }, $children->members()))]);
        ?>
).
    </div>
  <?php 
    }
}
?>

<?php 
foreach ($this->pools as $pool) {
    ?>
  <?php 
    echo $this->partial("post/show_partials/pool", array('pool' => $pool, 'pool_post' => PoolPost::where("pool_id = ? AND post_id = ?", $pool->id, $this->post->id)->first()));
}
예제 #3
0
파일: Pool.php 프로젝트: JCQS04/myimouto
 public function get_sample()
 {
     # By preference, pick the first post (by sequence) in the pool that isn't hidden from
     # the index.
     $pool_post = PoolPost::where("pool_id = ? AND posts.status = 'active' AND pools_posts.active", $this->id)->order("posts.is_shown_in_index DESC, pools_posts.sequence, pools_posts.post_id")->joins("JOIN posts ON posts.id = pools_posts.post_id")->take();
     foreach ($pool_post as $pp) {
         if ($pp->post->can_be_seen_by(current_user())) {
             return $pp->post;
         }
     }
 }