2009-08-21 19:29:45 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
Template Name: Comic Calendar Archive
|
|
|
|
*/
|
|
|
|
?>
|
2009-09-03 01:12:30 +00:00
|
|
|
<?php get_header(); ?>
|
2009-09-17 22:45:30 +00:00
|
|
|
<?php include(get_template_directory() . '/layout-head.php'); ?>
|
2009-09-19 10:11:37 +00:00
|
|
|
<?php remove_filter('pre_get_posts','comicpress_members_filter'); ?>
|
2009-08-21 19:29:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$dayWidth = 22; //set to .cpcal-day total width in pixels including: width, left & right border, left & right margin, left & right padding
|
|
|
|
|
|
|
|
if (isset($_GET['archive_year'])) {
|
|
|
|
$archive_year = (int)$_GET['archive_year'];
|
|
|
|
} else {
|
2009-08-26 04:01:17 +00:00
|
|
|
$latest_comic = get_terminal_post_in_category(get_all_comic_categories_as_cat_string(),true);
|
2009-08-21 19:29:45 +00:00
|
|
|
$archive_year = get_post_time('Y', false, $latest_comic, true);
|
|
|
|
}
|
2009-08-26 04:01:17 +00:00
|
|
|
if (empty($archive_year)) $archive_year = date('Y');
|
2009-08-21 19:29:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
$firstDayMargins = array();
|
|
|
|
for ($i = 1; $i <= 12; ++$i) {
|
|
|
|
$dateInfo = getdate(mktime(0,0,0,$i,1,$archive_year));
|
|
|
|
$firstDayMargins[$i] = $dateInfo['wday'] * $dayWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
$tempPost = $post;
|
|
|
|
$comicArchive = new WP_Query(); $comicArchive->query('&showposts=1000&cat='.get_all_comic_categories_as_cat_string().'&year='.$archive_year);
|
|
|
|
while ($comicArchive->have_posts()) : $comicArchive->the_post();
|
|
|
|
$calTitle = get_the_title();
|
|
|
|
$calLink = get_permalink();
|
|
|
|
$calDay = get_the_time('j');
|
|
|
|
$calMonth = get_the_time('F');
|
|
|
|
$calComic[$calMonth.$calDay] = array('link' => $calLink, 'title' => $calTitle);
|
|
|
|
endwhile;
|
|
|
|
$post = $tempPost;
|
|
|
|
|
|
|
|
function leapYear($yr) {
|
|
|
|
if ($yr % 4 != 0) {
|
|
|
|
return 28;
|
|
|
|
} else {
|
|
|
|
if ($yr % 100 != 0) {
|
|
|
|
return 29;
|
|
|
|
} else {
|
|
|
|
if ($yr % 400 != 0) {
|
|
|
|
return 28;
|
2009-08-26 04:01:17 +00:00
|
|
|
} else {
|
2009-08-21 19:29:45 +00:00
|
|
|
return 29;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$leapYear = leapYear($archive_year);
|
|
|
|
|
|
|
|
$month['1'] = array('month' => 'January', 'days' => '31');
|
|
|
|
$month['2'] = array('month' => 'February', 'days' => $leapYear);
|
|
|
|
$month['3'] = array('month' => 'March', 'days' => '31');
|
|
|
|
$month['4'] = array('month' => 'April', 'days' => '30');
|
|
|
|
$month['5'] = array('month' => 'May', 'days' => '31');
|
|
|
|
$month['6'] = array('month' => 'June', 'days' => '30');
|
|
|
|
$month['7'] = array('month' => 'July', 'days' => '31');
|
|
|
|
$month['8'] = array('month' => 'August', 'days' => '31');
|
|
|
|
$month['9'] = array('month' => 'September', 'days' => '30');
|
|
|
|
$month['10'] = array('month' => 'October', 'days' => '31');
|
|
|
|
$month['11'] = array('month' => 'November', 'days' => '30');
|
|
|
|
$month['12'] = array('month' => 'December', 'days' => '31');
|
|
|
|
|
|
|
|
?>
|
2009-09-19 10:11:37 +00:00
|
|
|
<div class="<?php comicpress_post_class(); ?>">
|
2009-08-21 19:29:45 +00:00
|
|
|
<div class="post-page-head"></div>
|
|
|
|
<div class="post-page">
|
2009-08-27 16:47:33 +00:00
|
|
|
<?php while (have_posts()) : the_post() ?>
|
2009-08-21 19:29:45 +00:00
|
|
|
<div class="entry">
|
2009-08-27 15:57:50 +00:00
|
|
|
<h2 class="pagetitle"><?php the_title() ?> <span class="page-archive-year"> <?php echo $archive_year; ?></span></h2>
|
2009-08-21 19:29:45 +00:00
|
|
|
<?php the_content(); ?>
|
|
|
|
</div>
|
2009-08-27 16:47:33 +00:00
|
|
|
<?php endwhile; ?>
|
2009-08-21 19:29:45 +00:00
|
|
|
|
|
|
|
<div class="archive-yearlist">|
|
|
|
|
<?php $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date ASC");
|
|
|
|
foreach ( $years as $year ) {
|
|
|
|
if ($year != (0) ) { ?>
|
|
|
|
<a href="<?php echo add_query_arg('archive_year', $year) ?>"><strong><?php echo $year ?></strong></a> |
|
|
|
|
<?php } } ?>
|
|
|
|
</div>
|
2009-09-15 10:23:54 +00:00
|
|
|
<div class="cpcal-cals">
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php $i=1; while($i<=12) {
|
2009-09-29 19:11:28 +00:00
|
|
|
$calendar_directory = get_option('comicpress-calendar_directory');
|
|
|
|
$themepack_directory = get_option('comicpress-themepack_directory');
|
2009-09-15 10:23:54 +00:00
|
|
|
if (!empty($calendar_directory) && $calendar_directory != 'none') { ?>
|
|
|
|
<div class="cpcal-month" style="height: 257px;" id="<?php echo $month[$i]['month'] ?>">
|
2009-09-29 19:11:28 +00:00
|
|
|
<?php if ($calendar_directory == 'themepack') { ?>
|
|
|
|
|
|
|
|
<?php if (file_exists(get_template_directory().'/themepack/'.$themepack_directory.'/cal/'.$archive_year)) { ?>
|
|
|
|
<?php if (count($monthfile = glob(get_template_directory().'/themepack/'.$themepack_directory.'/cal/'.$archive_year.'/'.strtolower($month[$i]['month']).'.*')) > 0) {
|
|
|
|
if (is_array($monthfile)) $monthfile = reset($monthfile); ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/themepack/<?php echo $themepack_directory; ?>/cal/<?php echo $archive_year; ?>/<?php echo basename($monthfile); ?>" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } else { ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/images/cal/default.png" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } ?>
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php } else { ?>
|
2009-09-29 19:11:28 +00:00
|
|
|
<?php if (count($monthfile = glob(get_template_directory().'/themepack/'.$themepack_directory.'/cal/'.strtolower($month[$i]['month']).'.*')) > 0) {
|
|
|
|
if (is_array($monthfile)) $monthfile = reset($monthfile); ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/themepack/<?php echo $themepack_directory; ?>/cal/<?php echo basename($monthfile); ?>" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } else { ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/images/cal/default.png" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } ?>
|
|
|
|
<?php } ?>
|
|
|
|
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php } else { ?>
|
2009-09-29 19:11:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
<?php if (file_exists(get_template_directory().'/images/cal/'.$calendar_directory.'/'.$archive_year)) { ?>
|
|
|
|
<?php if (count($monthfile = glob(get_template_directory().'/images/cal/'.$calendar_directory.'/'.$archive_year.'/'.strtolower($month[$i]['month']).'.*')) > 0) {
|
|
|
|
if (is_array($monthfile)) $monthfile = reset($monthfile); ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/images/cal/<?php echo $calendar_directory; ?>/<?php echo $archive_year; ?>/<?php echo basename($monthfile); ?>" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } else { ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/images/cal/default.png" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } ?>
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php } else { ?>
|
2009-09-29 19:11:28 +00:00
|
|
|
<?php if (count($monthfile = glob(get_template_directory().'/images/cal/'.$calendar_directory.'/'.strtolower($month[$i]['month']).'.*')) > 0) {
|
|
|
|
if (is_array($monthfile)) $monthfile = reset($monthfile); ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/images/cal/<?php echo $calendar_directory; ?>/<?php echo basename($monthfile); ?>" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } else { ?>
|
|
|
|
<img class="cpcal-image" src="<?php bloginfo('stylesheet_directory'); ?>/images/cal/default.png" alt="<?php echo $month[$i]['month'] ?>" title="<?php echo $month[$i]['month'] ?>" />
|
|
|
|
<?php } ?>
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php } ?>
|
2009-09-29 19:11:28 +00:00
|
|
|
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php } ?>
|
|
|
|
<?php } else { ?>
|
2009-09-15 10:23:54 +00:00
|
|
|
<div class="cpcal-month" style="height: 137px;" id="<?php echo $month[$i]['month'] ?>">
|
2009-08-29 21:36:45 +00:00
|
|
|
<?php } ?>
|
2009-09-15 10:23:54 +00:00
|
|
|
<div class="cpcal-monthtitle"><?php echo $month[$i]['month']." ".$archive_year ?></div>
|
2009-08-21 19:29:45 +00:00
|
|
|
<?php foreach(array("S", "M", "T", "W", "T", "F", "S") as $dow) { ?>
|
2009-09-15 10:23:54 +00:00
|
|
|
<div class="cpcal-dayletter"><?php echo $dow ?></div>
|
2009-08-21 19:29:45 +00:00
|
|
|
<?php } ?>
|
2009-09-15 10:23:54 +00:00
|
|
|
<div class="clear"></div>
|
|
|
|
<?php $day=1; while($day<=$month[$i]['days']) {
|
2009-08-21 19:29:45 +00:00
|
|
|
if ($day == 1) { ?>
|
|
|
|
<div style="width:<?php echo $firstDayMargins[$i]; ?>px;height:15px;float:left;"></div>
|
|
|
|
<?php } ?>
|
|
|
|
<div class="cpcal-day">
|
|
|
|
<?php if (isset($calComic[$month[$i]['month'].$day])) { ?>
|
|
|
|
<a href="<?php echo $calComic[$month[$i]['month'].$day]['link'] ?>" title="<?php echo $calComic[$month[$i]['month'].$day]['title'] ?>"><?php echo $day ?></a>
|
|
|
|
<?php } else {
|
|
|
|
echo $day." ";
|
|
|
|
} ?>
|
|
|
|
</div>
|
|
|
|
<?php ++$day;
|
|
|
|
}
|
|
|
|
++$i ?>
|
|
|
|
</div>
|
|
|
|
<?php } ?>
|
2009-09-15 10:23:54 +00:00
|
|
|
</div>
|
2009-08-21 19:29:45 +00:00
|
|
|
</div>
|
|
|
|
<div class="post-page-foot"></div>
|
2009-09-12 15:28:32 +00:00
|
|
|
</div>
|
2009-08-21 19:29:45 +00:00
|
|
|
<?php if ('open' == $post->comment_status) {
|
|
|
|
comments_template('', true);
|
|
|
|
} ?>
|
2009-09-03 01:12:30 +00:00
|
|
|
</div>
|
2009-08-21 19:29:45 +00:00
|
|
|
</div>
|
|
|
|
|
2009-09-17 22:45:30 +00:00
|
|
|
<?php include(get_template_directory() . '/layout-foot.php'); ?>
|
2009-08-21 17:45:23 +00:00
|
|
|
<?php get_footer() ?>
|