2009-10-18 21:59:40 +00:00
|
|
|
<?php
|
|
|
|
|
2009-10-20 11:22:34 +00:00
|
|
|
require_once('ComicPressStoryline.inc');
|
|
|
|
require_once('ComicPressDBInterface.inc');
|
|
|
|
|
2009-10-18 21:59:40 +00:00
|
|
|
class ComicPressNavigation {
|
2009-10-20 11:22:34 +00:00
|
|
|
function init($storyline) {
|
|
|
|
$this->_storyline = $storyline;
|
|
|
|
$this->_dbi = ComicPressDBInterface::get_instance();
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_post_nav($post) {
|
|
|
|
$nav = array();
|
2009-10-20 02:41:37 +00:00
|
|
|
|
2009-10-21 00:40:16 +00:00
|
|
|
// global previous/next
|
2009-10-20 11:22:34 +00:00
|
|
|
foreach (array('previous', 'next') as $field) {
|
|
|
|
$nav[$field] = $this->_dbi->{"get_${field}_comic"}(null, $post);
|
|
|
|
}
|
2009-10-21 00:40:16 +00:00
|
|
|
|
|
|
|
// global first/last
|
|
|
|
if ($root_category = $this->_storyline->root_category) {
|
|
|
|
foreach (array('first', 'last') as $field) {
|
|
|
|
$nav[$field] = $this->_dbi->{"get_${field}_comic"}($root_category);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($category = $this->_storyline->get_valid_post_category($post->ID)) {
|
|
|
|
// storyline previous/next
|
|
|
|
foreach (array('previous', 'next') as $field) {
|
|
|
|
$nav["storyline-${field}"] = $this->_dbi->{"get_${field}_comic"}($category, $post);
|
|
|
|
}
|
|
|
|
|
|
|
|
// adjacent storyline nodes
|
|
|
|
if (is_array($valid = $this->_storyline->valid($category))) {
|
|
|
|
foreach ($valid as $field) {
|
|
|
|
$nav["storyline-chapter-${field}"] = $this->_dbi->get_first_comic($this->_storyline->{$field}($category));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-20 11:22:34 +00:00
|
|
|
}
|
2009-10-18 21:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|