working on decoupling

This commit is contained in:
John Bintz 2009-10-19 20:56:32 -04:00
parent c23d3d646c
commit d0228e830a
4 changed files with 17 additions and 20 deletions

View File

@ -408,16 +408,6 @@ class ComicPress {
return new WP_Query(); 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. * Get the path to a partial.
* @param array $partials The partials to search for in each path. * @param array $partials The partials to search for in each path.

View File

@ -3,11 +3,9 @@
class ComicPressComicPost { class ComicPressComicPost {
var $post; var $post;
var $attachments = null; 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($post)) { $this->post = $post; }
if (!is_null($comicpress)) { $this->comicpress = $comicpress; }
} }
function get_comic_image_attachments() { function get_comic_image_attachments() {
@ -21,6 +19,9 @@ class ComicPressComicPost {
return $this->attachments; return $this->attachments;
} }
/**
* Display all the attached images.
*/
function display_attached_images($type = "comic", $limit = null, $size_type = null, $format = "%s") { function display_attached_images($type = "comic", $limit = null, $size_type = null, $format = "%s") {
if (is_null($size_type)) { $size_type = $type; } if (is_null($size_type)) { $size_type = $type; }
$found = false; $found = false;
@ -28,7 +29,7 @@ class ComicPressComicPost {
$output = array(); $output = array();
if (is_array($ordering[$type])) { if (is_array($ordering[$type])) {
$i = 1; $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) { if (get_post_meta($attachment_id, "comic_image_type", true) == $type) {
$attachment = get_post($attachment_id); $attachment = get_post($attachment_id);
$title = (!empty($attachment->post_excerpt) ? $attachment->post_excerpt : $attachment->post_title); $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; return $found;
} }
@ -69,6 +72,9 @@ class ComicPressComicPost {
function display_archive($format) { $this->_display_type(array('archive'. 'comic'), $format, true); } function display_archive($format) { $this->_display_type(array('archive'. 'comic'), $format, true); }
function display_rss($format) { $this->_display_type(array('rss'. 'comic'), $format); } 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()) { function get_comic_img_tag($url, $type, $additional_parameters = array()) {
$dimensions = array(); $dimensions = array();
@ -193,6 +199,7 @@ class ComicPressComicPost {
update_post_meta($this->post->ID, 'comic_ordering', $new_order); update_post_meta($this->post->ID, 'comic_ordering', $new_order);
} }
} }
?> ?>

View File

@ -96,7 +96,7 @@ class ComicPressStoryline {
return false; return false;
} }
function get_valid_storyline_nav($post_id) { function get_valid_nav($post_id) {
$data = false; $data = false;
foreach (wp_get_post_categories($post_id) as $category) { foreach (wp_get_post_categories($post_id) as $category) {

View File

@ -110,7 +110,7 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_value, $this->css->{$field}($category)); $this->assertEquals($expected_value, $this->css->{$field}($category));
} }
function providerTestGetValidStorylineNav() { function providerTestGetValidNav() {
return array( return array(
array(array(1), array('upcoming')), array(array(1), array('upcoming')),
array(array(1,2), false), 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); wp_set_post_categories(1, $post_categories);
$this->css->_structure = array( $this->css->_structure = array(