本文整理汇总了PHP中Thread::postCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Thread::postCount方法的具体用法?PHP Thread::postCount怎么用?PHP Thread::postCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::postCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildThread50
function buildThread50($id, $return = false, $mod = false, $thread = null, $antibot = false)
{
global $board, $config, $build_pages;
$id = round($id);
if ($antibot) {
$antibot->reset();
}
if (!$thread) {
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id` DESC LIMIT :limit", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->bindValue(':limit', $config['noko50_count'] + 1, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
$num_images = 0;
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
if (!isset($thread)) {
$thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
} else {
if ($post['files']) {
$num_images += $post['num_files'];
}
$thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod));
}
}
// Check if any posts were found
if (!isset($thread)) {
error($config['error']['nonexistant']);
}
if ($query->rowCount() == $config['noko50_count'] + 1) {
$count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL\n\t\t\t\t\t\t SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri']));
$count->bindValue(':thread', $id, PDO::PARAM_INT);
$count->execute() or error(db_error($count));
$c = $count->fetch();
$thread->omitted = $c['num'] - $config['noko50_count'];
$c = $count->fetch();
$thread->omitted_images = $c['num'] - $num_images;
}
$thread->posts = array_reverse($thread->posts);
} else {
$allPosts = $thread->posts;
$thread->posts = array_slice($allPosts, -$config['noko50_count']);
$thread->omitted += count($allPosts) - count($thread->posts);
foreach ($allPosts as $index => $post) {
if ($index == count($allPosts) - count($thread->posts)) {
break;
}
if ($post->files) {
$thread->omitted_images += $post->num_files;
}
}
}
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
$body = Element('thread.html', array('board' => $board, 'thread' => $thread, 'body' => $thread->build(false, true), 'config' => $config, 'id' => $id, 'mod' => $mod, 'hasnoko50' => $hasnoko50, 'isnoko50' => true, 'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)), 'boardlist' => createBoardlist($mod), 'return' => $mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']));
if ($return) {
return $body;
} else {
file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $id), $body);
}
}