Show omitted image replies count
This commit is contained in:
parent
f6d0bea5f7
commit
55f082a421
@ -194,7 +194,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Thread {
|
class Thread {
|
||||||
public $omitted = 0;
|
|
||||||
public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $root=null, $mod=false) {
|
public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $root=null, $mod=false) {
|
||||||
global $config;
|
global $config;
|
||||||
if(!isset($root)) $root = $config['root'];
|
if(!isset($root)) $root = $config['root'];
|
||||||
@ -215,6 +214,7 @@
|
|||||||
$this->filesize = $filesize;
|
$this->filesize = $filesize;
|
||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
$this->omitted = 0;
|
$this->omitted = 0;
|
||||||
|
$this->omitted_images = 0;
|
||||||
$this->posts = Array();
|
$this->posts = Array();
|
||||||
$this->ip = $ip;
|
$this->ip = $ip;
|
||||||
$this->sticky = $sticky;
|
$this->sticky = $sticky;
|
||||||
@ -348,7 +348,15 @@
|
|||||||
$built .= $this->body .
|
$built .= $this->body .
|
||||||
|
|
||||||
// Omitted posts
|
// Omitted posts
|
||||||
($this->omitted ? '<span class="omitted">' . $this->omitted . ' post' . ($this->omitted==1?'':'s') . ' omitted. Click reply to view.</span>':'') .
|
($this->omitted || $this->omitted_images? '<span class="omitted">' .
|
||||||
|
($this->omitted ?
|
||||||
|
$this->omitted . ' post' . ($this->omitted==1?'':'s') .
|
||||||
|
($this->omitted_images ? ' and ' : '')
|
||||||
|
:'') .
|
||||||
|
($this->omitted_images ?
|
||||||
|
$this->omitted_images . ' image repl' . ($this->omitted_images==1?'y':'ies')
|
||||||
|
:'') .
|
||||||
|
' omitted. Click reply to view.</span>':'') .
|
||||||
|
|
||||||
// End
|
// End
|
||||||
'</div>';
|
'</div>';
|
||||||
|
@ -440,22 +440,28 @@
|
|||||||
$posts->bindValue(2, ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']), PDO::PARAM_INT);
|
$posts->bindValue(2, ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']), PDO::PARAM_INT);
|
||||||
$posts->execute() or error(db_error($posts));
|
$posts->execute() or error(db_error($posts));
|
||||||
|
|
||||||
if($posts->rowCount() == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
|
$num_images = 0;
|
||||||
$count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = ?", $board['uri']));
|
|
||||||
$count->bindValue(1, $th['id']);
|
|
||||||
$count->execute() or error(db_error($count));
|
|
||||||
|
|
||||||
$count = $count->fetch();
|
|
||||||
$omitted = $count['num'] - ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
|
|
||||||
$thread->omitted = $omitted;
|
|
||||||
unset($count);
|
|
||||||
unset($omitted);
|
|
||||||
}
|
|
||||||
|
|
||||||
while($po = $posts->fetch()) {
|
while($po = $posts->fetch()) {
|
||||||
|
if($po['file'])
|
||||||
|
$num_images++;
|
||||||
|
|
||||||
$thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'], $mod ? '?/' : $config['root'], $mod));
|
$thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'], $mod ? '?/' : $config['root'], $mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($posts->rowCount() == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
|
||||||
|
$count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM `posts_%s` WHERE `file` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri']));
|
||||||
|
$count->bindValue(':thread', $th['id'], PDO::PARAM_INT);
|
||||||
|
$count->execute() or error(db_error($count));
|
||||||
|
|
||||||
|
$c = $count->fetch();
|
||||||
|
$thread->omitted = $c['num'] - ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
|
||||||
|
|
||||||
|
$c = $count->fetch();
|
||||||
|
$thread->omitted_images = $c['num'] - $num_images;
|
||||||
|
|
||||||
|
$thread->omitted -= $thread->omitted_images;
|
||||||
|
}
|
||||||
|
|
||||||
$thread->posts = array_reverse($thread->posts);
|
$thread->posts = array_reverse($thread->posts);
|
||||||
$body .= $thread->build(true);
|
$body .= $thread->build(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user