work on cleaning up sidebar rendering
This commit is contained in:
parent
a02562d9b0
commit
65c1ed1fbb
|
@ -31,14 +31,38 @@ class ComicPressSidebarStandard extends ComicPressView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function init() {
|
||||||
global $comicpress_manager;
|
|
||||||
|
|
||||||
$this->_get_subdir_path();
|
$this->_get_subdir_path();
|
||||||
$this->_all_comic_dates_ok();
|
$this->_all_comic_dates_ok();
|
||||||
$this->_get_thumbnail_generation_info();
|
$this->_get_thumbnail_generation_info();
|
||||||
|
}
|
||||||
|
|
||||||
import($this->_partial_path("sidebar"));
|
function render() {
|
||||||
|
global $comicpress_manager, $comicpress_manager_admin;
|
||||||
|
|
||||||
|
foreach (array(
|
||||||
|
'comiccat' => 'comic_category',
|
||||||
|
'blogcat' => 'blog_category'
|
||||||
|
) as $param => $field) {
|
||||||
|
$result = false;
|
||||||
|
if (isset($comicpress_manager->properties[$param])) {
|
||||||
|
$check = $comicpress_manager->properties[$param];
|
||||||
|
if (!is_array($check)) { $check = array($check); }
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
foreach ($check as $cat_id) {
|
||||||
|
$category = get_category($cat_id);
|
||||||
|
if (!is_wp_error($category)) {
|
||||||
|
$result[] = $category;
|
||||||
|
} else {
|
||||||
|
$result = false; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->{$field} = $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
include($this->_partial_path("sidebar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function _get_thumbnail_generation_info() {
|
function _get_thumbnail_generation_info() {
|
||||||
|
|
|
@ -29,38 +29,32 @@
|
||||||
<?php foreach (array('archive' => __('Archive folder:', 'comicpress-manager'),
|
<?php foreach (array('archive' => __('Archive folder:', 'comicpress-manager'),
|
||||||
'rss' => __('RSS feed folder:', 'comicpress-manager'))
|
'rss' => __('RSS feed folder:', 'comicpress-manager'))
|
||||||
as $type => $title) { ?>
|
as $type => $title) { ?>
|
||||||
<li><strong><?php echo $title ?></strong> <?php echo $comicpress_manager->properties["${type}_comic_folder"] . $subdir_path; ?>
|
<li>
|
||||||
<?php if (
|
<strong><?php echo $title ?></strong>
|
||||||
($comicpress_manager->scale_method !== false) &&
|
<?php echo $comicpress_manager->properties["${type}_comic_folder"] . $subdir_path; ?>
|
||||||
($comicpress_manager->get_cpm_option("cpm-${type}-generate-thumbnails") == 1) &&
|
(<?php
|
||||||
($comicpress_manager->separate_thumbs_folder_defined[$type]) &&
|
if ($this->thumbnail_generation[$type] === true) {
|
||||||
($comicpress_manager->thumbs_folder_writable[$type])
|
echo "<em>";
|
||||||
) { ?>
|
_e('generating', 'comicpress-manager');
|
||||||
(<em><?php _e('generating', 'comicpress-manager') ?></em>)
|
echo "</em>";
|
||||||
<?php } else {
|
|
||||||
$reasons = array();
|
|
||||||
|
|
||||||
if ($comicpress_manager->scale_method == false) { $reasons[] = __("No scaling software", 'comicpress-manager'); }
|
|
||||||
if ($comicpress_manager->get_cpm_option("cpm-${type}-generate-thumbnails") == 0) {
|
|
||||||
$reasons[] = __("Generation disabled", 'comicpress-manager');
|
|
||||||
} else {
|
} else {
|
||||||
if (!$comicpress_manager->separate_thumbs_folder_defined[$type]) { $reasons[] = __("Same as comics folder", 'comicpress-manager'); }
|
echo '<em style="cursor: help; text-decoration: underline" title="' . implode(", ", $this->thumbnail_generation[$type]) . '">';
|
||||||
if (!$comicpress_manager->thumbs_folder_writable[$type]) { $reasons[] = __("Not writable", 'comicpress-manager'); }
|
_e('not generating', 'comicpress-manager');
|
||||||
|
echo "</em>";
|
||||||
}
|
}
|
||||||
?>
|
?>)
|
||||||
(<em style="cursor: help; text-decoration: underline" title="<?php echo implode(", ", $reasons) ?>">not generating</em>)
|
|
||||||
<?php } ?>
|
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<li><strong>
|
<?php foreach (array('comic_category' => __("Comic categories:", 'comicpress-manager'),
|
||||||
<?php
|
'blog_category' => __("Blog categories:", 'comicpress-manager'))
|
||||||
if (is_array($comicpress_manager->properties['comiccat']) && count($comicpress_manager->properties['comiccat']) != 1) {
|
as $type => $title) { ?>
|
||||||
_e("Comic categories:", 'comicpress-manager');
|
<li>
|
||||||
} else {
|
<strong><?php echo $title ?></strong>
|
||||||
_e("Comic category:", 'comicpress-manager');
|
<?php if ($this->{$type} === false) { ?>
|
||||||
}
|
<em>Not defined!</em>
|
||||||
?></strong>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php if (is_array($comicpress_manager->properties['comiccat'])) { ?>
|
<?php if (is_array($comicpress_manager->properties['comiccat'])) { ?>
|
||||||
<ul>
|
<ul>
|
||||||
<?php foreach ($comicpress_manager->properties['comiccat'] as $cat_id) { ?>
|
<?php foreach ($comicpress_manager->properties['comiccat'] as $cat_id) { ?>
|
||||||
|
@ -72,9 +66,10 @@
|
||||||
<a href="<?php echo get_category_link($comicpress_manager->properties['comiccat']) ?>"><?php echo $comicpress_manager->category_info['comiccat']['name'] ?></a>
|
<a href="<?php echo get_category_link($comicpress_manager->properties['comiccat']) ?>"><?php echo $comicpress_manager->category_info['comiccat']['name'] ?></a>
|
||||||
<?php printf(__('(ID %s)', 'comicpress-manager'), $comicpress_manager->properties['comiccat']) ?>
|
<?php printf(__('(ID %s)', 'comicpress-manager'), $comicpress_manager->properties['comiccat']) ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li><strong><?php _e('Blog category:', 'comicpress-manager') ?></strong> <a href="<?php echo get_category_link($comicpress_manager->properties['blogcat']) ?>" ?>
|
<?php } ?>
|
||||||
<?php echo $comicpress_manager->category_info['blogcat']['name'] ?></a> <?php printf(__('(ID %s)', 'comicpress-manager'), $comicpress_manager->properties['blogcat']) ?></li>
|
|
||||||
|
|
||||||
<?php if (!function_exists('get_site_option')) { ?>
|
<?php if (!function_exists('get_site_option')) { ?>
|
||||||
<li><strong><?php _e("PHP Version:", 'comicpress-manager') ?></strong> <?php echo phpversion() ?>
|
<li><strong><?php _e("PHP Version:", 'comicpress-manager') ?></strong> <?php echo phpversion() ?>
|
||||||
|
@ -103,7 +98,7 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li>
|
<li>
|
||||||
<strong><a href="#" onclick="Element.show('debug-info'); $('cpm-right-column').style.minHeight = $('cpm-left-column').offsetHeight + 'px'; return false"><?php _e('Show debug info', 'comicpress-manager') ?></a></strong> (<em><?php _e("this data is sanitized to protect your server's configuration", 'comicpress-manager') ?></em>)
|
<strong><a href="#" onclick="Element.show('debug-info'); $('cpm-right-column').style.minHeight = $('cpm-left-column').offsetHeight + 'px'; return false"><?php _e('Show debug info', 'comicpress-manager') ?></a></strong> (<em><?php _e("this data is sanitized to protect your server's configuration", 'comicpress-manager') ?></em>)
|
||||||
<?php echo cpm_show_debug_info() ?>
|
<?php echo $comicpress_manager_admin->show_debug_info() ?>
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -113,10 +113,52 @@ class ComicPressSidebarStandardTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($info['result'], $result);
|
$this->assertEquals($info['result'], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRender() {
|
function testRenderCategoryIssues() {
|
||||||
global $comicpress_manager;
|
global $comicpress_manager, $comicpress_manager_admin;
|
||||||
|
|
||||||
//
|
$s = new ComicPressSidebarStandard();
|
||||||
|
$s->thumbnail_generation = array('rss' => true, 'archive' => array("test"));
|
||||||
|
|
||||||
|
$comicpress_manager_admin = $this->getMock('ComicPressManagerAdmin', array('show_debug_info'));
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$s->render();
|
||||||
|
$source = ob_get_clean();
|
||||||
|
|
||||||
|
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
||||||
|
$this->assertFalse($s->comic_category);
|
||||||
|
$this->assertFalse($s->blog_category);
|
||||||
|
|
||||||
|
foreach (array(
|
||||||
|
'//em[text()="Not defined!"]/../strong[text()="Comic categories:"]' => true,
|
||||||
|
'//em[text()="Not defined!"]/../strong[text()="Blog categories:"]' => true,
|
||||||
|
) as $xpath => $value) {
|
||||||
|
$this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testRenderGenerationStates() {
|
||||||
|
global $comicpress_manager, $comicpress_manager_admin;
|
||||||
|
|
||||||
|
add_category(1, (object)array('name' => 'Comics'));
|
||||||
|
add_category(2, (object)array('name' => 'Blog'));
|
||||||
|
|
||||||
|
$s = new ComicPressSidebarStandard();
|
||||||
|
$s->thumbnail_generation = array('rss' => true, 'archive' => array("test"));
|
||||||
|
|
||||||
|
$comicpress_manager_admin = $this->getMock('ComicPressManagerAdmin', array('show_debug_info'));
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$s->render();
|
||||||
|
$source = ob_get_clean();
|
||||||
|
|
||||||
|
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
||||||
|
foreach (array(
|
||||||
|
) as $xpath => $value) {
|
||||||
|
$this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue