Fixed #112.
This commit is contained in:
parent
57a89bc76c
commit
4f8a3a8c2b
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
class AvatarHelper extends Rails\ActionView\Helper
|
||||
{
|
||||
protected $avatar_posts_registry = [];
|
||||
|
||||
# id is an identifier for the object referencing this avatar; it's passed down
|
||||
# to the javascripts to implement blacklisting "click again to open".
|
||||
public function avatar(User $user, $id, array $html_options = array())
|
||||
@ -11,29 +13,28 @@ class AvatarHelper extends Rails\ActionView\Helper
|
||||
#if not @shown_avatars[user] then
|
||||
$shown_avatars[$user->id] = true;
|
||||
$posts_to_send[] = $user->avatar_post;
|
||||
$this->avatar_posts_registry[] = $user->avatar_post;
|
||||
$img = $this->imageTag($user->avatar_url() . "?" . strtotime($user->avatar_timestamp),
|
||||
array_merge(array('class' => "avatar", 'width' => $user->avatar_width, 'height' => $user->avatar_height), $html_options));
|
||||
return $this->linkTo($img,
|
||||
array("post#show", 'id' => $user->avatar_post->id),
|
||||
array('class' => "ca" . $user->avatar_post->id,
|
||||
'onclick' => "Post.check_avatar_blacklist(".$user->avatar_post->id.", ".$id.")"));
|
||||
'onclick' => "return Post.check_avatar_blacklist(".$user->avatar_post->id.", ".$id.")"));
|
||||
#end
|
||||
}
|
||||
|
||||
public function avatar_init(Post $post = null)
|
||||
{
|
||||
static $posts = array();
|
||||
|
||||
if ($post) {
|
||||
$posts[(string)$post->id] = $post;
|
||||
} else {
|
||||
if (!$posts)
|
||||
return '';
|
||||
$ret = '';
|
||||
foreach ($posts as $post)
|
||||
$ret .= 'Post.register('.$post->toJson().")\n";
|
||||
$ret .= 'Post.init_blacklisted()';
|
||||
return $ret;
|
||||
if (!$this->avatar_posts_registry) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$ret = '';
|
||||
foreach ($this->avatar_posts_registry as $post) {
|
||||
$ret .= 'Post.register('.$post->toJson().");\n";
|
||||
}
|
||||
$ret .= "Post.init_blacklisted();\n";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@
|
||||
<?= $this->linkTo($this->t(array('time.x_ago', 't' => $this->timeAgoInWords($this->comment->created_at))), array('post#show', 'id' => $this->comment->post_id, 'anchor' => "c".$this->comment->id)) ?>
|
||||
</span>
|
||||
<?php if ($this->comment->user and $this->comment->user->has_avatar()) : ?>
|
||||
<?php $this->avatar_init($this->comment->user->avatar_post) ?>
|
||||
<div class="comment-avatar-container"> <?= $this->avatar($this->comment->user, $this->comment->id) ?> </div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user