diff --git a/addons/Core/Core.inc b/addons/Core/Core.inc index 5246823..6034f61 100644 --- a/addons/Core/Core.inc +++ b/addons/Core/Core.inc @@ -173,7 +173,7 @@ class ComicPressAddonCore extends ComicPressAddon { */ function render_comic_image_ordering() { if (isset($_REQUEST['post'])) { - $comic_post = new ComicPressComicPost($_REQUEST['post'], &$this->comicpress); + $comic_post = new ComicPressComicPost(get_post($_REQUEST['post']), &$this->comicpress); $ordering = $comic_post->normalize_comic_image_ordering(); if (is_array($ordering)) { foreach ($ordering as $type => $attachment_ids) { @@ -181,8 +181,9 @@ class ComicPressAddonCore extends ComicPressAddon { $index = 1; foreach ($attachment_ids as $attachment_id) { echo ''; + echo ''; + ++$index; } - echo ''; } } } @@ -434,6 +435,9 @@ class ComicPressAddonCore extends ComicPressAddon { if (isset($_POST['attachments'])) { //coming from media editor $this->handle_update_attachments(); + } else if (isset($_POST['cp']['ordering'])) { + // comic ordering + $this->handle_update_comic_ordering(); } else { //coming from us $this->handle_update_comicpress_options(); diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index 964f2a6..afb6428 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -105,10 +105,10 @@ class ComicPressComicPost { return $orderings; } - function normalize_comic_image_ordering($post_id) { + function normalize_comic_image_ordering() { if (is_array($this->get_comic_image_attachments())) { $ordering_by_type = array(); - $ordering_types = get_post_meta($post_id, 'comic_ordering', true); + $ordering_types = get_post_meta($this->post->id, 'comic_ordering', true); if (!empty($ordering_types)) { $ordering_types = $this->breakdown_comic_ordering_string($ordering_types); } $comic_image_ordering = array(); diff --git a/test/ComicPressComicPostTest.php b/test/ComicPressComicPostTest.php index 04dc448..49bb249 100644 --- a/test/ComicPressComicPostTest.php +++ b/test/ComicPressComicPostTest.php @@ -158,6 +158,23 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase { $this->assertEquals(array('comic' => array(3,2), 'rss' => array(5,4)), $result); $this->assertEquals('comic:3,2;rss:5,4', get_post_meta(1, 'comic_ordering', true)); } + + function providerTestChangeComicImageOrdering() { + + } + + /** + * @dataProvider providerTestChangeComicImageOrdering + */ + function testChangeComicImageOrdering($current_ordering, $revised_ordering, $expected_result) { + update_post_meta(1, 'comic_ordering', array('comic:1,2,3')); + + $this->p->change_comic_image_ordering(array( + 'comic' => array( + '3' => 1, '2' => 3, '1' => 2 + ) + )); + } } ?> \ No newline at end of file