add url alt and hover text

This commit is contained in:
John Bintz 2009-12-08 20:09:34 -05:00
parent b886b513ab
commit 7b2b06deef
4 changed files with 27 additions and 5 deletions

View File

@ -21,6 +21,10 @@ class ComicPressBackendURL extends ComicPressBackend {
$valid_urls[$type] = $url; $valid_urls[$type] = $url;
if ($type == $default_type) { $key = substr(md5($url), 0, 10); } 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])) { if (isset($meta[$key])) {
$backend = new ComicPressBackendURL(); $backend = new ComicPressBackendURL();
$backend->id = $id; $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; return $backend;
} }
} }

View File

@ -43,6 +43,8 @@ class ComicPressBackendUrlFactoryTest extends PHPUnit_Framework_TestCase {
'comic' => 'comic', 'comic' => 'comic',
'rss' => 'rss' 'rss' => 'rss'
); );
$valid_backend->alt_text = 'alt text';
$valid_backend->hover_text = 'hover text';
return array( return array(
array('', false), array('', false),
@ -60,7 +62,14 @@ class ComicPressBackendUrlFactoryTest extends PHPUnit_Framework_TestCase {
function testGenerateFromID($id, $expected_result) { function testGenerateFromID($id, $expected_result) {
wp_insert_post((object)array('ID' => 1)); 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)); $this->assertEquals($expected_result, $this->fa->generate_from_id($id));
} }

View File

@ -21,12 +21,16 @@ class ComicPressBackendUrlTest extends PHPUnit_Framework_TestCase {
'test' => array( 'test' => array(
'comic' => 'http://test/test', 'comic' => 'http://test/test',
'rss' => 'http://test/test2', 'rss' => 'http://test/test2',
'__alt_text' => 'alt text',
'__hover_text' => 'hover text',
) )
), ),
array( array(
$key => array( $key => array(
'comic' => 'http://test/test', 'comic' => 'http://test/test',
'rss' => 'http://test/test2' 'rss' => 'http://test/test2',
'__alt_text' => 'alt text',
'__hover_text' => 'hover text',
) )
), ),
) )

View File

@ -1,5 +1,3 @@
<?php <?php
set_include_path(realpath(dirname(__FILE__) . '/../classes') . PATH_SEPARATOR . get_include_path()); set_include_path(realpath(dirname(__FILE__) . '/../classes') . PATH_SEPARATOR . get_include_path());
?>