<?php

	get_header();

	//
	// extract from comments-template.php
	//
	
	/** @todo Use API instead of SELECTs. */
	if ( $user_ID )
	{
		$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )  ORDER BY comment_date", $post->ID, $user_ID));
	}
	else
	{
		if ( empty($comment_author) )
		{
			$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post->ID));
		}
		else
		{
			$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date", $post->ID, $comment_author, $comment_author_email));
		}
	}
	
	// keep $comments for legacy's sake (remember $table*? ;) )
	$comments = $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
	$wp_query->comment_count = count($wp_query->comments);
	update_comment_cache($comments);


include(TEMPLATEPATH . '/sidebar_right.php');


echo "\n" . '<div id="content" class="widecolumn">' . "\n";

if (have_posts())
{
	while (have_posts())
	{
		the_post();
		
		echo "\n" . '		<div class="navigation">' . "\n" . 	'			<div class="alignleft">';

		previous_post_link('&laquo; %link');

		echo "\n" .	'		</div>' . "\n" . '     <div class="alignright">' . "\n";
		
		next_post_link('%link &raquo;');
		
		echo "\n" . '   </div>' . "\n" . '		</div>' . "\n" . '		<br />' . "\n" . '		<div class="post" id="post-' . get_the_ID() . '">' . "\n" . '			<h2>' . the_title( '', '', false ) . '</h2>' . "\n" . '			<div class="entry">' . "\n";

		the_content('<p class="serif">' . __('Read the rest of this entry &raquo;', 'german_newspaper') . '</p>');
		
		wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'german_newspaper') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
		
		
		echo "\n" . '				<p class="postmetadata">' . "\n";

		the_tags(__('Tags: ', 'german_newspaper'), ', ', '<br />');

		echo "\n" . '       </p>' . "\n" . '				<br />' . "\n" . '				<p class="postmetadata alt">' . "\n" . '					<small>' . "\n";

						/* This is commented, because it requires a little adjusting sometimes.
							You'll need to download this plugin, and follow the instructions:
							http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */
							/* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); $time_since = sprintf(__('%s ago', 'german_newspaper'), time_since($entry_datetime)); */

		printf(__('This entry was posted %1$s on %2$s at %3$s and is filed under %4$s.', 'german_newspaper'), $time_since, get_the_time(__('l, F jS, Y', 'german_newspaper')), get_the_time(), get_the_category_list(', '));
		printf(__(' You can follow any responses to this entry through the <a href="%s"><span class="rss_symbol"></span>RSS 2.0</a> feed.', 'german_newspaper'), get_post_comments_feed_link());

		if (('open' == $post->comment_status) && ('open' == $post->ping_status))
		{
			// Both Comments and Pings are open
			printf(__(' You can <a href="#respond">leave a response</a>, or <a href="%s" rel="trackback">trackback</a> from your own site.', 'german_newspaper'), get_trackback_url());
		}
		elseif (!('open' == $post->comment_status) && ('open' == $post->ping_status))
		{
			// Only Pings are Open
		  printf(__(' Responses are currently closed, but you can <a href="%s" rel="trackback">trackback</a> from your own site.', 'german_newspaper'), get_trackback_url());
		}
		elseif (('open' == $post->comment_status) && !('open' == $post->ping_status))
		{
			// Comments are open, Pings are not
			_e(' You can skip to the end and leave a response. Pinging is currently not allowed.', 'german_newspaper');
		}
		elseif (!('open' == $post->comment_status) && !('open' == $post->ping_status))
		{
			// Neither Comments, nor Pings are open
			_e(' Both comments and pings are currently closed.', 'german_newspaper');
		}

		edit_post_link(__(' Edit this entry.', 'german_newspaper'),'','');

		echo "\n" . '					</small>' . "\n" . '				</p>' . "\n" . '			</div>' . "\n" . '		</div>' . "\n\n";

		comments_template();
		
	}
}
else
{
	echo "\n" . '		<p>' . __('Sorry, no posts matched your criteria.', 'german_newspaper') . '</p>' . "\n\n";
}

echo "\n" . '</div>' . "\n\n";

get_footer();


?>
