diff --git a/addons/Core/Core.inc b/addons/Core/Core.inc index ecfe1ec..85fca4c 100644 --- a/addons/Core/Core.inc +++ b/addons/Core/Core.inc @@ -2,13 +2,17 @@ class ComicPressAddonCore extends ComicPressAddon { function init($comicpress) { - add_action('admin_init', array(&$this, 'add_theme_page')); + add_action('admin_init', array(&$this, 'setup_admin_interface')); $this->comicpress = $comicpress; } - function add_theme_page() { + function setup_admin_interface() { add_theme_page(__("ComicPress Core", 'comicpress'), __('ComicPress Core', 'comicpress'), 'edit_themes', basename(__FILE__), array(&$this, 'render_admin')); + + if (isset($_REQUEST['post'])) { + add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low"); + } } function render_admin() { @@ -18,6 +22,10 @@ class ComicPressAddonCore extends ComicPressAddon { include(dirname(__FILE__) . '/partials/options-admin.inc'); } + function render_comic_image_ordering() { + echo "made it"; + } + function get_root_categories() { $root_categories = array(); foreach (get_all_category_ids() as $id) { diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 34ebcc5..6c4d21e 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -9,6 +9,8 @@ class ComicPress { 'category_order' => false ); + var $comic_post_attachments_cache = array(); + var $category_tree = array(); function load() { @@ -32,29 +34,6 @@ class ComicPress { $this->sort_comic_categories(); } - function get_comic_img_tag($url, $type, $additional_parameters = array()) { - $dimensions = array(); - if (isset($this->comicpress_options["${type}_dimensions"])) { - list($width, $height) = explode("x", $this->comicpress_options["${type}_dimensions"]); - $dimensions = compact('width', 'height'); - } - - $output = ' $value) { - $output .= $parameter . '="' . $value . '" '; - } - } - $output .= "/>"; - - return $output; - } - /** * Flatten all WP categories into nodes like 0/3/5. */ @@ -194,12 +173,37 @@ class ComicPress { } function get_adjacent_comic($category, $next = false) { - + $categories_to_exclude = $this->non_comic_categories; + if (!is_null($category)) { + $categories_to_exclude = $this->get_string_to_exclude_all_but_provided_categories($category); + } + + return get_adjacent_post(false, $categories_to_exclude, $next); } + /** + * Given a category ID or an array of category IDs, create an exclusion string that will + * filter out every category but the provided ones. + */ + function get_string_to_exclude_all_but_provided_categories($category) { + $category_ids = array_keys($this->get_all_category_objects_by_id()); + if (!is_array($category)) { $category = array($category); } + return implode(",", array_diff($category_ids, $category)); + } + function _new_wp_query() { return new WP_Query(); } + + /** + * Get the previous comic from the current one. + */ + function get_previous_comic($category = null) { return get_adjacent_comic($category); } + + /** + * Get the next comic from the current one. + */ + function get_next_comic($category = null) { return get_adjacent_comic($category, true); } } ?> \ No newline at end of file diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc new file mode 100644 index 0000000..02f40df --- /dev/null +++ b/classes/ComicPressComicPost.inc @@ -0,0 +1,58 @@ +post = $post; } + if (!is_null($comicpress)) { $this->comicpress = $comicpress; } + } + + function get_comic_image_attachments() { + if (!isset($this->attachments)) { + $this->attachments = get_children(array( + 'post_parent' => $this->post->ID, + 'post_type' => 'attachment', + 'post_mime_type' => 'image' + )); + } + return $this->attachments; + } + + function display_comics() { + foreach ($this->get_comic_image_attachments() as $attachment) { + echo $this->get_comic_img_tag(wp_get_attachment_url($attachment->ID), "comic", array('title' => $attachment->post_title)); + } + } + + function get_comic_img_tag($url, $type, $additional_parameters = array()) { + $dimensions = array(); + if (isset($this->comicpress->comicpress_options["${type}_dimensions"])) { + list($width, $height) = explode("x", $this->comicpress->comicpress_options["${type}_dimensions"]); + $dimensions = compact('width', 'height'); + } + + $output = ' $value) { + $output .= $parameter . '="' . $value . '" '; + } + } + $output .= "/>"; + + return $output; + } + + function normalize_attachment_sorting() { + + } +} + +?> \ No newline at end of file diff --git a/functions.php b/functions.php index 120e59e..37a6fd0 100644 --- a/functions.php +++ b/functions.php @@ -74,7 +74,7 @@ function __comicpress_init() { } } - get_all_comic_categories(); + //get_all_comic_categories(); } function the_comic_img_tag($url, $type, $additional_parameters = array()) { @@ -105,16 +105,6 @@ function get_last_comic_permalink() { return !empty($terminal) ? get_permalink($terminal->ID) : false; } -/** - * Given a category ID or an array of category IDs, create an exclusion string that will - * filter out every category but the provided ones. - */ -function get_string_to_exclude_all_but_provided_categories($category) { - $category_ids = array_keys(get_all_category_objects_by_id()); - if (!is_array($category)) { $category = array($category); } - return implode(",", array_diff($category_ids, $category)); -} - /** * Get the link to the previous comic from the current one. */ @@ -131,16 +121,6 @@ function next_comic_link($format, $link) { next_post_link($format, $link, false, $non_comic_categories); } -/** - * Get the previous comic from the current one. - */ -function get_previous_comic($category = null) { return get_adjacent_comic($category); } - -/** - * Get the next comic from the current one. - */ -function get_next_comic($category = null) { return get_adjacent_comic($category, true); } - /** * Get the adjacent comic from the current one. * @param int $category The category to use. @@ -148,14 +128,6 @@ function get_next_comic($category = null) { return get_adjacent_comic($category, * @return array The WordPress post object for the comic post. */ function get_adjacent_comic($category, $next = false) { - global $non_comic_categories; - - $categories_to_exclude = $non_comic_categories; - if (!is_null($category)) { - $categories_to_exclude = get_string_to_exclude_all_but_provided_categories($category); - } - - return get_adjacent_post(false, $categories_to_exclude, $next); } /** @@ -208,8 +180,6 @@ function get_comic_url($folder = 'comic', $override_post = null, $filter = 'defa return false; } - - // ComicPress Template Functions function the_comic($filter = 'default') { echo get_comic_url('comic', null, $filter); } diff --git a/header.php b/header.php index d8f6eac..ccd20cf 100644 --- a/header.php +++ b/header.php @@ -35,20 +35,6 @@