comicpress-manager-1.5/classes/views/ComicPressSidebarStandard.php

99 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2009-06-16 00:52:57 +00:00
<?php
class ComicPressSidebarStandard extends ComicPressView {
2009-06-17 01:20:56 +00:00
function ComicPressSidebarStandard() {}
function _get_subdir_path() {
global $comicpress_manager;
$this->subdir_path = '';
if (($subdir = $comicpress_manager->get_subcomic_directory()) !== false) {
$this->subdir_path .= '/' . $subdir;
}
}
function _all_comic_dates_ok() {
2009-06-16 00:52:57 +00:00
global $comicpress_manager;
2009-06-17 11:07:57 +00:00
$all_comic_dates_ok = true;
$all_comic_dates = array();
2009-06-16 00:52:57 +00:00
foreach ($comicpress_manager->comic_files as $comic_file) {
if (($result = $comicpress_manager->breakdown_comic_filename(pathinfo($comic_file, PATHINFO_BASENAME))) !== false) {
2009-06-17 11:07:57 +00:00
if (isset($all_comic_dates[$result['date']])) { $all_comic_dates_ok = false; break; }
$all_comic_dates[$result['date']] = true;
2009-06-16 00:52:57 +00:00
}
}
$this->too_many_comics_message = "";
2009-06-17 11:07:57 +00:00
if (!$all_comic_dates_ok) {
2009-06-16 00:52:57 +00:00
$this->too_many_comics_message = ", <em>" . __("multiple files on the same date!", 'comicpress-manager') . "</em>";
}
}
2009-06-18 11:26:27 +00:00
function init() {
2009-06-17 01:20:56 +00:00
$this->_get_subdir_path();
$this->_all_comic_dates_ok();
$this->_get_thumbnail_generation_info();
2009-06-18 11:26:27 +00:00
}
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;
}
2009-06-17 01:20:56 +00:00
2009-06-18 11:26:27 +00:00
include($this->_partial_path("sidebar"));
2009-06-16 00:52:57 +00:00
}
function _get_thumbnail_generation_info() {
global $comicpress_manager;
$this->thumbnail_generation = array();
foreach (array('archive', 'rss') as $type) {
2009-06-17 10:58:55 +00:00
$option = $comicpress_manager->get_cpm_option("cpm-${type}-generate-thumbnails");
2009-06-16 00:52:57 +00:00
if (
($comicpress_manager->scale_method !== false) &&
2009-06-17 10:58:55 +00:00
($option == 1) &&
2009-06-16 00:52:57 +00:00
($comicpress_manager->separate_thumbs_folder_defined[$type]) &&
($comicpress_manager->thumbs_folder_writable[$type])
) {
$this->thumbnail_generation[$type] = true;
} else {
$reasons = array();
if ($comicpress_manager->scale_method == false) { $reasons[] = __("No scaling software", 'comicpress-manager'); }
2009-06-17 10:58:55 +00:00
if ($option == 0) {
2009-06-16 00:52:57 +00:00
$reasons[] = __("Generation disabled", 'comicpress-manager');
} else {
if (!$comicpress_manager->separate_thumbs_folder_defined[$type]) { $reasons[] = __("Same as comics folder", 'comicpress-manager'); }
if (!$comicpress_manager->thumbs_folder_writable[$type]) { $reasons[] = __("Not writable", 'comicpress-manager'); }
}
2009-06-17 10:58:55 +00:00
$this->thumbnail_generation[$type] = $reasons;
2009-06-16 00:52:57 +00:00
}
}
2009-06-17 10:58:55 +00:00
return $this->thumbnail_generation;
2009-06-16 00:52:57 +00:00
}
}
?>