";
}
$comicpress_manager->messages[] = __("The following files would have created duplicate posts. View them from the links below: ", 'comicpress-manager') . "
" . implode("", $post_links) . "
";
}
}
/**
* Find a comic file by date.
*/
function find_comic_by_date($timestamp) {
global $comicpress_manager;
if (!is_numeric($timestamp)) { return false; }
$files = $this->_f->glob($comicpress_manager->get_comic_folder_path() . '/' . date(CPM_DATE_FORMAT, $timestamp) . '*');
if (empty($files)) { return false; }
foreach ($files as $file) {
if (in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), $comicpress_manager->allowed_extensions)) {
return $file;
}
}
return false;
}
/**
* Handle deleting a post. If Edit Post Integration is enabled, delete any associated
* files from the comics folders.
*/
function handle_delete_post($post_id) {
global $comicpress_manager;
if (!$comicpress_manager->is_cpm_managing_posts) {
if ($comicpress_manager->get_cpm_option("cpm-edit-post-integrate") == 1) {
$post = get_post($post_id);
if (!empty($post)) {
if (!in_array($post->post_type, array("attachment", "revision", "page"))) {
$ok = $this->_is_post_in_comic_category($post_id);
if ($ok) {
if (($parsed_date = strtotime($post->post_date)) !== false) {
$original_date = date(CPM_DATE_FORMAT, $parsed_date);
if (empty($comicpress_manager->comic_files)) {
$comicpress_manager->read_information_and_check_config();
}
if (is_array($comicpress_manager->comic_files)) {
foreach ($comicpress_manager->comic_files as $file) {
$filename = pathinfo($file, PATHINFO_BASENAME);
if (($result = $comicpress_manager->breakdown_comic_filename($filename)) !== false) {
if ($result['date'] == $original_date) {
foreach ($this->find_thumbnails_by_filename($file) as $thumb_file) {
$thumb_file = CPM_DOCUMENT_ROOT . $thumb_file;
$this->_f->unlink($thumb_file);
}
$this->_f->unlink($file);
}
}
}
}
}
}
}
}
}
}
}
/**
* If a category is added, deleted, or edited, and it's not done through
* the Storyline Structure page, normalize the Storyline Structure
* so that it includes/removes the affected categories.
*/
function rebuild_storyline_structure($term_id) {
global $comicpress_manager;
if (empty($comicpress_manager->is_cpm_modifying_categories)) {
$comicpress_manager->read_information_and_check_config();
$comicpress_manager->normalize_storyline_structure();
}
}
/**
* Add the Comic column to Edit Posts.
*/
function manage_posts_columns($posts_columns) {
wp_enqueue_script('prototype');
$posts_columns['comic'] = "Comic";
return $posts_columns;
}
/**
* Populate the Comic coulmn in Edit Posts.
*/
function manage_posts_custom_column($column_name) {
global $comicpress_manager, $post, $comicpress_manager_admin;
if ($column_name == "comic") {
$post_date = date(CPM_DATE_FORMAT, strtotime($post->post_date));
if ($is_first = empty($this->broken_down_comic_files)) {
$this->broken_down_comic_files = array();
if (empty($comicpress_manager->comic_files)) {
$comicpress_manager->read_information_and_check_config();
}
if (is_array($comicpress_manager->comic_files) && !empty($comicpress_manager->comic_files)) {
foreach ($comicpress_manager->comic_files as $file) {
$filename = pathinfo($file, PATHINFO_BASENAME);
if (($result = $comicpress_manager->breakdown_comic_filename($filename)) !== false) {
if (!isset($this->broken_down_comic_files[$result['date']])) {
$this->broken_down_comic_files[$result['date']] = array();
}
$this->broken_down_comic_files[$result['date']][] = $file;
}
}
if (!empty($this->broken_down_comic_files)) {
?>
broken_down_comic_files)) {
$ok = false;
$categories = wp_get_post_categories($post->ID);
if ($comicpress_manager->get_subcomic_directory() !== false) {
$ok = in_array(get_option('comicpress-manager-manage-subcomic'), $categories);
} else {
extract($comicpress_manager->get_all_comic_categories());
foreach ($category_tree as $node) {
if (in_array(end(explode("/", $node)), $categories)) {
$ok = true; break;
}
}
}
if ($ok) {
if (isset($this->broken_down_comic_files[$post_date])) {
$index = 0;
foreach ($this->broken_down_comic_files[$post_date] as $file) {
$image_index = $post->ID . '-' . $index;
$thumbnails_found = $this->find_thumbnails_by_filename($file);
$icon_file_to_use = $file;
if (is_array($thumbnails_found)) {
foreach ($thumbnails_found as $type => $value) {
if (!empty($value)) { $icon_file_to_use = $value; }
}
}
$hovertext = get_post_meta($post->ID, "hovertext", true);
?>
File:
0) { ?>
Thumbs:
Hover:
2, 'show_summary' => true));
echo $after_widget;
}
/**
* Add the QuomicPress Dashboard widget.
*/
function add_quomicpress_widget($widgets) {
global $wp_registered_widgets;
if (!isset($wp_registered_widgets['dashboard_quomicpress'])) {
return $widgets;
}
array_splice($widgets, sizeof($widgets)-1, 0, 'dashboard_quomicpress');
return $widgets;
}
/**
* Write out the QuomicPress Dashboard widget.
*/
function quomicpress_widget($sidebar_args) {
if (is_array($sidebar_args)) {
extract($sidebar_args, EXTR_SKIP);
}
echo $before_widget . $before_title . $widget_name . $after_title;
$this->_show_view("ComicPressQuomicPressWidget");
echo $after_widget;
}
/**
* Write all of the styles and scripts.
*/
function write_global_styles_scripts() {
global $comicpress_manager, $blog_id;
$plugin_url_root = get_option('siteurl') . '/' . $this->get_plugin_path();
$ajax_request_url = isset($_SERVER['URL']) ? $_SERVER['URL'] : $_SERVER['SCRIPT_URL'];
?>
include_javascript("comicpress_script.js") ?>
need_calendars) { ?>
_f->realpath(dirname(__FILE__) . '/../js');
$plugin_url_root = get_option('siteurl') . '/' . $this->get_plugin_path();
$regular_file = $name;
$minified_file = 'minified-' . $name;
$file_to_use = $regular_file;
if ($this->_f->file_exists($js_path . '/' . $minified_file)) {
if ($this->_f->filemtime($js_path . '/' . $minified_file) >= $this->_f->filemtime($js_path . '/' . $regular_file)) {
$file_to_use = $minified_file;
}
}
?>_f->glob(dirname($comicpress_manager->config_filepath) . '/comicpress-config.php.*');
if ($found_backup_files === false) { $found_backup_files = array(); }
foreach ($found_backup_files as $file) {
if (preg_match('#\.([0-9]+)$#', $file, $matches) > 0) {
list($all, $time) = $matches;
$available_backup_files[] = $time;
}
}
arsort($available_backup_files);
return $available_backup_files;
}
function handle_warnings() {
global $comicpress_manager;
// display informative messages to the use
// TODO: remove separate arrays and tag messages based on an enum value
foreach (array(
array(
$comicpress_manager->messages,
__("The operation you just performed returned the following:", 'comicpress-manager'),
'messages'),
array(
$comicpress_manager->warnings,
__("The following warnings were generated:", 'comicpress-manager'),
'warnings'),
array(
$comicpress_manager->errors,
__("The following problems were found in your configuration:", 'comicpress-manager'),
'errors')
) as $info) {
list($messages, $header, $style) = $info;
if (count($messages) > 0) {
if (count($messages) == 1) {
$output = $messages[0];
} else {
ob_start(); ?>
If your error is permissions-related, you may have to set some Windows-specific permissions on your filesystem. Consult your Webhost for more information.", 'comicpress-manager');
}
?>
errors) > 0) {
$current_theme_info = get_theme(get_current_theme());
?>
show_config_editor) { ?>
name ?>
term_id ?>
show_config_editor = true;
} else {
if ($comicpress_manager->config_method == "comicpress-config.php") {
if (!$comicpress_manager->can_write_config) {
$update_automatically = false;
}
} else {
if (count($available_backup_files) > 0) {
if (!$comicpress_manager->can_write_config) {
$update_automatically = false;
}
} else {
$update_automatically = false;
}
}
if (!$update_automatically) { ?>
You won't be able to update your comicpress-config.php or functions.php file directly through the ComicPress Manager interface. Check to make sure the permissions on %s and comicpress-config.php are set so that the Webserver can write to them. Once you submit, you'll be given a block of code to paste into the comicpress-config.php file.", 'comicpress-manager'), $current_theme_info['Template Dir']) ?>
get_backup_files();
if (count($available_backup_files) > 0) { ?>
Some backup comicpress-config.php files were found in your theme directory. You can choose to restore one of these backup files, or you can go ahead and create a new configuration below.", 'comicpress-manager') ?>
show_config_editor) {
echo $this->edit_config();
} ?>
()
show_debug_info(false);
}
return false;
}
return true;
}
/**
* Show site debug info.
*/
function show_debug_info($display_none = true) {
global $comicpress_manager;
ob_start(); ?>
>comic_files) . " comic files";
$output_config['config_filepath'] = substr(realpath($comicpress_manager->config_filepath), CPM_STRLEN_REALPATH_DOCUMENT_ROOT);
$output_config['path'] = substr(realpath($comicpress_manager->path), CPM_STRLEN_REALPATH_DOCUMENT_ROOT);
$output_config['zip_enabled'] = extension_loaded("zip");
clearstatcache();
$output_config['folder_perms'] = array();
$subdir = "";
if (($subdir = $comicpress_manager->get_subcomic_directory()) !== false) {
$subdir = '/' . $subdir;
}
foreach (array(
'comic' => CPM_DOCUMENT_ROOT . '/' . $comicpress_manager->properties['comic_folder'] . $subdir,
'rss' => CPM_DOCUMENT_ROOT . '/' . $comicpress_manager->properties['rss_comic_folder'] . $subdir,
'archive' => CPM_DOCUMENT_ROOT . '/' . $comicpress_manager->properties['archive_comic_folder'] . $subdir,
'config' => $comicpress_manager->config_filepath
) as $key => $path) {
if (($s = @stat($path)) !== false) {
$output_config['folder_perms'][$key] = decoct($s[2]);
} else {
$output_config['folder_perms'][$key] = "folder does not exist";
}
}
$new_output_config = array();
foreach ($output_config as $key => $value) {
if (is_string($value)) {
$value = htmlentities($value);
}
$new_output_config[$key] = $value;
}
var_dump($new_output_config);
?>
0) {
$file = array_shift($folder_stack);
if (is_dir($file)) {
$root_file = substr($file, strlen(CPM_DOCUMENT_ROOT) + 1);
if (preg_match("#(${folders_to_ignore})$#", $root_file) == 0) {
if (count(explode("/", $root_file)) <= $max_depth) {
$found_folders[] = $root_file;
$folder_stack = array_merge($folder_stack, glob($file . "/*"));
} else {
if (!$max_depth_message) {
$comicpress_manager->messages[] = sprintf(__("I went %s levels deep in my search for comic directories. Are you sure you have your site set up correctly?", 'comicpress-manager'), $max_depth);
$max_depth_message = true;
}
}
}
}
if (count($found_folders) == $max_directories) {
$comicpress_manager->messages[] = sprintf(__("I found over %s directories from your site root. Are you sure you have your site set up correctly?", 'comicpress-manager'), $max_directories);
break;
}
}
sort($found_folders);
ob_start(); ?>
get_plugin_path());
$comicpress_manager->read_information_and_check_config();
$do_enqueue_prototype = false;
if (($pagenow == "post.php") && ($_REQUEST['action'] == "edit")) {
$do_enqueue_prototype = true;
}
$filename = plugin_basename(__FILE__);
if (strpos($plugin_page, $filename) !== false) {
$editor_load_pages = array($filename, $filename . '-import');
if (in_array($plugin_page, $editor_load_pages)) {
wp_enqueue_script('editor');
if (!function_exists('wp_tiny_mce')) {
wp_enqueue_script('wp_tiny_mce');
}
}
$do_enqueue_prototype = true;
$this->handle_actions();
}
if (in_array($pagenow, array("edit.php", "post-new.php"))) {
$do_enqueue_prototype = true;
}
if ($do_enqueue_prototype) {
wp_enqueue_script('prototype');
wp_enqueue_script('scriptaculous-effects');
wp_enqueue_script('scriptaculous-builder');
}
if (!isset($access_level)) { $access_level = 10; }
$plugin_title = __("ComicPress Manager", 'comicpress-manager');
add_menu_page($plugin_title, __("ComicPress", 'comicpress-manager'), $access_level, $filename, array($this, "_index_caller"), get_option('siteurl') . '/' . $this->get_plugin_path() . '/comicpress-icon.png');
add_submenu_page($filename, $plugin_title, __("Upload", 'comicpress-manager'), $access_level, $filename, array($this, '_index_caller'));
if (!function_exists('get_site_option')) {
add_submenu_page($filename, $plugin_title, __("Import", 'comicpress-manager'), $access_level, $filename . '-import', array($this, '_import_caller'));
}
add_submenu_page($filename, $plugin_title, __("Bulk Edit", 'comicpress-manager'), $access_level, $filename . '-status', array($this, '_bulk_edit_caller'));
add_submenu_page($filename, $plugin_title, __("Storyline Structure", 'comicpress-manager'), $access_level, $filename . '-storyline', array($this, '_storyline_caller'));
add_submenu_page($filename, $plugin_title, __("Change Dates", 'comicpress-manager'), $access_level, $filename . '-dates', array($this, '_dates_caller'));
add_submenu_page($filename, $plugin_title, __("ComicPress Config", 'comicpress-manager'), $access_level, $filename . '-config', array($this, '_comicpress_config_caller'));
add_submenu_page($filename, $plugin_title, __("Manager Config", 'comicpress-manager'), $access_level, $filename . '-cpm-config', array($this, '_manager_config_caller'));
if ($pagenow == "index.php") {
if ($comicpress_manager->get_cpm_option('cpm-enable-dashboard-rss-feed') == 1) {
wp_register_sidebar_widget( 'dashboard_cpm', __("ComicPress News", "comicpress-manager"), array($this, 'dashboard_widget'),
array( 'all_link' => "http://mindfaucet.com/comicpress/", 'feed_link' => "http://feeds.feedburner.com/comicpress?format=xml", 'width' => 'half', 'class' => 'widget_rss' )
);
add_filter('wp_dashboard_widgets', array($this, 'add_dashboard_widget'));
}
if (($option = generate_comic_categories_options('category')) !== false) {
if ($comicpress_manager->get_cpm_option('cpm-enable-quomicpress') == 1) {
if (count($comicpress_manager->errors) == 0) {
wp_register_sidebar_widget( 'dashboard_quomicpress', __("QuomicPress (Quick ComicPress)", "comicpress-manager"), array($this, 'quomicpress_widget'),
array( 'width' => 'half' )
);
add_filter('wp_dashboard_widgets', array($this, 'add_quomicpress_widget'));
}
}
}
}
}
function _index_caller() {
$this->_show_view('ComicPressUpload');
}
/**
* Handle all ComicPress actions.
*/
function handle_actions() {
global $comicpress_manager;
$valid_actions = array('multiple-upload-file', 'create-missing-posts',
'update-config', 'restore-backup', 'change-dates',
'write-comic-post', 'update-cpm-config', 'do-first-run', 'skip-first-run',
'build-storyline-schema', 'batch-processing', 'manage-subcomic');
//
// take actions based upon $_POST['action']
//
if (isset($_POST['action'])) {
if (in_array($_POST['action'], $valid_actions)) {
require_once('actions/comicpress_' . $_POST['action'] . '.php');
call_user_func("cpm_action_" . str_replace("-", "_", $_POST['action']));
}
}
}
}
?>