Merge branch 'master' of git@github.com:johnbintz/comicpress-theme-core
This commit is contained in:
commit
3543e14aea
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ComicPressAddonBookmarkWidget extends ComicPressAddon {
|
||||
var $name = "Bookmark Widget";
|
||||
|
||||
function init($comicpress) {
|
||||
wp_register_sidebar_widget('comic-bookmark', __('Comic Bookmark', 'comicpress'), array(&$this, 'render_widget'), array('description' => __('Let your readers save their place via a cookie.', 'comicpress')));
|
||||
|
||||
@ -8,31 +10,25 @@ class ComicPressAddonBookmarkWidget extends ComicPressAddon {
|
||||
|
||||
add_action('wp_head', array(&$this, 'wp_head'));
|
||||
$this->comicpress->additional_javascripts[] = '/js/bookmark.js';
|
||||
|
||||
wp_enqueue_script('prototype');
|
||||
wp_enqueue_script('cookiejar', get_template_directory_uri() . '/js/cookiejar.js', array('prototype'));
|
||||
wp_enqueue_script('bookmark', get_template_directory_uri() . '/js/bookmark.js', array('prototype', 'cookiejar'));
|
||||
}
|
||||
|
||||
function wp_head() {
|
||||
$last_comic = $this->comicpress->get_last_comic(); ?>
|
||||
<script type="text/javascript">
|
||||
var imgTag = '<?php bloginfo('template_directory'); ?>/images/1.gif'; //add tag image.
|
||||
var imgClearOff = '<?php bloginfo('template_directory'); ?>/images/3a.gif'; //no comic tagged, clear not possible
|
||||
var imgGotoOff = '<?php bloginfo('template_directory'); ?>/images/2a.gif'; //no comic tagged, goto not possible
|
||||
var imgClearOn = '<?php bloginfo('template_directory'); ?>/images/3.gif'; //clear a tag, shows when comic previously tagged
|
||||
var imgGotoOn = '<?php bloginfo('template_directory'); ?>/images/2.gif'; //shows when a comic is tagged
|
||||
var imgInfo = '<?php bloginfo('template_directory'); ?>/images/4.gif'; //img that displays the help
|
||||
var comicDir = '/'; //alter this if you run multiple comics in different directories on your site.
|
||||
|
||||
var comicPermalink = '<?php echo get_permalink($last_comic->ID) ?>';
|
||||
|
||||
var isHome = <?php echo is_home() ? "true" : "false" ?>;
|
||||
var isSingle = <?php echo (is_single() && $this->comicpress->in_comic_category()) ? "true" : "false" ?>;
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
function wp_head() { ?>
|
||||
<script type="text/javascript">
|
||||
var image_root = '<?php bloginfo('template_directory'); ?>/images/';
|
||||
var permalink = '<?php the_permalink() ?>';
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
function render_widget() {
|
||||
?>
|
||||
<div class="comic-bookmark">
|
||||
<script type="text/javascript">writeBookmarkWidget()</script>
|
||||
<div id="comic-bookmark-holder">
|
||||
<a href="#" class="tag-page"><img src="<?php bloginfo('template_directory'); ?>/images/1.gif" /></a>
|
||||
<a href="#" class="goto-tag"><img /></a>
|
||||
<a href="#" class="clear-tag"><img /></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
class ComicPressAddonCore extends ComicPressAddon {
|
||||
class ComicPressAddonCore extends ComicPressAddon {
|
||||
var $is_addon_manager = true;
|
||||
var $cannot_be_disabled = true;
|
||||
var $name = "ComicPress Core";
|
||||
|
||||
/**
|
||||
* Initialize the addon.
|
||||
* @param ComicPress $comicpress The master ComicPress object.
|
||||
@ -504,7 +508,9 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||
* Update ComicPress options.
|
||||
*/
|
||||
function handle_update_comicpress_options() {
|
||||
$this->comicpress->comicpress_options['helpers'] = array();
|
||||
foreach (array('helpers', 'options') as $type) {
|
||||
$this->comicpress->comicpress_options[$type] = array();
|
||||
}
|
||||
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
||||
if (isset($_POST['cp'][$option])) {
|
||||
switch ($option) {
|
||||
@ -550,8 +556,9 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
||||
break;
|
||||
case 'helpers':
|
||||
foreach ($_POST['cp'][$option] as $helper => $set) {
|
||||
$this->comicpress->comicpress_options['helpers'][$helper] = true;
|
||||
case 'addons':
|
||||
foreach ($_POST['cp'][$option] as $type => $set) {
|
||||
$this->comicpress->comicpress_options[$option][$type] = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -575,7 +582,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||
function handle_update_override_partial($info) {
|
||||
switch ($info['action']) {
|
||||
case __('Update partial', 'comicpress'):
|
||||
$this->comicpress->comicpress_options['override_partials'][$info['partial']] = $info['code'];
|
||||
$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']]);
|
||||
@ -643,4 +650,4 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -69,7 +69,7 @@
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
<p><em>(categories can be modified on the Posts -> Categories page)</em></p>
|
||||
<p><em><?php _e('(categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -98,20 +98,51 @@
|
||||
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
||||
<table class="widefat fixed">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
Enable editing helpers
|
||||
</th>
|
||||
<th scope="row"><?php _e('Enable editing helpers', 'comicpress') ?></th>
|
||||
<td>
|
||||
<?php
|
||||
foreach (array(
|
||||
"show_partials_info" => __('Show partials info', 'comicpress'),
|
||||
"show_inline_comic_ordering" => __('Show inline comic ordering', 'comicpress')
|
||||
) as $key => $label) { ?>
|
||||
<label><input type="checkbox" name="cp[helpers][<?php echo $key ?>]" value="yes" <?php echo (($this->comicpress->comicpress_options['helpers'][$key] === true) ? 'checked="checked"' : '') ?> /> <?php echo $label ?></label><br />
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
name="cp[helpers][<?php echo $key ?>]"
|
||||
value="yes"
|
||||
<?php echo (($this->comicpress->comicpress_options['helpers'][$key] === true) ? 'checked="checked"' : '') ?> />
|
||||
<?php echo $label ?>
|
||||
</label>
|
||||
<br />
|
||||
<?php }
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if (is_array($this->all_addons)) { ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Enable addons', 'comicpress') ?></th>
|
||||
<td>
|
||||
<?php
|
||||
foreach ($this->all_addons as $addon) {
|
||||
if (!empty($addon->name)) {
|
||||
$enabled = ($addon->is_addon_manager !== true);
|
||||
$checked = $enabled && $this->comicpress->comicpress_options['addons'][$addon->name];
|
||||
?>
|
||||
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
name="cp[addons][<?php echo $addon->name ?>]"
|
||||
value="yes"
|
||||
<?php echo !$enabled ? 'disabled="disabled"' : '' ?>
|
||||
<?php echo $checked ? 'checked="checked"' : '' ?> />
|
||||
<?php echo $addon->name ?>
|
||||
</label><br />
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /> </form>
|
||||
<input class="button" type="submit" value="<?php _e('Submit Changes', 'comicpress') ?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
class ComicPressAddonSearchTranscripts extends ComicPressAddon {
|
||||
var $custom_template_default = 'search-transcript.php';
|
||||
var $name = "Search Transcripts";
|
||||
|
||||
function init($comicpress) {
|
||||
add_filter('posts_join', array(&$this, 'search_custom_join'));
|
||||
|
@ -16,7 +16,8 @@ class ComicPress {
|
||||
'category_usage' => 'storyline',
|
||||
'layout' => 'classic.inc',
|
||||
'helpers' => array(),
|
||||
'override_partials' => array()
|
||||
'override_partials' => array(),
|
||||
'addons' => array()
|
||||
);
|
||||
|
||||
var $additional_stylesheets = array();
|
||||
|
@ -170,10 +170,16 @@ class ComicPressComicPost {
|
||||
usort($remaining_posts_to_sort[$type], array(&$this, 'sort_remaining_comic_images'));
|
||||
}
|
||||
|
||||
$result = array_merge($comic_image_ordering, $remaining_posts_to_sort);
|
||||
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', $this->build_comic_ordering_string($result));
|
||||
return $result;
|
||||
update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($comic_image_ordering));
|
||||
return $comic_image_ordering;
|
||||
}
|
||||
}
|
||||
|
||||
|
465
functions.php
465
functions.php
@ -1,236 +1,239 @@
|
||||
<?php
|
||||
|
||||
// load all of the comic & non-comic category information
|
||||
add_action('init', '__comicpress_init');
|
||||
|
||||
function __comicpress_init() {
|
||||
global $comicpress, $wp_query;
|
||||
|
||||
if (current_user_can('edit_files')) {
|
||||
wp_cache_flush();
|
||||
}
|
||||
|
||||
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
|
||||
if (is_file($file)) { require_once($file); }
|
||||
}
|
||||
|
||||
$comicpress = new ComicPress();
|
||||
$comicpress->init();
|
||||
<?php
|
||||
|
||||
// load all of the comic & non-comic category information
|
||||
add_action('init', '__comicpress_init');
|
||||
|
||||
function __comicpress_init() {
|
||||
global $comicpress, $wp_query;
|
||||
|
||||
if (current_user_can('edit_files')) {
|
||||
wp_cache_flush();
|
||||
}
|
||||
|
||||
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
|
||||
if (is_file($file)) { require_once($file); }
|
||||
}
|
||||
|
||||
$comicpress = new ComicPress();
|
||||
$comicpress->init();
|
||||
$addons = array();
|
||||
|
||||
if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) {
|
||||
$entries = glob($addons_dir . '/*');
|
||||
if (is_array($entries)) {
|
||||
foreach ($entries as $entry) {
|
||||
if (is_dir($entry)) {
|
||||
$classname = basename($entry);
|
||||
if (file_exists($entry . "/${classname}.inc")) {
|
||||
require_once($entry . "/${classname}.inc");
|
||||
$classname = "ComicPressAddon${classname}";
|
||||
if (class_exists($classname)) {
|
||||
$addon =& new $classname();
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$_POST = stripslashes_deep($_POST);
|
||||
$_GET = stripslashes_deep($_GET);
|
||||
$_REQUEST = stripslashes_deep($_REQUEST);
|
||||
}
|
||||
|
||||
if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) {
|
||||
$entries = glob($addons_dir . '/*');
|
||||
if (is_array($entries)) {
|
||||
foreach ($entries as $entry) {
|
||||
if (is_dir($entry)) {
|
||||
$classname = basename($entry);
|
||||
if (file_exists($entry . "/${classname}.inc")) {
|
||||
require_once($entry . "/${classname}.inc");
|
||||
$classname = "ComicPressAddon${classname}";
|
||||
if (class_exists($classname)) {
|
||||
$addon =& new $classname();
|
||||
|
||||
$addon->init(&$comicpress);
|
||||
if (current_user_can('edit_posts')) {
|
||||
if (is_array($_REQUEST['cp'])) {
|
||||
if (isset($_REQUEST['cp']['_nonce'])) {
|
||||
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
|
||||
if (method_exists($addon, 'handle_update')) {
|
||||
$addon->handle_update();
|
||||
$comicpress->load();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (
|
||||
$comicpress->comicpress_options['addons'][$addon->name] ||
|
||||
$addon->is_addon_manager
|
||||
) {
|
||||
$addon->init(&$comicpress);
|
||||
if (current_user_can('edit_posts')) {
|
||||
if (is_array($_REQUEST['cp'])) {
|
||||
if (isset($_REQUEST['cp']['_nonce'])) {
|
||||
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
|
||||
if (method_exists($addon, 'handle_update')) {
|
||||
$addon->handle_update();
|
||||
$comicpress->load();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_admin()) {
|
||||
add_action('admin_notices', array(&$addon, 'display_messages'));
|
||||
} else {
|
||||
add_action('wp_head', array(&$addon, 'display_messages'));
|
||||
}
|
||||
}
|
||||
if (is_admin()) {
|
||||
add_action('admin_notices', array(&$addon, 'display_messages'));
|
||||
} else {
|
||||
add_action('wp_head', array(&$addon, 'display_messages'));
|
||||
}
|
||||
}
|
||||
$addons[] = $addon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$addons[] = $addon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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() {
|
||||
global $post, $comicpress;
|
||||
|
||||
if (!empty($post)) {
|
||||
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
|
||||
$comicpress->setup_multicomic_partial_paths($post->ID);
|
||||
}
|
||||
}
|
||||
|
||||
$comicpress->partial_paths[] = get_template_directory() . '/partials';
|
||||
}
|
||||
|
||||
function comicpress_get_header() {
|
||||
get_header();
|
||||
}
|
||||
|
||||
function include_partial($partials = '') {
|
||||
global $comicpress, $post, $nav_comics;
|
||||
|
||||
if (!is_array($partials)) { $partials = func_get_args(); }
|
||||
|
||||
$content = $target = null;
|
||||
|
||||
if (($result = $comicpress->get_options_partial($partials)) !== false) {
|
||||
list($target, $code) = $result;
|
||||
ob_start(); eval('?>' . $code . '<?'); $content = ob_get_clean();
|
||||
} else {
|
||||
$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;
|
||||
|
||||
return $comicpress->in_comic_category($post->ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the list of Storyline categories.
|
||||
*/
|
||||
function comicpress_list_storyline_categories($args = "") {
|
||||
global $category_tree;
|
||||
|
||||
$defaults = array(
|
||||
'style' => 'list', 'title_li' => __('Storyline')
|
||||
);
|
||||
|
||||
$r = wp_parse_args($args, $defaults);
|
||||
|
||||
extract($r);
|
||||
|
||||
$categories_by_id = get_all_category_objects_by_id();
|
||||
|
||||
$output = '';
|
||||
if ($style == "list") { $output .= '<li class="categories storyline">'; }
|
||||
if ($title_li && ($style == "list")) { $output .= $title_li; }
|
||||
if ($style == "list") { $output .= "<ul>"; }
|
||||
$current_depth = 0;
|
||||
foreach ($category_tree as $node) {
|
||||
$parts = explode("/", $node);
|
||||
$category_id = end($parts);
|
||||
$target_depth = count($parts) - 2;
|
||||
if ($target_depth > $current_depth) {
|
||||
$output .= str_repeat("<li><ul>", ($target_depth - $current_depth));
|
||||
}
|
||||
if ($target_depth < $current_depth) {
|
||||
$output .= str_repeat("</ul></li>", ($current_depth - $target_depth));
|
||||
}
|
||||
$output .= '<li><a href="' . get_category_link($category_id) . '">';
|
||||
$output .= $categories_by_id[$category_id]->cat_name;
|
||||
$output .= "</a></li>";
|
||||
$current_depth = $target_depth;
|
||||
}
|
||||
if ($current_depth > 0) {
|
||||
$output .= str_repeat("</ul></li>", $current_depth);
|
||||
}
|
||||
if ($style == "list") { $output .= "</ul></li>"; }
|
||||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
?>
|
||||
foreach ($addons as $addon) {
|
||||
if ($addon->is_addon_manager) { $addon->all_addons =& $addons; break; }
|
||||
}
|
||||
|
||||
$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() {
|
||||
global $post, $comicpress;
|
||||
|
||||
if (!empty($post)) {
|
||||
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
|
||||
$comicpress->setup_multicomic_partial_paths($post->ID);
|
||||
}
|
||||
}
|
||||
|
||||
$comicpress->partial_paths[] = get_template_directory() . '/partials';
|
||||
}
|
||||
|
||||
function comicpress_get_header() {
|
||||
get_header();
|
||||
}
|
||||
|
||||
function include_partial($partials = '') {
|
||||
global $comicpress, $post, $nav_comics;
|
||||
|
||||
if (!is_array($partials)) { $partials = func_get_args(); }
|
||||
|
||||
$content = $target = null;
|
||||
|
||||
if (($result = $comicpress->get_options_partial($partials)) !== false) {
|
||||
list($target, $code) = $result;
|
||||
ob_start(); eval(' ?>' . $code . '<?php '); $content = ob_get_clean();
|
||||
} else {
|
||||
$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;
|
||||
|
||||
return $comicpress->in_comic_category($post->ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the list of Storyline categories.
|
||||
*/
|
||||
function comicpress_list_storyline_categories($args = "") {
|
||||
global $category_tree;
|
||||
|
||||
$defaults = array(
|
||||
'style' => 'list', 'title_li' => __('Storyline')
|
||||
);
|
||||
|
||||
$r = wp_parse_args($args, $defaults);
|
||||
|
||||
extract($r);
|
||||
|
||||
$categories_by_id = get_all_category_objects_by_id();
|
||||
|
||||
$output = '';
|
||||
if ($style == "list") { $output .= '<li class="categories storyline">'; }
|
||||
if ($title_li && ($style == "list")) { $output .= $title_li; }
|
||||
if ($style == "list") { $output .= "<ul>"; }
|
||||
$current_depth = 0;
|
||||
foreach ($category_tree as $node) {
|
||||
$parts = explode("/", $node);
|
||||
$category_id = end($parts);
|
||||
$target_depth = count($parts) - 2;
|
||||
if ($target_depth > $current_depth) {
|
||||
$output .= str_repeat("<li><ul>", ($target_depth - $current_depth));
|
||||
}
|
||||
if ($target_depth < $current_depth) {
|
||||
$output .= str_repeat("</ul></li>", ($current_depth - $target_depth));
|
||||
}
|
||||
$output .= '<li><a href="' . get_category_link($category_id) . '">';
|
||||
$output .= $categories_by_id[$category_id]->cat_name;
|
||||
$output .= "</a></li>";
|
||||
$current_depth = $target_depth;
|
||||
}
|
||||
if ($current_depth > 0) {
|
||||
$output .= str_repeat("</ul></li>", $current_depth);
|
||||
}
|
||||
if ($style == "list") { $output .= "</ul></li>"; }
|
||||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
?>
|
||||
|
139
js/bookmark.js
139
js/bookmark.js
@ -1,81 +1,70 @@
|
||||
var cl = 31;
|
||||
|
||||
/* Below are our functions for this little script */
|
||||
|
||||
function bmhome() {
|
||||
if(document.getElementById) {
|
||||
document.getElementById('gtc').src = imgGotoOn;
|
||||
document.getElementById('rmc').src = imgClearOn;
|
||||
var button_images = {
|
||||
'clear-tag': {
|
||||
'off': '3a.gif', 'on': '3.gif'
|
||||
},
|
||||
'goto-tag': {
|
||||
'off': '2a.gif', 'on': '2.gif'
|
||||
}
|
||||
createCookie("bm", comicPermalink, cl);
|
||||
}
|
||||
};
|
||||
|
||||
function bm() {
|
||||
if(document.getElementById) {
|
||||
document.getElementById('gtc').src = imgGotoOn;
|
||||
document.getElementById('rmc').src = imgClearOn;
|
||||
}
|
||||
createCookie("bm", window.location, cl);
|
||||
}
|
||||
var BookmarkInfo = Class.create({
|
||||
'default': {
|
||||
'permalink': false
|
||||
},
|
||||
'initialize': function() {
|
||||
this.jar = new CookieJar({
|
||||
'expires': 60 * 60 * 24 * 31,
|
||||
'path': '/'
|
||||
});
|
||||
},
|
||||
'read': function() {
|
||||
var bookmark_info = this.jar.get('bookmark-info');
|
||||
|
||||
function bmc() {
|
||||
if(document.getElementById) {
|
||||
document.getElementById('gtc').src = imgGotoOff;
|
||||
document.getElementById('rmc').src = imgClearOff;
|
||||
if ((typeof(bookmark_info) != 'object') || (bookmark_info == null)) {
|
||||
bookmark_info = this.default;
|
||||
}
|
||||
|
||||
return bookmark_info;
|
||||
},
|
||||
'write': function(bookmark_info) {
|
||||
this.jar.put('bookmark-info', bookmark_info);
|
||||
if (this.onWrite) { this.onWrite(bookmark_info); }
|
||||
}
|
||||
createCookie("bm","",-1);
|
||||
}
|
||||
});
|
||||
|
||||
Event.observe(window, 'load', function() {
|
||||
var bookmark_info = new BookmarkInfo();
|
||||
var info = bookmark_info.read();
|
||||
|
||||
function gto() {
|
||||
var g = readCookie('bm');
|
||||
if(g) {
|
||||
window.location = g;
|
||||
}
|
||||
}
|
||||
var hrefs = {};
|
||||
$$('#comic-bookmark-holder a').each(function(a) {
|
||||
var name = $w(a.className).shift();
|
||||
hrefs[name] = a;
|
||||
});
|
||||
|
||||
var set_goto_tag = function(i) {
|
||||
hrefs['goto-tag'].href = (i.permalink ? i.permalink : "#");
|
||||
[ 'goto-tag','clear-tag' ].each(function(which) {
|
||||
hrefs[which].select('img')[0].src = image_root + button_images[which][i.permalink ? "on" : "off"];
|
||||
});
|
||||
};
|
||||
|
||||
bookmark_info.onWrite = function(i) { set_goto_tag(i); }
|
||||
set_goto_tag(info);
|
||||
|
||||
/* The follow functions have been borrowed from Peter-Paul Koch. Please find them here: http://www.quirksmode.org */
|
||||
|
||||
function createCookie(name,value,days) {
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||
var expires = "; expires="+date.toGMTString();
|
||||
} else var expires = "";
|
||||
document.cookie = name+"="+value+expires+"; path="+comicDir;
|
||||
}
|
||||
function readCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function writeBookmarkWidget() {
|
||||
createCookie('t', 1);
|
||||
var c = readCookie('t');
|
||||
if (c && document.getElementById) {
|
||||
var l = readCookie('bm');
|
||||
var gt = imgGotoOff;
|
||||
var ct = imgClearOff;
|
||||
if (l) {
|
||||
gt = imgGotoOn;
|
||||
ct = imgClearOn;
|
||||
}
|
||||
document.write('<div id="bmh" style="width: 173px; margin: 15px 0 0 0; padding: 5px; position: absolute; color: #eee; font-size: 11px; background-color:#222; border: 1px solid #ccc; visibility: hidden;"><b>COMIC BOOKMARK</b><br />Click "Tag Page" to bookmark a comic page. When you return to the site, click "Goto Tag" to continue where you left off.</div>');
|
||||
if (isHome) {
|
||||
document.write('<a href="#" onClick="bmhome();return false;"><img src="'+imgTag+'" alt="Tag This Page" border="0"></a>');
|
||||
document.write('<a href="#" onClick="gto();return false;"><img src="'+gt+'" alt="Goto Tag" border="0" id="gtc"></a>');
|
||||
document.write('<a href="#" onClick="bmc();return false;"><img src="'+ct+'" alt="Clear Tag" border="0" id="rmc"></a>');
|
||||
document.write('<a href="#" onMouseOver="document.getElementById(\'bmh\').style.visibility=\'visible\';" onMouseOut="document.getElementById(\'bmh\').style.visibility=\'hidden\';" onClick="return false;"><img src="'+imgInfo+'" alt="" border="0"></a>');
|
||||
} else if (isSingle) {
|
||||
document.write('<a href="#" onClick="bm();return false;"><img src="'+imgTag+'" alt="Tag This Page" border="0"></a>');
|
||||
document.write('<a href="#" onClick="gto();return false;"><img src="'+gt+'" alt="Goto Tag" border="0" id="gtc"></a>');
|
||||
document.write('<a href="#" onClick="bmc();return false;"><img src="'+ct+'" alt="Clear Tag" border="0" id="rmc"></a>');
|
||||
document.write('<a href="#" onMouseOver="document.getElementById(\'bmh\').style.visibility=\'visible\';" onMouseOut="document.getElementById(\'bmh\').style.visibility=\'hidden\';" onClick="return false;"><img src="'+imgInfo+'" alt="" border="0"></a>');
|
||||
}
|
||||
}
|
||||
}
|
||||
Event.observe(hrefs['tag-page'], 'click', function(e) {
|
||||
Event.stop(e);
|
||||
info.permalink = permalink;
|
||||
bookmark_info.write(info);
|
||||
});
|
||||
|
||||
Event.observe(hrefs['clear-tag'], 'click', function(e) {
|
||||
Event.stop(e);
|
||||
info.permalink = false;
|
||||
bookmark_info.write(info);
|
||||
});
|
||||
|
||||
Event.observe(hrefs['goto-tag'], 'click', function(e) {
|
||||
if (hrefs['goto-tag'].href == "#") { Event.stop(e); }
|
||||
});
|
||||
});
|
||||
|
157
js/cookiejar.js
Normal file
157
js/cookiejar.js
Normal file
@ -0,0 +1,157 @@
|
||||
/**
|
||||
* Javascript code to store data as JSON strings in cookies.
|
||||
* It uses prototype.js 1.5.1 (http://www.prototypejs.org)
|
||||
*
|
||||
* Author : Lalit Patel
|
||||
* Website: http://www.lalit.org/lab/jsoncookies
|
||||
* License: Apache Software License 2
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Version: 0.5
|
||||
* Updated: Jan 26, 2009
|
||||
*
|
||||
* Chnage Log:
|
||||
* v 0.5
|
||||
* - Changed License from CC to Apache 2
|
||||
* v 0.4
|
||||
* - Removed a extra comma in options (was breaking in IE and Opera). (Thanks Jason)
|
||||
* - Removed the parameter name from the initialize function
|
||||
* - Changed the way expires date was being calculated. (Thanks David)
|
||||
* v 0.3
|
||||
* - Removed dependancy on json.js (http://www.json.org/json.js)
|
||||
* - empty() function only deletes the cookies set by CookieJar
|
||||
*/
|
||||
|
||||
var CookieJar = Class.create();
|
||||
|
||||
CookieJar.prototype = {
|
||||
|
||||
/**
|
||||
* Append before all cookie names to differntiate them.
|
||||
*/
|
||||
appendString: "__CJ_",
|
||||
|
||||
/**
|
||||
* Initializes the cookie jar with the options.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.options = {
|
||||
expires: 3600, // seconds (1 hr)
|
||||
path: '', // cookie path
|
||||
domain: '', // cookie domain
|
||||
secure: '' // secure ?
|
||||
};
|
||||
Object.extend(this.options, options || {});
|
||||
|
||||
if (this.options.expires != '') {
|
||||
var date = new Date();
|
||||
date = new Date(date.getTime() + (this.options.expires * 1000));
|
||||
this.options.expires = '; expires=' + date.toGMTString();
|
||||
}
|
||||
if (this.options.path != '') {
|
||||
this.options.path = '; path=' + escape(this.options.path);
|
||||
}
|
||||
if (this.options.domain != '') {
|
||||
this.options.domain = '; domain=' + escape(this.options.domain);
|
||||
}
|
||||
if (this.options.secure == 'secure') {
|
||||
this.options.secure = '; secure';
|
||||
} else {
|
||||
this.options.secure = '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a name values pair.
|
||||
*/
|
||||
put: function(name, value) {
|
||||
name = this.appendString + name;
|
||||
cookie = this.options;
|
||||
var type = typeof value;
|
||||
switch(type) {
|
||||
case 'undefined':
|
||||
case 'function' :
|
||||
case 'unknown' : return false;
|
||||
case 'boolean' :
|
||||
case 'string' :
|
||||
case 'number' : value = String(value.toString());
|
||||
}
|
||||
var cookie_str = name + "=" + escape(Object.toJSON(value));
|
||||
try {
|
||||
document.cookie = cookie_str + cookie.expires + cookie.path + cookie.domain + cookie.secure;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a particular cookie (name value pair) form the Cookie Jar.
|
||||
*/
|
||||
remove: function(name) {
|
||||
name = this.appendString + name;
|
||||
cookie = this.options;
|
||||
try {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() - (3600 * 1000));
|
||||
var expires = '; expires=' + date.toGMTString();
|
||||
document.cookie = name + "=" + expires + cookie.path + cookie.domain + cookie.secure;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a particular cookie by name;
|
||||
*/
|
||||
get: function(name) {
|
||||
name = this.appendString + name;
|
||||
var cookies = document.cookie.match(name + '=(.*?)(;|$)');
|
||||
if (cookies) {
|
||||
return (unescape(cookies[1])).evalJSON();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Empties the Cookie Jar. Deletes all the cookies.
|
||||
*/
|
||||
empty: function() {
|
||||
keys = this.getKeys();
|
||||
size = keys.size();
|
||||
for(i=0; i<size; i++) {
|
||||
this.remove(keys[i]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all cookies as a single object
|
||||
*/
|
||||
getPack: function() {
|
||||
pack = {};
|
||||
keys = this.getKeys();
|
||||
|
||||
size = keys.size();
|
||||
for(i=0; i<size; i++) {
|
||||
pack[keys[i]] = this.get(keys[i]);
|
||||
}
|
||||
return pack;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all keys.
|
||||
*/
|
||||
getKeys: function() {
|
||||
keys = $A();
|
||||
keyRe= /[^=; ]+(?=\=)/g;
|
||||
str = document.cookie;
|
||||
CJRe = new RegExp("^" + this.appendString);
|
||||
while((match = keyRe.exec(str)) != undefined) {
|
||||
if (CJRe.test(match[0].strip())) {
|
||||
keys.push(match[0].strip().gsub("^" + this.appendString,""));
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
<div class="post-comic-head"></div>
|
||||
<div class="post-comic">
|
||||
<?php include('nav.inc') ?>
|
||||
<?php include_partial('nav') ?>
|
||||
<div class="comicdate"><?php the_date('F jS, Y') ?></div>
|
||||
<br class="clear" />
|
||||
<h2>
|
||||
@ -14,4 +14,4 @@
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<div class="post-comic-foot"></div>
|
||||
<div class="post-comic-foot"></div>
|
||||
|
@ -151,7 +151,7 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase {
|
||||
$p->expects($this->any())->method('get_comic_image_attachments')->will($this->returnValue($attachments));
|
||||
|
||||
wp_insert_post((object)array('ID' => 1));
|
||||
update_post_meta(1, 'comic_ordering', "comic:3,2");
|
||||
update_post_meta(1, 'comic_ordering', "comic:3");
|
||||
|
||||
$p->post = (object)array('ID' => 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user