RT() function pretty much working

This commit is contained in:
John Bintz 2009-11-07 22:42:09 -05:00
parent f0bb9a0061
commit cab85e5f60
4 changed files with 32 additions and 7 deletions

View File

@ -499,8 +499,9 @@ class ComicPressStoryline {
$comic_post = new ComicPressComicPost(get_post($id));
$parents = $comic_post->find_parents();
if (!empty($parents)) {
$parents = array_keys($parents); $found[] = end($parents);
$parents = array_keys($parents); $found = $this->_find_children(end($parents));
}
}
}
return $found;
@ -534,11 +535,14 @@ class ComicPressStoryline {
$method_type = $type;
}
foreach ((array)$list as $restriction) {
if (!is_array($list)) { $list = array($list); }
foreach ($list as $restriction) {
$method = '';
$args = array($restriction);
switch ($method_type) {
case 'child_of': $method = 'children'; break;
case 'root_of': $method = 'post_root'; break;
case 'from_post': $method = 'post_category'; break;
case 'previous':
$method = 'adjacent';

View File

@ -97,6 +97,22 @@ function R($which, $restrictions = null, $override_post = null) {
}
}
if (is_array($restrictions)) {
$new_restrictions = array();
foreach ($restrictions as $type => $list) {
if (is_string($list)) {
$value = $list;
switch ($list) {
case '__post': $value = $post_to_use; break;
}
$new_restrictions[$type] = $value;
} else {
$new_restrictions[$type] = $list;
}
}
$restrictions = $new_restrictions;
}
$categories = $storyline->build_from_restrictions($restrictions);
$dbi = ComicPressDBInterface::get_instance();

View File

@ -1,13 +1,18 @@
<?php
$storyline = new ComicPressStoryline();
$storyline->read_from_options();
the_title(); echo '<br />';
Protect();
RT('first', 'from_post'); the_title(); echo '<br />';
RT('previous', 'from_post'); the_title(); echo '<br />';
RT('previous', array('root_of' => '__post')); the_title(); echo '<br />';
RT('previous'); the_title(); echo '<br />';
Restore(); the_title(); echo '<br />';
RT('next', array('child_of' => 'amoc')); the_title(); echo '<br />';
RT('next'); the_title(); echo '<br />';
RT('next', array('root_of' => '__post')); the_title(); echo '<br />';
RT('next', 'from_post'); the_title(); echo '<br />';
RT('last', 'from_post'); the_title(); echo '<br />';

View File

@ -476,8 +476,8 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
function providerTestFindPostRoot() {
return array(
array(array(1), array(1)),
array(array(4), array(1)),
array(array(1), array(1,2,3,4)),
array(array(4), array(1,2,3,4)),
array(array(5), array(5)),
array(array(1, 5), array()),
);