working on url backend admin

This commit is contained in:
John Bintz 2009-12-06 17:38:55 -05:00
parent 93fa9500b7
commit a57e9583e4
4 changed files with 79 additions and 10 deletions

View File

@ -483,6 +483,15 @@ class ComicPressAdmin {
$method = 'handle_update_' . strtolower(str_replace('-', '_', $action));
if (method_exists($this, $method)) {
$this->{$method}($_REQUEST['cp']);
} else {
foreach (get_declared_classes() as $class_name) {
if (preg_match('#^ComicPressBackend.+Admin$#', $class_name) > 0) {
if (method_exists($class_name, $method)) {
$fa = new $class_name();
$fa->{$method}($_REQUEST['cp']);
}
}
}
}
}
}

View File

@ -44,14 +44,6 @@ class ComicPressBackendURL extends ComicPressBackend {
return false;
}
function post_meta_box($post_id) {
echo "hello";
}
function admin_menu() {
add_meta_box('comicpess-url-backend-url', __('ComicPress Remote URL Images', 'comicpress'), array('ComicPressBackendURL', 'post_meta_box'), 'post', 'normal', 'low');
}
}
class ComicPressBackendURLFactory {
@ -99,4 +91,34 @@ class ComicPressBackendURLFactory {
}
}
add_action('admin_menu', array('ComicPressBackendURL', 'admin_menu'));
class ComicPressBackendURLAdmin {
function post_meta_box($post) {
$factory = new ComicPressBackendUrlFactory();
$backends = $factory->generate_from_post($post);
$nonce = wp_create_nonce('comicpress');
$action_nonce = wp_create_nonce('comicpress-backend-url');
$comicpress = ComicPress::get_instance();
include('partials/backend-url/metabox.inc');
}
function admin_menu() {
add_meta_box('comicpess-url-backend-url', __('ComicPress Remote URL Images', 'comicpress'), array('ComicPressBackendURLAdmin', 'post_meta_box'), 'post', 'normal', 'low');
wp_enqueue_script('scriptaculous-builder');
}
function handle_update_backend_url_new_editor($info) {
$comicpress = ComicPress::get_instance();
$backend = new ComicPressBackendUrl();
$backend->id = 'new-' . md5(rand());
include('partials/backend-url/_editor.inc');
exit(0);
}
}
add_action('admin_menu', array('ComicPressBackendURLAdmin', 'admin_menu'));

View File

@ -0,0 +1,14 @@
<div class="comicpress-url-backend-holder">
<table class="widefat">
<?php
foreach ($comicpress->comicpress_options['image_types'] as $type => $info) {
$url = isset($backend->urls_by_type[$type]) ? $backend->urls_by_type[$type] : ''; ?>
<tr>
<th scope="row"><?php echo esc_html($info['name']) ?></th>
<td><input type="text" style="width: 100%" name="cp[url][<?php echo esc_attr($backend->id) ?>][<?php echo esc_attr($type) ?>]" value="<?php echo esc_attr($url) ?>" />
</tr>
<?php
}
?>
</table>
</div>

View File

@ -0,0 +1,24 @@
<div id="comicpress-backend-url-holder-container">
<?php
foreach ($backends as $backend) {
include('_editor.inc');
}
?>
</div>
<a href="#" id="comicpress-backend-url-add-new">Add a new image</a>
<script type="text/javascript">
$('comicpress-backend-url-add-new').observe('click', function(e) {
Event.stop(e);
new Ajax.Updater(
'comicpress-backend-url-holder-container',
ComicPressAdmin.ajax_uri, {
'insertion': 'bottom',
'parameters': {
'cp[_nonce]': ComicPressAdmin.nonce,
'cp[action]': 'backend-url-new-editor',
'cp[_action_nonce]': '<?php echo esc_js(wp_create_nonce('comicpress-backend-url-new-editor')) ?>'
}
}
);
});
</script>