Merge branch 'master' of git@github.com:johnbintz/comicpress-2.8

This commit is contained in:
Philip M. Hofer (Frumph) 2009-08-26 17:28:49 -07:00
commit 4b7d18e103
2 changed files with 47 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*~

View File

@ -322,6 +322,51 @@ function get_terminal_post_in_category($categoryID, $first = true) {
return $terminalPost; return $terminalPost;
} }
/**
* Find the first post in the storyline prior to the current one.
*/
function get_previous_storyline_start_permalink() {
if (($category_id = get_adjacent_storyline_category_id()) !== false) {
return get_terminal_post_in_category($category_id);
}
return false;
}
/**
* Find the first post in the storyline following to the current one.
*/
function get_next_storyline_start_permalink() {
if (($category_id = get_adjacent_storyline_category_id(true)) !== false) {
return get_terminal_post_in_category($category_id);
}
return false;
}
function get_adjacent_storyline_category_id($next = false) {
global $post, $category_tree;
$categories = wp_get_post_categories($post->ID);
if (is_array($categories)) {
$category_id = reset($categories);
for ($i = 0, $il = count($category_tree); $i < $il; ++$i) {
$storyline_category_id = end(explode("/", $category_tree[$i]));
if ($storyline_category_id == $category_id) {
$target_index = false;
if ($next) {
$target_index = $i + 1;
} else {
$target_index = $i - 1;
}
if (isset($category_tree[$target_index])) {
return end(explode('/', $category_tree[$target_index]));
}
}
}
}
return false;
}
/** /**
* Find a comic file in the filesystem. * Find a comic file in the filesystem.
* @param string $folder The folder name to search. * @param string $folder The folder name to search.