From b7991c4e7c9bd24d09b32e8eb3e6f7e7bd8a8d70 Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Thu, 22 Oct 2009 18:37:40 -0700 Subject: [PATCH] Changed the interface Signed-off-by: Philip M. Hofer (Frumph) --- images/nav/default/navstyle.css | 4 +- searchform.php | 2 +- test/widgets/GraphicalNavigationTest.php | 2 +- widgets/graphical-navigation.php | 575 ++++++++++------------- 4 files changed, 257 insertions(+), 326 deletions(-) diff --git a/images/nav/default/navstyle.css b/images/nav/default/navstyle.css index b70165f..52eae55 100644 --- a/images/nav/default/navstyle.css +++ b/images/nav/default/navstyle.css @@ -42,7 +42,7 @@ Style: Default background: url('first.png') no-repeat; } -.navi-prevchap { +.navi-prevchap, .navi-story_prev { background: url('prevchap.png') no-repeat; } @@ -108,7 +108,7 @@ Style: Default background: url('next.png') no-repeat; } -.navi-nextchap { +.navi-nextchap, .navi-story_next { background: url('nextchap.png') no-repeat; } diff --git a/searchform.php b/searchform.php index 83c514e..0601d45 100644 --- a/searchform.php +++ b/searchform.php @@ -1,6 +1,6 @@
- +
\ No newline at end of file diff --git a/test/widgets/GraphicalNavigationTest.php b/test/widgets/GraphicalNavigationTest.php index 8c5ba14..b3387e2 100644 --- a/test/widgets/GraphicalNavigationTest.php +++ b/test/widgets/GraphicalNavigationTest.php @@ -7,7 +7,7 @@ require_once(dirname(__FILE__) . '/../../widgets/graphical-navigation.php'); class GraphicalNavigationTest extends PHPUnit_Framework_TestCase { function setUp() { _reset_wp(); - $this->w = new widget_comicpress_graphical_navigation(); + $this->w = new widget_comicpress_storyline_graphical_navigation(); } function testUpdateWidget() { diff --git a/widgets/graphical-navigation.php b/widgets/graphical-navigation.php index c4c0468..609a228 100644 --- a/widgets/graphical-navigation.php +++ b/widgets/graphical-navigation.php @@ -2,352 +2,283 @@ /* Widget Name: Graphical Navigation Widget URI: http://comicpress.org/ -Description: This widget places graphical navigation buttons on your comic. For ComicPress 2.8 -Author: Philip M. Hofer (Frumph) & John Bintz -Version: 1.2 +Description: You can place graphical navigation buttons on your comic, for ComicPress 2.8 +Author: Philip M. Hofer (Frumph) +Version: 1.01 Author URI: http://webcomicplanet.com/ + */ -require_once(dirname(__FILE__) . '/../classes/ComicPressNavigation.inc'); - class widget_comicpress_graphical_navigation extends WP_Widget { + function widget_comicpress_graphical_navigation() { $widget_ops = array('classname' => 'widget_comicpress_graphical_navigation', 'description' => __('Displays Graphical Navigation Buttons. (used in comic sidebars)','comicpress') ); $this->WP_Widget('graphicalnavigation', __('Comic Navigation','comicpress'), $widget_ops); } - - /** - * Initialize the widget class. - */ - function init() { - add_filter('comicpress_display_navigation_order', array(&$this, 'comicpress_display_navigation_order')); - add_filter('comicpress_display_navigation_link', array(&$this, 'comicpress_display_navigation_link'), 10, 5); - add_filter('comicpress_wrap_navigation_buttons', array(&$this, 'comicpress_wrap_navigation_buttons'), 10, 2); - - // these two need to be moved one level up - add_filter('comicpress_get_random_link_url', array(&$this, 'comicpress_get_random_link_url')); - add_filter('comicpress_get_buy_print_url', array(&$this, 'comicpress_get_buy_print_url')); - } - - /** - * Get the random link URL. - */ - function comicpress_get_random_link_url($url = '') { - return get_bloginfo('url') . '/?randomcomic'; - } - - /** - * Get the URL to buy a print. - * Handles hitting the global namespace for you. - */ - function comicpress_get_buy_print_url($url = '') { - global $buy_print_url; - return $buy_print_url; - } - - /** - * Render a button. - */ - function comicpress_display_navigation_link($which, $current, $target, $instance, $content = '') { - global $id; - - $ok = true; - switch ($which) { - case 'first': - case 'last': - $ok = $this->_will_display_nav_link($which, $current, $target); - break; - case 'previous': - case 'next': - case 'story_prev': - case 'story_next': - $ok = !empty($target); - break; - case 'archives': - $ok = !empty($instance['archive_path']); - break; - } - - ob_start(); - switch ($which) { - case 'first': - case 'last': - case 'previous': - case 'story_prev': - case 'story_next': - case 'next': - $link = get_permalink($target->ID); - if (($which == 'next') && ($instance['nextgohome'] == 'on')) { $link = get_bloginfo('url'); } - if ($ok) { - ?>">ID; - ?>ID != $current->ID); - default: - return true; - } - } - - /** - * Get the order of the buttons to be displayed on-screen. - */ - function comicpress_display_navigation_order($order = array()) { - return array( - 'first', 'story_prev', 'previous', 'archives', 'random', 'comictitle', 'comments', 'buyprint', 'next', 'story_next', 'last' - ); - } - - /** - * Wrap navigation buttons in a holder. - * @param string|array $buttons The buttons to wrap. - * @param string $content The wrapped content. - */ - function comicpress_wrap_navigation_buttons($buttons = '', $content = '') { - $buttons_text = $buttons; - if (is_array($buttons)) { $buttons_text = implode('', $buttons); } - ob_start(); ?> -
-
-
- create_structure(get_option('comicpress-storyline-category-order')); - - $dbi = ComicPressDBInterface::get_instance(); - $dbi->set_comic_categories($storyline->get_comic_categories()); - - $navigation = new ComicPressNavigation(); - $navigation->init($storyline); - $post_nav = $navigation->get_post_nav($post); - - $storyline_to_nav_mapping = array( - 'story_prev' => 'storyline-chapter-previous', - 'story_next' => 'storyline-chapter-next' - ); - - $nav_links = array(); - foreach (apply_filters('comicpress_display_navigation_order', array()) as $order) { - if ($instance[$order] == "on") { - $target_post_nav = (isset($storyline_to_nav_mapping[$order])) ? $storyline_to_nav_mapping[$order] : $order; - - $target_post = null; - if (isset($post_nav[$target_post_nav])) { $target_post = $post_nav[$target_post_nav]; } - - $nav_links[] = end(apply_filters('comicpress_display_navigation_link', $order, $post, $target_post, $instance, '')); - } + + $this_permalink = get_permalink(); + + $temp_query = $wp_query->is_single; + $wp_query->is_single = true; + $prev_comic = get_previous_comic_permalink(); + $next_comic = get_next_comic_permalink(); + $wp_query->is_single = $temp_query; + $temp_query = null; + + $first_comic = get_first_comic_permalink(); + $last_comic = get_last_comic_permalink(); + + $prev_story = get_previous_storyline_start_permalink(); + $next_story = get_next_storyline_start_permalink(); + + $latest_comic = get_permalink( get_terminal_post_in_category(get_all_comic_categories_as_cat_string(), false) ); + ?> +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + 'on', - 'last' => 'on', - 'story_prev' => 'off', - 'story_next' => 'off', - 'previous' => 'on', - 'random' => 'off', - 'archives' => 'off', - 'comments' => 'off', - 'next' => 'on', - 'archive_path' => '', - 'buyprint' => 'off', - 'comictitle' => 'off', - 'nextgohome' => 'off' - ); + $instance = wp_parse_args( (array) $instance, array( + 'first' => 'on', + 'last' => 'on', + 'story_prev' => 'off', + 'story_next' => 'off', + 'previous' => 'on', + 'random' => 'off', + 'archives' => 'off', + 'comments' => 'off', + 'next' => 'on', + 'archive_path' => '', + 'buyprint' => 'off', + 'first_title' => 'First', + 'last_title' => 'Latest', + 'story_prev_title' => 'Chapter', + 'story_next_title' => 'Chapter', + 'previous_title' => 'Previous', + 'random_title' => 'Random', + 'archives_title' => 'Archives', + 'comments_title' => 'Comments', + 'next_title' => 'Next', + 'buyprint_title' => 'Buy Print', + 'comictitle' => 'off', + 'nextgohome' => 'off', + ) ); + $first = $instance['first']; if (empty($first)) $first = 'on'; + $last = $instance['last']; if (empty($last)) $last = 'on'; + $story_prev = $instance['story_prev']; if (empty($story_prev)) $story_prev = 'off'; + $story_next = $instance['story_next']; if (empty($story_next)) $story_next = 'off'; + $previous = $instance['previous']; if (empty($previous)) $previous = 'on'; + $random = $instance['random']; if (empty($random)) $random = 'off'; + $archives = $instance['archives']; if (empty($archives)) $archives = 'off'; + $comments = $instance['comments']; if (empty($comments)) $comments = 'off'; + $archive_path = $instance['archive_path']; + $next = $instance['next']; if (empty($next)) $next = 'on'; + $buyprint = $instance['buyprint']; if (empty($buyprint)) $buyprint = 'off'; + $comictitle = $instance['comictitle']; if (empty($comictitle)) $comictitle = 'off'; + $nextgohome = $instance['nextgohome']; if (empty($nextgohome)) $nextgohome = 'off'; + + + $first_title = $instance['first_title']; + $last_title = $instance['last_title']; + $story_prev_title = $instance['story_prev_title']; + $story_next_title = $instance['story_next_title']; + $previous_title = $instance['previous_title']; + $random_title = $instance['random_title']; + $archives_title = $instance['archives_title']; + $comments_title = $instance['comments_title']; + $next_title = $instance['next_title']; + $buyprint_title = $instance['buyprint_title']; - $title_defaults = array( - 'first_title' => __('First', 'comicpress'), - 'last_title' => __('Latest', 'comicpress'), - 'story_prev_title' => __('Chapter', 'comicpress'), - 'story_next_title' => __('Chapter', 'comicpress'), - 'previous_title' => __('Previous', 'comicpress'), - 'random_title' => __('Random', 'comicpress'), - 'archives_title' => __('Archives', 'comicpress'), - 'comments_title' => __('Comments', 'comicpress'), - 'next_title' => __('Next', 'comicpress'), - 'buyprint_title' => __('Buy Print', 'comicpress') - ); + + + + ?> + +   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+ +
+   />Off
+ +
+   />Off
+ Title:
+
+ Archive URL:
+
- $instance = wp_parse_args((array)$instance, array_merge($field_defaults, $title_defaults)); - - foreach (array( - 'first' => __('First', 'comicpress'), - 'last' => __('Last', 'comicpress'), - 'previous' => __('Previous', 'comicpress'), - 'next' => __('Next', 'comicpress'), - 'story_prev' => __('Previous Chapter', 'comicpress'), - 'story_next' => __('Next Chapter', 'comicpress'), - 'comictitle' => __('Comic Title', 'comicpress'), - 'archives' => __('Archives', 'comicpress'), - 'comments' => __('Comments', 'comicpress'), - 'random' => __('Random', 'comicpress'), - 'buyprint' => __('Buy Print', 'comicpress') - ) as $field => $label) { - $title_field = "${field}_title"; ?> -
- - -
- - - - - -
- -
- -
- -
- -
- -
-
- - - +
+   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+ +
+   />Off
+ Title:
+
+
+
+ />On  />Off
init(); -} + +function widget_comicpress_graphical_navigation_init() { + new widget_comicpress_graphical_navigation(); +} add_action('widgets_init', 'widget_comicpress_graphical_navigation_init');