remove the idea of comic category

This commit is contained in:
John Bintz 2009-11-05 21:15:12 -05:00
parent 49ce41fdc9
commit 7a98ebbad1
5 changed files with 40 additions and 34 deletions

View File

@ -168,7 +168,7 @@ class ComicPressStoryline {
return $this->_merge_simple_storyline($simple_storyline);
}
function get_category_simple_structure($parent) {
function get_category_simple_structure($parent = null) {
$structure = array();
foreach (get_all_category_ids() as $category_id) {
$category = get_category($category_id);
@ -178,15 +178,17 @@ class ComicPressStoryline {
$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]); }
}
}
if (!empty($parent)) {
if (isset($structure[0])) {
foreach ($structure[0] as $key => $children) {
if ($key != $parent) { unset($structure[0][$key]); }
}
}
}
return $structure;
}
function get_category_flattened($parent) {
function get_category_flattened($parent = null) {
return $this->flatten_simple_storyline($this->get_category_simple_structure($parent));
}
@ -229,7 +231,7 @@ class ComicPressStoryline {
if (is_null($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);
if ($set) {
@ -258,7 +260,7 @@ class ComicPressStoryline {
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);

View File

@ -4,14 +4,6 @@
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
<h3><?php _e('Global Options', 'comicpress') ?></h3>
<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>
<th scope="row" valign="top"><?php _e('Layout', 'comicpress') ?></th>
<td>

View File

@ -12,7 +12,7 @@ Storyline.get_order = function() {
Storyline.setup = function() {
var i = 0;
var depths = {};
$$('#storyline-sorter .cp-children').each(function(ch) {
$$('.cp-children').each(function(ch) {
ch.id = 'children-' + i;
var depth = ch.ancestors().length;
if (!depths[depth]) { depths[depth] = []; }

View File

@ -2,14 +2,13 @@
require_once('PHPUnit/Framework.php');
require_once('MockPress/mockpress.php');
require_once(dirname(__FILE__) . '/../../classes/ComicPressAddon.inc');
require_once(dirname(__FILE__) . '/../../addons/Core/Core.inc');
require_once(dirname(__FILE__) . '/../classes/ComicPressAdmin.inc');
class CoreTest extends PHPUnit_Framework_TestCase {
class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
function setUp() {
_reset_wp();
$_POST = array();
$this->core = new ComicPressAddonCore();
$this->admin = new ComicPressAdmin();
}
function providerTestGetRootComicCategories() {
@ -34,7 +33,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
}
$result_ids = array();
foreach ($this->core->get_root_categories() as $category) {
foreach ($this->admin->get_root_categories() as $category) {
$result_ids[] = $category->term_id;
}
@ -49,7 +48,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
array(1,2),
array(get_category(1), get_category(2))
) 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);
@ -63,7 +62,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
}
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);
@ -137,23 +136,23 @@ class CoreTest extends PHPUnit_Framework_TestCase {
* @dataProvider providerTestHandleUpdate
*/
function testHandleUpdate($original, $change, $new) {
$this->core->comicpress = $this->getMock('ComicPress', array('save', 'init'));
$this->core->comicpress->comicpress_options = array(
$this->admin->comicpress = $this->getMock('ComicPress', array('save', 'init'));
$this->admin->comicpress->comicpress_options = array(
'comic_category_id' => 1,
'comic_dimensions' => '760x',
'rss_dimensions' => '350x',
'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'));
$_POST = $change;
$this->core->handle_update_comicpress_options($_POST['cp']);
$this->admin->handle_update_comicpress_options($_POST['cp']);
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)
);
$this->core->handle_update_attachments();
$this->admin->handle_update_attachments();
foreach ($expected_settings as $settings_type => $settings) {
switch ($settings_type) {
@ -264,7 +263,7 @@ class CoreTest extends PHPUnit_Framework_TestCase {
* @dataProvider providerTestHandleUpdateOverridePartial
*/
function testHandleUpdateOverridePartial($code, $action) {
$this->core->comicpress = (object)array(
$this->admin->comicpress = (object)array(
'comicpress_options' => array(
'override_partials' => array(
'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") {
$this->assertEquals($code, $this->core->comicpress->comicpress_options['override_partials']['index']);
$this->assertEquals($code, $this->admin->comicpress->comicpress_options['override_partials']['index']);
}
}
}

View File

@ -240,6 +240,7 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
add_category(2, (object)array('parent' => 1));
add_category(3, (object)array('parent' => 2));
add_category(4, (object)array('parent' => 2));
add_category(5, (object)array('parent' => 0));
$this->assertEquals(array(
'0' => array(
@ -251,6 +252,18 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
)
)
), $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() {