more polishing

This commit is contained in:
John Bintz 2009-11-18 21:25:35 -05:00
parent 2d03a4db01
commit cd64f57885
6 changed files with 78 additions and 48 deletions

View File

@ -95,6 +95,7 @@ class ComicPress {
}
function editor_max_image_size($current_max, $size) {
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'])) {
@ -103,6 +104,7 @@ class ComicPress {
}
}
}
}
return $current_max;
}

View File

@ -122,16 +122,25 @@ class ComicPressAdmin {
$is_managed = $comicpress_info['managed'];
}
if ($pagenow !== "media.php") {
$form_fields['auto_attach'] = array(
$form_fields['comicpress_management'] = array(
'label' => __("Let ComicPress Manage?", 'comicpress'),
'input' => 'html',
'html' => '<label><input type="checkbox" name="attachments[' . $post->ID . '][comicpress_management]" value="yes" ' . ($is_managed ? 'checked="checked"' : '') . '/> '
'html' => '<label><input type="checkbox" name="attachments[' . esc_attr($post->ID) . '][comicpress_management]" value="yes" ' . ($is_managed ? 'checked="checked"' : '') . '/> '
. __('Let ComicPress treat this image as a comic media file', 'comicpress')
. '</label>'
. '<input type="hidden" name="cp[_nonce]" value="' . wp_create_nonce('comicpress') . '" />'
. '<input type="hidden" name="attachments[' . $post->ID . '][post_parent]" value="' . $post->post_parent . '" />'
);
if ($pagenow !== "media.php") {
$form_fields['attach_parent'] = array(
'label' => __("Change parent?", 'comicpress'),
'input' => 'html',
'html' => '<label><input type="checkbox" name="attachments[' . esc_attr($post->ID) . '][change_parent]" value="yes" /> '
. __('Attach this image to the current post being edited?', 'comicpress')
. '</label>'
);
}
return $form_fields;
@ -209,6 +218,7 @@ class ComicPressAdmin {
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
if (is_numeric($override_post)) { $uploading_iframe_ID = $override_post; }
if ($uploading_iframe_ID > 0) {
$comic_post = new ComicPressComicPost(get_post($uploading_iframe_ID));
$ordering = $comic_post->normalize_ordering();
@ -246,6 +256,9 @@ class ComicPressAdmin {
} else {
include(dirname(__FILE__) . '/partials/_comic-image-ordering.inc');
}
} else {
_e('You\'ll need to save your post as a draft or publish it before you can order comic images.', 'comicpress');
}
}
// @codeCoverageIgnoreEnd
@ -297,7 +310,7 @@ class ComicPressAdmin {
*/
function handle_update_attachments() {
foreach ($_POST['attachments'] as $post_id => $settings) {
if (isset($settings['comicpress_management'])) {
if (isset($settings['change_parent'])) {
$media_post = get_post($post_id);
if (isset($media_post->post_parent)) {
$media_post->post_parent = $settings['post_parent'];

View File

@ -7,7 +7,6 @@
)
?>
<?php _e('Click the Refesh button underneath the zoom slider if you\'ve changed the images attached to this post.', 'comicpress') ?>
</em></p>
<?php if (!empty($ordering)) { ?>
<div id="comic-ordering">

View File

@ -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) {

View File

@ -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); });
});
});

View File

@ -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(