Exemplo n.º 1
0
function show_forum($forum, $start, $sort_style, $user)
{
    $gotoStr = "";
    $nav = show_page_nav($forum, $start);
    if ($nav) {
        $gotoStr = "<div align=\"right\">{$nav}</div><br />";
    }
    echo $gotoStr;
    // Display the navbar
    start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>" . tra("Last post") . "</nobr>"));
    $sticky_first = !$user || !$user->prefs->ignore_sticky_posts;
    // Show hidden threads if logged in user is a moderator
    //
    $show_hidden = is_moderator($user, $forum);
    $threads = get_forum_threads($forum->id, $start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first);
    if ($user) {
        $subs = BoincSubscription::enum("userid={$user->id}");
    }
    // Run through the list of threads, displaying each of them
    $n = 0;
    $i = 0;
    foreach ($threads as $thread) {
        $owner = BoincUser::lookup_id($thread->owner);
        $unread = thread_is_unread($user, $thread);
        //if ($thread->status==1){
        // This is an answered helpdesk thread
        if ($user && is_subscribed($thread, $subs)) {
            echo '<tr class="row_hd' . $n . '">';
        } else {
            echo '<tr class="row' . $n . '">';
        }
        echo '<td width="1%"><nobr>';
        if ($user && $thread->rating() > $user->prefs->high_rating_threshold) {
            show_image(EMPHASIZE_IMAGE, "This message has a high average rating", "Highly rated");
        }
        if ($user && $thread->rating() < $user->prefs->low_rating_threshold) {
            show_image(FILTER_IMAGE, "This message has a low average rating", "Low rated");
        }
        if ($thread->hidden) {
            echo "[hidden]";
        }
        if ($unread) {
            if ($thread->sticky) {
                if ($thread->locked) {
                    show_image(NEW_IMAGE_STICKY_LOCKED, "This thread is sticky and locked, and you haven't read it yet", "sticky/locked/unread");
                } else {
                    show_image(NEW_IMAGE_STICKY, "This thread is sticky and you haven't read it yet", "sticky/unread");
                }
            } else {
                if ($thread->locked) {
                    show_image(NEW_IMAGE_LOCKED, "You haven't read this thread yet, and it's locked", "unread/locked");
                } else {
                    show_image(NEW_IMAGE, "You haven't read this thread yet", "unread");
                }
            }
        } else {
            if ($thread->sticky) {
                if ($thread->locked) {
                    show_image(IMAGE_STICKY_LOCKED, "This thread is sticky and locked", "sticky/locked");
                } else {
                    show_image(IMAGE_STICKY, "This thread is sticky", "sticky");
                }
            } else {
                if ($thread->locked) {
                    show_image(IMAGE_LOCKED, "This thread is locked", "locked");
                }
            }
        }
        echo "</nobr></td>";
        $titlelength = 48;
        $title = $thread->title;
        if (strlen($title) > $titlelength) {
            $title = substr($title, 0, $titlelength) . "...";
        }
        $title = cleanup_title($title);
        echo '<td class="threadline">
			<a href="forum_thread.php?id=' . $thread->id . '"><strong>' . $title . '</strong></a>
			<br /></td>';
        $n = ($n + 1) % 2;
        echo '<td class="numbers leftborder">' . ($thread->replies + 1) . '</td>
			<td class="author leftborder">' . user_links($owner) . '</td>
			<td class="numbers leftborder">' . $thread->views . '</td>
			<td class="lastpost leftborder">' . time_diff_str($thread->timestamp, time()) . '</td>
			</tr>';
        flush();
    }
    end_table();
    echo "<br />{$gotoStr}";
    // show page links
}
Exemplo n.º 2
0
function show_post_list()
{
    global $__blog_data_items, $__selected_item_keys, $__query_params;
    global $__status, $__config;
    $last_post_id = 0;
    ?>
  <div class='entry_list'> <!-- page_type = {$__status['page_type']} -->
<?php 
    //
    // Using for loop instead of foreach, for easier pagination
    //
    $data_keys = array_keys($__selected_item_keys);
    if (sizeof($data_keys) == 0) {
        ?>
  No entries found! Go <a href="<?php 
        echo $__config['blog_url'];
        ?>
">home</a>?
<?php 
    } else {
        for ($post_id = 0; $post_id < sizeof($data_keys); $post_id++) {
            if ($post_id >= $__status['page_start'] && $post_id < $__status['page_start'] + $__config['posts_per_page']) {
                $data_item = $__blog_data_items[$data_keys[$post_id]];
                show_data_item($data_item);
                $__status['debug'] .= "  /**/ Showing {$post_id} (key={$data_keys[$post_id]})\n";
                $last_post_id = $post_id;
            }
        }
    }
    ?>
  </div><!-- entry_list -->
<?php 
    show_page_nav();
}