From f8f7470e61b8c9b79c1e1cde87d5fb15d89806b3 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 6 Sep 2008 16:59:02 +0000 Subject: [PATCH] much friendlier get_theme_object git-svn-id: file:///home/shish/svn/shimmie2/trunk@1019 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/bulk_add/main.php | 2 +- contrib/downtime/main.php | 2 +- contrib/et/main.php | 2 +- contrib/event_log/main.php | 2 +- contrib/featured/main.php | 2 +- contrib/home/main.php | 2 +- contrib/image_hash_ban/main.php | 2 +- contrib/ipban/main.php | 2 +- contrib/link_image/main.php | 2 +- contrib/news/main.php | 2 +- contrib/notes/main.php | 2 +- contrib/numeric_score/main.php | 2 +- contrib/rating/main.php | 2 +- contrib/regen_thumb/main.php | 2 +- contrib/report_image/main.php | 2 +- contrib/svn_update/main.php | 2 +- contrib/tag_history/main.php | 2 +- contrib/tagger/main.php | 2 +- contrib/text_score/main.php | 2 +- contrib/wiki/main.php | 2 +- contrib/zoom/main.php | 2 +- core/util.inc.php | 8 +++++--- ext/admin/main.php | 2 +- ext/alias_editor/main.php | 2 +- ext/comment/main.php | 2 +- ext/ext_manager/main.php | 2 +- ext/index/main.php | 2 +- ext/setup/main.php | 2 +- ext/tag_edit/main.php | 2 +- ext/tag_list/main.php | 2 +- ext/upload/main.php | 2 +- ext/user/main.php | 2 +- ext/view/main.php | 2 +- 33 files changed, 37 insertions(+), 35 deletions(-) diff --git a/contrib/bulk_add/main.php b/contrib/bulk_add/main.php index 293d360b..d9996bf3 100644 --- a/contrib/bulk_add/main.php +++ b/contrib/bulk_add/main.php @@ -10,7 +10,7 @@ class BulkAdd implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("bulk_add", "BulkAddTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "bulk_add")) { if($event->user->is_admin() && isset($_POST['dir'])) { diff --git a/contrib/downtime/main.php b/contrib/downtime/main.php index f34ee036..fbf9f55f 100644 --- a/contrib/downtime/main.php +++ b/contrib/downtime/main.php @@ -10,7 +10,7 @@ class Downtime implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("downtime", "DowntimeTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof SetupBuildingEvent) { $sb = new SetupBlock("Downtime"); diff --git a/contrib/et/main.php b/contrib/et/main.php index f9915f69..4e1ea20a 100644 --- a/contrib/et/main.php +++ b/contrib/et/main.php @@ -10,7 +10,7 @@ class ET implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("et", "ETTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "system_info")) { if($event->user->is_admin()) { diff --git a/contrib/event_log/main.php b/contrib/event_log/main.php index 3c62ebbb..da26aecc 100644 --- a/contrib/event_log/main.php +++ b/contrib/event_log/main.php @@ -10,7 +10,7 @@ class EventLog implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("event_log", "EventLogTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { $this->setup(); diff --git a/contrib/featured/main.php b/contrib/featured/main.php index 06bc15be..fb1670c7 100644 --- a/contrib/featured/main.php +++ b/contrib/featured/main.php @@ -10,7 +10,7 @@ class Featured implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("featured", "FeaturedTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/home/main.php b/contrib/home/main.php index c53a4b13..ff803f18 100644 --- a/contrib/home/main.php +++ b/contrib/home/main.php @@ -12,7 +12,7 @@ class Home implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("home", "HomeTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "home")) { diff --git a/contrib/image_hash_ban/main.php b/contrib/image_hash_ban/main.php index e54c8860..69494af5 100644 --- a/contrib/image_hash_ban/main.php +++ b/contrib/image_hash_ban/main.php @@ -34,7 +34,7 @@ class Image_Hash_Ban implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("Image_Hash_Ban", "ImageBanTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index 46cbbd17..58b103f4 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -34,7 +34,7 @@ class IPBan implements Extension { var $theme; // event handler {{{ public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("ipban", "IPBanTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/link_image/main.php b/contrib/link_image/main.php index 9b695019..29d76273 100644 --- a/contrib/link_image/main.php +++ b/contrib/link_image/main.php @@ -8,7 +8,7 @@ class LinkImage implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("link_image", "LinkImageTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof DisplayingImageEvent)) { global $config; $data_href = get_base_href(); diff --git a/contrib/news/main.php b/contrib/news/main.php index 72b28ee4..5f9b5028 100644 --- a/contrib/news/main.php +++ b/contrib/news/main.php @@ -10,7 +10,7 @@ class News implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("news", "NewsTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof PostListBuildingEvent) { global $config; diff --git a/contrib/notes/main.php b/contrib/notes/main.php index a3e2ed01..09a8b3d8 100644 --- a/contrib/notes/main.php +++ b/contrib/notes/main.php @@ -10,7 +10,7 @@ class Notes implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("notes", "NotesTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index aa1095d6..291246d4 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -20,7 +20,7 @@ class NumericScore implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("numeric_score", "NumericScoreTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/rating/main.php b/contrib/rating/main.php index aa042d60..9324b6ee 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -20,7 +20,7 @@ class Ratings implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("rating", "RatingsTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/regen_thumb/main.php b/contrib/regen_thumb/main.php index 73908a72..5529d1f8 100644 --- a/contrib/regen_thumb/main.php +++ b/contrib/regen_thumb/main.php @@ -10,7 +10,7 @@ class RegenThumb implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("regen_thumb", "RegenThumbTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "regen_thumb")) { global $user; diff --git a/contrib/report_image/main.php b/contrib/report_image/main.php index 811367a8..5064cef6 100755 --- a/contrib/report_image/main.php +++ b/contrib/report_image/main.php @@ -33,7 +33,7 @@ class ReportImage implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("report_image", "ReportImageTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/contrib/svn_update/main.php b/contrib/svn_update/main.php index a30a6517..5a8ba9e1 100644 --- a/contrib/svn_update/main.php +++ b/contrib/svn_update/main.php @@ -10,7 +10,7 @@ class SVNUpdate implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("svn_update", "SVNUpdateTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "update")) { if($event->user->is_admin()) { diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php index 2bc11a54..83b6a294 100644 --- a/contrib/tag_history/main.php +++ b/contrib/tag_history/main.php @@ -9,7 +9,7 @@ class Tag_History implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("tag_history", "Tag_HistoryTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof InitExtEvent)) { // shimmie is being installed so call install to create the table. diff --git a/contrib/tagger/main.php b/contrib/tagger/main.php index f104cfb2..a069d4e5 100644 --- a/contrib/tagger/main.php +++ b/contrib/tagger/main.php @@ -11,7 +11,7 @@ class Tagger implements Extension { public function receive_event ($event) { if(is_null($this->theme)) - $this->theme = get_theme_object("tagger", "taggerTheme"); + $this->theme = get_theme_object($this); if($event instanceof DisplayingImageEvent) { global $page, $config, $user; diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php index 2b0b3624..61ff4f26 100644 --- a/contrib/text_score/main.php +++ b/contrib/text_score/main.php @@ -20,7 +20,7 @@ class TextScore implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("text_score", "TextScoreTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof InitExtEvent)) { global $config; diff --git a/contrib/wiki/main.php b/contrib/wiki/main.php index a55de856..89ddade2 100644 --- a/contrib/wiki/main.php +++ b/contrib/wiki/main.php @@ -56,7 +56,7 @@ class Wiki implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("wiki", "WikiTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof InitExtEvent)) { $this->setup(); diff --git a/contrib/zoom/main.php b/contrib/zoom/main.php index 5cedd6cc..d0a00fef 100644 --- a/contrib/zoom/main.php +++ b/contrib/zoom/main.php @@ -10,7 +10,7 @@ class Zoom implements Extension { var $theme; public function receive_event(Event $event) { - if($this->theme == null) $this->theme = get_theme_object("zoom", "ZoomTheme"); + if($this->theme == null) $this->theme = get_theme_object($this); if($event instanceof DisplayingImageEvent) { global $config; diff --git a/core/util.inc.php b/core/util.inc.php index 0645c68d..7377a574 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -178,12 +178,14 @@ function _count_execs($db, $sql, $inputarray) { $null = null; return $null; } -function get_theme_object($file, $class) { - if(class_exists("Custom$class")) { - $class = "Custom$class"; +function get_theme_object($class) { + $base = get_class($class); + if(class_exists("Custom{$base}Theme")) { + $class = "Custom{$base}Theme"; return new $class(); } else { + $class = "{$base}Theme"; return new $class(); } } diff --git a/ext/admin/main.php b/ext/admin/main.php index 382513ad..a57a58ab 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -15,7 +15,7 @@ class AdminPage implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("admin", "AdminPageTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "admin")) { if(!$event->user->is_admin()) { diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 9abd9765..4383facc 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -14,7 +14,7 @@ class AliasEditor implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("alias_editor", "AliasEditorTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "alias")) { if($event->get_arg(0) == "add") { diff --git a/ext/comment/main.php b/ext/comment/main.php index 3a85d0dd..9d5aee3d 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -52,7 +52,7 @@ class CommentList implements Extension { var $theme; // event handler {{{ public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("comment", "CommentListTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 5db9685d..e6e99547 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -57,7 +57,7 @@ class ExtManager implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("ext_manager", "ExtManagerTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "ext_manager")) { if($event->user->is_admin()) { diff --git a/ext/index/main.php b/ext/index/main.php index e60574c4..a5244050 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -14,7 +14,7 @@ class Index implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("index", "IndexTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/ext/setup/main.php b/ext/setup/main.php index 57623973..cb76e93d 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -126,7 +126,7 @@ class Setup implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("setup", "SetupTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 6a9b7691..6813e39b 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -4,7 +4,7 @@ class TagEdit implements Extension { var $theme; // event handling {{{ public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("tag_edit", "TagEditTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "tag_edit")) { global $page; diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 8bb58057..ab858fd2 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -5,7 +5,7 @@ class TagList implements Extension { // event handling {{{ public function receive_event(Event $event) { - if($this->theme == null) $this->theme = get_theme_object("tag_list", "TagListTheme"); + if($this->theme == null) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/ext/upload/main.php b/ext/upload/main.php index 9015525c..6e72eb49 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -4,7 +4,7 @@ class Upload implements Extension { var $theme; // event handling {{{ public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("upload", "UploadTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); $is_full = (disk_free_space(realpath("./images/")) < 100*1024*1024); diff --git a/ext/user/main.php b/ext/user/main.php index eeca5307..3cdb27c3 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -41,7 +41,7 @@ class UserPage implements Extension { // event handling {{{ public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("user", "UserPageTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if($event instanceof InitExtEvent) { global $config; diff --git a/ext/view/main.php b/ext/view/main.php index 78498c2d..ec65f369 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -43,7 +43,7 @@ class ViewImage implements Extension { var $theme; public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object("view", "ViewTheme"); + if(is_null($this->theme)) $this->theme = get_theme_object($this); if(($event instanceof PageRequestEvent) && ($event->page_name == "post") && ($event->get_arg(0) == "view")) { $image_id = int_escape($event->get_arg(1));