move storyline structure to tag builder
This commit is contained in:
parent
b37a845743
commit
3b1727e476
|
@ -2,6 +2,7 @@
|
|||
|
||||
require_once('ComicPressStoryline.inc');
|
||||
|
||||
// TODO Loop preservation
|
||||
class ComicPressTagBuilderFactory {
|
||||
private $storyline, $dbi;
|
||||
|
||||
|
@ -59,6 +60,7 @@ class ComicPressTagBuilder {
|
|||
return new ComicPressComicPost($post);
|
||||
}
|
||||
|
||||
// TODO categories (SC and SL)
|
||||
public function __call($method, $arguments) {
|
||||
$ok = false;
|
||||
$return = $this;
|
||||
|
@ -115,6 +117,8 @@ class ComicPressTagBuilder {
|
|||
$which = (isset($arguments[1])) ? $arguments[1] : 'default';
|
||||
return ComicPressBackend::generate_from_id($arguments[0][$which]);
|
||||
}
|
||||
case 'structure':
|
||||
return $this->storyline->_structure;
|
||||
default:
|
||||
$methods = $this->parse_method($method, $arguments);
|
||||
if (!empty($methods)) {
|
||||
|
|
|
@ -18,7 +18,7 @@ foreach (array(
|
|||
}
|
||||
|
||||
// Global template functions for ComicPress
|
||||
|
||||
// TODO is this even necessary anymore?
|
||||
function F($name, $path, $override_post = null) {
|
||||
global $post;
|
||||
|
||||
|
@ -66,16 +66,6 @@ function Unprotect() {
|
|||
$__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.
|
||||
* If no category is provided, use the current post's category.
|
||||
|
|
|
@ -364,4 +364,18 @@ class ComicPressTagBuilderTest extends PHPUnit_Framework_TestCase {
|
|||
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,14 +61,6 @@ class FunctionsTest extends PHPUnit_Framework_TestCase {
|
|||
$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() {
|
||||
return array(
|
||||
array('next', 1, 2),
|
||||
|
|
Loading…
Reference in New Issue