major work on storyline cleanup

This commit is contained in:
John Bintz 2009-11-01 13:15:59 -05:00
parent 72fc0d356b
commit b96082826a
9 changed files with 333 additions and 302 deletions

View File

@ -9,7 +9,9 @@ class ComicPressAddonCore extends ComicPressAddon {
* Initialize the addon.
* @param ComicPress $comicpress The master ComicPress object.
*/
function init(&$comicpress) {
function init() {
$this->comicpress = ComicPress::get_instance();
add_action('admin_menu', array(&$this, 'setup_admin_interface'));
add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2);
add_action('show_comic', array(&$this, 'show_comic'), 1, 1);
@ -21,8 +23,6 @@ class ComicPressAddonCore extends ComicPressAddon {
add_action('template_redirect', array(&$this, 'go_to_random_comic'));
}
$this->comicpress = $comicpress;
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);
@ -192,12 +192,19 @@ class ComicPressAddonCore extends ComicPressAddon {
* Set up the admin interface and meta boxes.
*/
function setup_admin_interface() {
global $plugin_page;
add_theme_page(__("ComicPress Core", 'comicpress'), __('ComicPress Core', 'comicpress'), 'edit_themes', 'comicpress/render_admin', array(&$this, 'render_admin'));
add_theme_page(__("Edit Partials", 'comicpress'), __('Edit Partials', 'comicpress'), 'edit_themes', 'comicpress/edit_partials', array(&$this, 'render_edit_partials'));
if (isset($_REQUEST['post'])) {
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low");
}
if ($plugin_page == 'comicpress/render_admin') {
wp_enqueue_style('cp-admin', get_stylesheet_directory_uri() . '/css/cp-admin.css');
wp_enqueue_script('cp-admin', get_stylesheet_directory_uri() . '/js/Storyline.js', array('jquery', 'jquery-ui-sortable'));
}
}
/**
@ -293,11 +300,25 @@ class ComicPressAddonCore extends ComicPressAddon {
$nonce = wp_create_nonce('comicpress');
$root_categories = $this->get_root_categories();
$storyline = new ComicPressStoryline();
$storyline->create_structure(get_option('comicpress-storyline-category-order'));
$storyline->read_from_options();
include(dirname(__FILE__) . '/partials/options-admin.inc');
}
function _render_admin_storyline_tree($node, $parent_id = "0") {
foreach ($node as $category_id => $children) {
$category = get_category($category_id);
echo '<div class="cp-category-info category-' . $parent_id . '/' . $category_id . '">';
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>';
}
}
function render_edit_partials() {
$nonce = wp_create_nonce('comicpress');
@ -393,103 +414,6 @@ class ComicPressAddonCore extends ComicPressAddon {
return implode("\n", $output);
}
/**
* Determine whether or not storyline categories can be moved or not.
* @return array The storyline nodes with their move statuses.
*/
function get_storyline_move_statuses() {
$nodes_with_statuses = array();
for ($i = 0, $il = count($this->comicpress->category_tree); $i < $il; ++$i) {
$node = $this->comicpress->category_tree[$i];
$nodes_with_statuses[$node] = array();
$parts_count = count(explode("/", $node));
foreach (array(
'0' => -1,
'1' => 1
) as $position => $direction) {
$current_node_index = $i;
$status = false;
do {
$current_node_index += $direction;
if (isset($this->comicpress->category_tree[$current_node_index])) {
$current_node = $this->comicpress->category_tree[$current_node_index];
$current_parts_count = count(explode("/", $current_node));
if ($current_parts_count == $parts_count) { $status = true; break; }
if ($current_parts_count < $parts_count) { break; }
}
} while (isset($this->comicpress->category_tree[$current_node_index]));
$nodes_with_statuses[$node][$position] = $status;
}
}
return $nodes_with_statuses;
}
/**
* Move a category in the hierarchy.
* @param array $category The category to move.
* @param int $direction The direction to move it in (-1 for up, 1 for down)
*/
function move_storyline_category_order($category, $direction) {
for ($i = 0, $il = count($this->comicpress->category_tree); $i < $il; ++$i) {
$node = $this->comicpress->category_tree[$i];
$parts = explode("/", $node);
$parts_count = count($parts);
if (end($parts) == $category) {
$current_node_index = $i;
$target_index = null;
do {
$current_node_index += $direction;
if (isset($this->comicpress->category_tree[$current_node_index])) {
$current_parts_count = count(explode("/", $this->comicpress->category_tree[$current_node_index]));
if ($current_parts_count == $parts_count) { $target_index = $current_node_index; break; }
if ($current_parts_count < $parts_count) { break; }
}
} while (isset($this->comicpress->category_tree[$current_node_index]));
if (!is_null($target_index)) {
$end_i_index = $i;
do {
$end_i_index++;
if (isset($this->comicpress->category_tree[$end_i_index])) {
if (strpos($this->comicpress->category_tree[$end_i_index], $node) !== 0) {
break;
}
}
} while (isset($this->comicpress->category_tree[$end_i_index]));
$new_order = $this->comicpress->category_tree;
$target_index_node = $new_order[$target_index];
$move = array_splice($new_order, $i, $end_i_index - $i);
$target = array_search($target_index_node, $new_order);
$prefix = array_splice($new_order, 0, $target);
if ($direction == -1) {
$new_order = array_merge($prefix, $move, $new_order);
} else {
$leftover = array();
if (count($new_order) > 1) {
$start_parts_count = count(explode("/", $new_order[0]));
for ($j = 1, $jl = count($new_order); $j < $jl; ++$j) {
if (count(explode("/", $new_order[$i])) < $start_parts_count) {
$leftover = array_splice($new_order, $j); break;
}
}
}
$new_order = array_merge($prefix, $new_order, $move, $leftover);
}
$this->comicpress->comicpress_options['category_order'] = $new_order;
break;
}
}
}
}
/**
* Update attachment information.
*/
@ -509,18 +433,18 @@ class ComicPressAddonCore extends ComicPressAddon {
/**
* Update ComicPress options.
*/
function handle_update_comicpress_options() {
function handle_update_comicpress_options($info) {
foreach (array('helpers', 'options') as $type) {
$this->comicpress->comicpress_options[$type] = array();
}
foreach ($this->comicpress->comicpress_options as $option => $value) {
if (isset($_POST['cp'][$option])) {
if (isset($info[$option])) {
switch ($option) {
case 'comic_category_id':
if (is_numeric($_POST['cp'][$option])) {
$result = get_category($_POST['cp'][$option]);
if (is_numeric($info[$option])) {
$result = get_category($info[$option]);
if (!(is_a($result, 'WP_Error') || empty($result))) {
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
$this->comicpress->comicpress_options[$option] = $info[$option];
}
}
break;
@ -528,11 +452,11 @@ class ComicPressAddonCore extends ComicPressAddon {
case 'rss_dimensions':
case 'archive_dimensions':
case 'mini_dimensions':
if (is_array($_POST['cp'][$option])) {
if (is_array($info[$option])) {
$dim_parts = array();
$is_valid = true;
foreach (array('width', 'height') as $field) {
$requested_dim = trim($_POST['cp'][$option][$field]);
$requested_dim = trim($info[$option][$field]);
if ($requested_dim == "") {
$dim_parts[] = $requested_dim;
} else {
@ -550,19 +474,23 @@ class ComicPressAddonCore extends ComicPressAddon {
}
break;
case 'blogpost_count':
$this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option];
$this->comicpress->comicpress_options[$option] = (int)$info[$option];
break;
case 'comic_space':
case 'category_usage':
case 'layout';
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
$this->comicpress->comicpress_options[$option] = $info[$option];
break;
case 'helpers':
case 'addons':
foreach ($_POST['cp'][$option] as $type => $set) {
foreach ($info[$option] as $type => $set) {
$this->comicpress->comicpress_options[$option][$type] = true;
}
break;
case 'storyline_order':
$storyline = new ComicPressStoryline();
var_dump($storyline->set_flattened_storyline_order($info[$option]));
break;
}
}
}
@ -595,13 +523,14 @@ class ComicPressAddonCore extends ComicPressAddon {
/**
* Handle an update.
*/
function handle_update() {
function handle_update($info) {
if (isset($_POST['attachments'])) {
//coming from media editor
$this->handle_update_attachments();
} else if (is_array($_POST['cp']['ordering'])) {
} else if (is_array($info['ordering'])) {
// comic ordering
/*
if (isset($_POST['meta'])) {
$meta_key_to_ignore = false;
foreach ($_POST['meta'] as $meta_key => $params) {
@ -617,20 +546,17 @@ class ComicPressAddonCore extends ComicPressAddon {
}
}
$this->handle_update_comic_ordering();
} else if (isset($_POST['cp']['partial'])) {
$this->handle_update_override_partial($_POST['cp']);
$this->info(sprintf(__("Partial %s updated.", 'comicpress'), $_POST['cp']['partial']));
$this->handle_update_comic_ordering($info);
*/
} else if (isset($info['partial'])) {
$this->handle_update_override_partial($info);
$this->info(sprintf(__("Partial %s updated.", 'comicpress'), $info['partial']));
$this->comicpress->save();
$this->comicpress->init();
} else {
//coming from us
$this->handle_update_comicpress_options();
if (isset($_GET['cp']['move_direction']) && isset($_GET['cp']['category'])) {
$this->move_storyline_category_order($_GET['cp']['category'], $_GET['cp']['move_direction']);
}
$this->handle_update_comicpress_options($info);
$this->comicpress->save();

View File

@ -40,36 +40,16 @@
</td>
</tr>
<tr>
<th scope="row" valign="top"><?php _e("Set storyline category order", 'comicpress') ?></th>
<th scope="row" valign="top"><?php _e("Arrange storyline category order", 'comicpress') ?></th>
<td>
<input type="hidden" name="cp[storyline_order]" />
<div id="storyline-sorter" class="cp-children">
<?php
foreach ($this->get_storyline_move_statuses() as $node => $statuses) {
$parts = explode("/", $node);
$category = get_category(end($parts));
if (!empty($category)) {
?>
<div class="storyline" style="padding-left: <?php echo (count($parts) - 2) * 20 ?>px">
<strong><?php echo $category->name ?></strong>
<?php
foreach (array(
"-1" => __("Up", 'comicpress'),
"1" => __("Down", 'comicpress')
) as $direction => $label) {
$status = array_shift($statuses);
if ($status) {
$query = add_query_arg('cp[_nonce]', $nonce);
$query = add_query_arg('cp[category]', $category->term_id, $query);
$query = add_query_arg('cp[move_direction]', $direction, $query); ?>
| <a href="<?php echo $query ?>"><?php echo $label ?></a>
<?php
}
}
$this->_render_admin_storyline_tree(reset($storyline->get_simple_storyline()))
?>
</div>
<?php }
}
?>
<p><em><?php _e('(categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
<script type="text/javascript">Storyline.setup()</script>
<p><em><?php _e('(drag and drop desired order. categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
</td>
</tr>
<tr>

View File

@ -17,7 +17,8 @@ class ComicPress {
'layout' => 'classic.inc',
'helpers' => array(),
'override_partials' => array(),
'addons' => array()
'addons' => array(),
'storyline_order' => ''
);
var $additional_stylesheets = array();
@ -29,6 +30,16 @@ class ComicPress {
var $partial_paths = array();
var $layouts = null;
function get_instance() {
static $instance;
if (empty($instance)) {
$instance = &new ComicPress();
}
return $instance;
}
/**
* Load ComicPress options.
*/

View File

@ -1,10 +1,43 @@
<?php
require_once('ComicPress.inc');
require_once('ComicPressDBInterface.inc');
class ComicPressStoryline {
var $_structure, $root_category;
function read_from_options() {
$comicpress = ComicPress::get_instance();
var_dump($comicpress);
$this->create_structure($comicpress->comicpress_options['storyline_order']);
}
function get_flattened_storyline() {
$comicpress = ComicPress::get_instance();
return $comicpress->comicpress_options['storyline_order'];
}
function set_flattened_storyline($storyline) {
$comicpress = ComicPress::get_instance();
$comicpress->comicpress_options['storyline_order'] = $storyline;
$comicpress->save();
}
function set_order_via_flattened_storyline($order) {
$nodes = explode(',', $order);
$original_nodes = explode(',', $this->get_flattened_storyline());
$missing_good_nodes = array_diff($original_nodes, $nodes);
$any_bad_nodes = array_diff($nodes, $original_nodes);
if (empty($missing_good_nodes) && empty($any_bad_nodes)) {
$this->set_flattened_storyline($order);
return true;
} else {
return false;
}
}
/**
* Create a searchable structure from a node list.
* @param array $structure The structure to process.
@ -134,6 +167,28 @@ class ComicPressStoryline {
$simple_storyline[$parent][$category_id] = true;
}
return $this->_merge_simple_storyline($simple_storyline);
}
function get_category_simple_structure($parent) {
$structure = array();
foreach (get_all_category_ids() as $category_id) {
$category = get_category($category_id);
if (!isset($structure[$category->parent])) {
$structure[$category->parent] = array();
}
$structure[$category->parent][$category_id] = true;
}
$structure = $this->_merge_simple_storyline($structure);
if (isset($structure[0])) {
foreach ($structure[0] as $key => $children) {
if ($key != $parent) { unset($structure[0][$key]); }
}
}
return $structure;
}
function _merge_simple_storyline($simple_storyline) {
while (count($simple_storyline) > 0) {
$merge_found = false;
foreach ($simple_storyline as $parent => $children) {
@ -163,6 +218,61 @@ class ComicPressStoryline {
}
return $simple_storyline;
}
function normalize_flattened_storyline($storyline, $comic_categories) {
$storyline_nodes = explode(",", $storyline);
$category_nodes = explode(",", $comic_categories);
$missing_from_storyline = array_diff($category_nodes, $storyline_nodes);
$extra_in_storyline = array_diff($storyline_nodes, $category_nodes);
if (!empty($missing_from_storyline)) {
foreach ($missing_from_storyline as $node) {
$parent_pattern = implode('/', array_slice(explode('/', $node), 0, -1));
$last = null;
for ($i = 0, $il = count($storyline_nodes); $i < $il; ++$i) {
if (strpos($storyline_nodes[$i], $parent_pattern) === 0) {
$last = $i;
}
}
if (!is_null($last)) {
array_splice($storyline_nodes, $last + 1, 0, array($node));
}
}
}
if (!empty($extra_in_storyline)) {
$new = array();
foreach ($storyline_nodes as $node) {
if (!in_array($node, $extra_in_storyline)) {
$new[] = $node;
}
}
$storyline_nodes = $new;
}
return implode(',', $storyline_nodes);
}
function flatten_simple_storyline($storyline) {
return implode(',', $this->_follow_simple_storyline($storyline));
}
function _follow_simple_storyline($storyline, $parent = null) {
$output = array();
foreach ($storyline as $key => $children) {
if (is_null($parent)) {
$new_parent = $key;
} else {
$new_parent = $parent . '/' . $key;
$output[] = $new_parent;
}
if (is_array($children)) {
$output = array_merge($output, $this->_follow_simple_storyline($children, $new_parent));
}
}
return $output;
}
}
?>

17
css/cp-admin.css Normal file
View File

@ -0,0 +1,17 @@
.cp-children {
padding-left: 20px
}
.ui-draggable {
border: solid black 1px;
background-color: #ddd
}
.cp-category-info span {
cursor: move;
color: #004
}
.placeholder {
border: dashed #ddd 2px
}

View File

@ -14,7 +14,7 @@ function __comicpress_init() {
if (is_file($file)) { require_once($file); }
}
$comicpress = new ComicPress();
$comicpress = ComicPress::get_instance();
$comicpress->init();
$addons = array();
@ -34,13 +34,13 @@ function __comicpress_init() {
$comicpress->comicpress_options['addons'][$addon->name] ||
$addon->is_addon_manager
) {
$addon->init(&$comicpress);
$addon->init();
if (current_user_can('edit_posts')) {
if (is_array($_REQUEST['cp'])) {
if (isset($_REQUEST['cp']['_nonce'])) {
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
if (method_exists($addon, 'handle_update')) {
$addon->handle_update();
$addon->handle_update($_REQUEST['cp']);
$comicpress->load();
}
}

25
js/Storyline.js Normal file
View File

@ -0,0 +1,25 @@
var Storyline = {};
Storyline.get_order = function() {
var order = []
jQuery('#storyline-sorter .cp-category-info').each(function() {
var matches = this.className.match(/category-([0-9\/]+)/);
if (matches) { order.push(matches[1]); }
});
jQuery('input[name=cp[storyline_order]]').attr('value', order.join(','));
};
Storyline.setup = function() {
jQuery('.cp-children').sortable({
handle: 'span',
cursor: 'move',
placeholder: 'placeholder',
forcePlaceholderSize: true,
opacity: 0.4,
change: function(e, ui) {
Storyline.get_order();
}
});
};
jQuery(function() { Storyline.get_order(); });

View File

@ -181,6 +181,110 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_result, $this->css->get_simple_storyline());
}
function providerTestSetFlattenedStorylineOrder() {
return array(
array('0/1,0/1/2,0/1/2/3,0/1/2/4', '0/1,0/1/2,0/1/2/3,0/1/2/4', true),
array('0/1,0/1/2,0/1/2/4,0/1/2/3', '0/1,0/1/2,0/1/2/4,0/1/2/3', true),
array('0/1,0/1/2,0/1/2/5,0/1/2/3', '0/1,0/1/2,0/1/2/3,0/1/2/4', false),
);
}
/**
* @dataProvider providerTestSetFlattenedStorylineOrder
*/
function testSetFlattenedStorylineOrder($input, $expected_result, $expected_return) {
$css = $this->getMock('ComicPressStoryline', array(
'get_flattened_storyline', 'set_flattened_storyline'
));
$css->expects($this->once())
->method('get_flattened_storyline')
->will($this->returnValue('0/1,0/1/2,0/1/2/3,0/1/2/4'));
if ($expected_return === true) {
$css->expects($this->once())
->method('set_flattened_storyline')
->with($input);
} else {
$css->expects($this->never())
->method('set_flattened_storyline');
}
$this->assertEquals($expected_return, $css->set_order_via_flattened_storyline($input));
}
function testMergeSimpleStoryline() {
$original = array(
0 => array(1 => true),
1 => array(2 => true),
2 => array(3 => true, 4 => true)
);
$expected = array(
0 => array(
1 => array(
2 => array(
3 => true,
4 => true
)
)
)
);
$this->assertEquals($expected, $this->css->_merge_simple_storyline($original));
}
function testGetCategorySimpleStructure() {
add_category(1, (object)array('parent' => 0));
add_category(2, (object)array('parent' => 1));
add_category(3, (object)array('parent' => 2));
add_category(4, (object)array('parent' => 2));
$this->assertEquals(array(
'0' => array(
'1' => array(
'2' => array(
'3' => true,
'4' => true
)
)
)
), $this->css->get_category_simple_structure(1));
}
function providerTestNormalizeFlattenedStoryline() {
return array(
array('0/1,0/1/2,0/1/2/4', '0/1,0/1/2,0/1/2/4,0/1/2/3'),
array('0/1,0/1/2,0/1/2/4,0/1/2/3,0/1/5', '0/1,0/1/2,0/1/2/4,0/1/2/3'),
array('0/1,0/1/2,0/1/2/3,0/1/5', '0/1,0/1/2,0/1/2/3,0/1/2/4'),
);
}
/**
* @dataProvider providerTestNormalizeFlattenedStoryline
*/
function testNormalizeFlattenedStoryline($original_structure, $expected_structure) {
$this->assertEquals(
$expected_structure,
$this->css->normalize_flattened_storyline($original_structure, '0/1,0/1/2,0/1/2/3,0/1/2/4')
);
}
function testFlattenSimpleStoryline() {
$this->assertEquals('0/1,0/1/2,0/1/2/3,0/1/2/4', $this->css->flatten_simple_storyline(
array(
0 => array(
1 => array(
2 => array(
3 => true,
4 => true
)
)
)
)
));
}
}
?>

View File

@ -12,25 +12,6 @@ class CoreTest extends PHPUnit_Framework_TestCase {
$this->core = new ComicPressAddonCore();
}
function testShowOptionsPage() {
$nonce = wp_create_nonce('comicpress');
$this->core->comicpress = $this->getMock('ComicPress', array('get_layout_choices'));
$this->core->comicpress->expects($this->once())->method('get_layout_choices')->will($this->returnValue(array()));
ob_start();
$this->core->render_admin();
$source = ob_get_clean();
$this->assertTrue(($xml = _to_xml($source)) !== false);
foreach (array(
'//input[@name="cp[_nonce]" and @value="' . $nonce . '"]' => true,
'//select[@name="cp[comic_category_id]"]' => true
) as $xpath => $value) {
$this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath);
}
}
function providerTestGetRootComicCategories() {
return array(
array(array(), array()),
@ -169,136 +150,13 @@ class CoreTest extends PHPUnit_Framework_TestCase {
$_POST = $change;
$this->core->handle_update_comicpress_options();
$this->core->handle_update_comicpress_options($_POST['cp']);
foreach ($new as $key => $value) {
$this->assertEquals($value, $this->core->comicpress->comicpress_options[$key]);
}
}
function testGetStorylineMoveStatuses() {
$this->core->comicpress = (object)array(
'category_tree' => array(
'0/1',
'0/1/2',
'0/1/2/3',
'0/1/2/4',
'0/1/2/5',
'0/1/6',
'0/1/6/7',
'0/1/6/8',
'0/1/9',
'0/1/9/10',
'0/1/11'
)
);
$this->assertEquals(array(
'0/1' => array(false, false),
'0/1/2' => array(false, true),
'0/1/2/3' => array(false, true),
'0/1/2/4' => array(true, true),
'0/1/2/5' => array(true, false),
'0/1/6' => array(true, true),
'0/1/6/7' => array(false, true),
'0/1/6/8' => array(true, false),
'0/1/9' => array(true, true),
'0/1/9/10' => array(false, false),
'0/1/11' => array(true, false)
), $this->core->get_storyline_move_statuses());
}
function providerTestMoveStorylineCategoryOrder() {
return array(
array(
array('0/1', '0/1/2', '0/1/3'),
3, -1,
array('0/1', '0/1/3', '0/1/2')
),
array(
array('0/1', '0/1/2', '0/1/2/4', '0/1/3'),
3, -1,
array('0/1', '0/1/3', '0/1/2', '0/1/2/4')
),
array(
array('0/1', '0/1/2', '0/1/2/4', '0/1/3', '0/1/3/5'),
3, -1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/2', '0/1/2/4')
),
array(
array('0/1', '0/1/2', '0/1/3', '0/1/3/5'),
3, -1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/2')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7'),
7, -1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/7', '0/1/3/6')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7', '0/1/4'),
7, -1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/7', '0/1/3/6', '0/1/4')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7', '0/1/4'),
3, 1,
array('0/1', '0/1/4', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7')
),
array(
array('0/1', '0/1/2', '0/1/2/4', '0/1/3'),
2, 1,
array('0/1', '0/1/3', '0/1/2', '0/1/2/4')
),
array(
array('0/1', '0/1/2', '0/1/2/4', '0/1/3', '0/1/3/5'),
2, 1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/2', '0/1/2/4')
),
array(
array('0/1', '0/1/2', '0/1/3', '0/1/3/5'),
2, 1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/2')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7'),
6, 1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/7', '0/1/3/6')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7', '0/1/4'),
6, 1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/7', '0/1/3/6', '0/1/4')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7', '0/1/4'),
5, 1,
array('0/1', '0/1/3', '0/1/3/6', '0/1/3/5', '0/1/3/7', '0/1/4')
),
array(
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7', '0/1/4', '0/1/4/9'),
9, 1,
array('0/1', '0/1/3', '0/1/3/5', '0/1/3/6', '0/1/3/7', '0/1/4', '0/1/4/9')
),
);
}
/**
* @dataProvider providerTestMoveStorylineCategoryOrder
*/
function testMoveStorylineCategoryOrder($original_order, $category, $direction, $new_order) {
$this->core->comicpress = (object)array(
'category_tree' => $original_order,
'comicpress_options' => array(
'category_order' => $original_order
)
);
$this->core->move_storyline_category_order($category, $direction);
$this->assertEquals($new_order, $this->core->comicpress->comicpress_options['category_order']);
}
function providerTestUpdateAttachments() {
return array(
array(