From cd64f578859ae37bf9fde7563eb1f1ae6aa0ba72 Mon Sep 17 00:00:00 2001
From: John Bintz
Date: Wed, 18 Nov 2009 21:25:35 -0500
Subject: [PATCH] more polishing
---
classes/ComicPress.inc | 12 +--
classes/ComicPressAdmin.inc | 79 +++++++++++--------
.../_comic-image-ordering-sorters.inc | 1 -
functions.inc | 26 ++++--
js/MediaUpload.js | 5 +-
test/ComicPressAdminTest.php | 3 +-
6 files changed, 78 insertions(+), 48 deletions(-)
diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc
index cd7feb2..5c971cb 100644
--- a/classes/ComicPress.inc
+++ b/classes/ComicPress.inc
@@ -95,11 +95,13 @@ class ComicPress {
}
function editor_max_image_size($current_max, $size) {
- if (isset($this->comicpress_options['image_types'])) {
- if (isset($this->comicpress_options['image_types'][$size])) {
- if (isset($this->comicpress_options['image_types'][$size]['dimensions'])) {
- list($width, $height) = explode('x', $this->comicpress_options['image_types'][$size]['dimensions']);
- $current_max = array(intval($width), intval($height));
+ if (is_string($size)) {
+ if (isset($this->comicpress_options['image_types'])) {
+ if (isset($this->comicpress_options['image_types'][$size])) {
+ if (isset($this->comicpress_options['image_types'][$size]['dimensions'])) {
+ list($width, $height) = explode('x', $this->comicpress_options['image_types'][$size]['dimensions']);
+ $current_max = array(intval($width), intval($height));
+ }
}
}
}
diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc
index 136adb7..7018924 100644
--- a/classes/ComicPressAdmin.inc
+++ b/classes/ComicPressAdmin.inc
@@ -122,15 +122,24 @@ class ComicPressAdmin {
$is_managed = $comicpress_info['managed'];
}
+ $form_fields['comicpress_management'] = array(
+ 'label' => __("Let ComicPress Manage?", 'comicpress'),
+ 'input' => 'html',
+ 'html' => ''
+
+ . ''
+ . ''
+ );
+
if ($pagenow !== "media.php") {
- $form_fields['auto_attach'] = array(
- 'label' => __("Let ComicPress Manage?", 'comicpress'),
+ $form_fields['attach_parent'] = array(
+ 'label' => __("Change parent?", 'comicpress'),
'input' => 'html',
- 'html' => '
diff --git a/functions.inc b/functions.inc
index f477a58..364b796 100644
--- a/functions.inc
+++ b/functions.inc
@@ -31,11 +31,16 @@ function F($name, $path, $override_post = null) {
/**
* Protect global $post and $wp_query.
*/
-function Protect() {
+function Protect($use_this_post = null) {
global $post, $wp_query, $__post, $__wp_query;
$__post = $post;
$__wp_query = $wp_query;
+
+ if (!is_null($use_this_post)) {
+ $post = $use_this_post;
+ setup_postdata($post);
+ }
}
/**
@@ -102,11 +107,7 @@ function R($which, $restrictions = null, $override_post = null) {
global $post;
$post_to_use = !is_null($override_post) ? $override_post : $post;
- $storyline = new ComicPressStoryline();
-
- $restrictions = __prep_R($restrictions, $post_to_use);
-
- $categories = $storyline->build_from_restrictions($restrictions);
+ $categories = RL($restrictions, $post_to_use);
$dbi = ComicPressDBInterface::get_instance();
@@ -138,6 +139,17 @@ function RT($which, $restrictions = null, $override_post = null) {
return $post;
}
+function RL($restrictions = null, $override_post = null) {
+ global $post;
+ $post_to_use = !is_null($override_post) ? $override_post : $post;
+
+ $storyline = new ComicPressStoryline();
+
+ $restrictions = __prep_R($restrictions, $post_to_use);
+
+ return $storyline->build_from_restrictions($restrictions);
+}
+
// @codeCoverageIgnoreEnd
function M($override_post = null) {
@@ -206,4 +218,4 @@ function SC($which = 'current', $relative_to = null) {
}
return false;
-}
\ No newline at end of file
+}
diff --git a/js/MediaUpload.js b/js/MediaUpload.js
index 2f0a8fd..8a1d3e6 100644
--- a/js/MediaUpload.js
+++ b/js/MediaUpload.js
@@ -7,7 +7,7 @@ Event.observe(window, 'load', function() {
var show_insert = function(t) {
var b = item.select('input[name*=send]').pop();
- if (b) { b[(t.value == 'none') ? 'show' : 'hide'](); }
+ if (b) { b[(t.checked) ? 'hide' : 'show'](); }
}
var type = item.select('input[name*=comicpress_management][checked]').pop();
@@ -15,5 +15,8 @@ Event.observe(window, 'load', function() {
item.select('.filename.new').pop().insert({bottom: new Element('div').addClassName('comicpress-is-managing')});
show_insert(type);
}
+
+ item.select('input[name*=comicpress_management]').invoke('observe', 'change', function(e) { show_insert(e.target); });
+
});
});
diff --git a/test/ComicPressAdminTest.php b/test/ComicPressAdminTest.php
index a23c049..2322af1 100644
--- a/test/ComicPressAdminTest.php
+++ b/test/ComicPressAdminTest.php
@@ -173,7 +173,8 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
),
array(
'post_parent' => "2",
- 'comicpress_management' => "yes"
+ 'comicpress_management' => "yes",
+ 'change_parent' => "yes"
),
array(
'post' => array(