<?php
/**
 * This file creates a list-style layout of posts, useful if you are putting together a literary-style site.
 * This file is not to be loaded directly, but is instead loaded from different templates.
 *
 * @package Suffusion
 * @subpackage Templates
 */

global $suffusion, $query_string, $full_content_post_counter, $full_post_count, $page_of_posts, $suffusion_list_layout, $suffusion_duplicate_posts;
global $suffusion_unified_options;
foreach ($suffusion_unified_options as $id => $value) {
	$$id = $value;
}
$context = $suffusion->get_context();
$suffusion_list_layout = true;
if (!isset($suffusion_duplicate_posts)) $suffusion_duplicate_posts = array();

$page_title = get_bloginfo('name');
if (have_posts()) {
	the_post();
	$temp_title = wp_title('', false);
	if (trim($temp_title) != '') {
		$page_title = $temp_title;
	}
}

if ($suf_excerpt_list_count == 'all' && !$page_of_posts) {
	query_posts($query_string.'&posts_per_page=-1');
}
else if ($page_of_posts) {
	query_posts('posts_per_page=-1');
}

if (have_posts()) {
	$full_content_post_counter = 0;
	$full_post_count = suffusion_get_full_content_count();
	$total = $wp_query->post_count - $full_post_count;

	if ($full_post_count > 0) {
		suffusion_after_begin_content();
	}

	while (have_posts()) {
		$full_content_post_counter++;
		if ($full_content_post_counter > $full_post_count) {
			break;
		}
		the_post();
		if (in_array($post->ID, $suffusion_duplicate_posts)) {
			$full_content_post_counter--;
			continue;
		}
?>
	<div class="post fix <?php if (is_sticky()) { echo " sticky-post "; } ?>" id="post-<?php the_ID(); ?>">
<?php
		suffusion_after_begin_post();
?>
		<div class="entry fix">
<?php
		suffusion_content();
?>
		</div><!--entry -->
<?php
		suffusion_before_end_post();
?>
	</div><!--post -->
<?php
	}

	$class = "";
	$information = "";
	if (in_array('category', $context)) {
		$information = $suf_cat_info_enabled == 'enabled' ? suffusion_get_category_information() : false;
		$class = 'category-info';
	}
	else if (in_array('author', $context)) {
		$information = $suf_author_info_enabled == 'enabled' ? suffusion_get_author_information() : false;
		$class = 'author-profile';
	}
	else if (in_array('tag', $context)) {
		$tag_id = get_query_var('tag_id');
		$information = $suf_tag_info_enabled == 'enabled' ? tag_description($tag_id) : false;
		$class = 'tag-info';
	}

	if ($full_post_count == 0) {
?>
	<div class='post <?php echo $class; ?> fix'>
		<h2 class="posttitle"><?php echo $page_title; ?></h2>
		<div class="entry fix">
<?php
		echo $information;
	}
	else if ($total > 0) {
?>
	<div class='post <?php echo $class; ?> fix'>
		<div class="entry fix">
<?php
	}

	if ($total > 0) {
		echo "<$suf_excerpt_list_style>\n";
		while (have_posts()) {
			the_post();
			if (in_array($post->ID, $suffusion_duplicate_posts)) {
				continue;
			}
			echo "<li>";
			echo suffusion_get_post_title_and_link();
			echo "</li>\n";
		}
		echo "</$suf_excerpt_list_style>\n";
?>
		</div> <!-- /.entry -->
	</div> <!-- /.post -->
<?php
	}

	if ($suf_excerpt_list_count != 'all') {
		suffusion_before_end_content();
	}
}
else {
	if (!function_exists('get_template_part')) {
		include_once(TEMPLATEPATH . '/layouts/template-missing.php');
	}
	else {
		get_template_part('layouts/template-missing');
	}
}
?>