From 9525ed566a01768da0f1e310751e1d84e5e79df3 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 6 Dec 2009 14:18:11 -0500 Subject: [PATCH] rework backend post generation --- classes/ComicPressComicPost.inc | 8 +++++++- classes/backends/ComicPressBackendAttachment.inc | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index efac07e..1daafd9 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -15,7 +15,13 @@ class ComicPressComicPost { $comicpress = ComicPress::get_instance(); $attachments = array(); foreach ($comicpress->backends as $backend) { - $attachments = array_merge($attachments, call_user_func(array($backend, 'generate_from_post'), $this->post)); + if (is_string($backend)) { + $a = new $backend(); + } + if (is_object($backend)) { + $a = $backend; + } + $attachments = array_merge($attachments, $a->generate_from_post($this->post)); } return $attachments; } diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc index ddaca16..cd7a553 100644 --- a/classes/backends/ComicPressBackendAttachment.inc +++ b/classes/backends/ComicPressBackendAttachment.inc @@ -31,10 +31,12 @@ class ComicPressBackendAttachment extends ComicPressBackend { return $result; } - function ComicPressBackendAttachment($attachment) { - $this->attachment = $attachment; - $this->id = sprintf('%s-%d', $this->root_id, $this->attachment->ID); - $this->type = get_post_meta($this->attachment->ID, 'comic_image_type', true); + function ComicPressBackendAttachment($attachment = null) { + if (!is_null($attachment)) { + $this->attachment = $attachment; + $this->id = sprintf('%s-%d', $this->root_id, $this->attachment->ID); + $this->type = get_post_meta($this->attachment->ID, 'comic_image_type', true); + } } function dims($size = 'comic') {