working on category sort ordering
This commit is contained in:
parent
aca8e0110d
commit
ef1077b3d4
@ -178,6 +178,33 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
return implode("\n", $output);
|
return implode("\n", $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
function handle_update() {
|
function handle_update() {
|
||||||
if (isset($_POST['attachments'])) {
|
if (isset($_POST['attachments'])) {
|
||||||
//coming from media editor
|
//coming from media editor
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
|
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php _e('Master Comic Category', 'comicpress') ?></th>
|
<th scope="row" valign="top"><?php _e('Master Comic Category', 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
<select name="cp[comic_category_id]">
|
<select name="cp[comic_category_id]">
|
||||||
<?php echo $this->create_category_options($root_categories, $this->comicpress->comicpress_options['comic_category_id']) ?>
|
<?php echo $this->create_category_options($root_categories, $this->comicpress->comicpress_options['comic_category_id']) ?>
|
||||||
@ -15,23 +15,61 @@
|
|||||||
'comic_dimensions' => __('Comic Image Dimensions', 'comicpress'),
|
'comic_dimensions' => __('Comic Image Dimensions', 'comicpress'),
|
||||||
'rss_dimensions' => __('RSS Feed Image Dimensions', 'comicpress'),
|
'rss_dimensions' => __('RSS Feed Image Dimensions', 'comicpress'),
|
||||||
'archive_dimensions' => __('Archive Image Dimensions', 'comicpress'),
|
'archive_dimensions' => __('Archive Image Dimensions', 'comicpress'),
|
||||||
|
'mini_dimensions' => __('Mini Image Dimensions', 'comicpress'),
|
||||||
) as $field => $name) { ?>
|
) as $field => $name) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php echo $name ?></th>
|
<th scope="row" valign="top"><?php echo $name ?></th>
|
||||||
<td>
|
<td>
|
||||||
<?php echo $this->create_dimension_selector('cp[' . $field . ']', $this->comicpress->comicpress_options[$field]) ?>
|
<?php echo $this->create_dimension_selector('cp[' . $field . ']', $this->comicpress->comicpress_options[$field]) ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php _e("Number of blog posts on home page") ?></th>
|
<th scope="row" valign="top"><?php _e("Number of blog posts on home page", 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="cp[blogpost_count]" value="<?php echo $this->comicpress->comicpress_options['blogpost_count'] ?>" size="3" />
|
<input type="text" name="cp[blogpost_count]" value="<?php echo $this->comicpress->comicpress_options['blogpost_count'] ?>" size="3" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row" valign="top"><?php _e("Set storyline category order", 'comicpress') ?></th>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
for ($i = 0, $il = count($this->comicpress->category_tree); $i < $il; ++$i) {
|
||||||
|
$node = $this->comicpress->category_tree[$i];
|
||||||
|
$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) {
|
||||||
|
$target = ($i - $direction);
|
||||||
|
if (isset($this->comicpress->category_tree[$target])) {
|
||||||
|
$target_parts = explode("/", $this->comicpress->category_tree[$target]);
|
||||||
|
if (count($target_parts) == count($parts)) {
|
||||||
|
$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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php }
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<p><em>(categories can be modified on the Posts -> Categories page)</em></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td><input type="submit" value="Submit Changes" /></td>
|
<td><input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once(dirname(__FILE__) . '/../../../../mockpress/mockpress.php');
|
require_once(dirname(__FILE__) . '/../../../../mockpress/mockpress.php');
|
||||||
|
require_once(dirname(__FILE__) . '/../../../classes/ComicPressAddon.inc');
|
||||||
require_once(dirname(__FILE__) . '/../Core.inc');
|
require_once(dirname(__FILE__) . '/../Core.inc');
|
||||||
|
|
||||||
class CoreTest extends PHPUnit_Framework_TestCase {
|
class CoreTest extends PHPUnit_Framework_TestCase {
|
||||||
@ -171,6 +172,38 @@ class CoreTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals($value, $this->core->comicpress->comicpress_options[$key]);
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -9,6 +9,7 @@ class ComicPress {
|
|||||||
'comic_dimensions' => '760x',
|
'comic_dimensions' => '760x',
|
||||||
'rss_dimensions' => '350x',
|
'rss_dimensions' => '350x',
|
||||||
'archive_dimensions' => '125x',
|
'archive_dimensions' => '125x',
|
||||||
|
'mini_dimensions' => '100x',
|
||||||
'category_order' => false,
|
'category_order' => false,
|
||||||
'blogpost_count' => 10
|
'blogpost_count' => 10
|
||||||
);
|
);
|
||||||
|
@ -48,7 +48,6 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testNormalizeAttachmentSorting() {
|
function testNormalizeAttachmentSorting() {
|
||||||
update_post_meta(1, 'comic_order', '2,1')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user