resolve conflict
This commit is contained in:
commit
996e64eece
|
@ -1,3 +1,5 @@
|
||||||
*~
|
*~
|
||||||
.directory
|
.directory
|
||||||
|
.buildpath
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes() ?>>
|
||||||
|
<?php get_header(); ?>
|
||||||
|
<body <?php if (function_exists('body_class')) { body_class(); } ?>>
|
||||||
|
<div id="page"><!-- Defines entire site width - Ends in Footer -->
|
||||||
|
<div id="header">
|
||||||
|
<h1><a href="<?php echo get_settings('home') ?>"><?php bloginfo('name') ?></a></h1>
|
||||||
|
<div class="description"><?php bloginfo('description') ?></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="menubar">
|
||||||
|
<ul id="menu">
|
||||||
|
<li><a href="<?php bloginfo('url') ?>">Home</a></li>
|
||||||
|
<?php wp_list_pages('sort_column=menu_order&depth=4&title_li=') ?>
|
||||||
|
<li><a href="<?php bloginfo('rss2_url') ?>">Subscribe</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br class="clear" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php echo $content ?>
|
||||||
|
|
||||||
|
<br class="clear" />
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
<p>
|
||||||
|
<?php bloginfo('name') ?> is powered by <a href="http://wordpress.org/">WordPress</a> with <a href="http://comicpress.org/">ComicPress</a>
|
||||||
|
| Subscribe: <a href="<?php bloginfo('rss2_url') ?>">RSS Feed</a>
|
||||||
|
<!-- <?php echo get_num_queries() ?> queries. <?php timer_stop(1) ?> seconds. -->
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php wp_footer() ?>
|
||||||
|
</body>
|
||||||
|
<?php get_footer(); ?>
|
||||||
|
</html>
|
|
@ -1,33 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__) . '/ComicPressComicPost.inc');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The core functions of ComicPress.
|
* The core functions of ComicPress.
|
||||||
*/
|
*/
|
||||||
class ComicPress {
|
class ComicPress {
|
||||||
var $comicpress_options = array(
|
var $comicpress_options = array(
|
||||||
'comic_category_id' => 1,
|
|
||||||
'comic_dimensions' => '760x',
|
'comic_dimensions' => '760x',
|
||||||
'rss_dimensions' => '350x',
|
'rss_dimensions' => '350x',
|
||||||
'archive_dimensions' => '125x',
|
'archive_dimensions' => '125x',
|
||||||
'mini_dimensions' => '100x',
|
'mini_dimensions' => '100x',
|
||||||
'category_order' => false,
|
|
||||||
'blogpost_count' => 10,
|
|
||||||
'comic_space' => 'comic_only',
|
|
||||||
'category_usage' => 'storyline',
|
|
||||||
'layout' => 'classic.inc',
|
|
||||||
'helpers' => array(),
|
'helpers' => array(),
|
||||||
'addons' => array(),
|
'addons' => array(),
|
||||||
'storyline_order' => ''
|
'storyline_order' => '',
|
||||||
|
'subattachment_types' => array(
|
||||||
|
'rss' => 'RSS',
|
||||||
|
'archive' => 'Archive',
|
||||||
|
'mini' => 'Mini Thumb'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var $additional_stylesheets = array();
|
var $backends = array('ComicPressBackendAttachment');
|
||||||
var $additional_javascripts = array();
|
|
||||||
|
|
||||||
var $comic_post_attachments_cache = array();
|
|
||||||
var $category_tree = array();
|
|
||||||
|
|
||||||
var $partial_paths = array();
|
|
||||||
var $layouts = null;
|
|
||||||
|
|
||||||
function &get_instance() {
|
function &get_instance() {
|
||||||
static $instance;
|
static $instance;
|
||||||
|
@ -64,22 +58,14 @@ class ComicPress {
|
||||||
function init() {
|
function init() {
|
||||||
$this->load();
|
$this->load();
|
||||||
|
|
||||||
add_action('wp_head', array(&$this, 'wp_head'));
|
|
||||||
add_filter('comicpress_nav', array(&$this, 'comicpress_nav'), 10, 2);
|
|
||||||
add_filter('comicpress_nav_fields', array(&$this, 'comicpress_nav_fields'));
|
|
||||||
|
|
||||||
if (current_user_can('edit_themes')) {
|
if (current_user_can('edit_themes')) {
|
||||||
if (!empty($this->comicpress_options['helpers'])) {
|
if (!empty($this->comicpress_options['helpers'])) {
|
||||||
if (isset($this->comicpress_options['helpers']['show_partials_info'])) {
|
|
||||||
add_filter('comicpress_partial', array(&$this, 'comicpress_partial'), 10, 2);
|
|
||||||
add_action('wp_head', array(&$this, 'setup_comicpress_partial'));
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('wp_footer', array(&$this, 'announce_activated_helpers'));
|
add_action('wp_footer', array(&$this, 'announce_activated_helpers'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('intermediate_image_sizes', array(&$this, 'intermediate_image_sizes'));
|
add_filter('intermediate_image_sizes', array(&$this, 'intermediate_image_sizes'));
|
||||||
|
add_filter('editor_max_image_size', array(&$this, 'editor_max_image_size'), 10, 2);
|
||||||
|
|
||||||
foreach (array('comic', 'rss', 'archive', 'mini') as $size) {
|
foreach (array('comic', 'rss', 'archive', 'mini') as $size) {
|
||||||
list($w, $h) = explode("x", $this->comicpress_options["${size}_dimensions"]);
|
list($w, $h) = explode("x", $this->comicpress_options["${size}_dimensions"]);
|
||||||
|
@ -93,113 +79,18 @@ class ComicPress {
|
||||||
return array_merge($sizes, array('comic', 'rss', 'archive', 'mini'));
|
return array_merge($sizes, array('comic', 'rss', 'archive', 'mini'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function needs_storyline_nav() {
|
function editor_max_image_size($current_max, $size) {
|
||||||
return (count($this->category_tree) > 1) && ($this->comicpress_options['category_usage'] == "storyline");
|
if (isset($this->comicpress_options["${size}_dimensions"])) {
|
||||||
}
|
list($width, $height) = explode('x', $this->comicpress_options["${size}_dimensions"]);
|
||||||
|
$current_max = array(intval($width), intval($height));
|
||||||
function is_multicomic() {
|
}
|
||||||
return $this->comicpress_options['category_usage'] == "multicomic";
|
return $current_max;
|
||||||
}
|
|
||||||
|
|
||||||
function comicpress_nav($type, $content) {
|
|
||||||
return $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
function comicpress_nav_fields($nav_fields) {
|
|
||||||
$nav_fields = array(
|
|
||||||
'first' => '‹‹ ' . __('First', 'comicpress'),
|
|
||||||
'previous' => '‹ ' . __('Previous', 'comicpress'),
|
|
||||||
'next' => __('Next', 'comicpress') . ' ›',
|
|
||||||
'last' => __('Last', 'comicpress') . ' ››'
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($this->needs_storyline_nav()) {
|
|
||||||
$nav_fields = array_merge(
|
|
||||||
array('prior' => '‹‹ ' . __('Prior Storyline', 'comicpress')),
|
|
||||||
$nav_fields,
|
|
||||||
array('upcoming' => __('Upcoming Storyline', 'comicpress') . ' ››')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $nav_fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
function wp_head() {
|
|
||||||
foreach ($this->additional_stylesheets as $uri) { ?>
|
|
||||||
<link rel="stylesheet" href="<?php echo get_template_directory_uri() . $uri ?>" type="text/css" />
|
|
||||||
<?php }
|
|
||||||
foreach ($this->additional_javascripts as $uri) { ?>
|
|
||||||
<script type="text/javascript" src="<?php echo get_template_directory_uri() . $uri ?>"></script>
|
|
||||||
<?php }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function announce_activated_helpers() {
|
function announce_activated_helpers() {
|
||||||
echo "<center>[ <strong>Activated ComicPress helpers:</strong> " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]</center>";
|
echo "<center>[ <strong>Activated ComicPress helpers:</strong> " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]</center>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_comicpress_partial() { ?>
|
|
||||||
<style type="text/css">
|
|
||||||
.partial-helper {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 100;
|
|
||||||
padding: 4px;
|
|
||||||
border: solid #333 1px;
|
|
||||||
background-color: #99d;
|
|
||||||
opacity: 0.2;
|
|
||||||
-moz-opacity: 0.2;
|
|
||||||
-khtml-opacity: 0.2;
|
|
||||||
zoom: 1;
|
|
||||||
cursor: crosshair
|
|
||||||
}
|
|
||||||
|
|
||||||
.partial-helper:hover {
|
|
||||||
opacity: 1;
|
|
||||||
-moz-opacity: 1;
|
|
||||||
-khtml-opacity: 1;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<!--[if IE gte 6]>
|
|
||||||
<style type="text/css">
|
|
||||||
.partial-helper { filter: alpha(opacity=20); }
|
|
||||||
.partial-helper:hover { filter: alpha(opacity=100); }
|
|
||||||
</style>
|
|
||||||
<![endif]-->
|
|
||||||
<?php }
|
|
||||||
|
|
||||||
function comicpress_partial($content, $target) {
|
|
||||||
return '<div class="partial-helper">' . str_replace(get_template_directory() . DIRECTORY_SEPARATOR, '', $target) . '</div>' . $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the path to a partial.
|
|
||||||
* @param array $partials The partials to search for in each path.
|
|
||||||
* @return string|boolean The partial path to use, or false if no matches.
|
|
||||||
*/
|
|
||||||
function get_partial_path($partials) {
|
|
||||||
foreach ($partials as $partial) {
|
|
||||||
foreach ($this->partial_paths as $path) {
|
|
||||||
$target = $path . '/' . $partial . '.inc';
|
|
||||||
if (file_exists($target)) {
|
|
||||||
return $target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_options_partial($partials) {
|
|
||||||
foreach ($partials as $partial) {
|
|
||||||
foreach ($this->partial_paths as $path) {
|
|
||||||
$target = str_replace(get_template_directory() . DIRECTORY_SEPARATOR, '', $path) . DIRECTORY_SEPARATOR . $partial;
|
|
||||||
|
|
||||||
if (isset($this->comicpress_options['override_partials'][$target])) {
|
|
||||||
return array($target, $this->comicpress_options['override_partials'][$target]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gather blog posts for the given index page.
|
* Gather blog posts for the given index page.
|
||||||
*/
|
*/
|
||||||
|
@ -221,102 +112,52 @@ class ComicPress {
|
||||||
return $wp_query;
|
return $wp_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _glob($pattern) { return glob($pattern); }
|
/**
|
||||||
function _file_get_contents($file) { return file_get_contents($file); }
|
* Search a path for directories named after the slugs provided.
|
||||||
|
* @param array $categories A list of category slugs going from child -> parent -> root.
|
||||||
|
* @param string $path The path to search.
|
||||||
|
* @return array All matching paths.
|
||||||
|
*/
|
||||||
|
function category_search($categories, $path) {
|
||||||
|
$path = trailingslashit($path);
|
||||||
|
$all_categories = array_reverse($categories);
|
||||||
|
$all_paths = array();
|
||||||
|
while (count($all_categories) > 0) {
|
||||||
|
$target = $path . implode('/', $all_categories);
|
||||||
|
if (is_dir($target)) { $all_paths[] = $target; }
|
||||||
|
array_pop($all_categories);
|
||||||
|
}
|
||||||
|
return array_reverse($all_paths);
|
||||||
|
}
|
||||||
|
|
||||||
function get_layout_choices() {
|
/**
|
||||||
if (!is_array($this->layouts)) {
|
* Recursively search a particular template directory for a specified file, limiting the search to the provided categories.
|
||||||
$this->layouts = array();
|
* @param string $name The name of the file with no path information.
|
||||||
foreach ($this->_glob(get_template_directory() . '/layouts/*') as $file) {
|
* @param string $path The path within the template directories to start the search.
|
||||||
$content = $this->_file_get_contents($file);
|
* @param attay $categories The child -> root category slugs to search within the specified path. If not provided, retrieve from current post.
|
||||||
$basename = pathinfo($file, PATHINFO_BASENAME);
|
* @return string|boolean The path to the file, for false if not found.
|
||||||
foreach (array(
|
*/
|
||||||
"Layout Name", "Sidebars"
|
function find_file($name, $path = '', $categories = null) {
|
||||||
) as $field) {
|
global $post;
|
||||||
if (preg_match('#/\*.*' . $field . ': ([^\n]+).*\*/#s', $content, $matches) > 0) {
|
if (!is_array($categories)) {
|
||||||
if (!is_array($this->layouts[$basename])) {
|
$comic_post = new ComicPressComicPost($post);
|
||||||
$this->layouts[$basename] = array();
|
$categories = $comic_post->find_parents();
|
||||||
}
|
}
|
||||||
$this->layouts[$basename][$field] = $matches[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->layouts;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_previous_next_categories($category_id) {
|
foreach (array(get_stylesheet_directory(), get_template_directory()) as $dir) {
|
||||||
$prev_next_categories = array();
|
$dir = trailingslashit($dir) . $path;
|
||||||
|
$dirs_to_search = $this->category_search($categories, $dir);
|
||||||
|
$dirs_to_search[] = $dir;
|
||||||
|
|
||||||
for ($i = 0, $il = count($this->category_tree); $i < $il; ++$i) {
|
foreach ($dirs_to_search as $category_path) {
|
||||||
$parts = explode("/", $this->category_tree[$i]);
|
$target = trailingslashit($category_path) . $name;
|
||||||
if (count($parts) > 2) {
|
if (file_exists($target)) {
|
||||||
if (end($parts) == $category_id) {
|
return $target;
|
||||||
while (count($parts) > 2) {
|
}
|
||||||
foreach (array(
|
}
|
||||||
'previous' => -1,
|
}
|
||||||
'next' => 1
|
return false;
|
||||||
) as $key => $direction) {
|
}
|
||||||
$index = $i;
|
|
||||||
while (isset($this->category_tree[$index])) {
|
|
||||||
$index += $direction;
|
|
||||||
if (isset($this->category_tree[$index])) {
|
|
||||||
$compare_parts = explode("/", $this->category_tree[$index]);
|
|
||||||
if (count($compare_parts) == count($parts)) {
|
|
||||||
$target_category = array_pop($compare_parts);
|
|
||||||
$parent_category = array_pop($compare_parts);
|
|
||||||
|
|
||||||
if (!isset($prev_next_categories[$parent_category])) {
|
|
||||||
$prev_next_categories[$parent_category] = array();
|
|
||||||
}
|
|
||||||
$prev_next_categories[$parent_category][$key] = $target_category;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
array_pop($parts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $prev_next_categories;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_sorted_post_categories($override_post = null) {
|
|
||||||
global $post;
|
|
||||||
$post_to_use = (!empty($override_post)) ? $override_post : $post;
|
|
||||||
|
|
||||||
$categories = wp_get_post_categories($post_to_use->ID);
|
|
||||||
|
|
||||||
$sorted_categories = array();
|
|
||||||
|
|
||||||
foreach ($this->category_tree as $node) {
|
|
||||||
$category_id = end(explode("/", $node));
|
|
||||||
if (in_array($category_id, $categories)) {
|
|
||||||
$sorted_categories[] = $category_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sorted_categories;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _is_dir($dir) { return is_dir($dir); }
|
|
||||||
|
|
||||||
function setup_multicomic_partial_paths($post_id) {
|
|
||||||
$this->partial_paths = array();
|
|
||||||
$category_ids = wp_get_post_categories($post_id);
|
|
||||||
if (is_array($category_ids)) {
|
|
||||||
foreach ($category_ids as $id) {
|
|
||||||
$category = get_category($id);
|
|
||||||
if (!empty($category)) {
|
|
||||||
if ($this->_is_dir($target = get_template_directory() . '/subthemes/' . $category->slug)) {
|
|
||||||
$this->partial_paths[] = $target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -70,18 +70,18 @@ class ComicPressAdmin {
|
||||||
|
|
||||||
if (strpos($pagenow, "post") === 0) {
|
if (strpos($pagenow, "post") === 0) {
|
||||||
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low");
|
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low");
|
||||||
wp_enqueue_script('cp-ordering', get_stylesheet_directory_uri() . '/js/ComicImageOrdering.js', array('scriptaculous', 'scriptaculous-slider'));
|
wp_enqueue_script('cp-ordering', get_template_directory_uri() . '/js/ComicImageOrdering.js', array('scriptaculous', 'scriptaculous-slider'));
|
||||||
wp_enqueue_style('cp-admin', get_stylesheet_directory_uri() . '/css/cp-admin.css');
|
wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css');
|
||||||
add_action('admin_footer', array(&$this, 'admin_footer'));
|
add_action('admin_footer', array(&$this, 'admin_footer'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($plugin_page == 'comicpress/render_admin') {
|
if ($plugin_page == 'comicpress/render_admin') {
|
||||||
wp_enqueue_style('cp-admin', get_stylesheet_directory_uri() . '/css/cp-admin.css');
|
wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css');
|
||||||
wp_enqueue_script('cp-admin', get_stylesheet_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous'));
|
wp_enqueue_script('cp-admin', get_template_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($pagenow, "media-upload") === 0) {
|
if (strpos($pagenow, "-upload") !== false) {
|
||||||
wp_enqueue_script('cp-media', get_stylesheet_directory_uri() . '/js/MediaUpload.js', array('prototype'));
|
wp_enqueue_script('cp-media', get_template_directory_uri() . '/js/MediaUpload.js', array('prototype'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,6 @@ class ComicPressAdmin {
|
||||||
*/
|
*/
|
||||||
function render_admin() {
|
function render_admin() {
|
||||||
$nonce = wp_create_nonce('comicpress');
|
$nonce = wp_create_nonce('comicpress');
|
||||||
$root_categories = $this->get_root_categories();
|
|
||||||
$storyline = new ComicPressStoryline();
|
$storyline = new ComicPressStoryline();
|
||||||
$storyline->normalize();
|
$storyline->normalize();
|
||||||
$storyline->read_from_options();
|
$storyline->read_from_options();
|
||||||
|
@ -175,77 +174,29 @@ class ComicPressAdmin {
|
||||||
if (is_numeric($override_post)) { $uploading_iframe_ID = $override_post; }
|
if (is_numeric($override_post)) { $uploading_iframe_ID = $override_post; }
|
||||||
|
|
||||||
$comic_post = new ComicPressComicPost(get_post($uploading_iframe_ID));
|
$comic_post = new ComicPressComicPost(get_post($uploading_iframe_ID));
|
||||||
$ordering = $comic_post->normalize_comic_image_ordering();
|
$ordering = $comic_post->normalize_ordering();
|
||||||
|
|
||||||
if (is_array($ordering)) {
|
$nonce = wp_create_nonce('comicpress');
|
||||||
$nonce = wp_create_nonce('comicpress');
|
$zoom_level = 40;
|
||||||
$zoom_level = 40;
|
$current_user = wp_get_current_user();
|
||||||
$current_user = wp_get_current_user();
|
if (!empty($current_user)) {
|
||||||
if (!empty($current_user)) {
|
$comicpress_meta = get_usermeta($current_user->ID, 'comicpress-settings');
|
||||||
$comicpress_meta = get_usermeta($current_user->ID, 'comicpress-settings');
|
if (is_array($comicpress_meta)) {
|
||||||
if (is_array($comicpress_meta)) {
|
if (isset($comicpress_meta['zoom_level'])) {
|
||||||
if (isset($comicpress_meta['zoom_level'])) {
|
$zoom_level = floor($comicpress_meta['zoom_level']);
|
||||||
$zoom_level = floor($comicpress_meta['zoom_level']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// from wp-admin/includes/media.php O_o
|
|
||||||
$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
|
|
||||||
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image&TB_iframe=true");
|
|
||||||
|
|
||||||
if ($is_ajax === true) {
|
|
||||||
include(dirname(__FILE__) . '/partials/_comic-image-ordering-sorters.inc');
|
|
||||||
} else {
|
|
||||||
include(dirname(__FILE__) . '/partials/_comic-image-ordering.inc');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all categories with a parent ID of 0.
|
|
||||||
* @return array All root categories.
|
|
||||||
*/
|
|
||||||
function get_root_categories() {
|
|
||||||
$root_categories = array();
|
|
||||||
foreach (get_all_category_ids() as $id) {
|
|
||||||
$category = get_category($id);
|
|
||||||
if (!empty($category)) {
|
|
||||||
if ($category->parent == 0) {
|
|
||||||
$root_categories[] = $category;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $root_categories;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// from wp-admin/includes/media.php O_o
|
||||||
* Create <option> elements for each of the provided categories.
|
$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
|
||||||
* @param array $categories The categories to display as either IDs or category objects.
|
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image&TB_iframe=true");
|
||||||
* @param int $selected_id The category to mark as selected.
|
|
||||||
* @return string The category options as HTML.
|
|
||||||
*/
|
|
||||||
function create_category_options($categories, $selected_id) {
|
|
||||||
$output = array();
|
|
||||||
if (is_array($categories)) {
|
|
||||||
$final_categories = array();
|
|
||||||
foreach ($categories as $category) {
|
|
||||||
if (is_numeric($category)) {
|
|
||||||
$result = get_category($category);
|
|
||||||
if (!(is_a($result, "WP_Error") || empty($result))) {
|
|
||||||
$final_categories[] = $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is_object($category)) {
|
|
||||||
$final_categories[] = $category;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($final_categories as $category) {
|
if ($is_ajax === true) {
|
||||||
$output[] = '<option value="' . $category->term_id . '"' . (($category->term_id == $selected_id) ? ' selected="selected"' : '') . '>' . $category->name . '</option>';
|
include(dirname(__FILE__) . '/partials/_comic-image-ordering-sorters.inc');
|
||||||
}
|
} else {
|
||||||
|
include(dirname(__FILE__) . '/partials/_comic-image-ordering.inc');
|
||||||
}
|
}
|
||||||
return implode("\n", $output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,14 +254,6 @@ class ComicPressAdmin {
|
||||||
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
||||||
if (isset($info[$option])) {
|
if (isset($info[$option])) {
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
case 'comic_category_id':
|
|
||||||
if (is_numeric($info[$option])) {
|
|
||||||
$result = get_category($info[$option]);
|
|
||||||
if (!(is_a($result, 'WP_Error') || empty($result))) {
|
|
||||||
$this->comicpress->comicpress_options[$option] = $info[$option];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'comic_dimensions':
|
case 'comic_dimensions':
|
||||||
case 'rss_dimensions':
|
case 'rss_dimensions':
|
||||||
case 'archive_dimensions':
|
case 'archive_dimensions':
|
||||||
|
@ -336,14 +279,6 @@ class ComicPressAdmin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'blogpost_count':
|
|
||||||
$this->comicpress->comicpress_options[$option] = (int)$info[$option];
|
|
||||||
break;
|
|
||||||
case 'comic_space':
|
|
||||||
case 'category_usage':
|
|
||||||
case 'layout';
|
|
||||||
$this->comicpress->comicpress_options[$option] = $info[$option];
|
|
||||||
break;
|
|
||||||
case 'helpers':
|
case 'helpers':
|
||||||
case 'addons':
|
case 'addons':
|
||||||
foreach ($info[$option] as $type => $set) {
|
foreach ($info[$option] as $type => $set) {
|
||||||
|
@ -378,17 +313,10 @@ class ComicPressAdmin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_update_override_partial($info) {
|
/**
|
||||||
switch ($info['action']) {
|
* Update the zoom slider info.
|
||||||
case __('Update partial', 'comicpress'):
|
* @param $info The browser input.
|
||||||
$this->comicpress->comicpress_options['override_partials'][$info['partial']] = stripslashes($info['code']);
|
*/
|
||||||
break;
|
|
||||||
case __('Delete override partial', 'comicpress'):
|
|
||||||
unset($this->comicpress->comicpress_options['override_partials'][$info['partial']]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle_update_zoom_slider($info) {
|
function handle_update_zoom_slider($info) {
|
||||||
$this->is_ajax = true;
|
$this->is_ajax = true;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ComicPressBackend {
|
||||||
|
function _embed_image($size) {
|
||||||
|
$extras = array();
|
||||||
|
if (($dims = $this->dims($size)) !== false) {
|
||||||
|
$extras = array_merge($extras, $dims);
|
||||||
|
}
|
||||||
|
foreach ($extras as $field => $value) {
|
||||||
|
$extras[] = "${field}=\"${value}\"";
|
||||||
|
unset($extras[$field]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = sprintf('<img src="%s" alt="%s" title="%s" %s />', $this->url(), $this->alt(), $this->title(), implode(" ", $extras));
|
||||||
|
return apply_filters('comicpress_embed_image', $output, $this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,15 +8,17 @@ class ComicPressComicPost {
|
||||||
if (!is_null($post)) { $this->post = $post; }
|
if (!is_null($post)) { $this->post = $post; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_comic_image_attachments() {
|
/**
|
||||||
if (is_null($this->attachments)) {
|
* TODO normalize the attachments
|
||||||
$this->attachments = get_children(array(
|
* @return unknown_type
|
||||||
'post_parent' => $this->post->ID,
|
*/
|
||||||
'post_type' => 'attachment',
|
function get_attachments() {
|
||||||
'post_mime_type' => 'image'
|
$comicpress = ComicPress::get_instance();
|
||||||
));
|
$attachments = array();
|
||||||
}
|
foreach ($comicpress->backends as $backend) {
|
||||||
return $this->attachments;
|
$attachments = array_merge($attachments, call_user_func(array($backend, 'generate_from_post'), $this->post));
|
||||||
|
}
|
||||||
|
return $attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +81,11 @@ class ComicPressComicPost {
|
||||||
$dimensions = array();
|
$dimensions = array();
|
||||||
|
|
||||||
if (isset($this->comicpress->comicpress_options["${type}_dimensions"])) {
|
if (isset($this->comicpress->comicpress_options["${type}_dimensions"])) {
|
||||||
list($width, $height) = explode("x", $this->comicpress->comicpress_options["${type}_dimensions"]);
|
$parts = explode("x", $this->comicpress->comicpress_options["${type}_dimensions"]);
|
||||||
|
switch (count($parts)) {
|
||||||
|
case 1: list($width) = $parts; break;
|
||||||
|
case 2: list($width, $height) = $parts; break;
|
||||||
|
}
|
||||||
$dimensions = compact('width', 'height');
|
$dimensions = compact('width', 'height');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,63 +109,74 @@ class ComicPressComicPost {
|
||||||
* Normalize the ordering of comic images in this post.
|
* Normalize the ordering of comic images in this post.
|
||||||
* If images have beed added or removed, intelligently update the metadata.
|
* If images have beed added or removed, intelligently update the metadata.
|
||||||
*/
|
*/
|
||||||
function normalize_comic_image_ordering() {
|
function normalize_ordering() {
|
||||||
if (is_array($this->get_comic_image_attachments())) {
|
$attachments = $this->get_attachments();
|
||||||
$ordering_by_type = array();
|
if (is_array($attachments)) {
|
||||||
$ordering_types = get_post_meta($this->post->ID, 'comic_ordering', true);
|
$new_ordering = array();
|
||||||
|
$current_ordering = get_post_meta($this->post->ID, 'image-ordering', true);
|
||||||
|
if (!is_array($current_ordering)) { $current_ordering = array(); }
|
||||||
|
|
||||||
$comic_image_ordering = array();
|
$all_current_ids = array();
|
||||||
$found_post_ids = array();
|
foreach ($current_ordering as $key => $properties) {
|
||||||
if (!empty($ordering_types)) {
|
$all_current_ids[$key] = true;
|
||||||
foreach ($ordering_types as $type => $post_ids) {
|
if (isset($properties['children'])) {
|
||||||
$comic_image_ordering[$type] = array();
|
foreach ($properties['children'] as $type => $kids) {
|
||||||
foreach ($post_ids as $ordering_post_id) {
|
$all_current_ids = array_merge($all_current_ids, $kids);
|
||||||
foreach ($this->get_comic_image_attachments() as $attachment) {
|
}
|
||||||
if (!isset($found_post_ids[$attachment->ID])) {
|
}
|
||||||
if ($attachment->ID == $ordering_post_id) {
|
}
|
||||||
$comic_image_ordering[$type][] = $attachment->ID;
|
$all_current_ids = array_keys($all_current_ids);
|
||||||
$found_post_ids[$ordering_post_id] = true;
|
|
||||||
}
|
$attachment_ids = array();
|
||||||
}
|
foreach ($attachments as $attachment) { $attachment_ids[] = $attachment->id; }
|
||||||
}
|
|
||||||
}
|
$new_attachments = array_diff($attachment_ids, $all_current_ids);
|
||||||
}
|
$missing_attachments = array_diff($all_current_ids, $attachment_ids);
|
||||||
|
|
||||||
|
foreach ($new_attachments as $attachment_id) {
|
||||||
|
$current_ordering[$attachment_id] = array('enabled' => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$remaining_posts_to_sort = array();
|
foreach ($missing_attachments as $attachment_id) {
|
||||||
foreach ($this->get_comic_image_attachments() as $attachment) {
|
if (isset($current_ordering[$attachment_id])) {
|
||||||
$comic_image_type = get_post_meta($attachment->ID, 'comic_image_type', true);
|
unset($current_ordering[$attachment_id]);
|
||||||
|
} else {
|
||||||
if (!empty($comic_image_type)) {
|
foreach ($current_ordering as $key => $properties) {
|
||||||
if (!isset($found_post_ids[$attachment->ID])) {
|
if (isset($properties['children'])) {
|
||||||
if (!isset($remaining_posts_to_sort[$comic_image_type])) {
|
foreach ($properties['children'] as $type => $kids) {
|
||||||
$remaining_posts_to_sort[$comic_image_type] = array();
|
if (isset($kids[$attachment_id])) { unset($kids[$attachment_id]); }
|
||||||
}
|
if (empty($kids)) {
|
||||||
$remaining_posts_to_sort[$comic_image_type][] = $attachment->ID;
|
unset($properties['children'][$type]);
|
||||||
}
|
} else {
|
||||||
}
|
$properties['children'][$type] = $kids;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($properties['children'])) {
|
||||||
|
unset($current_ordering[$key]['children']);
|
||||||
|
} else {
|
||||||
|
$current_ordering[$key] = $properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($remaining_posts_to_sort as $type => $posts) {
|
update_post_meta($this->post->ID, 'image-ordering', $current_ordering);
|
||||||
usort($remaining_posts_to_sort[$type], array(&$this, 'sort_remaining_comic_images'));
|
return $current_ordering;
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($remaining_posts_to_sort as $type => $posts) {
|
|
||||||
if (is_array($comic_image_ordering[$type])) {
|
|
||||||
$comic_image_ordering[$type] = array_merge($comic_image_ordering[$type], $posts);
|
|
||||||
} else {
|
|
||||||
$comic_image_ordering[$type] = $posts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update_post_meta($this->post->ID, 'comic_ordering', $comic_image_ordering);
|
|
||||||
return $comic_image_ordering;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort the remaining comic images by file date.
|
||||||
|
* @param object $a
|
||||||
|
* @param object $b
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function sort_remaining_comic_images($a, $b) {
|
function sort_remaining_comic_images($a, $b) {
|
||||||
return strtotime($a->post_date) - strtotime($b->post_date);
|
$a_date = isset($a->post_date) ? $a->post_date : 0;
|
||||||
|
$b_date = isset($b->post_date) ? $b->post_date : 0;
|
||||||
|
return $a_date - $b_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,8 +221,28 @@ class ComicPressComicPost {
|
||||||
update_post_meta($this->post->ID, 'comic_ordering', $new_order);
|
update_post_meta($this->post->ID, 'comic_ordering', $new_order);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_parent_categories() {
|
function find_parents() {
|
||||||
$parents = wp_get_post_categories($this->post->ID);
|
$parents = array();
|
||||||
|
$post_categories = wp_get_post_categories($this->post->ID);
|
||||||
|
if (count($post_categories) == 1) {
|
||||||
|
do {
|
||||||
|
$category_parent = 0;
|
||||||
|
$category = get_category(end($post_categories));
|
||||||
|
if (!empty($category)) {
|
||||||
|
$category_parent = $category->parent;
|
||||||
|
if ($category_parent != 0) {
|
||||||
|
$post_categories[] = $category_parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while ($category_parent != 0);
|
||||||
|
|
||||||
|
foreach ($post_categories as $category_id) {
|
||||||
|
$category = get_category($category_id);
|
||||||
|
$parents[$category_id] = $category->slug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $parents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ComicPressDBInterface {
|
class ComicPressDBInterface {
|
||||||
var $_non_comic_categories, $_all_categories;
|
function ComicPressDBInterface() {}
|
||||||
|
|
||||||
function ComicPressDBInterface() {}
|
|
||||||
|
|
||||||
function get_instance() {
|
function get_instance() {
|
||||||
static $instance;
|
static $instance;
|
||||||
|
@ -14,27 +12,22 @@ class ComicPressDBInterface {
|
||||||
|
|
||||||
function _get_categories() { return get_categories("hide_empty=0"); }
|
function _get_categories() { return get_categories("hide_empty=0"); }
|
||||||
|
|
||||||
/**
|
function get_terminal_post($first = true, $include_categories = null) {
|
||||||
* Set the comic categories for the current run of ComicPress.
|
|
||||||
*/
|
|
||||||
function set_comic_categories($categories) {
|
|
||||||
$this->_all_categories = get_all_category_ids();
|
|
||||||
$this->_non_comic_categories = array_values(array_diff($this->_all_categories, $categories));
|
|
||||||
}
|
|
||||||
|
|
||||||
function _get_categories_to_exclude($category = null) {
|
|
||||||
return (is_null($category)) ? $this->_non_comic_categories : array_values(array_diff($this->_all_categories, array($category)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the terminal post in a specific category.
|
|
||||||
*/
|
|
||||||
function get_terminal_post_in_category($category_id, $first = true) {
|
|
||||||
$this->_prepare_wp_query();
|
$this->_prepare_wp_query();
|
||||||
|
|
||||||
$sort_order = $first ? "asc" : "desc";
|
|
||||||
$terminal_comic_query = new WP_Query();
|
$terminal_comic_query = new WP_Query();
|
||||||
$terminal_comic_query->query("showposts=1&order=${sort_order}&cat=${category_id}&status=publish");
|
|
||||||
|
$query_parameters = array(
|
||||||
|
'showposts' => 1,
|
||||||
|
'order' => $first ? "asc" : "desc",
|
||||||
|
'status' => 'publish'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_array($include_categories)) {
|
||||||
|
$query_parameters['category_in'] = $include_categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
$terminal_comic_query->query($query_parameters);
|
||||||
$post = false;
|
$post = false;
|
||||||
if ($terminal_comic_query->have_posts()) {
|
if ($terminal_comic_query->have_posts()) {
|
||||||
$post = reset($terminal_comic_query->posts);
|
$post = reset($terminal_comic_query->posts);
|
||||||
|
@ -47,28 +40,28 @@ class ComicPressDBInterface {
|
||||||
/**
|
/**
|
||||||
* Get the first comic in a category.
|
* Get the first comic in a category.
|
||||||
*/
|
*/
|
||||||
function get_first_comic($category_id) {
|
function get_first_post($include_categories = null) {
|
||||||
return $this->get_terminal_post_in_category($category_id);
|
return $this->get_terminal_post(true, $include_categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last comic in a category.
|
* Get the last comic in a category.
|
||||||
*/
|
*/
|
||||||
function get_last_comic($category_id) {
|
function get_last_post($include_categories = null) {
|
||||||
return $this->get_terminal_post_in_category($category_id, false);
|
return $this->get_terminal_post(false, $include_categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the comic post adjacent to the current comic.
|
* Get the comic post adjacent to the current comic.
|
||||||
* Wrapper around get_adjacent_post(). Don't unit test this method.
|
* Wrapper around get_adjacent_post(). Don't unit test this method.
|
||||||
*/
|
*/
|
||||||
function get_adjacent_comic($category, $next = false, $override_post = null) {
|
function get_adjacent_post($categories = array(), $next = false, $override_post = null) {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
$this->_prepare_wp_query();
|
$this->_prepare_wp_query();
|
||||||
if (!is_null($override_post)) { $temp_post = $post; $post = $override_post; }
|
if (!is_null($override_post)) { $temp_post = $post; $post = $override_post; }
|
||||||
|
|
||||||
$result = get_adjacent_post(false, implode(" and ", $this->_get_categories_to_exclude($category)), !$next);
|
$result = get_adjacent_post(false, implode(" and ", array_diff(get_all_category_ids(), $categories)), !$next);
|
||||||
|
|
||||||
$this->_reset_wp_query();
|
$this->_reset_wp_query();
|
||||||
if (!is_null($override_post)) { $post = $temp_post; }
|
if (!is_null($override_post)) { $post = $temp_post; }
|
||||||
|
@ -95,12 +88,12 @@ class ComicPressDBInterface {
|
||||||
/**
|
/**
|
||||||
* Get the previous comic from the current one.
|
* Get the previous comic from the current one.
|
||||||
*/
|
*/
|
||||||
function get_previous_comic($category = null, $override_post = null) { return $this->get_adjacent_comic($category, false, $override_post); }
|
function get_previous_post($categories = array(), $override_post = null) { return $this->get_adjacent_post($categories, false, $override_post); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next comic from the current one.
|
* Get the next comic from the current one.
|
||||||
*/
|
*/
|
||||||
function get_next_comic($category = null, $override_post = null) { return $this->get_adjacent_comic($category, true, $override_post); }
|
function get_next_post($categories = array(), $override_post = null) { return $this->get_adjacent_post($categories, true, $override_post); }
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -11,32 +11,56 @@ class ComicPressNavigation {
|
||||||
|
|
||||||
function get_post_nav($post) {
|
function get_post_nav($post) {
|
||||||
$nav = array();
|
$nav = array();
|
||||||
|
if (is_object($post)) {
|
||||||
|
if (isset($post->ID)) {
|
||||||
|
$cache_key = 'navigation-' . $post->ID;
|
||||||
|
|
||||||
// global previous/next
|
if (($result = wp_cache_get($cache_key, 'comicpress')) !== false) {
|
||||||
foreach (array('previous', 'next') as $field) {
|
foreach ($result as $key => $post_id) {
|
||||||
$nav[$field] = $this->_dbi->{"get_${field}_comic"}(null, $post);
|
$nev[$key] = get_post($post_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// global first/last
|
// global previous/next
|
||||||
foreach (array('first', 'last') as $field) {
|
foreach (array('previous', 'next') as $field) {
|
||||||
$nav[$field] = $this->_dbi->{"get_${field}_comic"}(null);
|
$nav[$field] = $this->_dbi->{"get_${field}_comic"}(null, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($category = $this->_storyline->get_valid_post_category($post->ID)) {
|
// global first/last
|
||||||
// storyline previous/next
|
foreach (array('first', 'last') as $field) {
|
||||||
foreach (array('previous', 'next') as $field) {
|
$nav[$field] = $this->_dbi->{"get_${field}_comic"}(null);
|
||||||
$nav["storyline-${field}"] = $this->_dbi->{"get_${field}_comic"}($category, $post);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// adjacent storyline nodes
|
if ($category = $this->_storyline->get_valid_post_category($post->ID)) {
|
||||||
if (is_array($valid = $this->_storyline->valid($category))) {
|
// storyline previous/next
|
||||||
foreach ($valid as $field) {
|
foreach (array('previous', 'next') as $field) {
|
||||||
$nav["storyline-chapter-${field}"] = $this->_dbi->get_first_comic($this->_storyline->{$field}($category));
|
$nav["storyline-${field}"] = $this->_dbi->{"get_${field}_comic"}($category, $post);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $nav;
|
// adjacent storyline nodes
|
||||||
|
if (is_array($valid = $this->_storyline->valid($category))) {
|
||||||
|
foreach ($valid as $field) {
|
||||||
|
$all_adjacents = $this->_storyline->all_adjacent($category, $field);
|
||||||
|
foreach ($all_adjacents as $adjacent_category) {
|
||||||
|
$result = $this->_dbi->get_first_comic($adjacent_category);
|
||||||
|
if (!empty($result)) {
|
||||||
|
$nav["storyline-chapter-${field}"] = $result; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache_data = array();
|
||||||
|
foreach ($nav as $key => $output_post) {
|
||||||
|
if (!empty($output_post)) { $cache_data[$key] = $output_post->ID; }
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_cache_set($cache_key, $cache_data, 'comicpress');
|
||||||
|
|
||||||
|
return $nav;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class ComicPressStorylineCategory {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,17 +1,64 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ComicPressBackendAttachment {
|
require_once(dirname(__FILE__) . '/../ComicPressBackend.inc');
|
||||||
function ComicPressBackendAttachment($attachment_id) {
|
|
||||||
$this->attachment_id = $attachment_id;
|
class ComicPressBackendAttachment extends ComicPressBackend {
|
||||||
|
var $root_id = 'attachment';
|
||||||
|
|
||||||
|
function generate_from_post($post) {
|
||||||
|
$result = array();
|
||||||
|
if (is_object($post)) {
|
||||||
|
if (isset($post->ID)) {
|
||||||
|
$children = get_children(array(
|
||||||
|
'post_parent' => $post->ID,
|
||||||
|
'post_type' => 'attachment',
|
||||||
|
'post_mime_type' => 'image'
|
||||||
|
));
|
||||||
|
|
||||||
|
if (!empty($children)) {
|
||||||
|
foreach ($children as $child) {
|
||||||
|
$result[] = new ComicPressBackendAttachment($child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ComicPressBackendAttachment($attachment) {
|
||||||
|
$this->attachment = $attachment;
|
||||||
|
$this->id = sprintf('%s-%d', $this->root_id, $this->attachment->ID);
|
||||||
|
$this->type = get_post_meta($this->attachment->ID, 'comic_image_type', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_url() {
|
function dims($size = 'comic') {
|
||||||
return wp_get_attachment_url($this->attachment_id);
|
$metadata = image_downsize($this->attachment->ID, $size);
|
||||||
|
if (!empty($metadata)) {
|
||||||
|
if (is_array($metadata)) {
|
||||||
|
return array_combine(array('width', 'height'), array_slice($metadata, 1, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_info() {
|
function url($size = 'comic') {
|
||||||
return wp_get_attachment_metadata($this->attachment_id);
|
$metadata = image_downsize($this->attachment->ID, $size);
|
||||||
|
if (!empty($metadata)) {
|
||||||
|
if (is_array($metadata)) {
|
||||||
|
return $metadata[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function embed($size = 'comic') {
|
||||||
|
return $this->_embed_image($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
function alt() { return $this->attachment->post_title; }
|
||||||
|
function title() { return $this->attachment->post_excerpt; }
|
||||||
|
|
||||||
|
function get_info() { return array(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -9,29 +9,31 @@
|
||||||
<?php _e('Click the Refesh button underneath the zoom slider if you\'ve changed the images attached to this post.', 'comicpress') ?>
|
<?php _e('Click the Refesh button underneath the zoom slider if you\'ve changed the images attached to this post.', 'comicpress') ?>
|
||||||
|
|
||||||
</em></p>
|
</em></p>
|
||||||
<?php foreach ($ordering as $type => $attachment_ids) { ?>
|
<?php if (!empty($ordering)) { ?>
|
||||||
<h3><?php echo $this->comic_image_types[$type] ?></h3>
|
<?php foreach ($ordering as $type => $attachment_ids) { ?>
|
||||||
<div class="comic-ordering" id="comic-ordering-<?php echo $type ?>">
|
<h3><?php echo $this->comic_image_types[$type] ?></h3>
|
||||||
<?php foreach ($attachment_ids as $attachment_id) {
|
<div class="comic-ordering" id="comic-ordering-<?php echo $type ?>">
|
||||||
$backend = new ComicPressBackendAttachment($attachment_id);
|
<?php foreach ($attachment_ids as $attachment_id) {
|
||||||
$info = $backend->get_info(); ?>
|
$backend = new ComicPressBackendAttachment($attachment_id);
|
||||||
<div class="cp-comic-attachment" id="attachment_<?php echo $attachment_id ?>">
|
$info = $backend->get_info(); ?>
|
||||||
<img src="<?php echo $backend->get_url() ?>" border="0" height="<?php echo $zoom_level ?>" />
|
<div class="cp-comic-attachment" id="attachment_<?php echo $attachment_id ?>">
|
||||||
<div>
|
<img src="<?php echo $backend->url() ?>" border="0" height="<?php echo $zoom_level ?>" />
|
||||||
<?php if (isset($info['file'])) { ?>
|
<div>
|
||||||
<p><strong><?php echo basename($info['file']) ?></strong></p>
|
<?php if (isset($info['file'])) { ?>
|
||||||
<?php } ?>
|
<p><strong><?php echo basename($info['file']) ?></strong></p>
|
||||||
<?php if (isset($info['width']) && isset($info['height'])) { ?>
|
<?php } ?>
|
||||||
<p>
|
<?php if (isset($info['width']) && isset($info['height'])) { ?>
|
||||||
<?php _e('Size:', 'comicpress') ?>
|
<p>
|
||||||
<?php printf('%dx%d', $info['width'], $info['height'] ) ?>
|
<?php _e('Size:', 'comicpress') ?>
|
||||||
</p>
|
<?php printf('%dx%d', $info['width'], $info['height'] ) ?>
|
||||||
<?php } ?>
|
</p>
|
||||||
</div>
|
<?php } ?>
|
||||||
<br style="clear: both" />
|
</div>
|
||||||
</div>
|
<br style="clear: both" />
|
||||||
<?php } ?>
|
</div>
|
||||||
</div>
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -5,11 +5,16 @@
|
||||||
<h3><?php _e('Global Options', 'comicpress') ?></h3>
|
<h3><?php _e('Global Options', 'comicpress') ?></h3>
|
||||||
<table class="widefat fixed">
|
<table class="widefat fixed">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" valign="top"><?php _e('Layout', 'comicpress') ?></th>
|
<th scope="row" valign="top"><?php _e("Arrange storyline category order", 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
<select name="cp[layout]">
|
<input type="hidden" name="cp[storyline_order]" />
|
||||||
<?php echo $this->create_layout_options($this->comicpress->get_layout_choices(), $this->comicpress->comicpress_options['layout']) ?>
|
<div id="storyline-sorter" class="cp-children">
|
||||||
</select>
|
<?php
|
||||||
|
$this->_render_admin_storyline_tree(reset($storyline->get_simple_storyline()))
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">Storyline.setup()</script>
|
||||||
|
<p><em><?php _e('(drag and drop desired order. categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php foreach (array(
|
<?php foreach (array(
|
||||||
|
@ -25,47 +30,6 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<tr>
|
|
||||||
<th scope="row" valign="top"><?php _e("Number of blog posts on home page", 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="cp[blogpost_count]" value="<?php echo $this->comicpress->comicpress_options['blogpost_count'] ?>" size="3" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row" valign="top"><?php _e("Arrange storyline category order", 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<input type="hidden" name="cp[storyline_order]" />
|
|
||||||
<div id="storyline-sorter" class="cp-children">
|
|
||||||
<?php
|
|
||||||
$this->_render_admin_storyline_tree(reset($storyline->get_simple_storyline()))
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">Storyline.setup()</script>
|
|
||||||
<p><em><?php _e('(drag and drop desired order. categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row"><?php _e('Insert into comic space:', 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<?php foreach (array(
|
|
||||||
"comic_only" => __("The comic only, with post content below", 'comicpress'),
|
|
||||||
"post_content" => __("The post content", 'comicpress')
|
|
||||||
) as $value => $label) { ?>
|
|
||||||
<label><input type="radio" name="cp[comic_space]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['comic_space'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
|
|
||||||
<?php } ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row"><?php _e('Use subcategories of the Master Comic Category as:', 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<?php foreach (array(
|
|
||||||
"storyline" => __("Storyline indicators for a single comic", 'comicpress'),
|
|
||||||
"multicomic" => __("Multicomic indicators, with direct descendents being separate comics", 'comicpress')
|
|
||||||
) as $value => $label) { ?>
|
|
||||||
<label><input type="radio" name="cp[category_usage]" value="<?php echo $value ?>" <?php echo ($this->comicpress->comicpress_options['category_usage'] == $value) ? 'checked="checked"' : "" ?> /> <?php echo $label ?></label><br />
|
|
||||||
<?php } ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
||||||
<table class="widefat fixed">
|
<table class="widefat fixed">
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
padding-left: 20px
|
padding-left: 20px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#children-0 {
|
||||||
|
padding-left: 0
|
||||||
|
}
|
||||||
|
|
||||||
.cp-category-info span {
|
.cp-category-info span {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
color: #004
|
color: #004
|
||||||
|
|
17
footer.php
17
footer.php
|
@ -1,17 +0,0 @@
|
||||||
<div class="clear"></div><!-- Clears floated columns and sidebars -->
|
|
||||||
|
|
||||||
<div id="footer">
|
|
||||||
<p>
|
|
||||||
<?php bloginfo('name') ?> is powered by <a href="http://wordpress.org/">WordPress</a> with <a href="http://comicpress.org/">ComicPress</a>
|
|
||||||
| Subscribe: <a href="<?php bloginfo('rss2_url') ?>">RSS Feed</a>
|
|
||||||
<!-- <?php echo get_num_queries() ?> queries. <?php timer_stop(1) ?> seconds. -->
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div><!-- Ends "page" -->
|
|
||||||
|
|
||||||
<?php wp_footer() ?>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,64 +0,0 @@
|
||||||
/**
|
|
||||||
* Find a comic file in the filesystem.
|
|
||||||
* @param string $folder The folder name to search.
|
|
||||||
* @param string $override_post A WP Post object to use in place of global $post.
|
|
||||||
* @param string $filter The $comic_filename_filters to use.
|
|
||||||
* @return string The relative path to the comic file, or false if not found.
|
|
||||||
*/
|
|
||||||
function get_comic_path($folder = 'comic', $override_post = null, $filter = 'default') {
|
|
||||||
global $post, $comic_filename_filters, $comic_folder, $archive_comic_folder, $rss_comic_folder, $comic_pathfinding_errors;
|
|
||||||
|
|
||||||
if (isset($comic_filename_filters[$filter])) {
|
|
||||||
$filter_to_use = $comic_filename_filters[$filter];
|
|
||||||
} else {
|
|
||||||
$filter_to_use = '{date}*.*';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($folder) {
|
|
||||||
case "rss": $folder_to_use = $rss_comic_folder; break;
|
|
||||||
case "archive": $folder_to_use = $archive_comic_folder; break;
|
|
||||||
case "comic": default: $folder_to_use = $comic_folder; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_to_use = (is_object($override_post)) ? $override_post : $post;
|
|
||||||
$post_date = mysql2date(CP_DATE_FORMAT, $post_to_use->post_date);
|
|
||||||
|
|
||||||
$filter_with_date = str_replace('{date}', $post_date, $filter_to_use);
|
|
||||||
|
|
||||||
if (count($results = glob("${folder_to_use}/${filter_with_date}")) > 0) {
|
|
||||||
return reset($results);
|
|
||||||
}
|
|
||||||
|
|
||||||
$comic_pathfinding_errors[] = sprintf(__("Unable to find the file in the <strong>%s</strong> folder that matched the pattern <strong>%s</strong>. Check your WordPress and ComicPress settings.", 'comicpress'), $folder, $filter_with_date);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find a comic file in the filesystem and return an absolute URL to that file.
|
|
||||||
* @param string $folder The folder name to search.
|
|
||||||
* @param string $override_post A WP Post object to use in place of global $post.
|
|
||||||
* @param string $filter The $comic_filename_filters to use.
|
|
||||||
* @return string The absolute URL to the comic file, or false if not found.
|
|
||||||
*/
|
|
||||||
function get_comic_url($folder = 'comic', $override_post = null, $filter = 'default') {
|
|
||||||
if (($result = get_comic_path($folder, $override_post, $filter)) !== false) {
|
|
||||||
return get_option('home') . '/' . $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ComicPress Template Functions
|
|
||||||
|
|
||||||
function the_comic($filter = 'default') { echo get_comic_url('comic', null, $filter); }
|
|
||||||
//The following is deprecated...
|
|
||||||
function comic_display($filter = 'default') { echo get_comic_url('comic', null, $filter); }
|
|
||||||
|
|
||||||
function the_comic_archive($filter = 'default') { echo get_comic_url('archive', null, $filter); }
|
|
||||||
//The following is deprecated...
|
|
||||||
function comic_archive($filter = 'default') { echo get_comic_url('archive', null, $filter); }
|
|
||||||
|
|
||||||
function the_comic_rss($filter = 'default') { echo get_comic_url('rss', null, $filter); }
|
|
||||||
//The following is deprecated...
|
|
||||||
function comic_rss($filter = 'default') { echo get_comic_url('rss', null, $filter); }
|
|
||||||
|
|
217
functions.php
217
functions.php
|
@ -32,56 +32,124 @@ function __comicpress_init() {
|
||||||
|
|
||||||
$comicpress_filters = new ComicPressFilters();
|
$comicpress_filters = new ComicPressFilters();
|
||||||
$comicpress_filters->init();
|
$comicpress_filters->init();
|
||||||
|
|
||||||
$layouts = $comicpress->get_layout_choices();
|
|
||||||
if (isset($layouts[$comicpress->comicpress_options['layout']])) {
|
|
||||||
if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) {
|
|
||||||
foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) {
|
|
||||||
$sidebar = trim($sidebar);
|
|
||||||
register_sidebar($sidebar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function comicpress_init() {
|
function F($name, $path, $override_post = null) {
|
||||||
global $post, $comicpress;
|
global $post;
|
||||||
|
|
||||||
if (!empty($post)) {
|
$comic_post = new ComicPressComicPost(is_null($override_post) ? $post : $override_post);
|
||||||
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
|
|
||||||
$comicpress->setup_multicomic_partial_paths($post->ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$comicpress->partial_paths[] = get_template_directory() . '/partials';
|
return ComicPress::get_instance()->find_file($name, $path, $comic_post->find_parents());
|
||||||
}
|
}
|
||||||
|
|
||||||
function comicpress_get_header() {
|
/**
|
||||||
get_header();
|
* Finish rendering this template and shove the output into application.php.
|
||||||
|
*/
|
||||||
|
function finish_comicpress() {
|
||||||
|
$content = ob_get_clean();
|
||||||
|
|
||||||
|
include(F('application.php', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
function include_partial($partials = '') {
|
/**
|
||||||
global $comicpress, $post, $nav_comics;
|
* Protect global $post and $wp_query.
|
||||||
|
*/
|
||||||
|
function Protect() {
|
||||||
|
global $post, $wp_query, $__post, $__wp_query;
|
||||||
|
|
||||||
if (!is_array($partials)) { $partials = func_get_args(); }
|
$__post = $post;
|
||||||
|
$__wp_query = $wp_query;
|
||||||
$content = $target = null;
|
|
||||||
|
|
||||||
$target = $comicpress->get_partial_path($partials);
|
|
||||||
|
|
||||||
if ($target !== false) {
|
|
||||||
ob_start(); include($target); $content = ob_get_clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
$target = str_replace(".inc", "", $target);
|
|
||||||
|
|
||||||
if (!empty($target) && !empty($content)) {
|
|
||||||
echo apply_filters("comicpress_partial", $content, $target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function in_comic_category() {
|
/**
|
||||||
global $post, $comicpress;
|
* Temporarily restore the global $post variable and set it up for use.
|
||||||
|
*/
|
||||||
|
function Restore() {
|
||||||
|
global $post, $__post;
|
||||||
|
|
||||||
|
$post = $__post;
|
||||||
|
setup_postdata($post);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore global $post and $wp_query.
|
||||||
|
*/
|
||||||
|
function Unprotect() {
|
||||||
|
global $post, $wp_query, $__post, $__wp_query;
|
||||||
|
|
||||||
|
$post = $__post;
|
||||||
|
$wp_query = $__wp_query;
|
||||||
|
|
||||||
|
$__post = $__wp_query = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function R($which, $restrictions = null, $override_post = null) {
|
||||||
|
global $post;
|
||||||
|
$post_to_use = !is_null($override_post) ? $override_post : $post;
|
||||||
|
|
||||||
|
$storyline = new ComicPressStoryline();
|
||||||
|
|
||||||
|
if (is_string($restrictions)) {
|
||||||
|
switch ($restrictions) {
|
||||||
|
case 'from_post':
|
||||||
|
$restrictions = array('from_post' => $post_to_use);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($restrictions)) {
|
||||||
|
$new_restrictions = array();
|
||||||
|
foreach ($restrictions as $type => $list) {
|
||||||
|
if (is_string($list)) {
|
||||||
|
$value = $list;
|
||||||
|
switch ($list) {
|
||||||
|
case '__post': $value = $post_to_use; break;
|
||||||
|
}
|
||||||
|
$new_restrictions[$type] = $value;
|
||||||
|
} else {
|
||||||
|
$new_restrictions[$type] = $list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$restrictions = $new_restrictions;
|
||||||
|
}
|
||||||
|
|
||||||
|
$categories = $storyline->build_from_restrictions($restrictions);
|
||||||
|
|
||||||
|
$dbi = ComicPressDBInterface::get_instance();
|
||||||
|
|
||||||
|
$new_post = false;
|
||||||
|
|
||||||
|
switch ($which) {
|
||||||
|
case 'first': $new_post = $dbi->get_first_post($categories); break;
|
||||||
|
case 'last': $new_post = $dbi->get_last_post($categories); break;
|
||||||
|
case 'next': $new_post = $dbi->get_next_post($categories, $post_to_use); break;
|
||||||
|
case 'previous': $new_post = $dbi->get_previous_post($categories, $post_to_use); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_post;
|
||||||
|
}
|
||||||
|
|
||||||
|
function RT($which, $restrictions = null, $override_post = null) {
|
||||||
|
global $post, $__post;
|
||||||
|
if (!empty($override_post)) {
|
||||||
|
$post_to_use = $override_post;
|
||||||
|
} else {
|
||||||
|
$post_to_use = (!empty($__post)) ? $__post : $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($new_post = R($which, $restrictions, $post_to_use)) !== false) {
|
||||||
|
$post = $new_post;
|
||||||
|
setup_postdata($post);
|
||||||
|
}
|
||||||
|
return $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
function M($override_post = null) {
|
||||||
|
global $post;
|
||||||
|
$post_to_use = !is_null($override_post) ? $override_post : $post;
|
||||||
|
|
||||||
|
$comic_post = new ComicPressComicPost($post_to_use);
|
||||||
|
return $comic_post->get_attachments();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,74 +195,5 @@ function comicpress_list_storyline_categories($args = "") {
|
||||||
echo $output;
|
echo $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
ob_start();
|
||||||
* Display the comic transcript
|
|
||||||
* Transcript must be entered into a custom field named "transcript"
|
|
||||||
* @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander)
|
|
||||||
*/
|
|
||||||
function the_transcript($displaymode = 'raw') {
|
|
||||||
$transcript = get_post_meta( get_the_ID(), "transcript", true );
|
|
||||||
switch ($displaymode) {
|
|
||||||
case "raw":
|
|
||||||
echo $transcript;
|
|
||||||
break;
|
|
||||||
case "br":
|
|
||||||
echo nl2br($transcript);
|
|
||||||
break;
|
|
||||||
case "styled":
|
|
||||||
if (!empty($transcript)) { ?>
|
|
||||||
<script type='text/javascript'>
|
|
||||||
<!--
|
|
||||||
function toggle_expander(id) {
|
|
||||||
var e = document.getElementById(id);
|
|
||||||
if(e.style.height == 'auto')
|
|
||||||
e.style.height = '1px';
|
|
||||||
else
|
|
||||||
e.style.height = 'auto';
|
|
||||||
}
|
|
||||||
//-->
|
|
||||||
</script>
|
|
||||||
<div class="transcript-border"><div id="transcript"><a href="javascript:toggle_expander('transcript-content');" class="transcript-title">↓ Transcript</a><div id="transcript-content"><?php echo nl2br($transcript); ?><br /><br /></div></div></div>
|
|
||||||
<script type='text/javascript'>
|
|
||||||
<!--
|
|
||||||
document.getElementById('transcript-content').style.height = '1px';
|
|
||||||
//-->
|
|
||||||
</script><?php
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register Sidebar and Define Widgets
|
|
||||||
|
|
||||||
function widget_comicpress_latest_comics() { ?>
|
|
||||||
<li>
|
|
||||||
<h2>Latest Comics</h2>
|
|
||||||
<ul>
|
|
||||||
<?php global $post;
|
|
||||||
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string());
|
|
||||||
foreach($latestcomics as $post) : ?>
|
|
||||||
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<?php } if ( function_exists('register_sidebar_widget') )
|
|
||||||
register_sidebar_widget(__('Latest Comics'), 'widget_comicpress_latest_comics');
|
|
||||||
|
|
||||||
function widget_comicpress_random_comic() { ?>
|
|
||||||
<li>
|
|
||||||
<h2><a href="?randomcomic"><span class="random-comic-icon">?</span> Random Comic</a></h2>
|
|
||||||
</li>
|
|
||||||
<?php } if ( function_exists('register_sidebar_widget') )
|
|
||||||
register_sidebar_widget(__('Random Comic'), 'widget_comicpress_random_comic');
|
|
||||||
|
|
||||||
function widget_comicpress_archive_dropdown() { ?>
|
|
||||||
<li class="archive-dropdown-wrap">
|
|
||||||
<select name="archive-dropdown" class="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
|
|
||||||
<option value=""><?php echo attribute_escape(__('Archives...')); ?></option>
|
|
||||||
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
|
|
||||||
</li>
|
|
||||||
<?php } if ( function_exists('register_sidebar_widget') )
|
|
||||||
register_sidebar_widget(__('Archive Dropdown'), 'widget_comicpress_archive_dropdown');
|
|
||||||
|
|
||||||
?>
|
?>
|
23
header.php
23
header.php
|
@ -1,5 +1,3 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes() ?>>
|
|
||||||
<head profile="http://gmpg.org/xfn/11">
|
<head profile="http://gmpg.org/xfn/11">
|
||||||
<title><?php
|
<title><?php
|
||||||
bloginfo('name');
|
bloginfo('name');
|
||||||
|
@ -21,25 +19,4 @@
|
||||||
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name') ?> Atom Feed" href="<?php bloginfo('atom_url') ?>" />
|
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name') ?> Atom Feed" href="<?php bloginfo('atom_url') ?>" />
|
||||||
<link rel="pingback" href="<?php bloginfo('pingback_url') ?>" />
|
<link rel="pingback" href="<?php bloginfo('pingback_url') ?>" />
|
||||||
<?php wp_head() ?>
|
<?php wp_head() ?>
|
||||||
<!--[if lt IE 7]><script type="text/javascript" src="<?php bloginfo('template_directory') ?>/ie6submenus.js"></script><![endif]-->
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body <?php if (function_exists('body_class')) { body_class(); } ?>>
|
|
||||||
|
|
||||||
<div id="page"><!-- Defines entire site width - Ends in Footer -->
|
|
||||||
|
|
||||||
<div id="header">
|
|
||||||
<h1><a href="<?php echo get_settings('home') ?>"><?php bloginfo('name') ?></a></h1>
|
|
||||||
<div class="description"><?php bloginfo('description') ?></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="menubar">
|
|
||||||
|
|
||||||
<ul id="menu">
|
|
||||||
<li><a href="<?php bloginfo('url') ?>">Home</a></li>
|
|
||||||
<?php wp_list_pages('sort_column=menu_order&depth=4&title_li=') ?>
|
|
||||||
<li><a href="<?php bloginfo('rss2_url') ?>">Subscribe</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
|
@ -1,14 +0,0 @@
|
||||||
//Suckerfish Dropdown for IE6
|
|
||||||
|
|
||||||
sfHover = function() {
|
|
||||||
var sfEls = document.getElementById("menu").getElementsByTagName("LI");
|
|
||||||
for (var i=0; i<sfEls.length; i++) {
|
|
||||||
sfEls[i].onmouseover=function() {
|
|
||||||
this.className+=" sfhover";
|
|
||||||
}
|
|
||||||
sfEls[i].onmouseout=function() {
|
|
||||||
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (window.attachEvent) window.attachEvent("onload", sfHover);
|
|
35
index.php
35
index.php
|
@ -1,34 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
global $comicpress, $post, $nav_comics;
|
$previous_post = R('previous');
|
||||||
|
$next_post = R('next');
|
||||||
|
|
||||||
comicpress_init();
|
var_dump($previous_post);
|
||||||
|
var_dump($next_post);
|
||||||
|
|
||||||
$nav_comics = array();
|
finish_comicpress();
|
||||||
$t = $post;
|
|
||||||
$post = $nav_comics['last'];
|
|
||||||
setup_postdata($post);
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
if (!is_paged()) { include_partial('index-display-comic'); }
|
|
||||||
|
|
||||||
$comic = ob_get_clean();
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
if (!is_paged() && ($comicpress->comicpress_options['comic_space'] == "comic_only")) { include_partial('index-comic-post'); }
|
|
||||||
|
|
||||||
include_partial('index-blog-header');
|
|
||||||
|
|
||||||
$index_posts_query = $comicpress->get_index_blog_posts_query();
|
|
||||||
|
|
||||||
while ($index_posts_query->have_posts()) {
|
|
||||||
$index_posts_query->the_post();
|
|
||||||
include_partial('index-blog-post');
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = ob_get_clean();
|
|
||||||
$post = $t;
|
|
||||||
|
|
||||||
include(get_template_directory() . '/layouts/' . $comicpress->comicpress_options['layout']);
|
|
||||||
?>
|
?>
|
|
@ -1,19 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Layout Name: Classic
|
|
||||||
Sidebars: right
|
|
||||||
*/
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php get_header() ?>
|
|
||||||
|
|
||||||
<?php echo $comic ?>
|
|
||||||
|
|
||||||
<div id="content" class="narrowcolumn">
|
|
||||||
<?php echo $content ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php get_sidebar('right') ?>
|
|
||||||
|
|
||||||
<?php get_footer() ?>
|
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Layout Name: Three Column
|
|
||||||
Sidebars: left,right
|
|
||||||
*/
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php get_header() ?>
|
|
||||||
|
|
||||||
<?php echo $comic ?>
|
|
||||||
|
|
||||||
<?php get_sidebar('left') ?>
|
|
||||||
|
|
||||||
<div id="content" class="narrowcolumn">
|
|
||||||
<?php echo $content ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php get_sidebar('right') ?>
|
|
||||||
|
|
||||||
<?php get_footer() ?>
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit colors="true" bootstrap="test/bootstrap.php" />
|
50
single.php
50
single.php
|
@ -1,37 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
global $comicpress, $nav_comics;
|
$storyline = new ComicPressStoryline();
|
||||||
|
$storyline->read_from_options();
|
||||||
|
|
||||||
comicpress_init();
|
the_title(); echo '<br />';
|
||||||
|
|
||||||
ob_start();
|
Protect();
|
||||||
|
|
||||||
if (have_posts()) {
|
RT('first', 'from_post'); the_title(); echo '<br />';
|
||||||
the_post();
|
RT('previous', 'from_post'); the_title(); echo '<br />';
|
||||||
if (in_comic_category()) { include_partial('single-display-comic'); }
|
RT('previous', array('root_of' => '__post')); the_title(); echo '<br />';
|
||||||
}
|
RT('previous'); the_title(); echo '<br />';
|
||||||
rewind_posts();
|
Restore(); the_title(); echo '<br />';
|
||||||
|
|
||||||
$comic = ob_get_clean();
|
foreach (M() as $image) {
|
||||||
|
echo $image->embed();
|
||||||
ob_start();
|
|
||||||
|
|
||||||
$nav_comics = $comicpress->get_nav_comics();
|
|
||||||
|
|
||||||
if (have_posts()) {
|
|
||||||
while (have_posts()) { the_post();
|
|
||||||
if (in_comic_category()) {
|
|
||||||
if ($comicpress->comicpress_options['comic_space'] == "comic_only") {
|
|
||||||
include_partial('single-comic-post');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
include_partial('single-blog-post');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
include_partial('single-no-matches');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = ob_get_clean();
|
RT('next'); the_title(); echo '<br />';
|
||||||
|
RT('next', array('root_of' => '__post')); the_title(); echo '<br />';
|
||||||
|
RT('next', 'from_post'); the_title(); echo '<br />';
|
||||||
|
RT('last', 'from_post'); the_title(); echo '<br />';
|
||||||
|
|
||||||
include(get_template_directory() . '/layouts/' . $comicpress->comicpress_options['layout']);
|
Unprotect();
|
||||||
|
|
||||||
|
the_title(); echo '<br />';
|
||||||
|
|
||||||
|
finish_comicpress();
|
||||||
?>
|
?>
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressAdmin.inc');
|
require_once('ComicPressAdmin.inc');
|
||||||
|
|
||||||
class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
@ -11,56 +11,6 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->admin = new ComicPressAdmin();
|
$this->admin = new ComicPressAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestGetRootComicCategories() {
|
|
||||||
return array(
|
|
||||||
array(array(), array()),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
array('id' => 1, 'parent' => 0),
|
|
||||||
array('id' => 2, 'parent' => 1)
|
|
||||||
),
|
|
||||||
array(1)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider providerTestGetRootComicCategories
|
|
||||||
*/
|
|
||||||
function testGetRootCategories($categories, $expected_result) {
|
|
||||||
foreach ($categories as $category) {
|
|
||||||
add_category($category['id'], (object)$category);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result_ids = array();
|
|
||||||
foreach ($this->admin->get_root_categories() as $category) {
|
|
||||||
$result_ids[] = $category->term_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($expected_result, $result_ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testCreateCategoryOptions() {
|
|
||||||
add_category(1, (object)array('name' => 'test-one'));
|
|
||||||
add_category(2, (object)array('name' => 'test-two'));
|
|
||||||
|
|
||||||
foreach(array(
|
|
||||||
array(1,2),
|
|
||||||
array(get_category(1), get_category(2))
|
|
||||||
) as $category_test) {
|
|
||||||
$source = $this->admin->create_category_options($category_test, 1);
|
|
||||||
|
|
||||||
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
|
|
||||||
|
|
||||||
foreach (array(
|
|
||||||
'//option[@value="1" and @selected="selected"]' => "test-one",
|
|
||||||
'//option[@value="2"]' => "test-two",
|
|
||||||
) as $xpath => $value) {
|
|
||||||
$this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function testCreateDimensionSelector() {
|
function testCreateDimensionSelector() {
|
||||||
$source = $this->admin->create_dimension_selector("test", "760x340");
|
$source = $this->admin->create_dimension_selector("test", "760x340");
|
||||||
|
|
||||||
|
@ -76,32 +26,6 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
function providerTestHandleUpdate() {
|
function providerTestHandleUpdate() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
|
||||||
array('comic_category_id' => 1),
|
|
||||||
array('comic_category_id' => 2),
|
|
||||||
array('comic_category_id' => 1)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array('comic_category_id' => 1),
|
|
||||||
array('cp' => array(
|
|
||||||
'comic_category_id' => 2),
|
|
||||||
),
|
|
||||||
array('comic_category_id' => 2)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array('comic_category_id' => 1),
|
|
||||||
array('cp' => array(
|
|
||||||
'comic_category_id' => "cat"),
|
|
||||||
),
|
|
||||||
array('comic_category_id' => 1)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array('comic_category_id' => 1),
|
|
||||||
array('cp' => array(
|
|
||||||
'comic_category_id' => 3
|
|
||||||
)),
|
|
||||||
array('comic_category_id' => 1)
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
array('comic_dimensions' => '150x150'),
|
array('comic_dimensions' => '150x150'),
|
||||||
array('cp' => array(
|
array('cp' => array(
|
||||||
|
@ -138,7 +62,6 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
function testHandleUpdate($original, $change, $new) {
|
function testHandleUpdate($original, $change, $new) {
|
||||||
$this->admin->comicpress = $this->getMock('ComicPress', array('save', 'init'));
|
$this->admin->comicpress = $this->getMock('ComicPress', array('save', 'init'));
|
||||||
$this->admin->comicpress->comicpress_options = array(
|
$this->admin->comicpress->comicpress_options = array(
|
||||||
'comic_category_id' => 1,
|
|
||||||
'comic_dimensions' => '760x',
|
'comic_dimensions' => '760x',
|
||||||
'rss_dimensions' => '350x',
|
'rss_dimensions' => '350x',
|
||||||
'archive_dimensions' => '125x'
|
'archive_dimensions' => '125x'
|
||||||
|
@ -149,7 +72,9 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
$_POST = $change;
|
$_POST = $change;
|
||||||
|
|
||||||
$this->admin->handle_update_comicpress_options($_POST['cp']);
|
if (isset($_POST['cp'])) {
|
||||||
|
$this->admin->handle_update_comicpress_options($_POST['cp']);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($new as $key => $value) {
|
foreach ($new as $key => $value) {
|
||||||
$this->assertEquals($value, $this->admin->comicpress->comicpress_options[$key]);
|
$this->assertEquals($value, $this->admin->comicpress->comicpress_options[$key]);
|
||||||
|
@ -258,25 +183,6 @@ class ComicPressAdminTest extends PHPUnit_Framework_TestCase {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider providerTestHandleUpdateOverridePartial
|
|
||||||
*/
|
|
||||||
function testHandleUpdateOverridePartial($code, $action) {
|
|
||||||
$this->admin->comicpress = (object)array(
|
|
||||||
'comicpress_options' => array(
|
|
||||||
'override_partials' => array(
|
|
||||||
'index' => '$hiss;'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->admin->handle_update_override_partial(array_merge(compact('code', 'action'), array('partial' => 'index')));
|
|
||||||
|
|
||||||
if ($result && $action == "Update partial") {
|
|
||||||
$this->assertEquals($code, $this->admin->comicpress->comicpress_options['override_partials']['index']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressComicPost.inc');
|
require_once('ComicPressComicPost.inc');
|
||||||
|
|
||||||
class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
@ -47,80 +47,51 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNormalizeComicImageOrdering() {
|
function providerTestNormalizeOrdering() {
|
||||||
$p = $this->getMock('ComicPressComicPost', array('get_comic_image_attachments'));
|
return array(
|
||||||
|
array(
|
||||||
|
array('attachment-1'),
|
||||||
|
array(),
|
||||||
|
array('attachment-1' => array('enabled' => true))
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('attachment-1'),
|
||||||
|
array('attachment-1' => array('enabled' => false), 'attachment-2' => array('enabled' => true)),
|
||||||
|
array('attachment-1' => array('enabled' => false))
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('attachment-1'),
|
||||||
|
array('attachment-1' => array('enabled' => true, 'children' => array('rss' => array('attachment-2' => true)))),
|
||||||
|
array('attachment-1' => array('enabled' => true))
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('attachment-1', 'attachment-2', 'attachment-3'),
|
||||||
|
array('attachment-1' => array('enabled' => false, 'children' => array('rss' => array('attachment-2' => true)))),
|
||||||
|
array('attachment-1' => array('enabled' => false, 'children' => array('rss' => array('attachment-2' => true))), 'attachment-3' => array('enabled' => true))
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$comic_attachments = array(
|
/**
|
||||||
array(
|
* @dataProvider providerTestNormalizeOrdering
|
||||||
'ID' => 2,
|
*/
|
||||||
'post_parent' => 1,
|
function testNormalizeOrdering($attachments, $current_meta, $expected_result) {
|
||||||
'post_title' => 'Comic one',
|
$p = $this->getMock('ComicPressComicPost', array('get_attachments'));
|
||||||
'post_meta' => array(
|
|
||||||
'comic_image_type' => 'comic'
|
|
||||||
),
|
|
||||||
'post_date' => 1
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'ID' => 3,
|
|
||||||
'post_parent' => 1,
|
|
||||||
'post_title' => 'Comic two',
|
|
||||||
'post_meta' => array(
|
|
||||||
'comic_image_type' => 'comic'
|
|
||||||
),
|
|
||||||
'post_date' => 2
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'ID' => 4,
|
|
||||||
'post_parent' => 1,
|
|
||||||
'post_title' => 'Comic three',
|
|
||||||
'post_meta' => array(
|
|
||||||
'comic_image_type' => 'rss'
|
|
||||||
),
|
|
||||||
'post_date' => 4
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'ID' => 5,
|
|
||||||
'post_parent' => 1,
|
|
||||||
'post_title' => 'Comic four',
|
|
||||||
'post_meta' => array(
|
|
||||||
'comic_image_type' => 'rss'
|
|
||||||
),
|
|
||||||
'post_date' => 3
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$attachments = array();
|
$attachment_objects = array();
|
||||||
foreach ($comic_attachments as $attachment_info) {
|
foreach ($attachments as $attachment) {
|
||||||
$attachment = (object)array();
|
$attachment_objects[] = (object)array('id' => $attachment);
|
||||||
foreach ($attachment_info as $field => $value) {
|
|
||||||
switch ($field) {
|
|
||||||
case "post_meta":
|
|
||||||
foreach ($value as $meta => $meta_value) {
|
|
||||||
update_post_meta($attachment_info['ID'], $meta, $meta_value);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "post_date":
|
|
||||||
$attachment->{$field} = date("r", $value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$attachment->{$field} = $value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$attachments[] = $attachment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$p->expects($this->any())->method('get_comic_image_attachments')->will($this->returnValue($attachments));
|
$p->expects($this->any())->method('get_attachments')->will($this->returnValue($attachment_objects));
|
||||||
|
|
||||||
wp_insert_post((object)array('ID' => 1));
|
wp_insert_post((object)array('ID' => 1));
|
||||||
update_post_meta(1, 'comic_ordering', array('comic' => array(3)));
|
update_post_meta(1, 'image-ordering', $current_meta);
|
||||||
|
|
||||||
$p->post = (object)array('ID' => 1);
|
$p->post = (object)array('ID' => 1);
|
||||||
|
|
||||||
$result = $p->normalize_comic_image_ordering();
|
$this->assertEquals($expected_result, $p->normalize_ordering());
|
||||||
|
$this->assertEquals($expected_result, get_post_meta(1, 'image-ordering', true));
|
||||||
$this->assertEquals(array('comic' => array(3,2), 'rss' => array(5,4)), $result);
|
|
||||||
$this->assertEquals(array('comic' => array(3,2), 'rss' => array(5,4)), get_post_meta(1, 'comic_ordering', true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestChangeComicImageOrdering() {
|
function providerTestChangeComicImageOrdering() {
|
||||||
|
@ -162,8 +133,49 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($expected_result, get_post_meta(1, 'comic_ordering', true));
|
$this->assertEquals($expected_result, get_post_meta(1, 'comic_ordering', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFindParents() {
|
function providerTestFindParents() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array(),
|
||||||
|
array()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(1),
|
||||||
|
array(1 => 'root')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(2),
|
||||||
|
array(2 => 'comic', 1 => 'root')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(3),
|
||||||
|
array(3 => 'part-1', 2 => 'comic', 1 => 'root')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(4),
|
||||||
|
array(4 => 'blog', 1 => 'root')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(1, 4),
|
||||||
|
array()
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindParents
|
||||||
|
*/
|
||||||
|
function testFindParents($post_categories, $expected_result) {
|
||||||
|
add_category(1, (object)array('slug' => 'root', 'parent' => 0));
|
||||||
|
add_category(2, (object)array('slug' => 'comic', 'parent' => 1));
|
||||||
|
add_category(3, (object)array('slug' => 'part-1', 'parent' => 2));
|
||||||
|
add_category(4, (object)array('slug' => 'blog', 'parent' => 1));
|
||||||
|
|
||||||
|
wp_set_post_categories(1, $post_categories);
|
||||||
|
|
||||||
|
$this->p->post = (object)array('ID' => 1);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_result, $this->p->find_parents());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressDBInterface.inc');
|
require_once('ComicPressDBInterface.inc');
|
||||||
|
|
||||||
class ComicPressDBInterfaceTest extends PHPUnit_Framework_TestCase {
|
class ComicPressDBInterfaceTest extends PHPUnit_Framework_TestCase {
|
||||||
function testSingleton() {
|
function testSingleton() {
|
||||||
|
@ -14,35 +14,6 @@ class ComicPressDBInterfaceTest extends PHPUnit_Framework_TestCase {
|
||||||
$b = ComicPressDBInterface::get_instance();
|
$b = ComicPressDBInterface::get_instance();
|
||||||
$this->assertEquals("test", $b->test);
|
$this->assertEquals("test", $b->test);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSetComicCategories() {
|
|
||||||
$dbi = ComicPressDBInterface::get_instance();
|
|
||||||
|
|
||||||
for ($i = 1; $i <= 4; ++$i) { add_category($i, (object)array()); }
|
|
||||||
|
|
||||||
$dbi->set_comic_categories(array(2,3));
|
|
||||||
|
|
||||||
$this->assertEquals(array(1,2,3,4), $dbi->_all_categories);
|
|
||||||
$this->assertEquals(array(1,4), $dbi->_non_comic_categories);
|
|
||||||
}
|
|
||||||
|
|
||||||
function providerTestGetCategoriesToExclude() {
|
|
||||||
return array(
|
|
||||||
array(null, array(1 ,4)),
|
|
||||||
array(2, array(1, 3, 4)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider providerTestGetCategoriesToExclude
|
|
||||||
*/
|
|
||||||
function testGetCategoriesToExclude($category, $expected_results) {
|
|
||||||
$dbi = ComicPressDBInterface::get_instance();
|
|
||||||
$dbi->_all_categories = array(1,2,3,4);
|
|
||||||
$dbi->_non_comic_categories = array(1,4);
|
|
||||||
|
|
||||||
$this->assertEquals($expected_results, $dbi->_get_categories_to_exclude($category));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressNavigation.inc');
|
require_once('ComicPressNavigation.inc');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration Testing. Just make sure things are called correctly.
|
* Integration Testing. Just make sure things are called correctly.
|
||||||
|
@ -34,13 +34,53 @@ class ComicPressNavigationTest extends PHPUnit_Framework_TestCase {
|
||||||
$dbi->expects($this->at(3))->method('get_last_comic')->with(null);
|
$dbi->expects($this->at(3))->method('get_last_comic')->with(null);
|
||||||
$dbi->expects($this->at(4))->method('get_previous_comic')->with(2, $post);
|
$dbi->expects($this->at(4))->method('get_previous_comic')->with(2, $post);
|
||||||
$dbi->expects($this->at(5))->method('get_next_comic')->with(2, $post);
|
$dbi->expects($this->at(5))->method('get_next_comic')->with(2, $post);
|
||||||
$dbi->expects($this->at(6))->method('get_first_comic')->with(1);
|
$dbi->expects($this->at(6))->method('get_first_comic')->with(1)->will($this->returnValue((object)array('ID' => 1)));
|
||||||
$dbi->expects($this->at(7))->method('get_first_comic')->with(3);
|
$dbi->expects($this->at(7))->method('get_first_comic')->with(3)->will($this->returnValue((object)array('ID' => 1)));
|
||||||
|
|
||||||
$this->nav->_dbi = $dbi;
|
$this->nav->_dbi = $dbi;
|
||||||
$this->nav->_storyline = $storyline;
|
$this->nav->_storyline = $storyline;
|
||||||
|
|
||||||
|
$this->assertFalse(wp_cache_get('navigation-1', 'comicpress'));
|
||||||
|
|
||||||
$this->nav->get_post_nav($post);
|
$this->nav->get_post_nav($post);
|
||||||
|
|
||||||
|
$this->assertTrue(wp_cache_get('navigation-1', 'comicpress') !== false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSkipEmptyCategories() {
|
||||||
|
$dbi = $this->getMock('ComicPressDBInterface', array('get_previous_comic', 'get_next_comic', 'get_first_comic', 'get_last_comic'));
|
||||||
|
$storyline = new ComicPressStoryline();
|
||||||
|
|
||||||
|
$storyline->_structure = array(
|
||||||
|
'1' => array('next' => 2),
|
||||||
|
'2' => array('previous' => 1, 'next' => 3),
|
||||||
|
'3' => array('previous' => 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_insert_post(array('ID' => 1));
|
||||||
|
$post = get_post(1);
|
||||||
|
|
||||||
|
wp_set_post_categories(1, array(1));
|
||||||
|
|
||||||
|
$dbi->expects($this->any())->method('get_first_comic')->will($this->returnCallback(array(&$this, 'callbackTestSkipEmptyCategories')));
|
||||||
|
|
||||||
|
$this->nav->_dbi = $dbi;
|
||||||
|
$this->nav->_storyline = $storyline;
|
||||||
|
|
||||||
|
$nav = $this->nav->get_post_nav($post);
|
||||||
|
|
||||||
|
$this->assertEquals(10, $nav['storyline-chapter-next']->ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
function callbackTestSkipEmptyCategories($category_id) {
|
||||||
|
if (!is_null($category_id)) {
|
||||||
|
switch ($category_id) {
|
||||||
|
case 3: return (object)array('ID' => 10);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return (object)array('ID' => 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once('MockPress/mockpress.php');
|
|
||||||
require_once('PHPUnit/Framework.php');
|
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressStorylineCategory.inc');
|
|
||||||
|
|
||||||
class ComicPressStorylineCategoryTest extends PHPUnit_Framework_TestCase {
|
|
||||||
function setUp() {
|
|
||||||
_reset_wp();
|
|
||||||
}
|
|
||||||
|
|
||||||
function testGetAdjacentCategories() {
|
|
||||||
$sc = new ComicPressStorylineCategory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressStoryline.inc');
|
require_once('ComicPressStoryline.inc');
|
||||||
|
|
||||||
class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
@ -346,7 +346,16 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(array(), $this->css->_category_search);
|
$this->assertEquals(array(), $this->css->_category_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFindChildren() {
|
function providerTestFindChildren() {
|
||||||
|
return array(
|
||||||
|
array(2), array('test')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindChildren
|
||||||
|
*/
|
||||||
|
function testFindChildren($search) {
|
||||||
$this->css->_structure = array(
|
$this->css->_structure = array(
|
||||||
'1' => array('next' => 2),
|
'1' => array('next' => 2),
|
||||||
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3),
|
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3),
|
||||||
|
@ -354,27 +363,9 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
'4' => array('parent' => 2, 'previous' => 3)
|
'4' => array('parent' => 2, 'previous' => 3)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(2,3,4), $this->css->_find_children(2));
|
add_category(2, (object)array('slug' => 'test'));
|
||||||
}
|
|
||||||
|
|
||||||
function testIncludeChildren() {
|
$this->assertEquals(array(2,3,4), $this->css->_find_children($search));
|
||||||
$css = $this->getMock('ComicPressStoryline', array('_find_children'));
|
|
||||||
$css->expects($this->once())->method('_find_children')->will($this->returnValue(array(2,3,4)));
|
|
||||||
$css->_category_search = array(4,5);
|
|
||||||
|
|
||||||
$css->include_children(2);
|
|
||||||
|
|
||||||
$this->assertEquals(array(2,3,4,5), $css->_category_search);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testExcludeChildren() {
|
|
||||||
$css = $this->getMock('ComicPressStoryline', array('_find_children'));
|
|
||||||
$css->expects($this->once())->method('_find_children')->will($this->returnValue(array(2,3,4)));
|
|
||||||
$css->_category_search = array(4, 5, 6);
|
|
||||||
|
|
||||||
$css->exclude_children(2);
|
|
||||||
|
|
||||||
$this->assertEquals(array(5, 6), $css->_category_search);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFindLevelOrAbove() {
|
function testFindLevelOrAbove() {
|
||||||
|
@ -388,31 +379,211 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals(array(1, 2), $this->css->_find_level_or_above(2));
|
$this->assertEquals(array(1, 2), $this->css->_find_level_or_above(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testIncludeLevelOrAbove() {
|
|
||||||
$css = $this->getMock('ComicPressStoryline', array('_find_level_or_above'));
|
|
||||||
$css->expects($this->once())->method('_find_level_or_above')->will($this->returnValue(array(2,3,4)));
|
|
||||||
$css->_category_search = array(4,5);
|
|
||||||
|
|
||||||
$css->include_level_or_above(2);
|
|
||||||
|
|
||||||
$this->assertEquals(array(2,3,4,5), $css->_category_search);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testExcludeLevelOrAbove() {
|
|
||||||
$css = $this->getMock('ComicPressStoryline', array('_find_level_or_above'));
|
|
||||||
$css->expects($this->once())->method('_find_level_or_above')->will($this->returnValue(array(2,3,4)));
|
|
||||||
$css->_category_search = array(4, 5, 6);
|
|
||||||
|
|
||||||
$css->exclude_level_or_above(2);
|
|
||||||
|
|
||||||
$this->assertEquals(array(5, 6), $css->_category_search);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testEndSearch() {
|
function testEndSearch() {
|
||||||
$this->css->_category_search = array(1,2,3);
|
$this->css->_category_search = array(1,2,3);
|
||||||
$this->assertEquals(array(1,2,3), $this->css->end_search());
|
$this->assertEquals(array(1,2,3), $this->css->end_search());
|
||||||
$this->assertEquals(array(), $this->css->_category_search);
|
$this->assertEquals(array(), $this->css->_category_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function providerTestFindOnly() {
|
||||||
|
return array(
|
||||||
|
array(1, array(1)),
|
||||||
|
array(5, array()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindOnly
|
||||||
|
*/
|
||||||
|
function testFindOnly($id, $expected_return) {
|
||||||
|
$this->css->_structure = array(
|
||||||
|
'1' => array('next' => 2, 'level' => 1),
|
||||||
|
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3, 'level' => 2),
|
||||||
|
'3' => array('parent' => 2, 'next' => 4, 'previous' => 2, 'level' => 3),
|
||||||
|
'4' => array('parent' => 2, 'previous' => 3, 'level' => 3)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_return, $this->css->_find_only($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestFindLevel() {
|
||||||
|
return array(
|
||||||
|
array(1, array(1)),
|
||||||
|
array(2, array(2)),
|
||||||
|
array(3, array(3,4))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindLevel
|
||||||
|
*/
|
||||||
|
function testFindLevel($id, $expected_return) {
|
||||||
|
$this->css->_structure = array(
|
||||||
|
'1' => array('next' => 2, 'level' => 1),
|
||||||
|
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3, 'level' => 2),
|
||||||
|
'3' => array('parent' => 2, 'next' => 4, 'previous' => 2, 'level' => 3),
|
||||||
|
'4' => array('parent' => 2, 'previous' => 3, 'level' => 3)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_return, $this->css->_find_level($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestFindPostCategory() {
|
||||||
|
return array(
|
||||||
|
array(array(1), array(1)),
|
||||||
|
array(array(1,2), array())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindPostCategory
|
||||||
|
*/
|
||||||
|
function testFindPostCategory($post_categories, $expected_return) {
|
||||||
|
$this->css->_structure = array(
|
||||||
|
'1' => array('next' => 2, 'level' => 1),
|
||||||
|
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3, 'level' => 2),
|
||||||
|
'3' => array('parent' => 2, 'next' => 4, 'previous' => 2, 'level' => 3),
|
||||||
|
'4' => array('parent' => 2, 'previous' => 3, 'level' => 3)
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_set_post_categories(1, $post_categories);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_return, $this->css->_find_post_category(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestFindAdjacentCategory() {
|
||||||
|
return array(
|
||||||
|
array(3, false, array(2)),
|
||||||
|
array(3, true, array(4)),
|
||||||
|
array(1, false, array()),
|
||||||
|
array(4, true, array()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindAdjacentCategory
|
||||||
|
*/
|
||||||
|
function testFindAdjacentCategory($category, $which, $expected_return) {
|
||||||
|
$this->css->_structure = array(
|
||||||
|
'1' => array('next' => 2, 'level' => 1),
|
||||||
|
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3, 'level' => 2),
|
||||||
|
'3' => array('parent' => 2, 'next' => 4, 'previous' => 2, 'level' => 3),
|
||||||
|
'4' => array('parent' => 2, 'previous' => 3, 'level' => 3)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_return, $this->css->_find_adjacent($category, $which));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestFindPostRoot() {
|
||||||
|
return array(
|
||||||
|
array(array(1), array(1,2,3,4)),
|
||||||
|
array(array(4), array(1,2,3,4)),
|
||||||
|
array(array(5), array(5)),
|
||||||
|
array(array(1, 5), array()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFindPostRoot
|
||||||
|
*/
|
||||||
|
function testFindPostRoot($post_categories, $expected_return) {
|
||||||
|
$this->css->_structure = array(
|
||||||
|
'1' => array('next' => 2, 'level' => 1, 'parent' => 0),
|
||||||
|
'2' => array('parent' => 1, 'previous' => 1, 'next' => 3, 'level' => 2),
|
||||||
|
'3' => array('parent' => 2, 'next' => 4, 'previous' => 2, 'level' => 3),
|
||||||
|
'4' => array('parent' => 2, 'previous' => 3, 'next' => 5, 'level' => 3),
|
||||||
|
'5' => array('parent' => 0, 'previous' => 4, 'level' => 1),
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_set_post_categories(1, $post_categories);
|
||||||
|
wp_insert_post(array('ID' => 1));
|
||||||
|
|
||||||
|
add_category(1, (object)array('slug' => 'root', 'parent' => 0));
|
||||||
|
add_category(2, (object)array('slug' => 'comic', 'parent' => 1));
|
||||||
|
add_category(3, (object)array('slug' => 'part-1', 'parent' => 2));
|
||||||
|
add_category(4, (object)array('slug' => 'blog', 'parent' => 1));
|
||||||
|
add_category(5, (object)array('slug' => 'blog', 'parent' => 0));
|
||||||
|
|
||||||
|
$this->assertEquals($expected_return, $this->css->_find_post_root(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestBuildFromRestrictions() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
null,
|
||||||
|
array(1,2,3,4,5,6,7)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(),
|
||||||
|
array(1,2,3,4,5,6,7)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('child_of' => 1),
|
||||||
|
array(1,2,3)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('only' => 1),
|
||||||
|
array(1)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('child_of' => 1, 'only' => 7),
|
||||||
|
array(1,2,3,7)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('level' => 1),
|
||||||
|
array(1,4,7)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('from_post' => 1),
|
||||||
|
array(3)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('previous' => 3),
|
||||||
|
array(2)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('next' => 3),
|
||||||
|
array(4)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestBuildFromRestrictions
|
||||||
|
*/
|
||||||
|
function testBuildFromRestrictions($restrictions, $expected_categories) {
|
||||||
|
global $post;
|
||||||
|
|
||||||
|
$this->css->set_flattened_storyline('0/1,0/1/2,0/1/3,0/4,0/4/5,0/4/6,0/7');
|
||||||
|
|
||||||
|
wp_set_post_categories(1, array(3));
|
||||||
|
$post = (object)array('ID' => 1);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_categories, $this->css->build_from_restrictions($restrictions));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestAllAdjacent() {
|
||||||
|
return array(
|
||||||
|
array(3, 'previous', array(2, 1)),
|
||||||
|
array(2, 'next', array(3, 4)),
|
||||||
|
array(4, 'next', array()),
|
||||||
|
array(5, 'next', false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestAllAdjacent
|
||||||
|
*/
|
||||||
|
function testAllAdjacent($start, $direction, $expected_result) {
|
||||||
|
$this->css->_structure = array(
|
||||||
|
'1' => array('next' => 2),
|
||||||
|
'2' => array('previous' => 1, 'parent' => 1, 'next' => 3),
|
||||||
|
'3' => array('previous' => 2, 'parent' => 1, 'next' => 4),
|
||||||
|
'4' => array('previous' => 3, 'parent' => 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_result, $this->css->all_adjacent($start, $direction));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -2,140 +2,126 @@
|
||||||
|
|
||||||
require_once('PHPUnit/Framework.php');
|
require_once('PHPUnit/Framework.php');
|
||||||
require_once('MockPress/mockpress.php');
|
require_once('MockPress/mockpress.php');
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPress.inc');
|
require_once('ComicPress.inc');
|
||||||
|
require_once('vfsStream/vfsStream.php');
|
||||||
|
|
||||||
class ComicPressTest extends PHPUnit_Framework_TestCase {
|
class ComicPressTest extends PHPUnit_Framework_TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
global $post;
|
|
||||||
|
|
||||||
_reset_wp();
|
_reset_wp();
|
||||||
unset($post);
|
|
||||||
$this->cp = new ComicPress();
|
$this->cp = new ComicPress();
|
||||||
|
|
||||||
|
vfsStreamWrapper::register();
|
||||||
|
vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestGetLayoutChoices() {
|
function providerTestCategorySearch() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
array(),
|
array('comic'), array(vfsStream::url('root/style/comic'))
|
||||||
array()
|
),
|
||||||
),
|
array(
|
||||||
array(
|
array('chapter-1', 'comic'), array(vfsStream::url('root/style/comic'), vfsStream::url('root/style/comic/chapter-1'))
|
||||||
array(
|
),
|
||||||
'layout.php' => <<<FILE
|
array(
|
||||||
Test
|
array('part-1', 'chapter-1', 'comic'), array(vfsStream::url('root/style/comic'), vfsStream::url('root/style/comic/chapter-1'), vfsStream::url('root/style/comic/chapter-1/part-1'))
|
||||||
FILE
|
),
|
||||||
),
|
array(
|
||||||
array()
|
array('comic', 'chapter-1'), array()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array(
|
array(), array()
|
||||||
'layout.php' => <<<FILE
|
)
|
||||||
/*
|
);
|
||||||
Layout Name: Test
|
|
||||||
Sidebars: left,right
|
|
||||||
*/
|
|
||||||
FILE
|
|
||||||
),
|
|
||||||
array('layout.php' => array(
|
|
||||||
'Layout Name' => 'Test',
|
|
||||||
'Sidebars' => 'left,right',
|
|
||||||
))
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestGetLayoutChoices
|
* @dataProvider providerTestCategorySearch
|
||||||
*/
|
*/
|
||||||
function testGetLayoutChoices($files, $expected_results) {
|
function testCategorySearch($categories, $found_path) {
|
||||||
$cp = $this->getMock('ComicPress', array('_glob', '_file_get_contents'));
|
mkdir(vfsStream::url('root/style/comic/chapter-1/part-1'), 0777, true);
|
||||||
|
|
||||||
_set_template_directory('/test');
|
$this->assertEquals($found_path, $this->cp->category_search($categories, vfsStream::url('root/style')));
|
||||||
|
|
||||||
$file_names = array();
|
|
||||||
foreach (array_keys($files) as $file) { $file_names[] = '/test/layouts/' . $file; }
|
|
||||||
|
|
||||||
$cp->expects($this->once())->method('_glob')->with('/test/layouts/*')->will($this->returnValue($file_names));
|
|
||||||
foreach ($files as $file => $contents) {
|
|
||||||
$cp->expects($this->once())->method('_file_get_contents')->with('/test/layouts/' . $file)->will($this->returnValue($contents));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($expected_results, $cp->get_layout_choices());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestGetSortedPostCategories() {
|
function providerTestFindFile() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
array(1),
|
array(), 'partials', array(), false,
|
||||||
array('0/1'),
|
),
|
||||||
array(1)
|
array(
|
||||||
),
|
array('root/parent/partials/index.inc'),
|
||||||
array(
|
'partials',
|
||||||
array(2, 1),
|
array(),
|
||||||
array('0/1', '0/1/2'),
|
vfsStream::url('root/parent/partials/index.inc')
|
||||||
array(1, 2)
|
),
|
||||||
),
|
array(
|
||||||
array(
|
array('root/parent/index.inc'),
|
||||||
array(2, 1),
|
'',
|
||||||
array('0/1', '0/1/3', '0/1/2'),
|
array(),
|
||||||
array(1, 2)
|
vfsStream::url('root/parent/index.inc')
|
||||||
),
|
),
|
||||||
);
|
array(
|
||||||
|
array(
|
||||||
|
'root/parent/partials/index.inc',
|
||||||
|
'root/child/partials/index.inc'
|
||||||
|
),
|
||||||
|
'partials',
|
||||||
|
array(),
|
||||||
|
vfsStream::url('root/child/partials/index.inc')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'root/child/partials/index.inc',
|
||||||
|
'root/child/partials/comic/index.inc'
|
||||||
|
),
|
||||||
|
'partials',
|
||||||
|
array('comic'),
|
||||||
|
vfsStream::url('root/child/partials/comic/index.inc')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'root/child/partials/index.inc',
|
||||||
|
'root/child/partials/comic/index.inc'
|
||||||
|
),
|
||||||
|
'partials',
|
||||||
|
array('chapter-1', 'comic'),
|
||||||
|
vfsStream::url('root/child/partials/comic/index.inc')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'root/child/partials/index.inc',
|
||||||
|
'root/child/partials/comic/index.inc'
|
||||||
|
),
|
||||||
|
'partials',
|
||||||
|
null,
|
||||||
|
vfsStream::url('root/child/partials/comic/index.inc')
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestGetSortedPostCategories
|
* @dataProvider providerTestFindFile
|
||||||
*/
|
*/
|
||||||
function testGetSortedPostCategories($post_categories, $category_tree, $expected_sort_order) {
|
function testFindFile($files_to_setup, $search_path, $post_categories, $expected_path_result) {
|
||||||
$this->cp->category_tree = $category_tree;
|
global $post;
|
||||||
|
|
||||||
wp_set_post_categories(1, $post_categories);
|
mkdir(vfsStream::url('root/parent/partials/comic/chapter-1'), 0777, true);
|
||||||
|
mkdir(vfsStream::url('root/child/partials/comic/chapter-1'), 0777, true);
|
||||||
|
|
||||||
$this->assertEquals($expected_sort_order, $this->cp->get_sorted_post_categories((object)array('ID' => 1)));
|
foreach ($files_to_setup as $path) {
|
||||||
}
|
file_put_contents(vfsStream::url($path), "test");
|
||||||
|
}
|
||||||
|
|
||||||
function testSetupMulticomicPartialPaths() {
|
_set_template_directory(vfsStream::url('root/parent'));
|
||||||
$cp = $this->getMock('ComicPress', array('_is_dir'));
|
_set_stylesheet_directory(vfsStream::url('root/child'));
|
||||||
|
|
||||||
wp_set_post_categories(1, array('2', '3'));
|
$post = (object)array('ID' => 1);
|
||||||
|
wp_set_post_categories(1, array(2));
|
||||||
|
|
||||||
add_category('2', (object)array('slug' => 'test-one'));
|
add_category(1, (object)array('slug' => 'comic', 'parent' => 0));
|
||||||
add_category('3', (object)array('slug' => 'test-two'));
|
add_category(2, (object)array('slug' => 'chapter-1', 'parent' => 1));
|
||||||
|
|
||||||
$cp->expects($this->at(0))->method('_is_dir')->with('/subthemes/test-one')->will($this->returnValue(true));
|
$this->assertEquals($expected_path_result, $this->cp->find_file('index.inc', $search_path, $post_categories));
|
||||||
$cp->expects($this->at(1))->method('_is_dir')->with('/subthemes/test-two')->will($this->returnValue(false));
|
|
||||||
|
|
||||||
$cp->setup_multicomic_partial_paths(1);
|
|
||||||
|
|
||||||
$this->assertEquals(array('/subthemes/test-one'), $cp->partial_paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
function providerTestGetOverridePartials() {
|
|
||||||
return array(
|
|
||||||
array(
|
|
||||||
array('partials'),
|
|
||||||
array('index'),
|
|
||||||
array('partials/index'),
|
|
||||||
array('partials/index', true)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array('partials'),
|
|
||||||
array('index'),
|
|
||||||
array('partials/single'),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider providerTestGetOverridePartials
|
|
||||||
*/
|
|
||||||
function testGetOverridePartials($partial_paths, $requested_partials, $override_partials, $expected_result) {
|
|
||||||
$this->cp->partial_paths = $partial_paths;
|
|
||||||
foreach ($override_partials as $partial) {
|
|
||||||
$this->cp->comicpress_options['override_partials'][$partial] = true;
|
|
||||||
}
|
|
||||||
$this->assertEquals($expected_result, $this->cp->get_options_partial($requested_partials));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('PHPUnit/Framework.php');
|
||||||
|
require_once('MockPress/mockpress.php');
|
||||||
|
require_once('backends/ComicPressBackendAttachment.inc');
|
||||||
|
|
||||||
|
class ComicPressBackendAttachmentTest extends PHPUnit_Framework_TestCase {
|
||||||
|
function setUp() {
|
||||||
|
_reset_wp();
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestGenerateFromPost() {
|
||||||
|
return array(
|
||||||
|
array(array(), false),
|
||||||
|
array(array((object)array('ID' => 1)), array('attachment-1'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestGenerateFromPost
|
||||||
|
*/
|
||||||
|
function testGenerateFromPost($get_children_response, $expected_ids) {
|
||||||
|
_set_get_children(array(
|
||||||
|
'post_parent' => 1,
|
||||||
|
'post_type' => 'attachment',
|
||||||
|
'post_mime_type' => 'image'
|
||||||
|
), $get_children_response);
|
||||||
|
|
||||||
|
$results = ComicPressBackendAttachment::generate_from_post((object)array('ID' => 1));
|
||||||
|
if ($expected_ids === false) {
|
||||||
|
$this->assertTrue(empty($results));
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(count($expected_ids), count($results));
|
||||||
|
foreach ($results as $result) {
|
||||||
|
$this->assertTrue(in_array($result->id, $expected_ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
set_include_path(realpath(dirname(__FILE__) . '/../classes') . PATH_SEPARATOR . get_include_path());
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue