a bunch of work on storyline support
This commit is contained in:
parent
f2cdb8d7df
commit
4815766fe4
@ -413,7 +413,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||
$this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option];
|
||||
break;
|
||||
case 'comic_space':
|
||||
case 'category_page_usage':
|
||||
case 'category_usage':
|
||||
case 'layout';
|
||||
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
||||
break;
|
||||
|
@ -73,7 +73,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Insert into comic space:</th>
|
||||
<th scope="row"><?php _e('Insert into comic space:', 'comicpress') ?></th>
|
||||
<td>
|
||||
<?php foreach (array(
|
||||
"comic_only" => __("The comic only, with post content below", 'comicpress'),
|
||||
@ -84,13 +84,13 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Use comic category pages as:</th>
|
||||
<th scope="row"><?php _e('Use subcategories of the Master Comic Category as:', 'comicpress') ?></th>
|
||||
<td>
|
||||
<?php foreach (array(
|
||||
"archive_list" => __("The normal way, as a list of posts in that category", 'comicpress'),
|
||||
"comic_frontpage" => __("As the front page to the comics in that category", 'comicpress')
|
||||
"storyline" => __("Storyline indicators for a single comic", 'comicpress'),
|
||||
"multicomic" => __("Multicomic indicators, with direct descendents being separate comics", 'comicpress')
|
||||
) as $value => $label) { ?>
|
||||
<label><input type="radio" name="cp[category_page_usage]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['category_page_usage'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
|
||||
<label><input type="radio" name="cp[category_usage]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['category_usage'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -13,7 +13,7 @@ class ComicPress {
|
||||
'category_order' => false,
|
||||
'blogpost_count' => 10,
|
||||
'comic_space' => 'comic_only',
|
||||
'category_page_usage' => 'archive_list',
|
||||
'category_usage' => 'storyline',
|
||||
'layout' => 'classic.inc',
|
||||
'helpers' => array()
|
||||
);
|
||||
@ -70,6 +70,14 @@ class ComicPress {
|
||||
}
|
||||
}
|
||||
|
||||
function needs_storyline_nav() {
|
||||
return (count($this->category_tree) > 1) && ($this->comicpress_options['category_usage'] == "storyline");
|
||||
}
|
||||
|
||||
function is_multicomic() {
|
||||
return $this->comicpress_options['category_usage'] == "multicomic";
|
||||
}
|
||||
|
||||
function wp_head() {
|
||||
foreach ($this->additional_stylesheets as $uri) { ?>
|
||||
<link rel="stylesheet" href="<?php echo get_template_directory_uri() . $uri ?>" type="text/css" />
|
||||
@ -463,6 +471,24 @@ class ComicPress {
|
||||
|
||||
return $prev_next_categories;
|
||||
}
|
||||
|
||||
function get_sorted_post_categories($override_post = null) {
|
||||
global $post;
|
||||
$post_to_use = (!empty($override_post)) ? $override_post : $post;
|
||||
|
||||
$categories = wp_get_post_categories($post_to_use->ID);
|
||||
|
||||
$sorted_categories = array();
|
||||
|
||||
foreach ($this->category_tree as $node) {
|
||||
$category_id = end(explode("/", $node));
|
||||
if (in_array($category_id, $categories)) {
|
||||
$sorted_categories[] = $category_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $sorted_categories;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -64,7 +64,7 @@ function comicpress_init() {
|
||||
global $post, $comicpress;
|
||||
|
||||
if (!empty($post)) {
|
||||
if (in_comic_category()) {
|
||||
if (in_comic_category() && $comicpress->is_multicomic()) {
|
||||
$category_ids = wp_get_post_categories($post->ID);
|
||||
if (is_array($category_ids)) {
|
||||
foreach ($category_ids as $id) {
|
||||
|
@ -1,26 +1,17 @@
|
||||
<div class="post-comic-head"></div>
|
||||
<div class="post-comic">
|
||||
<?php include('nav.inc') ?>
|
||||
<div class="comicdate">
|
||||
<?php the_date('F jS, Y') ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<?php if (get_option('comicpress-enable-storyline-support') == 1) { ?>
|
||||
<ul class="storyline-cats"><li class="storyline-root"><?php the_category(' » </li><li>', multiple) ?></li></ul>
|
||||
<?php } ?>
|
||||
<div class="comicdate"><?php the_date('F jS, Y') ?></div>
|
||||
<br class="clear" />
|
||||
<h2>
|
||||
<a href="<?php get_permalink($last_comic_post->ID) ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'comicpress'), get_the_title()) ?>"><?php the_title() ?></a>
|
||||
</h2>
|
||||
<div class="entry">
|
||||
<?php the_content('↓ Read the rest of this entry...') ?>
|
||||
</div>
|
||||
<div class="entry"><?php the_content('↓ Read the rest of this entry...') ?></div>
|
||||
<?php the_transcript('styled') ?>
|
||||
<div class="tags">
|
||||
<?php the_tags('└ Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?>
|
||||
</div>
|
||||
<div class="tags"><?php the_tags('└ Tags: ', ', ', ''); edit_post_link('Edit Post', ' [ ', ' ] ') ?></div>
|
||||
<div class="comment-link">
|
||||
<?php if ('open' == $post->comment_status) { comments_popup_link('“Comment”', '“1 Comment”', '“% Comments”'); } ?>
|
||||
</div>
|
||||
<br class="clear-margins" />
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<div class="post-comic-foot"></div>
|
@ -1,26 +1,53 @@
|
||||
<div class="nav">
|
||||
<?php if ($nav_comics['show_first']) { ?>
|
||||
<div class="nav-first">
|
||||
<a href="<?php echo get_permalink($nav_comics['first']->ID) ?>"
|
||||
title="<?php _e('Go to the first comic', 'comicpress') ?>">‹‹ <?php _e('First', 'comicpress') ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($nav_comics['show_previous']) { ?>
|
||||
<div class="nav-previous">
|
||||
<a href="<?php echo get_permalink($nav_comics['previous']->ID) ?>"
|
||||
title="<?php _e('Go to the previous comic', 'comicpress') ?>">‹ <?php _e('Previous', 'comicpress') ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($nav_comics['show_next']) { ?>
|
||||
<div class="nav-first">
|
||||
<a href="<?php echo get_permalink($nav_comics['next']->ID) ?>"
|
||||
title="<?php _e('Go to the next comic', 'comicpress') ?>"><?php _e('Next', 'comicpress') ?> ›</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($nav_comics['show_last']) { ?>
|
||||
<div class="nav-previous">
|
||||
<a href="<?php echo get_permalink($nav_comics['last']->ID) ?>"
|
||||
title="<?php _e('Go to the last comic', 'comicpress') ?>"><?php _e('Last', 'comicpress') ?> ››</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
$nav_fields = array(
|
||||
'first' => '‹‹ ' . __('First', 'comicpress'),
|
||||
'previous' => '‹ ' . __('Previous', 'comicpress'),
|
||||
'next' => __('Next', 'comicpress') . ' ›',
|
||||
'last' => __('Last', 'comicpress') . ' ››'
|
||||
);
|
||||
|
||||
if ($comicpress->needs_storyline_nav()) {
|
||||
$nav_fields = array_merge(
|
||||
array('prior' => '‹‹ ' . __('Prior Storyline', 'comicpress')),
|
||||
$nav_fields,
|
||||
array('upcoming' => __('Upcoming Storyline', 'comicpress') . ' ››')
|
||||
);
|
||||
|
||||
foreach ($comicpress->get_sorted_post_categories() as $category_id) {
|
||||
$prev_next_categories = $comicpress->get_previous_next_categories($category_id);
|
||||
|
||||
foreach ($prev_next_categories as $master_id => $cat_list) {
|
||||
foreach ($cat_list as $which => $id) {
|
||||
switch ($which) {
|
||||
case "previous":
|
||||
$terminal_post = $comicpress->get_last_comic($id);
|
||||
$which_field = "prior";
|
||||
break;
|
||||
case "next":
|
||||
$terminal_post = $comicpress->get_first_comic($id);
|
||||
$which_field = "upcoming";
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_object($terminal_post)) {
|
||||
$nav_comics[$which_field] = $terminal_post;
|
||||
$nav_comics["show_${which_field}"] =true;
|
||||
}
|
||||
|
||||
if (count($terminal_post) == 2) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="nav">
|
||||
<?php foreach ($nav_fields as $field => $link_text) { ?>
|
||||
<?php if ($nav_comics['show_' . $field]) { ?>
|
||||
<div class="nav-<?php echo $field ?>">
|
||||
<a href="<?php echo (is_object($nav_comics[$field])) ? get_permalink($nav_comics[$field]->ID) : $nav_comics[$field] ?>"
|
||||
title="<?php sprintf(__('Go to the %s comic', 'comicpress'), $field) ?>"><?php echo $link_text ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
global $comicpress, $nav_comics;
|
||||
|
||||
comicpress_get_header();
|
||||
comicpress_init();
|
||||
|
||||
ob_start();
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
rewind_posts();
|
||||
|
||||
$comic = ob_get_clean();
|
||||
|
||||
|
||||
ob_start();
|
||||
|
||||
$nav_comics = $comicpress->get_nav_comics();
|
||||
|
@ -276,6 +276,37 @@ FILE
|
||||
|
||||
$this->assertEquals($expected_results, $cp->get_layout_choices());
|
||||
}
|
||||
|
||||
function providerTestGetSortedPostCategories() {
|
||||
return array(
|
||||
array(
|
||||
array(1),
|
||||
array('0/1'),
|
||||
array(1)
|
||||
),
|
||||
array(
|
||||
array(2, 1),
|
||||
array('0/1', '0/1/2'),
|
||||
array(1, 2)
|
||||
),
|
||||
array(
|
||||
array(2, 1),
|
||||
array('0/1', '0/1/3', '0/1/2'),
|
||||
array(1, 2)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestGetSortedPostCategories
|
||||
*/
|
||||
function testGetSortedPostCategories($post_categories, $category_tree, $expected_sort_order) {
|
||||
$this->cp->category_tree = $category_tree;
|
||||
|
||||
wp_set_post_categories(1, $post_categories);
|
||||
|
||||
$this->assertEquals($expected_sort_order, $this->cp->get_sorted_post_categories((object)array('ID' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user