From 2e7028a72eb19f4a3e5ddfd30df9f09756034aea Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 25 Jul 2009 13:15:13 -0400 Subject: [PATCH] in a quasi-working state, don't use this build --- archive-comic-calendar.php | 38 +++++++------ archive-comic-storyline-thumbs.php | 64 ++-------------------- archive-comic.php | 6 +-- classes/ComicPress.inc | 12 +++-- single.php | 50 ++++++++--------- style/archive-comic-storyline-thumbs.css | 63 ++++++++++++++++++++++ test/ComicPressTest.php | 69 ++++++++++++++++++++++++ 7 files changed, 191 insertions(+), 111 deletions(-) create mode 100644 style/archive-comic-storyline-thumbs.css diff --git a/archive-comic-calendar.php b/archive-comic-calendar.php index 28cf488..a3fdf74 100644 --- a/archive-comic-calendar.php +++ b/archive-comic-calendar.php @@ -6,20 +6,14 @@ Template Name: Comic Calendar Archive global $comicpress; $comicpress->additional_stylesheets[] = '/style/archive-comic-calendar.css'; -?> - - - -query('&showposts=1000&cat=' . $comicpress->get_all_comic_categories_as_cat_string() . '&year='.$archive_year); +$comic_archive_query->query('showposts=1000&cat=' . $comicpress->get_all_comic_categories_as_cat_string() . '&year=' . $archive_year); while ($comic_archive_query->have_posts()) { $comic_archive_query->the_post(); $comic_archive_posts[get_the_time('d-m')] = array( @@ -27,29 +21,32 @@ while ($comic_archive_query->have_posts()) { 'title' => get_the_title() ); } -$post = $temp_post; $days_of_week = array(); for ($i = 0; $i < 7; ++$i) { $days_of_week[] = substr(date("l", gmmktime(0, 0, 0, 7, 13 + $i, 2009)), 0, 1); } -?> +ob_start(); -
+?>
- -

+ +

-
- +
+
| 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 ) { ?> + if ($year != 0) { ?> | ">
- +
@@ -90,9 +87,10 @@ for ($i = 0; $i < 7; ++$i) {
+ +$content = ob_get_clean(); - +include(get_template_directory() . '/layouts/' . $comicpress->comicpress_options['layout']); - \ No newline at end of file +?> \ No newline at end of file diff --git a/archive-comic-storyline-thumbs.php b/archive-comic-storyline-thumbs.php index 324990e..906a4f1 100644 --- a/archive-comic-storyline-thumbs.php +++ b/archive-comic-storyline-thumbs.php @@ -2,67 +2,13 @@ /* Template Name: Comic Storyline with Thumbs */ + +global $comicpress; + +$comicpress->additional_stylesheets[] = '/style/archive-comic-calendar.css'; + ?> - - - - - -
-
diff --git a/archive-comic.php b/archive-comic.php index d0cb5f8..0c8470d 100644 --- a/archive-comic.php +++ b/archive-comic.php @@ -3,11 +3,11 @@ Template Name: Comic Archive */ - global $comicpress; +global $comicpress; - $comicpress->additional_stylesheets[] = '/style/archive-comic-calendar.css'; - get_header(); + +get_header(); ?>
diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 1856428..06700da 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -210,26 +210,28 @@ class ComicPress { * Get the first comic in a category. */ function get_first_comic() { - return $this->get_terminal_post_in_category($this->get_all_comic_categories_as_cat_string()); + return $this->get_terminal_post_in_category($category); } /** * Get the last comic in a category. */ - function get_last_comic() { - return $this->get_terminal_post_in_category($this->get_all_comic_categories_as_cat_string(), false); + function get_last_comic($category) { + return $this->get_terminal_post_in_category($category, false); } /** * Get the comics necessary to build the navigation. * @tested */ - function get_nav_comics() { + function get_nav_comics($override_category_id = null) { global $post; + $category = is_numeric($override_category_id) ? $override_category_id : $this->comicpress_options['comic_category_id']; + $comic_posts = array(); foreach (array('first', 'last', 'previous', 'next') as $which) { - $comic_posts[$which] = $this->{"get_${which}_comic"}(); + $comic_posts[$which] = $this->{"get_${which}_comic"}($category); } $comic_posts['show_first'] = (trim($post->ID) != trim($comic_posts['first']->ID)); diff --git a/single.php b/single.php index 0badb74..cc37c34 100644 --- a/single.php +++ b/single.php @@ -1,37 +1,39 @@ -get_nav_comics(); -?> - -
- comicpress_options['comic_space'] == "comic_only") { - include(get_template_directory() . '/partials/single-comic-post.inc'); - } - } else { - include(get_template_directory() . '/partials/single-blog-post.inc'); + + if (have_posts()) { + while (have_posts()) { the_post(); + if (in_comic_category()) { + if ($comicpress->comicpress_options['comic_space'] == "comic_only") { + include_partial('single-comic-post'); } - - comments_template(); + } else { + include_partial('single-blog-post'); } - } else { - include(get_template_directory() . '/partials/single-no-matches.inc'); + + comments_template(); } - ?> -
- - - - \ No newline at end of file + } else { + include_partial('single-no-matches'); + } + + $content = ob_get_clean(); + + include(get_template_directory() . '/layouts/' . $comicpress->comicpress_options['layout']); +?> \ No newline at end of file diff --git a/style/archive-comic-storyline-thumbs.css b/style/archive-comic-storyline-thumbs.css new file mode 100644 index 0000000..3da5c3d --- /dev/null +++ b/style/archive-comic-storyline-thumbs.css @@ -0,0 +1,63 @@ +#storyline, #storyline ul { + padding: 0; + margin: 0; + list-style: none; +} + +#storyline li { + padding: 0; + margin: 0; +} + +#storyline li img { + height: 50px; + display: none; +} + +#storyline li li img { + display: block; + float: right; + padding: 0 0 0 10px; +} + +#storyline ul ul { + margin: 0 0 0 20px; +} + +#storyline li li .storyline-title { + font-size: 24px; + font-weight: bold; + display: block; + color: #000; +} + +#storyline li li .storyline-title:hover { + color: #900; +} + +#storyline li li li a.storyline-title { + font-size: 18px; +} + +#storyline li li li li a.storyline-title { + font-size: 14px; +} + +.storyline-description { + font-size: 11px; +} + +.storyline-foot { + clear: both; + margin: 0 0 10px 0; + height: 10px; + border-bottom: 4px solid #000; +} + +#storyline li li .storyline-foot { + border-bottom: 2px solid #000; +} + +#storyline li li li .storyline-foot { + border-bottom: 1px solid #000; +} diff --git a/test/ComicPressTest.php b/test/ComicPressTest.php index d077992..c4bef1d 100644 --- a/test/ComicPressTest.php +++ b/test/ComicPressTest.php @@ -171,6 +171,75 @@ class ComicPressTest extends PHPUnit_Framework_TestCase { $this->assertEquals($expected, $comic_posts["show_${show}"], $show); } } + + function providerTestGetStorylineNavComics() { + return array( + array( + array( + '1' => array( + 'first' => 8, + 'previous' => 9, + 'next' => 11, + 'last' => 12 + ), + '2' => array( + 'first' => 10, + 'previous' => false, + 'next' => 15, + 'last' => 15 + ), + '3' => array( + 'first' => 20, + 'previous' => 20, + 'next' => false, + 'last' => 21 + ) + ) + ), + array( + '1' => array( + 'first' => true, + 'previous' => true, + 'next' => true, + 'last' => true + ), + '2' => array( + 'first' => true, + 'previous' => false, + 'next' => false, + 'last' => true + ), + '3' => array( + 'first' => true, + 'previous' => false, + 'next' => false, + 'last' => true + ) + ) + ); + } + + /** + * @dataProvider providerTestGetStorylineNavComics + */ + function testGetStorylineNavComics($category_info, $expected_category_results) { + $cp = $this->getMock('ComicPress', array('get_first_comic', 'get_last_comic', 'get_previous_comic', 'get_next_comic')); + foreach ($category_info as $category => $nav_comics) { + foreach ($nav_comics as $key => $result) { + $return = (is_numeric($result)) ? (object)array('ID' => $result) : false; + $cp->expects($this->once())->method("get_${key}_comic")->with($category)->will($this->returnValue($return)); + } + } + + $post = (is_numeric($given_post)) ? (object)array('ID' => $given_post) : false; + + $comic_posts = $cp->get_nav_comics(); + + foreach ($expected_shows as $show => $expected) { + $this->assertEquals($expected, $comic_posts["show_${show}"], $show); + } + + } function providerTestGetLayoutChoices() {