<?php
global  $theme_version,
        $wpdb;
global  $comments;

	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);



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>');


    /* print out the attachments */
    $args = array(
              'post_type' => 'attachment',
              'numberposts' => null,
              'post_status' => null,
              'post_parent' => $post->ID
            );

    $attachments = get_posts($args);
    if ($attachments) 
    {
      echo "\n" . '<br />' . "\n";
      echo "\n" . '<i>' . __('the attachments to this post:', 'german_newspaper') . '</i>' . "\n";
      echo "\n" . '<br />' . "\n";
    
      foreach ($attachments as $attachment) 
      {
        echo "\n" . '<p>' . "\n";
        echo wp_get_attachment_link( $attachment->ID );
        echo "\n" . '<br />' . apply_filters('the_title', $attachment->post_title) . '<br />' . "\n";
        echo "\n" . '</p>' . "\n";
      }
    }

		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";

		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(', ', 'single'));
		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();


?>