Exemplo n.º 1
0
function buildpostlist($posts, $mode, $max_depth)
{
    switch ($mode) {
        case 'no_indent':
            $max_depth = 1;
            break;
        case 'max_indent':
            break;
        case 'full_indent':
        default:
            $max_depth = -1;
            break;
    }
    $html = '';
    foreach ($posts as $post) {
        // calculates the indent tabs for the post
        $indent = $max_depth == 1 ? 1 : count(explode('/', $post->path, $max_depth));
        $html .= renderpost($post, $indent, $mode);
    }
    return $html;
}
Exemplo n.º 2
0
/**
 * Builds a flat list of posts
 *
 * @param array $posts the posts in the topic
 *
 * @returns string the html for the topc
 */
function buildflatposts(&$posts)
{
    $localposts = $posts;
    $first_post = array_shift($localposts);
    if (!isset($first_post->subject) || empty($first_post->subject)) {
        $first_post->subject = get_string('re', 'interaction.forum', '');
    }
    $children = array();
    foreach ($localposts as $index => $post) {
        $children[] = $post;
    }
    $first_post->children = $children;
    return renderpost($first_post);
}