diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc
index 20af209..72ac4eb 100644
--- a/classes/ComicPress.inc
+++ b/classes/ComicPress.inc
@@ -31,6 +31,7 @@ class ComicPress {
),
'helpers' => array(),
'storyline_order' => '',
+ 'active_backends' => null
);
var $backends = array();
@@ -141,6 +142,8 @@ class ComicPress {
}
// @codeCoverageIgnoreStart
+ function _get_declared_classes() { return get_declared_classes(); }
+ // @codeCoverageIgnoreEnd
/**
* Initialize the class.
@@ -153,13 +156,28 @@ class ComicPress {
$this->normalize_image_size_options();
- foreach (get_declared_classes() as $class) {
- if (preg_match('#^ComicPressBackend.+Factory$#', $class) > 0) {
- $this->backends[] = new $class();
- }
- }
+ foreach ($this->normalize_active_backends() as $class) {
+ $this->backends[] = new $class();
+ }
}
+ function normalize_active_backends() {
+ $available_backends = array();
+ foreach ($this->_get_declared_classes() as $class) {
+ if (preg_match('#^ComicPressBackend(.*)Factory$#', $class, $matches) > 0) {
+ $available_backends[] = $class;
+ }
+ }
+
+ if (!is_array($this->comicpress_options['active_backends'])) {
+ $this->comicpress_options['active_backends'] = array();
+ }
+
+ $this->comicpress_options['active_backends'] = array_intersect($available_backends, $this->comicpress_options['active_backends']);
+ }
+
+ // @codeCoverageIgnoreStart
+
function announce_activated_helpers() {
echo "
[ Activated ComicPress helpers: " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]";
}
@@ -248,5 +266,3 @@ class ComicPress {
return false;
}
}
-
-?>
diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc
index 3fe52db..35abfc3 100644
--- a/classes/backends/ComicPressBackendAttachment.inc
+++ b/classes/backends/ComicPressBackendAttachment.inc
@@ -46,6 +46,10 @@ class ComicPressBackendAttachment extends ComicPressBackend {
}
class ComicPressBackendAttachmentFactory {
+ function __construct() {
+ $this->description = __('Uses post attachments as comic images.', 'comicpress');
+ }
+
function generate_from_post($post) {
$result = array();
if (is_object($post)) {
@@ -71,7 +75,6 @@ class ComicPressBackendAttachmentFactory {
return $result;
}
-
function generate_from_id($id) {
if (strpos($id, 'attachment-') === 0) {
$id = str_replace('attachment-', '', $id);
diff --git a/classes/backends/ComicPressBackendFilesystem.inc b/classes/backends/ComicPressBackendFilesystem.inc
index 913745a..f014177 100644
--- a/classes/backends/ComicPressBackendFilesystem.inc
+++ b/classes/backends/ComicPressBackendFilesystem.inc
@@ -239,6 +239,10 @@ class ComicPressBackendFilesystemFactory {
// @codeCoverageIgnoreStart
class ComicPressBackendFilesystemAdmin {
+ function __construct() {
+ $this->description = __('Uses files on the filesystem as comic images, similar to ComicPress Legacy.', 'comicpress');
+ }
+
function options_admin() {
$pattern = ComicPressBackendFilesystemFactory::_get_search_pattern();
diff --git a/classes/backends/ComicPressBackendURL.inc b/classes/backends/ComicPressBackendURL.inc
index 91c42eb..774b30f 100644
--- a/classes/backends/ComicPressBackendURL.inc
+++ b/classes/backends/ComicPressBackendURL.inc
@@ -56,6 +56,10 @@ class ComicPressBackendURL extends ComicPressBackend {
}
class ComicPressBackendURLFactory {
+ function __construct() {
+ $this->description = __('Uses URLs assigned to posts as comic images.', 'comicpress');
+ }
+
function generate_from_id($id) {
if (preg_match('#^url-([0-9]+)-(.+)$#', $id, $matches) > 0) {
list($all, $post_id, $key) = $matches;
diff --git a/classes/backends/partials/backend-filesystem/options-admin.inc b/classes/backends/partials/backend-filesystem/options-admin.inc
index 53afe3b..6fef2d2 100644
--- a/classes/backends/partials/backend-filesystem/options-admin.inc
+++ b/classes/backends/partials/backend-filesystem/options-admin.inc
@@ -16,6 +16,7 @@
- %wordpress%: the local path to the WordPress installation', 'comicpress') ?>
+ - %upload-path%: the value of the upload_path option, used by WMPU', 'comicpress') ?>
- %type%: the image type short name', 'comicpress') ?>
- %type-folder%: the image type folder', 'comicpress') ?>
- %date-(pattern)%: the date of the post as run through the date() function. Ex: %date-Y-m-d%', 'comicpress') ?>
diff --git a/classes/partials/_comic-image-types.inc b/classes/partials/_comic-image-types.inc
new file mode 100644
index 0000000..3f13266
--- /dev/null
+++ b/classes/partials/_comic-image-types.inc
@@ -0,0 +1,12 @@
+
+
diff --git a/classes/partials/_storyline-order.inc b/classes/partials/_storyline-order.inc
new file mode 100644
index 0000000..ca09306
--- /dev/null
+++ b/classes/partials/_storyline-order.inc
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+ _render_admin_storyline_tree(reset($storyline->get_simple_storyline()))
+ ?>
+
+
+
+
Categories page)', 'comicpress') ?>
+
+
+
diff --git a/classes/partials/options-admin.inc b/classes/partials/options-admin.inc
index 015bd64..dd80b14 100644
--- a/classes/partials/options-admin.inc
+++ b/classes/partials/options-admin.inc
@@ -5,36 +5,9 @@
-
-
-
-
-
-
-
- _render_admin_storyline_tree(reset($storyline->get_simple_storyline()))
- ?>
-
-
-
-
Categories page)', 'comicpress') ?>
+
-
-
-
-
-
+
diff --git a/test/ComicPressTest.php b/test/ComicPressTest.php
index b0979a9..5f34cfb 100644
--- a/test/ComicPressTest.php
+++ b/test/ComicPressTest.php
@@ -319,4 +319,50 @@ class ComicPressTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_result, $this->cp->get_default_image_type());
}
+
+ function testInit() {
+ $cp = $this->getMock('ComicPress', array('load', 'normalize_image_size_options', 'normalize_active_backends'));
+ $cp->comicpress_options = array(
+ 'active_backends' => array('ComicPressBackendURLFactory')
+ );
+
+ $cp->expects($this->once())->method('load');
+ $cp->expects($this->once())->method('normalize_image_size_options');
+
+ $cp->expects($this->once())->method('normalize_active_backends')->will($this->returnValue(array(
+ 'ComicPressBackendURLFactory'
+ )));
+
+ $cp->init();
+
+ $this->assertEquals(array(new ComicPressBackendURLFactory()), $cp->backends);
+ }
+
+ function providerTestNormalizeActiveBackends() {
+ return array(
+ array(
+ array(), array('ComicPressBackendBadFactory'), array()
+ ),
+ array(
+ array('ComicPressBackendURLFactory'), array(), array()
+ ),
+ array(
+ array('ComicPressBackendURLFactory'), array('ComicPressBackendURLFactory'), array('ComicPressBackendURLFactory')
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider providerTestNormalizeActiveBackends
+ */
+ function testNormalizeActiveBackends($available_backends, $enabled_backends, $expected_backends) {
+ $cp = $this->getMock('ComicPress', array('_get_declared_classes'));
+ $cp->comicpress_options['active_backends'] = $enabled_backends;
+
+ $cp->expects($this->once())->method('_get_declared_classes')->will($this->returnValue($available_backends));
+
+ $cp->normalize_active_backends();
+
+ $this->assertEquals($expected_backends, $cp->comicpress_options['active_backends']);
+ }
}