move storyline structure to tag builder

This commit is contained in:
John Bintz 2010-02-04 20:55:03 -05:00
parent b37a845743
commit 3b1727e476
4 changed files with 19 additions and 19 deletions

View File

@ -2,6 +2,7 @@
require_once('ComicPressStoryline.inc'); require_once('ComicPressStoryline.inc');
// TODO Loop preservation
class ComicPressTagBuilderFactory { class ComicPressTagBuilderFactory {
private $storyline, $dbi; private $storyline, $dbi;
@ -59,6 +60,7 @@ class ComicPressTagBuilder {
return new ComicPressComicPost($post); return new ComicPressComicPost($post);
} }
// TODO categories (SC and SL)
public function __call($method, $arguments) { public function __call($method, $arguments) {
$ok = false; $ok = false;
$return = $this; $return = $this;
@ -115,6 +117,8 @@ class ComicPressTagBuilder {
$which = (isset($arguments[1])) ? $arguments[1] : 'default'; $which = (isset($arguments[1])) ? $arguments[1] : 'default';
return ComicPressBackend::generate_from_id($arguments[0][$which]); return ComicPressBackend::generate_from_id($arguments[0][$which]);
} }
case 'structure':
return $this->storyline->_structure;
default: default:
$methods = $this->parse_method($method, $arguments); $methods = $this->parse_method($method, $arguments);
if (!empty($methods)) { if (!empty($methods)) {

View File

@ -18,7 +18,7 @@ foreach (array(
} }
// Global template functions for ComicPress // Global template functions for ComicPress
// TODO is this even necessary anymore?
function F($name, $path, $override_post = null) { function F($name, $path, $override_post = null) {
global $post; global $post;
@ -66,16 +66,6 @@ function Unprotect() {
$__post = $__wp_query = null; $__post = $__wp_query = null;
} }
/**
* Return the raw storyline structure.
* @return array The astoryline structure from ComicPressStoryline
*/
function SL() {
$storyline = new ComicPressStoryline();
$storyline->read_from_options();
return $storyline->_structure;
}
/** /**
* Get a category relative to the provided category. * Get a category relative to the provided category.
* If no category is provided, use the current post's category. * If no category is provided, use the current post's category.

View File

@ -364,4 +364,18 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('my-backend', $core->media(array('default' => 'my-image'))); $this->assertEquals('my-backend', $core->media(array('default' => 'my-image')));
} }
function testCategoryStructure() {
$storyline = new ComicPressStoryline();
$storyline->set_flattened_storyline('0/1,0/2,0/3');
$dbi = $this->getMock('ComicPressDBInterface');
$core = new ComicPressTagBuilderFactory($dbi);
$this->assertEquals(array(
'1' => array('next' => 2, 'level' => 1),
'2' => array('next' => 3, 'previous' => 1, 'level' => 1),
'3' => array('previous' => 2, 'level' => 1),
), $core->structure());
}
} }

View File

@ -61,14 +61,6 @@ class FunctionsTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(is_null($__wp_query)); $this->assertTrue(is_null($__wp_query));
} }
function testSL() {
$s = new ComicPressStoryline();
$s->set_flattened_storyline('0/1,0/2,0/2/3');
$s->read_from_options();
$this->assertEquals($s->_structure, SL());
}
function providerTestSC() { function providerTestSC() {
return array( return array(
array('next', 1, 2), array('next', 1, 2),