From 7b2b06deef21a66ab446b2b1a1c5e5c26f955be8 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 8 Dec 2009 20:09:34 -0500 Subject: [PATCH] add url alt and hover text --- classes/backends/ComicPressBackendURL.inc | 13 ++++++++++++- test/backends/ComicPressBackendURLFactoryTest.php | 11 ++++++++++- test/backends/ComicPressBackendURLTest.php | 6 +++++- test/bootstrap.php | 2 -- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/classes/backends/ComicPressBackendURL.inc b/classes/backends/ComicPressBackendURL.inc index 47d1aed..d223139 100644 --- a/classes/backends/ComicPressBackendURL.inc +++ b/classes/backends/ComicPressBackendURL.inc @@ -21,6 +21,10 @@ class ComicPressBackendURL extends ComicPressBackend { $valid_urls[$type] = $url; if ($type == $default_type) { $key = substr(md5($url), 0, 10); } } + } else { + if (strpos($type, '__') === 0) { + $valid_urls[$type] = $url; + } } } } @@ -57,7 +61,14 @@ class ComicPressBackendURLFactory { if (isset($meta[$key])) { $backend = new ComicPressBackendURL(); $backend->id = $id; - $backend->urls_by_type = $meta[$key]; + $backend->urls_by_type = array(); + foreach ($meta[$key] as $k => $v) { + if (strpos($k, '__') === 0) { + $backend->{substr($k, 2)} = $v; + } else { + $backend->urls_by_type[$k] = $v; + } + } return $backend; } } diff --git a/test/backends/ComicPressBackendURLFactoryTest.php b/test/backends/ComicPressBackendURLFactoryTest.php index 2639546..b1e7f4b 100644 --- a/test/backends/ComicPressBackendURLFactoryTest.php +++ b/test/backends/ComicPressBackendURLFactoryTest.php @@ -43,6 +43,8 @@ class ComicPressBackendUrlFactoryTest extends PHPUnit_Framework_TestCase { 'comic' => 'comic', 'rss' => 'rss' ); + $valid_backend->alt_text = 'alt text'; + $valid_backend->hover_text = 'hover text'; return array( array('', false), @@ -60,7 +62,14 @@ class ComicPressBackendUrlFactoryTest extends PHPUnit_Framework_TestCase { function testGenerateFromID($id, $expected_result) { wp_insert_post((object)array('ID' => 1)); - update_post_meta(1, 'backend_url_image_urls', array('12345' => array('comic' => 'comic', 'rss' => 'rss'))); + update_post_meta(1, 'backend_url_image_urls', array( + '12345' => array( + 'comic' => 'comic', + 'rss' => 'rss', + '__alt_text' => 'alt text', + '__hover_text' => 'hover text' + ) + )); $this->assertEquals($expected_result, $this->fa->generate_from_id($id)); } diff --git a/test/backends/ComicPressBackendURLTest.php b/test/backends/ComicPressBackendURLTest.php index 5b1222b..1b6afc6 100644 --- a/test/backends/ComicPressBackendURLTest.php +++ b/test/backends/ComicPressBackendURLTest.php @@ -21,12 +21,16 @@ class ComicPressBackendUrlTest extends PHPUnit_Framework_TestCase { 'test' => array( 'comic' => 'http://test/test', 'rss' => 'http://test/test2', + '__alt_text' => 'alt text', + '__hover_text' => 'hover text', ) ), array( $key => array( 'comic' => 'http://test/test', - 'rss' => 'http://test/test2' + 'rss' => 'http://test/test2', + '__alt_text' => 'alt text', + '__hover_text' => 'hover text', ) ), ) diff --git a/test/bootstrap.php b/test/bootstrap.php index f31480b..63e88b7 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,5 +1,3 @@ \ No newline at end of file