From 0698b780f94ca757eeaac6a389f29dbb0bfb124c Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 8 Feb 2012 12:07:01 +0000 Subject: [PATCH] remove regular Extension, have SimpleExtension take its place, optimise the event system based on SimpleExtension methods --- contrib/admin/main.php | 2 +- contrib/amazon_s3/main.php | 2 +- contrib/artists/main.php | 2 +- contrib/ban_words/main.php | 2 +- contrib/blocks/main.php | 2 +- contrib/blotter/main.php | 2 +- contrib/bookmarks/main.php | 2 +- contrib/browser_search/main.php | 2 +- contrib/bulk_add/main.php | 2 +- contrib/danbooru_api/main.php | 2 +- contrib/downtime/main.php | 2 +- contrib/emoticons/main.php | 2 +- contrib/et/main.php | 2 +- contrib/favorites/main.php | 2 +- contrib/featured/main.php | 2 +- contrib/forum/main.php | 2 +- contrib/handle_archive/main.php | 2 +- contrib/handle_ico/main.php | 2 +- contrib/handle_svg/main.php | 2 +- contrib/holiday/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/log_db/main.php | 2 +- contrib/mass_tagger/main.php | 2 +- contrib/news/main.php | 2 +- contrib/notes/main.php | 2 +- contrib/numeric_score/main.php | 2 +- contrib/oekaki/main.php | 2 +- contrib/pm/main.php | 2 +- contrib/pools/main.php | 2 +- contrib/qr_code/main.php | 2 +- contrib/random_image/main.php | 2 +- contrib/rating/main.php | 2 +- contrib/regen_thumb/main.php | 2 +- contrib/report_image/main.php | 2 +- contrib/res_limit/main.php | 2 +- contrib/resize/main.php | 2 +- contrib/rss_comments/main.php | 2 +- contrib/rss_images/main.php | 2 +- contrib/shimmie_api/main.php | 2 +- contrib/simpletest/main.php | 2 +- contrib/site_description/main.php | 2 +- contrib/sitemap/main.php | 2 +- contrib/tag_editcloud/main.php | 2 +- contrib/tag_history/main.php | 2 +- contrib/tagger/main.php | 4 +-- contrib/tips/main.php | 2 +- contrib/twitter_soc/main.php | 2 +- contrib/update/main.php | 2 +- contrib/wiki/main.php | 2 +- contrib/word_filter/main.php | 2 +- core/extension.class.php | 43 +++++-------------------------- core/util.inc.php | 14 +++------- ext/alias_editor/main.php | 2 +- ext/comment/main.php | 2 +- ext/ext_manager/main.php | 2 +- ext/handle_404/main.php | 2 +- ext/image/main.php | 2 +- ext/index/main.php | 2 +- ext/mail/main.php | 4 +-- ext/setup/main.php | 2 +- ext/tag_edit/main.php | 2 +- ext/tag_list/main.php | 2 +- ext/upgrade/main.php | 2 +- ext/upload/main.php | 2 +- ext/user/main.php | 2 +- ext/view/main.php | 2 +- 69 files changed, 79 insertions(+), 116 deletions(-) diff --git a/contrib/admin/main.php b/contrib/admin/main.php index 12c2e347..020d4640 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -35,7 +35,7 @@ class AdminBuildingEvent extends Event { } } -class AdminPage extends SimpleExtension { +class AdminPage extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page, $user; diff --git a/contrib/amazon_s3/main.php b/contrib/amazon_s3/main.php index 741b7378..b4191a69 100644 --- a/contrib/amazon_s3/main.php +++ b/contrib/amazon_s3/main.php @@ -9,7 +9,7 @@ require_once "lib/S3.php"; -class UploadS3 extends SimpleExtension { +class UploadS3 extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string("amazon_s3_access", ""); diff --git a/contrib/artists/main.php b/contrib/artists/main.php index 2b8a79fd..4c2422fa 100644 --- a/contrib/artists/main.php +++ b/contrib/artists/main.php @@ -19,7 +19,7 @@ class AuthorSetEvent extends Event { } } -class Artists extends SimpleExtension { +class Artists extends Extension { public function onImageInfoSet(ImageInfoSetEvent $event) { global $user; if (isset($_POST["tag_edit__author"])) { diff --git a/contrib/ban_words/main.php b/contrib/ban_words/main.php index aee98417..e5f42b89 100644 --- a/contrib/ban_words/main.php +++ b/contrib/ban_words/main.php @@ -19,7 +19,7 @@ * from Essex" */ -class BanWords extends SimpleExtension { +class BanWords extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string('banned_words', " diff --git a/contrib/blocks/main.php b/contrib/blocks/main.php index 2fd3dfa7..f3ee274d 100644 --- a/contrib/blocks/main.php +++ b/contrib/blocks/main.php @@ -27,7 +27,7 @@ * */ -class Blocks extends SimpleExtension { +class Blocks extends Extension { public function onPageRequest(PageRequestEvent $event) { global $config, $page; $all = $config->get_string("blocks_text"); diff --git a/contrib/blotter/main.php b/contrib/blotter/main.php index 8dd4daad..23dc5fe8 100644 --- a/contrib/blotter/main.php +++ b/contrib/blotter/main.php @@ -8,7 +8,7 @@ * * Development TODO at http://github.com/zshall/shimmie2/issues */ -class Blotter extends SimpleExtension { +class Blotter extends Extension { public function onInitExt(InitExtEvent $event) { /** * I love re-using this installer don't I... diff --git a/contrib/bookmarks/main.php b/contrib/bookmarks/main.php index 3ed8db45..8e47bc83 100644 --- a/contrib/bookmarks/main.php +++ b/contrib/bookmarks/main.php @@ -6,7 +6,7 @@ * Description: Allow users to bookmark searches */ -class Bookmarks extends SimpleExtension { +class Bookmarks extends Extension { public function onInitExt(InitExtEvent $event) { $this->install(); } diff --git a/contrib/browser_search/main.php b/contrib/browser_search/main.php index 80c399c2..78c3b878 100755 --- a/contrib/browser_search/main.php +++ b/contrib/browser_search/main.php @@ -13,7 +13,7 @@ * engine" notification they have */ -class BrowserSearch extends SimpleExtension { +class BrowserSearch extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string("search_suggestions_results_order", 'a'); diff --git a/contrib/bulk_add/main.php b/contrib/bulk_add/main.php index 676fc14e..21e5a9a3 100644 --- a/contrib/bulk_add/main.php +++ b/contrib/bulk_add/main.php @@ -14,7 +14,7 @@ *

Note: requires the "admin" extension to be enabled */ -class BulkAdd extends SimpleExtension { +class BulkAdd extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page, $user; if($event->page_matches("bulk_add")) { diff --git a/contrib/danbooru_api/main.php b/contrib/danbooru_api/main.php index f47a34e8..ad9cc13c 100644 --- a/contrib/danbooru_api/main.php +++ b/contrib/danbooru_api/main.php @@ -47,7 +47,7 @@ Completely compatibility will probably involve a rewrite with a different URL */ -class DanbooruApi extends SimpleExtension { +class DanbooruApi extends Extension { public function onPageRequest(PageRequestEvent $event) { if($event->page_matches("api") && ($event->get_arg(0) == 'danbooru')) { $this->api_danbooru($event); diff --git a/contrib/downtime/main.php b/contrib/downtime/main.php index 8c9ced34..3e87bdf3 100644 --- a/contrib/downtime/main.php +++ b/contrib/downtime/main.php @@ -11,7 +11,7 @@ * message specified in the box. */ -class Downtime extends SimpleExtension { +class Downtime extends Extension { public function get_priority() {return 10;} public function onSetupBuilding($event) { diff --git a/contrib/emoticons/main.php b/contrib/emoticons/main.php index d7805f47..be958040 100644 --- a/contrib/emoticons/main.php +++ b/contrib/emoticons/main.php @@ -24,7 +24,7 @@ class Emoticons extends FormatterExtension { } } -class EmoticonList extends SimpleExtension { +class EmoticonList extends Extension { public function onPageRequest(PageRequestEvent $event) { if($event->page_matches("emote/list")) { $this->theme->display_emotes(glob("ext/emoticons/default/*")); diff --git a/contrib/et/main.php b/contrib/et/main.php index d54b5631..6a26ec40 100644 --- a/contrib/et/main.php +++ b/contrib/et/main.php @@ -12,7 +12,7 @@ * versions of PHP I should test with, etc. */ -class ET extends SimpleExtension { +class ET extends Extension { public function onPageRequest(PageRequestEvent $event) { global $user; if($event->page_matches("system_info")) { diff --git a/contrib/favorites/main.php b/contrib/favorites/main.php index 9a66fd65..7c14554f 100644 --- a/contrib/favorites/main.php +++ b/contrib/favorites/main.php @@ -26,7 +26,7 @@ class FavoriteSetEvent extends Event { } } -class Favorites extends SimpleExtension { +class Favorites extends Extension { public function onInitExt(InitExtEvent $event) { global $config; if($config->get_int("ext_favorites_version", 0) < 1) { diff --git a/contrib/featured/main.php b/contrib/featured/main.php index a4defb11..ee25b121 100644 --- a/contrib/featured/main.php +++ b/contrib/featured/main.php @@ -18,7 +18,7 @@ * every couple of hours. */ -class Featured extends SimpleExtension { +class Featured extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_int('featured_id', 0); diff --git a/contrib/forum/main.php b/contrib/forum/main.php index 2604c426..cd5ccdaf 100644 --- a/contrib/forum/main.php +++ b/contrib/forum/main.php @@ -8,7 +8,7 @@ * Documentation: */ -class Forum extends SimpleExtension { +class Forum extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; diff --git a/contrib/handle_archive/main.php b/contrib/handle_archive/main.php index c8b92200..2fb2498b 100644 --- a/contrib/handle_archive/main.php +++ b/contrib/handle_archive/main.php @@ -10,7 +10,7 @@ *
7-zip: 7zr x -o"%d" "%f" */ -class ArchiveFileHandler extends SimpleExtension { +class ArchiveFileHandler extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"'); diff --git a/contrib/handle_ico/main.php b/contrib/handle_ico/main.php index d8475279..7582fc53 100644 --- a/contrib/handle_ico/main.php +++ b/contrib/handle_ico/main.php @@ -5,7 +5,7 @@ * Description: Handle windows icons */ -class IcoFileHandler extends SimpleExtension { +class IcoFileHandler extends Extension { public function onDataUpload(DataUploadEvent $event) { if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { $hash = $event->hash; diff --git a/contrib/handle_svg/main.php b/contrib/handle_svg/main.php index c65edf49..0c59f59d 100644 --- a/contrib/handle_svg/main.php +++ b/contrib/handle_svg/main.php @@ -5,7 +5,7 @@ * Description: Handle SVG files */ -class SVGFileHandler extends SimpleExtension { +class SVGFileHandler extends Extension { public function onDataUpload(DataUploadEvent $event) { if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { $hash = $event->hash; diff --git a/contrib/holiday/main.php b/contrib/holiday/main.php index 58c90a37..f435099a 100644 --- a/contrib/holiday/main.php +++ b/contrib/holiday/main.php @@ -6,7 +6,7 @@ * License: GPLv2 * Description: Use an additional stylesheet on certain holidays. */ -class Holiday extends SimpleExtension { +class Holiday extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_bool("holiday_aprilfools", false); diff --git a/contrib/home/main.php b/contrib/home/main.php index f9485309..2ac2412d 100644 --- a/contrib/home/main.php +++ b/contrib/home/main.php @@ -15,7 +15,7 @@ * alongside the default choices. */ -class Home extends SimpleExtension { +class Home extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string("home_links", '[$base/post/list|Posts] diff --git a/contrib/image_hash_ban/main.php b/contrib/image_hash_ban/main.php index ab0f9bf0..79150d98 100644 --- a/contrib/image_hash_ban/main.php +++ b/contrib/image_hash_ban/main.php @@ -29,7 +29,7 @@ class AddImageHashBanEvent extends Event { } } // }}} -class ImageBan extends SimpleExtension { +class ImageBan extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; if($config->get_int("ext_imageban_version") < 1) { diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index 2697155a..4da24231 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -34,7 +34,7 @@ class AddIPBanEvent extends Event { } // }}} -class IPBan extends SimpleExtension { +class IPBan extends Extension { public function get_priority() {return 10;} public function onInitExt(InitExtEvent $event) { diff --git a/contrib/link_image/main.php b/contrib/link_image/main.php index 28366e4d..ab52935e 100644 --- a/contrib/link_image/main.php +++ b/contrib/link_image/main.php @@ -4,7 +4,7 @@ * Author: Artanis * Description: Show various forms of link to each image, for copy & paste */ -class LinkImage extends SimpleExtension { +class LinkImage extends Extension { public function onDisplayingImage(DisplayingImageEvent $event) { global $page; $this->theme->links_block($page, $this->data($event->image)); diff --git a/contrib/log_db/main.php b/contrib/log_db/main.php index f83a2aa6..bba7c996 100644 --- a/contrib/log_db/main.php +++ b/contrib/log_db/main.php @@ -6,7 +6,7 @@ * Visibility: admin */ -class LogDatabase extends SimpleExtension { +class LogDatabase extends Extension { public function onInitExt(InitExtEvent $event) { global $database; global $config; diff --git a/contrib/mass_tagger/main.php b/contrib/mass_tagger/main.php index 8cc3c893..751cfcdf 100644 --- a/contrib/mass_tagger/main.php +++ b/contrib/mass_tagger/main.php @@ -14,7 +14,7 @@ * As of now only compatible with the lite theme. */ -class MassTagger extends SimpleExtension { +class MassTagger extends Extension { public function onPostListBuilding(PostListBuildingEvent $event) { global $config, $page, $user; diff --git a/contrib/news/main.php b/contrib/news/main.php index 2091a6ef..27765c71 100644 --- a/contrib/news/main.php +++ b/contrib/news/main.php @@ -8,7 +8,7 @@ * Any HTML is allowed */ -class News extends SimpleExtension { +class News extends Extension { public function onPostListBuilding(PostListBuildingEvent $event) { global $config, $page; if(strlen($config->get_string("news_text")) > 0) { diff --git a/contrib/notes/main.php b/contrib/notes/main.php index 3e894770..aa960c1d 100644 --- a/contrib/notes/main.php +++ b/contrib/notes/main.php @@ -7,7 +7,7 @@ * Documentation: */ -class Notes extends SimpleExtension { +class Notes extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 7bcf15aa..7df72142 100755 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -19,7 +19,7 @@ class NumericScoreSetEvent extends Event { } } -class NumericScore extends SimpleExtension { +class NumericScore extends Extension { public function onInitExt(InitExtEvent $event) { global $config; if($config->get_int("ext_numeric_score_version", 0) < 1) { diff --git a/contrib/oekaki/main.php b/contrib/oekaki/main.php index 3027dcfd..16e5748e 100644 --- a/contrib/oekaki/main.php +++ b/contrib/oekaki/main.php @@ -5,7 +5,7 @@ * Description: ChibiPaint-based Oekaki uploader */ -class Oekaki extends SimpleExtension { +class Oekaki extends Extension { public function onPageRequest(PageRequestEvent $event) { global $user, $page; diff --git a/contrib/pm/main.php b/contrib/pm/main.php index 5e380278..dc95db92 100755 --- a/contrib/pm/main.php +++ b/contrib/pm/main.php @@ -42,7 +42,7 @@ class PM { } } -class PrivMsg extends SimpleExtension { +class PrivMsg extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; diff --git a/contrib/pools/main.php b/contrib/pools/main.php index fb15d491..afec342c 100644 --- a/contrib/pools/main.php +++ b/contrib/pools/main.php @@ -10,7 +10,7 @@ class PoolCreationException extends SCoreException { } -class Pools extends SimpleExtension { +class Pools extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; diff --git a/contrib/qr_code/main.php b/contrib/qr_code/main.php index 7f5b706f..ed671fd3 100644 --- a/contrib/qr_code/main.php +++ b/contrib/qr_code/main.php @@ -7,7 +7,7 @@ * Further modified by Shish to remove the 7MB local QR generator * and replace it with a link to google chart APIs */ -class QRImage extends SimpleExtension { +class QRImage extends Extension { public function onDisplayingImage(DisplayingImageEvent $event) { $this->theme->links_block(make_http(make_link('image/'.$event->image->id.'.jpg'))); } diff --git a/contrib/random_image/main.php b/contrib/random_image/main.php index 79fc6d4f..11d5daa7 100644 --- a/contrib/random_image/main.php +++ b/contrib/random_image/main.php @@ -19,7 +19,7 @@ * /random_image/download/size=1024x768+cute */ -class RandomImage extends SimpleExtension { +class RandomImage extends Extension { public function onPageRequest(PageRequestEvent $event) { global $config, $database, $page, $user; if($event->page_matches("random_image")) { diff --git a/contrib/rating/main.php b/contrib/rating/main.php index 71fc0cf8..4bcbe3f7 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -17,7 +17,7 @@ class RatingSetEvent extends Event { } } -class Ratings extends SimpleExtension { +class Ratings extends Extension { public function onAdminBuilding(AdminBuildingEvent $event) { $this->theme->display_bulk_rater(); } diff --git a/contrib/regen_thumb/main.php b/contrib/regen_thumb/main.php index e5855976..11355330 100644 --- a/contrib/regen_thumb/main.php +++ b/contrib/regen_thumb/main.php @@ -12,7 +12,7 @@ * since been increased. */ -class RegenThumb extends SimpleExtension { +class RegenThumb extends Extension { public function onPageRequest(PageRequestEvent $event) { global $config, $database, $page, $user; diff --git a/contrib/report_image/main.php b/contrib/report_image/main.php index 28c0e826..aa4290f8 100755 --- a/contrib/report_image/main.php +++ b/contrib/report_image/main.php @@ -29,7 +29,7 @@ class AddReportedImageEvent extends Event { } } -class ReportImage extends SimpleExtension { +class ReportImage extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_bool('report_image_show_thumbs', true); diff --git a/contrib/res_limit/main.php b/contrib/res_limit/main.php index 459faa90..b9657a17 100644 --- a/contrib/res_limit/main.php +++ b/contrib/res_limit/main.php @@ -5,7 +5,7 @@ * License: GPLv2 * Description: Allows the admin to set min / max image dimentions */ -class ResolutionLimit extends SimpleExtension { +class ResolutionLimit extends Extension { public function get_priority() {return 40;} // early, to veto ImageUploadEvent public function onImageAddition(ImageAdditionEvent $event) { diff --git a/contrib/resize/main.php b/contrib/resize/main.php index 60bc86b9..38075290 100644 --- a/contrib/resize/main.php +++ b/contrib/resize/main.php @@ -26,7 +26,7 @@ class ImageResizeException extends SCoreException { /** * This class handles image resize requests. */ -class ResizeImage extends SimpleExtension { +class ResizeImage extends Extension { public function onInitExt(InitExtEvent $event) { global $config; diff --git a/contrib/rss_comments/main.php b/contrib/rss_comments/main.php index 8c32bbbf..d7c02b87 100644 --- a/contrib/rss_comments/main.php +++ b/contrib/rss_comments/main.php @@ -6,7 +6,7 @@ * Description: Self explanatory */ -class RSS_Comments extends SimpleExtension { +class RSS_Comments extends Extension { public function onPostListBuilding(PostListBuildingEvent $event) { global $config, $page; $title = $config->get_string('title'); diff --git a/contrib/rss_images/main.php b/contrib/rss_images/main.php index 675016e7..26924d62 100644 --- a/contrib/rss_images/main.php +++ b/contrib/rss_images/main.php @@ -6,7 +6,7 @@ * Description: Self explanatory */ -class RSS_Images extends SimpleExtension { +class RSS_Images extends Extension { public function onPostListBuilding(PostListBuildingEvent $event) { global $config, $page; $title = $config->get_string('title'); diff --git a/contrib/shimmie_api/main.php b/contrib/shimmie_api/main.php index d7f3128f..b8b9bc0d 100644 --- a/contrib/shimmie_api/main.php +++ b/contrib/shimmie_api/main.php @@ -26,7 +26,7 @@ class _SafeImage { } } -class ShimmieApi extends SimpleExtension { +class ShimmieApi extends Extension { public function onPageRequest(PageRequestEvent $event) { global $database, $page; diff --git a/contrib/simpletest/main.php b/contrib/simpletest/main.php index f56d322a..38666898 100644 --- a/contrib/simpletest/main.php +++ b/contrib/simpletest/main.php @@ -205,7 +205,7 @@ class TestFinder extends TestSuite { } } -class SimpleSCoreTest extends SimpleExtension { +class SimpleSCoreTest extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page; if($event->page_matches("test")) { diff --git a/contrib/site_description/main.php b/contrib/site_description/main.php index 43ed38b1..f2f7f57d 100644 --- a/contrib/site_description/main.php +++ b/contrib/site_description/main.php @@ -9,7 +9,7 @@ * This extension sets the "description" meta tag in the header * of pages so that search engines can pick it up */ -class SiteDescription extends SimpleExtension { +class SiteDescription extends Extension { public function onPageRequest(PageRequestEvent $event) { global $config, $page; if(strlen($config->get_string("site_description")) > 0) { diff --git a/contrib/sitemap/main.php b/contrib/sitemap/main.php index 8858bb9c..e481510f 100644 --- a/contrib/sitemap/main.php +++ b/contrib/sitemap/main.php @@ -7,7 +7,7 @@ * Documentation: */ -class XMLSitemap extends SimpleExtension { +class XMLSitemap extends Extension { public function onPageRequest(PageRequestEvent $event) { if($event->page_matches("sitemap.xml")) { $images = Image::find_images(0, 50, array()); diff --git a/contrib/tag_editcloud/main.php b/contrib/tag_editcloud/main.php index 75819299..71dabc9e 100644 --- a/contrib/tag_editcloud/main.php +++ b/contrib/tag_editcloud/main.php @@ -12,7 +12,7 @@ * colorize used tags in cloud || always show used tags in front of cloud * theme junk */ -class TagEditCloud extends SimpleExtension { +class TagEditCloud extends Extension { public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event) { global $config; diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php index e83fd2c0..2a6d45ca 100644 --- a/contrib/tag_history/main.php +++ b/contrib/tag_history/main.php @@ -5,7 +5,7 @@ * Description: Keep a record of tag changes, and allows you to revert changes. */ -class Tag_History extends SimpleExtension { +class Tag_History extends Extension { // in before tags are actually set, so that "get current tags" works public function get_priority() {return 40;} diff --git a/contrib/tagger/main.php b/contrib/tagger/main.php index 3f2256f9..076457b6 100644 --- a/contrib/tagger/main.php +++ b/contrib/tagger/main.php @@ -6,7 +6,7 @@ * Do not remove this notice. */ -class Tagger extends SimpleExtension { +class Tagger extends Extension { public function onDisplayingImage(DisplayingImageEvent $event) { global $page, $config, $user; @@ -32,7 +32,7 @@ class Tagger extends SimpleExtension { } // Tagger AJAX back-end -class TaggerXML extends SimpleExtension { +class TaggerXML extends Extension { public function get_priority() {return 10;} public function onPageRequest(PageRequestEvent $event) { diff --git a/contrib/tips/main.php b/contrib/tips/main.php index bf6ced29..41cc7823 100644 --- a/contrib/tips/main.php +++ b/contrib/tips/main.php @@ -8,7 +8,7 @@ * Formatting is done with HTML */ -class Tips extends SimpleExtension { +class Tips extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; diff --git a/contrib/twitter_soc/main.php b/contrib/twitter_soc/main.php index 9f7bed06..90f60658 100644 --- a/contrib/twitter_soc/main.php +++ b/contrib/twitter_soc/main.php @@ -6,7 +6,7 @@ * Description: Show a twitter feed with the Sea of Clouds script */ -class TwitterSoc extends SimpleExtension { +class TwitterSoc extends Extension { public function onPostListBuilding(PostListBuildingEvent $event) { global $config, $page; if(strlen($config->get_string("twitter_soc_username")) > 0) { diff --git a/contrib/update/main.php b/contrib/update/main.php index a2ac7ad6..3a2f9a11 100644 --- a/contrib/update/main.php +++ b/contrib/update/main.php @@ -6,7 +6,7 @@ * License: GPLv2 * Description: Shimmie updater! */ -class Update extends SimpleExtension { +class Update extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string("update_url", "http://nodeload.github.com/shish/shimmie2/zipball/master"); //best to avoid using https diff --git a/contrib/wiki/main.php b/contrib/wiki/main.php index 9b5df534..ff7da165 100644 --- a/contrib/wiki/main.php +++ b/contrib/wiki/main.php @@ -53,7 +53,7 @@ class WikiPage { } } -class Wiki extends SimpleExtension { +class Wiki extends Extension { public function onInitExt(InitExtEvent $event) { global $database; global $config; diff --git a/contrib/word_filter/main.php b/contrib/word_filter/main.php index 5e9e8acb..df13e73f 100644 --- a/contrib/word_filter/main.php +++ b/contrib/word_filter/main.php @@ -6,7 +6,7 @@ * Description: Simple search and replace */ -class WordFilter extends SimpleExtension { +class WordFilter extends Extension { // before emoticon filter public function get_priority() {return 40;} diff --git a/core/extension.class.php b/core/extension.class.php index b54956de..6798df29 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -13,20 +13,14 @@ * $formatted_text = $tfe->formatted; * \endcode * - * An extension is something which is capable of reacting to events. They - * register themselves using the add_event_listener() function, after which - * events will be sent to the object's recieve_event() function. - * - * SimpleExtension subclasses are slightly different -- they are registered - * automatically, and events are sent to a named method, eg PageRequestEvent - * will be sent to onPageRequest() + * An extension is something which is capable of reacting to events. * * * \page hello The Hello World Extension * * \code * // ext/hello/main.php - * public class Hello extends SimpleExtension { + * public class Hello extends Extension { * public void onPageRequest(PageRequestEvent $event) { * global $page, $user; * $this->theme->display_hello($page, $user); @@ -62,33 +56,17 @@ * */ -/** - * A generic extension class, for subclassing - */ -interface Extension { - public function receive_event(Event $event); - public function get_priority(); -} - /** * send_event(BlahEvent()) -> onBlah($event) * * Also loads the theme object into $this->theme if available * - * index.php will load all SimpleExtension subclasses, - * so no need for register_extension(new Foo()) - * - * Automatic registration is done with priority returned by get_priority() - * - * Hopefully this removes as much copy & paste code from the extension - * files as possible~ - * - * The original concept came from Artanis's SimpleExtension extension + * The original concept came from Artanis's Extension extension * --> http://github.com/Artanis/simple-extension/tree/master * Then re-implemented by Shish after he broke the forum and couldn't * find the thread where the original was posted >_< */ -abstract class SimpleExtension implements Extension { +abstract class Extension { var $theme; var $_child; @@ -100,15 +78,6 @@ abstract class SimpleExtension implements Extension { if(is_null($this->theme)) $this->theme = get_theme_object($child, false); } - public function receive_event(Event $event) { - $name = get_class($event); - // this is rather clever.. - $name = "on".str_replace("Event", "", $name); - if(method_exists($this->_child, $name)) { - $this->_child->$name($event); - } - } - public function get_priority() { return 50; } @@ -117,7 +86,7 @@ abstract class SimpleExtension implements Extension { /** * Several extensions have this in common, make a common API */ -abstract class FormatterExtension extends SimpleExtension { +abstract class FormatterExtension extends Extension { public function onTextFormatting(TextFormattingEvent $event) { $event->formatted = $this->format($event->formatted); $event->stripped = $this->strip($event->stripped); @@ -131,7 +100,7 @@ abstract class FormatterExtension extends SimpleExtension { * This too is a common class of extension with many methods in common, * so we have a base class to extend from */ -abstract class DataHandlerExtension extends SimpleExtension { +abstract class DataHandlerExtension extends Extension { public function onDataUpload(DataUploadEvent $event) { if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { if(!move_upload_to_archive($event)) return; diff --git a/core/util.inc.php b/core/util.inc.php index 3529fb87..43197f5c 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -824,6 +824,7 @@ $_event_count = 0; function send_event(Event $event) { global $_event_listeners, $_event_count; if(!isset($_event_listeners[get_class($event)])) return; + $method_name = "on".str_replace("Event", "", get_class($event)); ctx_log_start(get_class($event)); // SHIT: http://bugs.php.net/bug.php?id=35106 @@ -831,7 +832,7 @@ function send_event(Event $event) { ksort($my_event_listeners); foreach($my_event_listeners as $listener) { ctx_log_start(get_class($listener)); - $listener->receive_event($event); + $listener->$method_name($event); ctx_log_endok(); } $_event_count++; @@ -1001,7 +1002,7 @@ function _load_extensions() { if($rclass->isAbstract()) { // don't do anything } - elseif(is_subclass_of($class, "SimpleExtension")) { + elseif(is_subclass_of($class, "Extension")) { $c = new $class(); $c->i_am($c); $my_events = array(); @@ -1012,10 +1013,6 @@ function _load_extensions() { } add_event_listener($c, $c->get_priority(), $my_events); } - elseif(is_subclass_of($class, "Extension")) { - $c = new $class(); - add_event_listener($c, $c->get_priority(), $all_events); - } } if(COMPILE_ELS) { @@ -1024,13 +1021,10 @@ function _load_extensions() { foreach(get_declared_classes() as $class) { $rclass = new ReflectionClass($class); if($rclass->isAbstract()) {} - elseif(is_subclass_of($class, "SimpleExtension")) { + elseif(is_subclass_of($class, "Extension")) { $p .= "\$$class = new $class(); "; $p .= "\${$class}->i_am(\$$class);\n"; } - elseif(is_subclass_of($class, "Extension")) { - $p .= "\$$class = new $class();\n"; - } } $p .= "\$_event_listeners = array(\n"; diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 7a246144..cfbf1777 100755 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -22,7 +22,7 @@ class AddAliasEvent extends Event { class AddAliasException extends SCoreException {} -class AliasEditor extends SimpleExtension { +class AliasEditor extends Extension { public function onPageRequest(PageRequestEvent $event) { global $config, $database, $page, $user; diff --git a/ext/comment/main.php b/ext/comment/main.php index b64a8984..451cbd51 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -60,7 +60,7 @@ class Comment { } } -class CommentList extends SimpleExtension { +class CommentList extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; $config->set_default_bool('comment_anon', true); diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 3500401c..911274e5 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -87,7 +87,7 @@ class ExtensionInfo { } } -class ExtManager extends SimpleExtension { +class ExtManager extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page, $user; if($event->page_matches("ext_manager")) { diff --git a/ext/handle_404/main.php b/ext/handle_404/main.php index b7e80aa0..ed01cec1 100644 --- a/ext/handle_404/main.php +++ b/ext/handle_404/main.php @@ -8,7 +8,7 @@ * Description: Shows an error message when the user views a page with no content */ -class Handle404 extends SimpleExtension { +class Handle404 extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page; // hax. diff --git a/ext/image/main.php b/ext/image/main.php index d0288131..b6d842b0 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -129,7 +129,7 @@ class ParseLinkTemplateEvent extends Event { /** * A class to handle adding / getting / removing image files from the disk. */ -class ImageIO extends SimpleExtension { +class ImageIO extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_int('thumb_width', 192); diff --git a/ext/index/main.php b/ext/index/main.php index 14a0ac5c..3494edef 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -128,7 +128,7 @@ class PostListBuildingEvent extends Event { } } -class Index extends SimpleExtension { +class Index extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_int("index_width", 3); diff --git a/ext/mail/main.php b/ext/mail/main.php index 9bf09169..fb3aec97 100644 --- a/ext/mail/main.php +++ b/ext/mail/main.php @@ -7,7 +7,7 @@ * Description: Provides an interface for sending and receiving mail. */ -class Mail extends SimpleExtension { +class Mail extends Extension { public function onSetupBuilding(SetupBuildingEvent $event) { $sb = new SetupBlock("Mailing Options"); $sb->add_text_option("mail_sub", "
Subject prefix: "); @@ -26,7 +26,7 @@ class Mail extends SimpleExtension { $config->set_default_string("mail_fot", "".$config->get_string("site_title").""); } } -class MailTest extends SimpleExtension { +class MailTest extends Extension { public function onPageRequest(PageRequestEvent $event) { if($event->page_matches("mail/test")) { global $page; diff --git a/ext/setup/main.php b/ext/setup/main.php index 4e5b950a..40551e5c 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -161,7 +161,7 @@ class SetupBlock extends Block { } // }}} -class Setup extends SimpleExtension { +class Setup extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_string("title", "Shimmie"); diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 184a5dba..bdae3ec0 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -55,7 +55,7 @@ class LockSetEvent extends Event { } } -class TagEdit extends SimpleExtension { +class TagEdit extends Extension { public function onPageRequest(PageRequestEvent $event) { global $user, $page; if($event->page_matches("tag_edit")) { diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index c30aacb6..d21de882 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -5,7 +5,7 @@ * Description: Show the tags in various ways */ -class TagList extends SimpleExtension { +class TagList extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_int("tag_list_length", 15); diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 35854e1d..0ddc9401 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -6,7 +6,7 @@ * Visibility: admin */ -class Upgrade extends SimpleExtension { +class Upgrade extends Extension { public function onInitExt(InitExtEvent $event) { global $config, $database; diff --git a/ext/upload/main.php b/ext/upload/main.php index 938a27fa..ae719f4e 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -41,7 +41,7 @@ class UploadException extends SCoreException {} * All files that are uploaded to the site are handled through this class. * This also includes transloaded files as well. */ -class Upload extends SimpleExtension { +class Upload extends Extension { // early, so it can stop the DataUploadEvent before any data handlers see it public function get_priority() {return 40;} diff --git a/ext/user/main.php b/ext/user/main.php index 678b5b9c..96f5ac69 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -42,7 +42,7 @@ class UserCreationEvent extends Event { class UserCreationException extends SCoreException {} -class UserPage extends SimpleExtension { +class UserPage extends Extension { public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_bool("login_signup_enabled", true); diff --git a/ext/view/main.php b/ext/view/main.php index 3fa700f6..4c4eb074 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -66,7 +66,7 @@ class ImageAdminBlockBuildingEvent extends Event { } } -class ViewImage extends SimpleExtension { +class ViewImage extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page, $user;