working on reordering, broken build

This commit is contained in:
John Bintz 2009-08-01 11:05:39 -04:00
parent 90c7a23747
commit fa6d62e9d0
3 changed files with 25 additions and 4 deletions

View File

@ -173,7 +173,7 @@ class ComicPressAddonCore extends ComicPressAddon {
*/ */
function render_comic_image_ordering() { function render_comic_image_ordering() {
if (isset($_REQUEST['post'])) { 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(); $ordering = $comic_post->normalize_comic_image_ordering();
if (is_array($ordering)) { if (is_array($ordering)) {
foreach ($ordering as $type => $attachment_ids) { foreach ($ordering as $type => $attachment_ids) {
@ -181,8 +181,9 @@ class ComicPressAddonCore extends ComicPressAddon {
$index = 1; $index = 1;
foreach ($attachment_ids as $attachment_id) { foreach ($attachment_ids as $attachment_id) {
echo '<img src="' . wp_get_attachment_url($attachment_id) . '" width="60" height="60" />'; echo '<img src="' . wp_get_attachment_url($attachment_id) . '" width="60" height="60" />';
echo '<input size="3" type="text" name="cp[ordering][' . $type . '][' . $attachment_id . ']" value="' . $index . '" />';
++$index;
} }
echo '<input type="text" name="cp[ordering][' . $type . '][' . $attachment_id . ']" value="' . $index . '" />';
} }
} }
} }
@ -434,6 +435,9 @@ class ComicPressAddonCore extends ComicPressAddon {
if (isset($_POST['attachments'])) { if (isset($_POST['attachments'])) {
//coming from media editor //coming from media editor
$this->handle_update_attachments(); $this->handle_update_attachments();
} else if (isset($_POST['cp']['ordering'])) {
// comic ordering
$this->handle_update_comic_ordering();
} else { } else {
//coming from us //coming from us
$this->handle_update_comicpress_options(); $this->handle_update_comicpress_options();

View File

@ -105,10 +105,10 @@ class ComicPressComicPost {
return $orderings; return $orderings;
} }
function normalize_comic_image_ordering($post_id) { function normalize_comic_image_ordering() {
if (is_array($this->get_comic_image_attachments())) { if (is_array($this->get_comic_image_attachments())) {
$ordering_by_type = array(); $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); } if (!empty($ordering_types)) { $ordering_types = $this->breakdown_comic_ordering_string($ordering_types); }
$comic_image_ordering = array(); $comic_image_ordering = array();

View File

@ -158,6 +158,23 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(array('comic' => array(3,2), 'rss' => array(5,4)), $result); $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)); $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
)
));
}
} }
?> ?>