<div id="content" class="narrowcolumn"> <?php $user = wp_get_current_user(); if ($user->ID) { ?> <h2>Your favorites</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $foo = $wpdb->get_results("select p.post_title as title,f.post_id as post_id from saasta_posts p,saasta_faves f where f.post_id=p.ID and f.user_id=" . $user->ID . " order by title"); if (count($foo) > 0) { foreach ($foo as $f) { print '<tr><td width="100%" style="padding-top:0.5em;"><a href="' . get_permalink($f->post_id) . '" title="' . $f->title . '">' . $f->title . '</a></td>'; print '<td valign="middle" align="right" style="padding-top:0.5em;">'; saasta_print_del_fave_form($f->post_id); print '</td></tr>'; print '<tr><td colspan="2" style="height:0.5empx;border-top:1px dashed #666666;"></td></tr>'; } } ?> </table> <?php } ?> </div> <?php get_sidebar(); ?>
/** * Print post header. Contains author image (avatar), post title, * author, date etc and fave button & count. * * muumi 080819: refactored the whole thing into a simple table */ function saasta_print_post_header() { global $user_ID; global $wpdb; $people_images_dir = "people/" . get_option('saasta_subsite') . '/'; $icon = $people_images_dir . "unknown.png"; $pic_name = $people_images_dir . get_the_author_login(); if (file_exists($pic_name . ".png")) { $icon = $pic_name . ".png"; } else { if (file_exists($pic_name . ".gif")) { $icon = $pic_name . ".gif"; } } saasta_print_admin_notice(TRUE); print '<table class="postheader">'; print '<tr>'; // left column: author image print '<td width="40" align="center">'; print '<img align="absmiddle" src="' . $icon . '" width="32" height="32" border="0" alt="' . get_the_author_login() . '"/>'; print '</td>'; // middle column: post title, author etc print '<td width="420" style="padding-right:0.5em;">'; // post title print '<span style="font-weight:bold;font-size:1.2em;"><a name="saasta' . get_the_ID() . '" href="'; the_permalink(); print '" rel="bookmark" title="Permanent Link to '; the_title(); print '">'; the_title(); print '</a></span><br/><small>'; the_time('F jS, Y'); print ' by '; the_author(); print '</small>'; print '</td>'; // right column: add fave/unfave buttons, # of faves print '<td valign="middle" align="center" style="border-left:1px dashed #666666;padding-left:0.5em;padding-right:0.5em;">'; //print '<div style="border:1px solid #666666;padding:0.2em;">'; if ($user_ID == '') { saasta_print_add_fave_form(); } else { $foo = $wpdb->get_results("select post_id from " . $wpdb->prefix . "faves where user_id=" . $user_ID . " and post_id=" . get_the_ID()); if (count($foo) == 0) { saasta_print_add_fave_form(); } else { saasta_print_del_fave_form(get_the_ID()); } } $foo = $wpdb->get_row("select count(post_id) as numfaves from " . $wpdb->prefix . "faves where post_id=" . get_the_ID()); if ($foo->numfaves > 0) { print '<span style="font-weight:bold;color:#333;">' . $foo->numfaves . '</span>'; } //print '</div>'; print '</td>'; // close post header table print '</tr></table>'; // next/prev navigation for single post view if (is_single()) { print '<table class="singleprevnext">'; print '<tr><td align="left" style="font-size:0.88em;">'; next_post_link('« %link'); print '</td><td align="right" style="font-size:0.88em;">'; previous_post_link('%link »'); print '</td></tr></table>'; } }