category group editing
This commit is contained in:
parent
3e803220fd
commit
ab37be9aa9
|
@ -31,7 +31,8 @@ class ComicPress {
|
||||||
),
|
),
|
||||||
'helpers' => array(),
|
'helpers' => array(),
|
||||||
'storyline_order' => '',
|
'storyline_order' => '',
|
||||||
'enabled_backends' => null
|
'enabled_backends' => null,
|
||||||
|
'category_groupings' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
var $backends = array();
|
var $backends = array();
|
||||||
|
|
|
@ -224,6 +224,23 @@ class ComicPressAdmin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _render_admin_storyline_grouping_tree($node, $group_name, $category_ids) {
|
||||||
|
foreach ($node as $category_id => $children) {
|
||||||
|
$category = get_category($category_id);
|
||||||
|
echo '<li>';
|
||||||
|
echo '<label><input
|
||||||
|
type="checkbox"' .
|
||||||
|
(in_array($category_id, $category_ids) ? 'checked="checked"' : '') .
|
||||||
|
' name="cp[category_groupings][' . esc_attr($group_name) . '][category][]" value="' . $category_id . '" /> ' . esc_html($category->name) . '</label>';
|
||||||
|
if (is_array($children)) {
|
||||||
|
echo '<ul>';
|
||||||
|
$this->_render_admin_storyline_grouping_tree($children, $group_name, $category_ids);
|
||||||
|
echo '</ul>';
|
||||||
|
}
|
||||||
|
echo '</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the comic image ordering interface.
|
* Render the comic image ordering interface.
|
||||||
*/
|
*/
|
||||||
|
@ -394,6 +411,14 @@ class ComicPressAdmin {
|
||||||
case 'enabled_backends':
|
case 'enabled_backends':
|
||||||
$this->comicpress->comicpress_options['enabled_backends'] = array_intersect(array_keys($info[$option]), $this->comicpress->get_valid_backends());
|
$this->comicpress->comicpress_options['enabled_backends'] = array_intersect(array_keys($info[$option]), $this->comicpress->get_valid_backends());
|
||||||
break;
|
break;
|
||||||
|
case 'category_groupings':
|
||||||
|
$this->comicpress->comicpress_options['category_groupings'] = array();
|
||||||
|
foreach ($info[$option] as $key => $settings) {
|
||||||
|
if (!empty($settings['name'])) {
|
||||||
|
$this->comicpress->comicpress_options['category_groupings'][$settings['name']] = isset($settings['category']) ? $settings['category'] : array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,6 +477,20 @@ class ComicPressAdmin {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function handle_update_get_new_category_group_editor($info) {
|
||||||
|
$key = substr(md5(rand()), 0, 6);
|
||||||
|
$name = 'group';
|
||||||
|
$category_ids = array();
|
||||||
|
|
||||||
|
$storyline = new ComicPressStoryline();
|
||||||
|
$storyline->normalize();
|
||||||
|
$storyline->read_from_options();
|
||||||
|
|
||||||
|
require_once('partials/_category-grouping-editor.inc');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the zoom slider info.
|
* Update the zoom slider info.
|
||||||
* @param $info The browser input.
|
* @param $info The browser input.
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<div class="category-group-holder">
|
||||||
|
<a class="delete-category-group-holder" href="#">X</a>
|
||||||
|
<table cellspacing="0" width="100%">
|
||||||
|
<tr class="category-group-holder-name">
|
||||||
|
<th scope="row" width="20%">Group name:</th>
|
||||||
|
<td width="80%">
|
||||||
|
<input type="text" name="cp[category_groupings][<?php echo esc_attr($key) ?>][name]" value="<?php echo esc_attr($name) ?>" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="category-group-holder-name">
|
||||||
|
<th scope="row"><?php _e('Categories:', 'comicpress') ?></th>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<?php $this->_render_admin_storyline_grouping_tree(reset($storyline->get_simple_storyline()), $key, $category_ids) ?>
|
||||||
|
</ul>
|
||||||
|
<div class="empty-group-warning">
|
||||||
|
<?php _e('Empty groups will be deleted! Be sure to check at least one category if you want to keep the group.', 'comicpress') ?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
|
@ -7,6 +7,23 @@
|
||||||
|
|
||||||
<?php include('_storyline-order.inc') ?>
|
<?php include('_storyline-order.inc') ?>
|
||||||
|
|
||||||
|
<h3><?php _e('Category Groups', 'comicpress') ?></h3>
|
||||||
|
|
||||||
|
<div id="comicpress-category-groups-holder" class="comicpress-holder">
|
||||||
|
<div id="category-groups-holder">
|
||||||
|
<?php
|
||||||
|
foreach ($this->comicpress->comicpress_options['category_groupings'] as $name => $category_ids) {
|
||||||
|
$key = $name;
|
||||||
|
include('_category-grouping-editor.inc');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<a id="add-new-category-group" href="#">[+] Add a new category group</a>
|
||||||
|
<script type="text/javascript">CategoryGroupings.setup()</script>
|
||||||
|
<br />
|
||||||
|
<input class="button-primary" type="submit" value="<?php _e('Submit Updated ComicPress Options', 'comicpress') ?>" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php include('_comic-image-types.inc') ?>
|
<?php include('_comic-image-types.inc') ?>
|
||||||
|
|
||||||
<h3><?php _e('Enabled Backends', 'comicpress') ?></h3>
|
<h3><?php _e('Enabled Backends', 'comicpress') ?></h3>
|
||||||
|
@ -73,5 +90,10 @@
|
||||||
tab_holder.childElements().pop().addClassName('last');
|
tab_holder.childElements().pop().addClassName('last');
|
||||||
|
|
||||||
show_tab(tab_holder.childElements().shift().id);
|
show_tab(tab_holder.childElements().shift().id);
|
||||||
|
|
||||||
|
Event.observe(document, 'dom:loaded', function() {
|
||||||
|
ComicPressAdmin.image_type_editor_nonce = '<?php echo wp_create_nonce('comicpress-get-new-image-type-editor') ?>';
|
||||||
|
ComicPressAdmin.category_group_editor_nonce = '<?php echo wp_create_nonce('comicpress-get-new-category-group-editor') ?>';
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -259,3 +259,21 @@ tr.highlighted td {
|
||||||
border: solid black 1px;
|
border: solid black 1px;
|
||||||
padding: 0 10px 10px;
|
padding: 0 10px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.category-group-holder ul ul {
|
||||||
|
margin-left: 20px
|
||||||
|
}
|
||||||
|
|
||||||
|
.category-group-holder {
|
||||||
|
border: solid #aaa 1px;
|
||||||
|
margin: 0 0 10px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-category-group-holder {
|
||||||
|
float: right
|
||||||
|
}
|
||||||
|
|
||||||
|
.category-group-holder .selected {
|
||||||
|
background-color: #99ccbb
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var Storyline = {};
|
var Storyline = {};
|
||||||
var ComicImageTypes = {};
|
var ComicImageTypes = {};
|
||||||
|
var CategoryGroupings = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Storyline.get_order = function() {
|
Storyline.get_order = function() {
|
||||||
|
@ -76,7 +77,8 @@ var ComicImageTypes = {};
|
||||||
method: 'get',
|
method: 'get',
|
||||||
parameters: {
|
parameters: {
|
||||||
'cp[_nonce]': ComicPressAdmin.nonce,
|
'cp[_nonce]': ComicPressAdmin.nonce,
|
||||||
'cp[action]': 'get-new-image-type-editor'
|
'cp[action]': 'get-new-image-type-editor',
|
||||||
|
'cp[_action_nonce]': ComicPressAdmin.image_type_editor_nonce
|
||||||
},
|
},
|
||||||
insertion: 'bottom',
|
insertion: 'bottom',
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
|
@ -85,4 +87,58 @@ var ComicImageTypes = {};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CategoryGroupings.highlight_child_levels = function(e) {
|
||||||
|
$$('.category-group-holder input[type=checkbox]').each(function(cb) {
|
||||||
|
cb.disabled = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$$('.category-group-holder li').each(function(li) {
|
||||||
|
var all_cb = li.select('input[type=checkbox]');
|
||||||
|
var cb = all_cb.shift();
|
||||||
|
li.removeClassName('selected');
|
||||||
|
if (cb && cb.checked) {
|
||||||
|
all_cb.each(function(ncb) {
|
||||||
|
ncb.disabled = true;
|
||||||
|
});
|
||||||
|
li.addClassName('selected');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$$('.category-group-holder').each(function(cgh) {
|
||||||
|
var all_off = true;
|
||||||
|
cgh.select('input[type=checkbox]').each(function(c) {
|
||||||
|
if (c.checked) { all_off = false; }
|
||||||
|
});
|
||||||
|
cgh.select('.empty-group-warning').pop()[all_off ? 'show' : 'hide']();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CategoryGroupings.setup_editors = function() {
|
||||||
|
$$('.category-group-holder input[type=checkbox], .category-group-holder label').each(function(cb) {
|
||||||
|
cb.stopObserving('click');
|
||||||
|
cb.observe('click', CategoryGroupings.highlight_child_levels);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CategoryGroupings.setup = function() {
|
||||||
|
CategoryGroupings.setup_editors();
|
||||||
|
CategoryGroupings.highlight_child_levels();
|
||||||
|
|
||||||
|
$('add-new-category-group').observe('click', function(e) {
|
||||||
|
Event.stop(e);
|
||||||
|
new Ajax.Updater('category-groups-holder', ComicPressAdmin.ajax_uri, {
|
||||||
|
method: 'get',
|
||||||
|
parameters: {
|
||||||
|
'cp[_nonce]': ComicPressAdmin.nonce,
|
||||||
|
'cp[action]': 'get-new-category-group-editor',
|
||||||
|
'cp[_action_nonce]': ComicPressAdmin.category_group_editor_nonce
|
||||||
|
},
|
||||||
|
onComplete: function() {
|
||||||
|
CategoryGroupings.setup_editors();
|
||||||
|
},
|
||||||
|
insertion: 'bottom'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}())
|
}())
|
||||||
|
|
Loading…
Reference in New Issue