gut more of admin

This commit is contained in:
John Bintz 2009-11-07 17:52:21 -05:00
parent 62603a4982
commit 57ef1784d6

View File

@ -7,40 +7,34 @@ require_once(dirname(__FILE__) . '/ComicPressComicPost.inc');
*/ */
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' => ''
); );
var $additional_stylesheets = array(); var $additional_stylesheets = array();
var $additional_javascripts = array(); var $additional_javascripts = array();
var $comic_post_attachments_cache = array(); var $comic_post_attachments_cache = array();
var $category_tree = array(); var $category_tree = array();
var $partial_paths = array(); var $partial_paths = array();
var $layouts = null; var $layouts = null;
function &get_instance() { function &get_instance() {
static $instance; static $instance;
if (!$instance) { if (!$instance) {
$instance = array(new ComicPress()); $instance = array(new ComicPress());
} }
return $instance[0]; return $instance[0];
} }
/** /**
* Load ComicPress options. * Load ComicPress options.
*/ */
@ -50,7 +44,7 @@ class ComicPress {
$this->comicpress_options = array_merge($this->comicpress_options, $result); $this->comicpress_options = array_merge($this->comicpress_options, $result);
} }
} }
/** /**
* Save ComicPress options. * Save ComicPress options.
*/ */
@ -65,15 +59,15 @@ class ComicPress {
*/ */
function init() { function init() {
$this->load(); $this->load();
if (current_user_can('edit_themes')) { if (current_user_can('edit_themes')) {
if (!empty($this->comicpress_options['helpers'])) { if (!empty($this->comicpress_options['helpers'])) {
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'));
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"]);
update_option("${size}_size_w", $w); update_option("${size}_size_w", $w);
@ -85,32 +79,32 @@ class ComicPress {
function intermediate_image_sizes($sizes) { function intermediate_image_sizes($sizes) {
return array_merge($sizes, array('comic', 'rss', 'archive', 'mini')); return array_merge($sizes, array('comic', 'rss', 'archive', 'mini'));
} }
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>";
} }
/** /**
* Gather blog posts for the given index page. * Gather blog posts for the given index page.
*/ */
function get_index_blog_posts_query() { function get_index_blog_posts_query() {
global $post, $paged; global $post, $paged;
$t = $post; $t = $post;
$wp_query = new WP_Query(); $wp_query = new WP_Query();
$wp_query->query( $wp_query->query(
'showposts=' . 'showposts=' .
(int)$this->comicpress_options['blogpost_count'] . (int)$this->comicpress_options['blogpost_count'] .
'&cat=-' . '&cat=-' .
$this->comicpress_options['comic_category_id'] . $this->comicpress_options['comic_category_id'] .
'&paged=' . '&paged=' .
$paged $paged
); );
return $wp_query; return $wp_query;
} }
/** /**
* Search a path for directories named after the slugs provided. * Search a path for directories named after the slugs provided.
* @param array $categories A list of category slugs going from child -> parent -> root. * @param array $categories A list of category slugs going from child -> parent -> root.
@ -128,7 +122,7 @@ class ComicPress {
} }
return array_reverse($all_paths); return array_reverse($all_paths);
} }
/** /**
* Recursively search a particular template directory for a specified file, limiting the search to the provided categories. * Recursively search a particular template directory for a specified file, limiting the search to the provided categories.
* @param string $name The name of the file with no path information. * @param string $name The name of the file with no path information.
@ -142,12 +136,12 @@ class ComicPress {
$comic_post = new ComicPressComicPost($post); $comic_post = new ComicPressComicPost($post);
$categories = $comic_post->find_parents(); $categories = $comic_post->find_parents();
} }
foreach (array(get_stylesheet_directory(), get_template_directory()) as $dir) { foreach (array(get_stylesheet_directory(), get_template_directory()) as $dir) {
$dir = trailingslashit($dir) . $path; $dir = trailingslashit($dir) . $path;
$dirs_to_search = $this->category_search($categories, $dir); $dirs_to_search = $this->category_search($categories, $dir);
$dirs_to_search[] = $dir; $dirs_to_search[] = $dir;
foreach ($dirs_to_search as $category_path) { foreach ($dirs_to_search as $category_path) {
$target = trailingslashit($category_path) . $name; $target = trailingslashit($category_path) . $name;
if (file_exists($target)) { if (file_exists($target)) {