From d0228e830ad900355f57bc9060e5d60590c28e9e Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 19 Oct 2009 20:56:32 -0400 Subject: [PATCH] working on decoupling --- classes/ComicPress.inc | 10 ---------- classes/ComicPressComicPost.inc | 19 +++++++++++++------ classes/ComicPressStoryline.inc | 2 +- test/ComicPressStorylineTest.php | 6 +++--- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index d3e6747..bb409c8 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -408,16 +408,6 @@ class ComicPress { return new WP_Query(); } - /** - * Get the previous comic from the current one. - */ - function get_previous_comic($category = null, $override_post = null) { return $this->get_adjacent_comic($category, false, $override_post); } - - /** - * Get the next comic from the current one. - */ - function get_next_comic($category = null, $override_post = null) { return $this->get_adjacent_comic($category, true, $override_post); } - /** * Get the path to a partial. * @param array $partials The partials to search for in each path. diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index aa98883..b10f7d1 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -3,11 +3,9 @@ class ComicPressComicPost { var $post; var $attachments = null; - var $comicpress; - function ComicPressComicPost($post = null, $comicpress = null) { + function ComicPressComicPost($post = null) { if (!is_null($post)) { $this->post = $post; } - if (!is_null($comicpress)) { $this->comicpress = $comicpress; } } function get_comic_image_attachments() { @@ -21,6 +19,9 @@ class ComicPressComicPost { return $this->attachments; } + /** + * Display all the attached images. + */ function display_attached_images($type = "comic", $limit = null, $size_type = null, $format = "%s") { if (is_null($size_type)) { $size_type = $type; } $found = false; @@ -28,7 +29,7 @@ class ComicPressComicPost { $output = array(); if (is_array($ordering[$type])) { $i = 1; - foreach ($ordering[$type] as $attachment_id) { + foreach ($ordering[$type] as $attachment_id) { if (get_post_meta($attachment_id, "comic_image_type", true) == $type) { $attachment = get_post($attachment_id); $title = (!empty($attachment->post_excerpt) ? $attachment->post_excerpt : $attachment->post_title); @@ -51,8 +52,10 @@ class ComicPressComicPost { } } } - echo apply_filters('comicpress_display_attached_images', implode("\n", $output), $this->post->ID); - + if (!empty($output)) { + echo apply_filters('comicpress_display_attached_images', $output, $this->post->ID, ''); + } + return $found; } @@ -69,6 +72,9 @@ class ComicPressComicPost { function display_archive($format) { $this->_display_type(array('archive'. 'comic'), $format, true); } function display_rss($format) { $this->_display_type(array('rss'. 'comic'), $format); } + /** + * Build an <img /> tag for a comic. + */ function get_comic_img_tag($url, $type, $additional_parameters = array()) { $dimensions = array(); @@ -193,6 +199,7 @@ class ComicPressComicPost { update_post_meta($this->post->ID, 'comic_ordering', $new_order); } + } ?> \ No newline at end of file diff --git a/classes/ComicPressStoryline.inc b/classes/ComicPressStoryline.inc index 3057353..513989d 100644 --- a/classes/ComicPressStoryline.inc +++ b/classes/ComicPressStoryline.inc @@ -96,7 +96,7 @@ class ComicPressStoryline { return false; } - function get_valid_storyline_nav($post_id) { + function get_valid_nav($post_id) { $data = false; foreach (wp_get_post_categories($post_id) as $category) { diff --git a/test/ComicPressStorylineTest.php b/test/ComicPressStorylineTest.php index d0461ea..ecbdceb 100644 --- a/test/ComicPressStorylineTest.php +++ b/test/ComicPressStorylineTest.php @@ -110,7 +110,7 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase { $this->assertEquals($expected_value, $this->css->{$field}($category)); } - function providerTestGetValidStorylineNav() { + function providerTestGetValidNav() { return array( array(array(1), array('upcoming')), array(array(1,2), false), @@ -121,9 +121,9 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase { } /** - * @dataProvider providerTestGetValidStorylineNav + * @dataProvider providerTestGetValidNav */ - function testGetValidStorylineNav($post_categories, $expected_navigation) { + function testGetValidNav($post_categories, $expected_navigation) { wp_set_post_categories(1, $post_categories); $this->css->_structure = array(