From 3b0c3cea0d8dafaf29d7566773a30b2f81ce9485 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 20 Dec 2009 18:54:01 -0500 Subject: [PATCH] working on bookmark widget --- test/widgets/BookmarkWidgetTest.php | 1 + widgets/BookmarkWidget.inc | 118 +++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 test/widgets/BookmarkWidgetTest.php diff --git a/test/widgets/BookmarkWidgetTest.php b/test/widgets/BookmarkWidgetTest.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/test/widgets/BookmarkWidgetTest.php @@ -0,0 +1 @@ + __CLASS__, 'description' => __('Allow the user to bookmark a page and then jump to it upon return.','comicpress') ); $this->WP_Widget(__CLASS__, __('ComicPress Bookmark','comicpress'), $widget_ops); } + + $this->text_fields = array( + 'three-button' => array( + 'tag-page' => array( + 'label' => __('Tag page', 'comicpress'), + 'default' => __('Bookmark', 'comicpress') + ), + 'clear-tag-off' => array( + 'label' => __('Clear tag off', 'comicpress'), + 'default' => '' + ), + 'clear-tag-on' => array( + 'label' => __('Clear tag on', 'comicpress'), + 'default' => __('Clear', 'comicpress') + ), + 'goto-tag-off' => array( + 'label' => __('Goto tag off', 'comicpress'), + 'default' => '' + ), + 'goto-tag-on' => array( + 'label' => __('Goto tag on', 'comicpress'), + 'default' => __('Goto', 'comicpress') + ) + ), + 'one-button' => array( + 'set-bookmark' => array( + 'label' => __('Set bookmark', 'comicpress'), + 'default' => __('+Bookmark', 'comicpress') + ), + 'use-bookmark' => array( + 'label' => __('Use bookmark', 'comicpress'), + 'default' => __('>>Bookmark', 'comicpress') + ) + ) + ); } function init() { @@ -29,7 +66,86 @@ class BookmarkWidget extends WP_Widget { +
+

+ +

+ __('Three-button mode', 'comicpress'), + 'one-button' => __('One-button mode', 'comicpress') + ) as $mode => $label) { ?> +

+ +

+
">

+ text_fields[$mode] as $name => $info) { + extract($info); + $value = empty($instance[$name]) ? $default : $instance[$name]; + ?> + +
+

+ +
+ + text_fields as $type => $fields) { + $all_text_fields = array_merge($all_text_fields, array_keys($fields)); + } + + foreach ($all_text_fields as $key) { + $instance[$key] = strip_tags($new_instance[$key]); + } + + if (isset($this->text_fields[$new_instance['mode']])) { + $instance['mode'] = $new_instance['mode']; + } else { + $instance['mode'] = array_shift(array_keys($this->text_fields)); + } + + return $instance; + } + + function widget($instance) { ?>