remove the idea of comic category
This commit is contained in:
parent
49ce41fdc9
commit
7a98ebbad1
|
@ -168,7 +168,7 @@ class ComicPressStoryline {
|
||||||
return $this->_merge_simple_storyline($simple_storyline);
|
return $this->_merge_simple_storyline($simple_storyline);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_category_simple_structure($parent) {
|
function get_category_simple_structure($parent = null) {
|
||||||
$structure = array();
|
$structure = array();
|
||||||
foreach (get_all_category_ids() as $category_id) {
|
foreach (get_all_category_ids() as $category_id) {
|
||||||
$category = get_category($category_id);
|
$category = get_category($category_id);
|
||||||
|
@ -178,15 +178,17 @@ class ComicPressStoryline {
|
||||||
$structure[$category->parent][$category_id] = true;
|
$structure[$category->parent][$category_id] = true;
|
||||||
}
|
}
|
||||||
$structure = $this->_merge_simple_storyline($structure);
|
$structure = $this->_merge_simple_storyline($structure);
|
||||||
if (isset($structure[0])) {
|
if (!empty($parent)) {
|
||||||
foreach ($structure[0] as $key => $children) {
|
if (isset($structure[0])) {
|
||||||
if ($key != $parent) { unset($structure[0][$key]); }
|
foreach ($structure[0] as $key => $children) {
|
||||||
}
|
if ($key != $parent) { unset($structure[0][$key]); }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $structure;
|
return $structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_category_flattened($parent) {
|
function get_category_flattened($parent = null) {
|
||||||
return $this->flatten_simple_storyline($this->get_category_simple_structure($parent));
|
return $this->flatten_simple_storyline($this->get_category_simple_structure($parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +231,7 @@ class ComicPressStoryline {
|
||||||
if (is_null($flattened_storyline)) {
|
if (is_null($flattened_storyline)) {
|
||||||
$flattened_storyline = $this->get_flattened_storyline();
|
$flattened_storyline = $this->get_flattened_storyline();
|
||||||
}
|
}
|
||||||
$all_categories_flattened = $this->get_category_flattened($comicpress->comicpress_options['comic_category_id']);
|
$all_categories_flattened = $this->get_category_flattened();
|
||||||
|
|
||||||
$result = $this->normalize_flattened_storyline($flattened_storyline, $all_categories_flattened);
|
$result = $this->normalize_flattened_storyline($flattened_storyline, $all_categories_flattened);
|
||||||
if ($set) {
|
if ($set) {
|
||||||
|
@ -258,7 +260,7 @@ class ComicPressStoryline {
|
||||||
function normalize_flattened_storyline($storyline, $comic_categories) {
|
function normalize_flattened_storyline($storyline, $comic_categories) {
|
||||||
$storyline_nodes = explode(",", $storyline);
|
$storyline_nodes = explode(",", $storyline);
|
||||||
$category_nodes = explode(",", $comic_categories);
|
$category_nodes = explode(",", $comic_categories);
|
||||||
|
|
||||||
$missing_from_storyline = array_diff($category_nodes, $storyline_nodes);
|
$missing_from_storyline = array_diff($category_nodes, $storyline_nodes);
|
||||||
$extra_in_storyline = array_diff($storyline_nodes, $category_nodes);
|
$extra_in_storyline = array_diff($storyline_nodes, $category_nodes);
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,6 @@
|
||||||
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
|
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
|
||||||
<h3><?php _e('Global Options', 'comicpress') ?></h3>
|
<h3><?php _e('Global Options', 'comicpress') ?></h3>
|
||||||
<table class="widefat fixed">
|
<table class="widefat fixed">
|
||||||
<tr>
|
|
||||||
<th scope="row" valign="top"><?php _e('Master Comic Category', 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<select name="cp[comic_category_id]">
|
|
||||||
<?php echo $this->create_category_options($root_categories, $this->comicpress->comicpress_options['comic_category_id']) ?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" valign="top"><?php _e('Layout', 'comicpress') ?></th>
|
<th scope="row" valign="top"><?php _e('Layout', 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -12,7 +12,7 @@ Storyline.get_order = function() {
|
||||||
Storyline.setup = function() {
|
Storyline.setup = function() {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var depths = {};
|
var depths = {};
|
||||||
$$('#storyline-sorter .cp-children').each(function(ch) {
|
$$('.cp-children').each(function(ch) {
|
||||||
ch.id = 'children-' + i;
|
ch.id = 'children-' + i;
|
||||||
var depth = ch.ancestors().length;
|
var depth = ch.ancestors().length;
|
||||||
if (!depths[depth]) { depths[depth] = []; }
|
if (!depths[depth]) { depths[depth] = []; }
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
|
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once(dirname(__FILE__) . '/../../classes/ComicPressAddon.inc');
|
require_once(dirname(__FILE__) . '/../classes/ComicPressAdmin.inc');
|
||||||
require_once(dirname(__FILE__) . '/../../addons/Core/Core.inc');
|
|
||||||
|
|
||||||
class CoreTest extends PHPUnit_Framework_TestCase {
|
class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
_reset_wp();
|
_reset_wp();
|
||||||
$_POST = array();
|
$_POST = array();
|
||||||
$this->core = new ComicPressAddonCore();
|
$this->admin = new ComicPressAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestGetRootComicCategories() {
|
function providerTestGetRootComicCategories() {
|
||||||
|
@ -34,7 +33,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result_ids = array();
|
$result_ids = array();
|
||||||
foreach ($this->core->get_root_categories() as $category) {
|
foreach ($this->admin->get_root_categories() as $category) {
|
||||||
$result_ids[] = $category->term_id;
|
$result_ids[] = $category->term_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +48,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
array(1,2),
|
array(1,2),
|
||||||
array(get_category(1), get_category(2))
|
array(get_category(1), get_category(2))
|
||||||
) as $category_test) {
|
) as $category_test) {
|
||||||
$source = $this->core->create_category_options($category_test, 1);
|
$source = $this->admin->create_category_options($category_test, 1);
|
||||||
|
|
||||||
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCreateDimensionSelector() {
|
function testCreateDimensionSelector() {
|
||||||
$source = $this->core->create_dimension_selector("test", "760x340");
|
$source = $this->admin->create_dimension_selector("test", "760x340");
|
||||||
|
|
||||||
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
||||||
|
|
||||||
|
@ -137,23 +136,23 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
* @dataProvider providerTestHandleUpdate
|
* @dataProvider providerTestHandleUpdate
|
||||||
*/
|
*/
|
||||||
function testHandleUpdate($original, $change, $new) {
|
function testHandleUpdate($original, $change, $new) {
|
||||||
$this->core->comicpress = $this->getMock('ComicPress', array('save', 'init'));
|
$this->admin->comicpress = $this->getMock('ComicPress', array('save', 'init'));
|
||||||
$this->core->comicpress->comicpress_options = array(
|
$this->admin->comicpress->comicpress_options = array(
|
||||||
'comic_category_id' => 1,
|
'comic_category_id' => 1,
|
||||||
'comic_dimensions' => '760x',
|
'comic_dimensions' => '760x',
|
||||||
'rss_dimensions' => '350x',
|
'rss_dimensions' => '350x',
|
||||||
'archive_dimensions' => '125x'
|
'archive_dimensions' => '125x'
|
||||||
);
|
);
|
||||||
$this->core->comicpress->comicpress_options = array_merge($this->core->comicpress->comicpress_options, $original);
|
$this->admin->comicpress->comicpress_options = array_merge($this->admin->comicpress->comicpress_options, $original);
|
||||||
|
|
||||||
add_category(2, (object)array('name' => 'test'));
|
add_category(2, (object)array('name' => 'test'));
|
||||||
|
|
||||||
$_POST = $change;
|
$_POST = $change;
|
||||||
|
|
||||||
$this->core->handle_update_comicpress_options($_POST['cp']);
|
$this->admin->handle_update_comicpress_options($_POST['cp']);
|
||||||
|
|
||||||
foreach ($new as $key => $value) {
|
foreach ($new as $key => $value) {
|
||||||
$this->assertEquals($value, $this->core->comicpress->comicpress_options[$key]);
|
$this->assertEquals($value, $this->admin->comicpress->comicpress_options[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +228,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
'attachments' => array('1' => $changes)
|
'attachments' => array('1' => $changes)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->core->handle_update_attachments();
|
$this->admin->handle_update_attachments();
|
||||||
|
|
||||||
foreach ($expected_settings as $settings_type => $settings) {
|
foreach ($expected_settings as $settings_type => $settings) {
|
||||||
switch ($settings_type) {
|
switch ($settings_type) {
|
||||||
|
@ -264,7 +263,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
* @dataProvider providerTestHandleUpdateOverridePartial
|
* @dataProvider providerTestHandleUpdateOverridePartial
|
||||||
*/
|
*/
|
||||||
function testHandleUpdateOverridePartial($code, $action) {
|
function testHandleUpdateOverridePartial($code, $action) {
|
||||||
$this->core->comicpress = (object)array(
|
$this->admin->comicpress = (object)array(
|
||||||
'comicpress_options' => array(
|
'comicpress_options' => array(
|
||||||
'override_partials' => array(
|
'override_partials' => array(
|
||||||
'index' => '$hiss;'
|
'index' => '$hiss;'
|
||||||
|
@ -272,10 +271,10 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->core->handle_update_override_partial(array_merge(compact('code', 'action'), array('partial' => 'index')));
|
$this->admin->handle_update_override_partial(array_merge(compact('code', 'action'), array('partial' => 'index')));
|
||||||
|
|
||||||
if ($result && $action == "Update partial") {
|
if ($result && $action == "Update partial") {
|
||||||
$this->assertEquals($code, $this->core->comicpress->comicpress_options['override_partials']['index']);
|
$this->assertEquals($code, $this->admin->comicpress->comicpress_options['override_partials']['index']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -240,6 +240,7 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
add_category(2, (object)array('parent' => 1));
|
add_category(2, (object)array('parent' => 1));
|
||||||
add_category(3, (object)array('parent' => 2));
|
add_category(3, (object)array('parent' => 2));
|
||||||
add_category(4, (object)array('parent' => 2));
|
add_category(4, (object)array('parent' => 2));
|
||||||
|
add_category(5, (object)array('parent' => 0));
|
||||||
|
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(array(
|
||||||
'0' => array(
|
'0' => array(
|
||||||
|
@ -251,6 +252,18 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
), $this->css->get_category_simple_structure(1));
|
), $this->css->get_category_simple_structure(1));
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'0' => array(
|
||||||
|
'1' => array(
|
||||||
|
'2' => array(
|
||||||
|
'3' => true,
|
||||||
|
'4' => true
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'5' => true
|
||||||
|
)
|
||||||
|
), $this->css->get_category_simple_structure());
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestNormalizeFlattenedStoryline() {
|
function providerTestNormalizeFlattenedStoryline() {
|
||||||
|
|
Loading…
Reference in New Issue