示例#1
0
function print_faved_posts($user_id)
{
    global $quarters;
    $title_prefix = "Most faved posts in";
    if ($user_id) {
        $title_prefix = "My faves in";
    }
    foreach ($quarters as $q) {
        $qrtr = $q["q"];
        $year = $q["y"];
        // TODO misleading title for own faves
        print "<h3>{$title_prefix} Q" . $qrtr . "/" . $year . "</h3>";
        if (!$user_id) {
            $r = saasta_query_top_faved_posts($qrtr, $year);
            echo '<table><tr><th>Author</th><th>Faves</th><th>Title</th></tr>';
        } else {
            $r = saasta_query_top_faved_posts_for_user($user_id, $qrtr, $year);
            echo '<table><tr><th>Author</th><th>Title</th></tr>';
        }
        foreach ($r as $f) {
            $url = get_permalink($f->post_id);
            echo '<tr><td>' . $f->author . '</td>';
            if (!$user_id) {
                echo '<td>' . $f->fave_count . '</td>';
            }
            echo '<td><a href="' . $url . '">';
            echo $f->title == "" ? $url : $f->title;
            print "</a>";
            echo "</tr>\n";
        }
        echo '</table>';
    }
}
示例#2
0
     print '<tr><th>name</th><th>num faves</th><th>num posts</th><th>faves per post</th><th>fave weight</th></tr>';
     $foo = query_best_posters_in_quarter($q, $year);
     foreach ($foo as $f) {
         print "<tr>";
         print "<td>" . $f->name . "</td>";
         print "<td>" . $f->num_faves . "</td>";
         print "<td>" . $f->num_posts . "</td>";
         printf("<td>%.3f</td>", $f->favesPerPost);
         printf("<td>%.3f</td>", $f->faveWeight);
         print "</tr>";
     }
 } else {
     if ($mode == 'faves') {
         print '<tr><th colspan="6">Q' . $q . '/' . $year . '</th></tr>';
         print '<tr><th>title</th><th>author</th><th>num faves</th><th>post id</th><th>date posted</th></tr>';
         $foo = saasta_query_top_faved_posts($q, $year);
         foreach ($foo as $f) {
             print '<tr>';
             print '<td><a href="' . $f->url . '">' . $f->title . '</a></td>';
             print '<td>' . $f->author . '</td>';
             print '<td>' . $f->fave_count . '</td>';
             print '<td>' . $f->post_id . '</td>';
             print '<td>' . $f->date_posted . '</td>';
             print '</tr>';
         }
     } else {
         if ($mode == 'topfavers') {
             print '<tr><th colspan="2">Q' . $q . '/' . $year . '</th></tr>';
             print '<tr><th>user</th><th>num posts faved</th></tr>';
             $foo = query_top_favers_in_quarter($q, $year);
             foreach ($foo as $f) {