2009-07-08 23:51:02 +00:00
|
|
|
<?php
|
|
|
|
|
2009-11-05 12:00:29 +00:00
|
|
|
class ComicPressAdmin {
|
2009-07-20 22:27:12 +00:00
|
|
|
/**
|
|
|
|
* Initialize the addon.
|
|
|
|
* @param ComicPress $comicpress The master ComicPress object.
|
|
|
|
*/
|
2009-11-01 18:15:59 +00:00
|
|
|
function init() {
|
2009-11-01 19:04:15 +00:00
|
|
|
$this->comicpress = &ComicPress::get_instance();
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-11-03 12:55:08 +00:00
|
|
|
add_action('admin_menu', array(&$this, 'admin_menu'));
|
2009-07-11 00:27:36 +00:00
|
|
|
add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2);
|
2009-07-13 08:30:01 +00:00
|
|
|
|
2009-08-04 01:28:59 +00:00
|
|
|
if (current_user_can('edit_posts') && isset($comicpress->comicpress_options['helpers']['show_inline_comic_ordering'])) {
|
|
|
|
add_filter('comicpress_attached_image', array(&$this, 'comicpress_attached_image'), 10, 3);
|
|
|
|
add_filter('comicpress_display_attached_images', array(&$this, 'comicpress_display_attached_images'), 10, 2);
|
|
|
|
}
|
|
|
|
|
2009-11-04 03:46:43 +00:00
|
|
|
$this->comic_image_types = array(
|
2009-07-23 00:55:12 +00:00
|
|
|
'none' => __('Not a comic', 'comicpress'),
|
|
|
|
'comic' => __('Comic', 'comicpress'),
|
|
|
|
'rss' => __('RSS', 'comicpress'),
|
|
|
|
'archive' => __('Archive', 'comicpress')
|
|
|
|
);
|
2009-11-05 12:00:29 +00:00
|
|
|
|
|
|
|
if (is_admin()) {
|
|
|
|
add_action('admin_notices', array(&$this, 'display_messages'));
|
|
|
|
} else {
|
|
|
|
add_action('wp_head', array(&$this, 'display_messages'));
|
|
|
|
}
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
2009-07-13 02:31:14 +00:00
|
|
|
|
2009-08-04 01:28:59 +00:00
|
|
|
function comicpress_attached_image($content, $attachment_id, $index) {
|
|
|
|
$content .= '<label class="comic-image-ordering">'
|
|
|
|
. __('Image index:', 'comicpress')
|
|
|
|
. ' '
|
|
|
|
. '<input type="text" name="cp[ordering][comic]['
|
|
|
|
. $attachment_id
|
|
|
|
. ']" value="'
|
|
|
|
. $index
|
|
|
|
. '" /></label>';
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-08-04 01:28:59 +00:00
|
|
|
return $content;
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-08-04 01:28:59 +00:00
|
|
|
function comicpress_display_attached_images($content, $post_id) {
|
|
|
|
$content = '<form method="post">'
|
|
|
|
. '<input type="hidden" name="cp[_nonce]" value="'
|
|
|
|
. wp_create_nonce('comicpress')
|
|
|
|
. '" />'
|
|
|
|
. '<input type="hidden" name="post_ID" value="'
|
|
|
|
. $post_id
|
|
|
|
. '" />'
|
|
|
|
. $content
|
|
|
|
. '<input type="submit" value="'
|
|
|
|
. __('Change image ordering', 'comicpress')
|
|
|
|
. '" />'
|
|
|
|
. '</form>';
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-08-04 01:28:59 +00:00
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
2009-07-20 22:27:12 +00:00
|
|
|
/**
|
|
|
|
* Set up the admin interface and meta boxes.
|
|
|
|
*/
|
2009-11-03 12:55:08 +00:00
|
|
|
function admin_menu() {
|
2009-11-02 01:20:40 +00:00
|
|
|
global $plugin_page, $pagenow, $post;
|
2009-11-01 18:15:59 +00:00
|
|
|
|
2009-11-04 03:48:45 +00:00
|
|
|
add_theme_page(__("ComicPress", 'comicpress'), __('ComicPress', 'comicpress'), 'edit_themes', 'comicpress/render_admin', array(&$this, 'render_admin'));
|
2009-11-05 12:00:29 +00:00
|
|
|
|
2009-11-03 12:55:08 +00:00
|
|
|
if (strpos($pagenow, "post") === 0) {
|
2009-07-10 11:48:20 +00:00
|
|
|
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low");
|
2009-11-07 22:50:47 +00:00
|
|
|
wp_enqueue_script('cp-ordering', get_template_directory_uri() . '/js/ComicImageOrdering.js', array('scriptaculous', 'scriptaculous-slider'));
|
|
|
|
wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css');
|
2009-11-03 12:55:08 +00:00
|
|
|
add_action('admin_footer', array(&$this, 'admin_footer'));
|
2009-07-10 11:48:20 +00:00
|
|
|
}
|
2009-11-05 12:00:29 +00:00
|
|
|
|
2009-11-01 18:15:59 +00:00
|
|
|
if ($plugin_page == 'comicpress/render_admin') {
|
2009-11-07 22:50:47 +00:00
|
|
|
wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css');
|
|
|
|
wp_enqueue_script('cp-admin', get_template_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous'));
|
2009-11-01 18:15:59 +00:00
|
|
|
}
|
2009-11-02 01:20:40 +00:00
|
|
|
|
2009-11-09 03:11:26 +00:00
|
|
|
if (strpos($pagenow, "-upload") !== false) {
|
2009-11-07 22:50:47 +00:00
|
|
|
wp_enqueue_script('cp-media', get_template_directory_uri() . '/js/MediaUpload.js', array('prototype'));
|
2009-11-02 01:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-03 12:55:08 +00:00
|
|
|
|
|
|
|
function admin_footer() {
|
|
|
|
$nonce = wp_create_nonce('comicpress');
|
|
|
|
?><script type="text/javascript">
|
|
|
|
var ComicPressAdmin = {
|
|
|
|
nonce: '<?php echo $nonce ?>',
|
|
|
|
ajax_uri: '<?php echo trailingslashit(get_bloginfo('url')) ?>'
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<?php }
|
2009-07-13 02:31:14 +00:00
|
|
|
|
2009-07-20 22:27:12 +00:00
|
|
|
/**
|
|
|
|
* Modify the Media Gallery for ComicPress use.
|
|
|
|
*/
|
2009-07-11 00:27:36 +00:00
|
|
|
function setup_comic_metadata_buttons($form_fields, $post) {
|
2009-07-13 08:26:26 +00:00
|
|
|
global $pagenow;
|
2009-11-02 01:20:40 +00:00
|
|
|
|
2009-07-11 00:27:36 +00:00
|
|
|
$current_type = get_post_meta($post->ID, 'comic_image_type', true);
|
2009-11-02 03:32:35 +00:00
|
|
|
if (empty($current_type)) { $current_type = reset(array_keys($this->comic_image_types)); }
|
2009-11-02 01:20:40 +00:00
|
|
|
|
2009-07-11 00:27:36 +00:00
|
|
|
$field_html_lines = array();
|
|
|
|
$field_html_lines[] = '<input type="hidden" name="cp[_nonce]" value="' . wp_create_nonce('comicpress') . '" />';
|
2009-07-22 22:18:57 +00:00
|
|
|
foreach ($this->comic_image_types as $field => $label) {
|
2009-07-11 00:27:36 +00:00
|
|
|
$field_html_lines[] = '<label>'
|
|
|
|
. ' <input type="radio" name="attachments['
|
|
|
|
. $post->ID
|
|
|
|
. '][comic_image_type]" value="'
|
|
|
|
. $field
|
|
|
|
. '"'
|
|
|
|
. (($field == $current_type) ? ' checked="checked"' : '')
|
|
|
|
. ' /> '
|
|
|
|
. $label
|
|
|
|
. '</label>';
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-11 00:27:36 +00:00
|
|
|
$form_fields['comic_image_type'] = array(
|
|
|
|
'label' => __("Comic Image Type", 'comicpress'),
|
|
|
|
'input' => 'html',
|
|
|
|
'html' => '<center>' . implode("\n", $field_html_lines) . '</center>'
|
|
|
|
);
|
2009-07-13 08:26:26 +00:00
|
|
|
|
|
|
|
if ($pagenow !== "media.php") {
|
|
|
|
$form_fields['auto_attach'] = array(
|
|
|
|
'label' => __("Auto-attach?", 'comicpress'),
|
|
|
|
'input' => 'html',
|
|
|
|
'html' => '<input type="checkbox" name="attachments[' . $post->ID . '][auto_attach]" value="yes" checked="checked" /> <em>'
|
|
|
|
. __('Attach to this post w/o needing to insert into post', 'comicpress')
|
|
|
|
. '</em>'
|
|
|
|
);
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-11 00:27:36 +00:00
|
|
|
return $form_fields;
|
|
|
|
}
|
2009-07-08 23:51:02 +00:00
|
|
|
|
2009-07-20 22:27:12 +00:00
|
|
|
/**
|
|
|
|
* Render the admin interface.
|
|
|
|
*/
|
2009-07-08 23:51:02 +00:00
|
|
|
function render_admin() {
|
|
|
|
$nonce = wp_create_nonce('comicpress');
|
2009-10-31 20:04:29 +00:00
|
|
|
$storyline = new ComicPressStoryline();
|
2009-11-01 19:04:15 +00:00
|
|
|
$storyline->normalize();
|
2009-11-01 18:15:59 +00:00
|
|
|
$storyline->read_from_options();
|
2009-07-08 23:51:02 +00:00
|
|
|
|
2009-11-08 03:47:28 +00:00
|
|
|
include(dirname(__FILE__) . '/partials/options-admin.inc');
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-11-01 18:15:59 +00:00
|
|
|
function _render_admin_storyline_tree($node, $parent_id = "0") {
|
|
|
|
foreach ($node as $category_id => $children) {
|
|
|
|
$category = get_category($category_id);
|
2009-11-03 03:21:53 +00:00
|
|
|
echo '<div id="category_' . $parent_id . '/' . $category_id . '" class="cp-category-info">';
|
2009-11-01 18:15:59 +00:00
|
|
|
echo '<span>' . $category->name . '</span>';
|
|
|
|
if (is_array($children)) {
|
|
|
|
echo '<div class="cp-children">';
|
|
|
|
$this->_render_admin_storyline_tree($children, $parent_id . '/' . $category_id);
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-20 22:27:12 +00:00
|
|
|
/**
|
|
|
|
* Render the comic image ordering interface.
|
|
|
|
*/
|
2009-11-04 02:45:56 +00:00
|
|
|
function render_comic_image_ordering($is_ajax = false, $override_post = null) {
|
|
|
|
global $post_ID, $temp_ID;
|
|
|
|
|
|
|
|
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
|
|
|
|
if (is_numeric($override_post)) { $uploading_iframe_ID = $override_post; }
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-11-04 02:45:56 +00:00
|
|
|
$comic_post = new ComicPressComicPost(get_post($uploading_iframe_ID));
|
2009-11-11 00:55:03 +00:00
|
|
|
$ordering = $comic_post->normalize_ordering();
|
2009-11-04 02:45:56 +00:00
|
|
|
|
2009-11-09 03:11:26 +00:00
|
|
|
$nonce = wp_create_nonce('comicpress');
|
|
|
|
$zoom_level = 40;
|
|
|
|
$current_user = wp_get_current_user();
|
|
|
|
if (!empty($current_user)) {
|
|
|
|
$comicpress_meta = get_usermeta($current_user->ID, 'comicpress-settings');
|
|
|
|
if (is_array($comicpress_meta)) {
|
|
|
|
if (isset($comicpress_meta['zoom_level'])) {
|
|
|
|
$zoom_level = floor($comicpress_meta['zoom_level']);
|
2009-07-22 22:18:57 +00:00
|
|
|
}
|
2009-11-04 02:45:56 +00:00
|
|
|
}
|
2009-11-09 03:11:26 +00:00
|
|
|
}
|
2009-11-03 12:55:08 +00:00
|
|
|
|
2009-11-09 03:11:26 +00:00
|
|
|
// from wp-admin/includes/media.php O_o
|
|
|
|
$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
|
|
|
|
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image&TB_iframe=true");
|
2009-11-04 02:45:56 +00:00
|
|
|
|
2009-11-09 03:11:26 +00:00
|
|
|
if ($is_ajax === true) {
|
|
|
|
include(dirname(__FILE__) . '/partials/_comic-image-ordering-sorters.inc');
|
|
|
|
} else {
|
|
|
|
include(dirname(__FILE__) . '/partials/_comic-image-ordering.inc');
|
2009-07-22 22:18:57 +00:00
|
|
|
}
|
2009-07-10 11:48:20 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 22:27:12 +00:00
|
|
|
/**
|
|
|
|
* Create a dimension selector.
|
|
|
|
* @param string $root The field name root.
|
|
|
|
* @param $dimension The dimension to pre-fill into the fields.
|
|
|
|
* @return string The dimension selector as HTML.
|
|
|
|
*/
|
2009-07-08 23:51:02 +00:00
|
|
|
function create_dimension_selector($root, $dimension) {
|
|
|
|
$output = array();
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-08 23:51:02 +00:00
|
|
|
$parts = explode("x", $dimension);
|
|
|
|
foreach (array(
|
|
|
|
'width' => __('Width', 'comicpress'),
|
|
|
|
'height' => __('Height', 'comicpress')
|
|
|
|
) as $id => $name) {
|
|
|
|
$dim = array_shift($parts);
|
|
|
|
if (!empty($dim) && !is_numeric($dim)) { $dim = ""; }
|
2009-11-08 03:47:28 +00:00
|
|
|
$output[] = '<label>' . $name . ': <input type="text" name="' . $root . '[' . $id . ']" value="' . $dim . '" size="4" />px</label><br />';
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
return implode("\n", $output);
|
|
|
|
}
|
2009-07-14 01:21:53 +00:00
|
|
|
|
2009-11-04 02:45:56 +00:00
|
|
|
/**
|
|
|
|
* Update attachment information.
|
|
|
|
*/
|
|
|
|
function handle_update_refresh_ordering($info) {
|
|
|
|
$this->render_comic_image_ordering(true, $info['post_id']);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-21 17:40:24 +00:00
|
|
|
* Update attachment information.
|
2009-07-20 22:27:12 +00:00
|
|
|
*/
|
2009-07-21 17:40:24 +00:00
|
|
|
function handle_update_attachments() {
|
|
|
|
foreach ($_POST['attachments'] as $post_id => $settings) {
|
|
|
|
if (isset($settings['comic_image_type'])) {
|
2009-11-08 03:47:28 +00:00
|
|
|
update_post_meta($post_id, 'comic_image_type', $settings['comic_image_type']);
|
2009-07-11 00:27:36 +00:00
|
|
|
}
|
2009-07-21 17:40:24 +00:00
|
|
|
if (isset($settings['auto_attach']) && isset($settings['post_parent'])) {
|
|
|
|
$media_post = get_post($post_id);
|
|
|
|
$media_post->post_parent = $settings['post_parent'];
|
|
|
|
wp_update_post($media_post);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-21 17:40:24 +00:00
|
|
|
/**
|
|
|
|
* Update ComicPress options.
|
|
|
|
*/
|
2009-11-01 18:15:59 +00:00
|
|
|
function handle_update_comicpress_options($info) {
|
2009-08-23 20:44:54 +00:00
|
|
|
foreach (array('helpers', 'options') as $type) {
|
|
|
|
$this->comicpress->comicpress_options[$type] = array();
|
|
|
|
}
|
2009-07-21 17:40:24 +00:00
|
|
|
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
2009-11-01 18:15:59 +00:00
|
|
|
if (isset($info[$option])) {
|
2009-07-21 17:40:24 +00:00
|
|
|
switch ($option) {
|
|
|
|
case 'comic_dimensions':
|
|
|
|
case 'rss_dimensions':
|
|
|
|
case 'archive_dimensions':
|
|
|
|
case 'mini_dimensions':
|
2009-11-01 18:15:59 +00:00
|
|
|
if (is_array($info[$option])) {
|
2009-07-21 17:40:24 +00:00
|
|
|
$dim_parts = array();
|
|
|
|
$is_valid = true;
|
|
|
|
foreach (array('width', 'height') as $field) {
|
2009-11-01 18:15:59 +00:00
|
|
|
$requested_dim = trim($info[$option][$field]);
|
2009-07-21 17:40:24 +00:00
|
|
|
if ($requested_dim == "") {
|
|
|
|
$dim_parts[] = $requested_dim;
|
|
|
|
} else {
|
|
|
|
if ((int)$requested_dim == $requested_dim) {
|
2009-07-08 23:51:02 +00:00
|
|
|
$dim_parts[] = $requested_dim;
|
|
|
|
} else {
|
2009-07-21 17:40:24 +00:00
|
|
|
$is_valid = false; break;
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-21 17:40:24 +00:00
|
|
|
if ($is_valid) {
|
|
|
|
$this->comicpress->comicpress_options[$option] = implode("x", $dim_parts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-07-28 02:09:20 +00:00
|
|
|
case 'helpers':
|
2009-08-23 20:44:54 +00:00
|
|
|
case 'addons':
|
2009-11-01 18:15:59 +00:00
|
|
|
foreach ($info[$option] as $type => $set) {
|
2009-08-23 20:44:54 +00:00
|
|
|
$this->comicpress->comicpress_options[$option][$type] = true;
|
2009-07-28 02:09:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-11-01 18:15:59 +00:00
|
|
|
case 'storyline_order':
|
|
|
|
$storyline = new ComicPressStoryline();
|
2009-11-01 19:04:15 +00:00
|
|
|
$storyline->normalize($info[$option]);
|
2009-11-01 18:15:59 +00:00
|
|
|
break;
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-21 17:40:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-04 02:45:56 +00:00
|
|
|
|
|
|
|
function _json_decode($string) {
|
|
|
|
if (function_exists('json_decode')) {
|
|
|
|
return json_decode($string);
|
|
|
|
} else {
|
|
|
|
require_once(ABSPATH."/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php");
|
|
|
|
$j = new Moxiecode_JSON();
|
|
|
|
return $j->decode($string);
|
2009-11-08 03:47:28 +00:00
|
|
|
}
|
2009-11-04 02:45:56 +00:00
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-08-03 10:51:30 +00:00
|
|
|
function handle_update_comic_ordering() {
|
|
|
|
if (is_numeric($_POST['post_ID'])) {
|
|
|
|
if ($post = get_post($_POST['post_ID'])) {
|
|
|
|
$comic_post = new ComicPressComicPost(&$post);
|
2009-11-04 02:45:56 +00:00
|
|
|
$comic_post->change_comic_image_ordering($this->_json_decode(stripslashes($_POST['cp']['comic_order'])));
|
2009-08-03 10:51:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-06 02:29:54 +00:00
|
|
|
|
2009-11-07 16:40:25 +00:00
|
|
|
/**
|
|
|
|
* Update the zoom slider info.
|
|
|
|
* @param $info The browser input.
|
|
|
|
*/
|
2009-11-03 12:55:08 +00:00
|
|
|
function handle_update_zoom_slider($info) {
|
|
|
|
$this->is_ajax = true;
|
|
|
|
|
|
|
|
$current_user = wp_get_current_user();
|
|
|
|
if (!empty($current_user)) {
|
|
|
|
$comicpress_meta = get_usermeta($current_user->ID, 'comicpress-settings');
|
|
|
|
if (!is_array($comicpress_meta)) { $comicpress_meta = array(); }
|
|
|
|
$comicpress_meta['zoom_level'] = $info['zoom_level'];
|
|
|
|
update_usermeta($current_user->ID, 'comicpress-settings', $comicpress_meta);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2009-07-21 17:40:24 +00:00
|
|
|
/**
|
|
|
|
* Handle an update.
|
|
|
|
*/
|
2009-11-05 12:00:29 +00:00
|
|
|
function handle_update() {
|
|
|
|
if (is_array($_REQUEST['cp'])) {
|
|
|
|
if (isset($_REQUEST['cp']['_nonce'])) {
|
|
|
|
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
|
|
|
|
if (isset($_POST['attachments'])) {
|
|
|
|
//coming from media editor
|
|
|
|
$this->handle_update_attachments();
|
|
|
|
} else if (isset($_REQUEST['cp']['action'])) {
|
|
|
|
$method = 'handle_update_' . strtolower(str_replace('-', '_', $_REQUEST['cp']['action']));
|
|
|
|
if (method_exists($this, $method)) {
|
|
|
|
$this->{$method}($_REQUEST['cp']);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//coming from us
|
|
|
|
// clean this up O_o
|
|
|
|
$this->handle_update_comicpress_options($_REQUEST['cp']);
|
|
|
|
|
|
|
|
$this->comicpress->save();
|
|
|
|
|
|
|
|
$this->info(__("ComicPress configuration updated.", 'comicpress'));
|
|
|
|
|
|
|
|
$this->comicpress->init();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->comicpress->load();
|
|
|
|
}
|
2009-11-03 12:55:08 +00:00
|
|
|
}
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-08 03:47:28 +00:00
|
|
|
|
2009-07-23 22:25:02 +00:00
|
|
|
/**
|
|
|
|
* Create the dropdown for choosing a layout.
|
|
|
|
*/
|
2009-07-23 18:43:15 +00:00
|
|
|
function create_layout_options($layouts, $current_layout) {
|
|
|
|
$output = array();
|
2009-07-23 22:25:02 +00:00
|
|
|
foreach ($layouts as $layout_filename => $info) {
|
|
|
|
$output[] = '<option value="' . $layout_filename . '"' . (($layout_filename == $current_layout) ? ' selected="selected"' : '') . '>' . $info['Layout Name'] . '</option>';
|
2009-07-23 18:43:15 +00:00
|
|
|
}
|
|
|
|
return implode("\n", $output);
|
|
|
|
}
|
2009-11-05 12:00:29 +00:00
|
|
|
|
|
|
|
var $messages = array(
|
|
|
|
'info' => array(),
|
|
|
|
'warn' => array(),
|
|
|
|
'error' => array()
|
|
|
|
);
|
|
|
|
|
|
|
|
function info($message) { $this->messages['info'][] = $message; }
|
|
|
|
function warn($message) { $this->messages['warn'][] = $message; }
|
|
|
|
function error($message) { $this->messages['error'][] = $message; }
|
|
|
|
|
|
|
|
function display_messages() {
|
|
|
|
foreach ($this->messages as $type => $messages) {
|
|
|
|
if (!empty($messages)) {
|
|
|
|
echo '<div class="updated fade cp-' . $type . '">';
|
|
|
|
foreach ($messages as $message) {
|
|
|
|
echo '<p>' . $message . '</p>';
|
|
|
|
}
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-05 12:00:29 +00:00
|
|
|
?>
|