make things use SimpleExtension
This commit is contained in:
parent
e29d475dea
commit
5ab092946a
@ -13,26 +13,24 @@
|
||||
* tagged "holiday 2008")
|
||||
*/
|
||||
|
||||
class BulkAdd implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("bulk_add")) {
|
||||
if($event->user->is_admin() && isset($_POST['dir'])) {
|
||||
class BulkAdd extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
if($event->page_matches("bulk_add")) {
|
||||
if($user->is_admin() && isset($_POST['dir'])) {
|
||||
set_time_limit(0);
|
||||
|
||||
$this->add_dir($_POST['dir']);
|
||||
$this->theme->display_upload_results($event->page);
|
||||
$this->theme->display_upload_results($page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof AdminBuildingEvent) {
|
||||
public function onAdminBuilding($event) {
|
||||
global $page;
|
||||
$this->theme->display_admin_block($page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function add_image($tmpname, $filename, $tags) {
|
||||
if(file_exists($tmpname)) {
|
||||
@ -97,5 +95,4 @@ class BulkAdd implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new BulkAdd());
|
||||
?>
|
||||
|
@ -10,14 +10,13 @@
|
||||
* <br>7-zip: <code>7zr x -o"%d" "%f"</code>
|
||||
*/
|
||||
|
||||
class ArchiveFileHandler implements Extension {
|
||||
public function receive_event(Event $event) {
|
||||
if($event instanceof InitExtEvent) {
|
||||
class ArchiveFileHandler extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config;
|
||||
$config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"');
|
||||
}
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Archive Handler Options");
|
||||
$sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
|
||||
$sb->add_text_option("archive_extract_command", "<br>Extraction command: ");
|
||||
@ -25,7 +24,8 @@ class ArchiveFileHandler implements Extension {
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
if(($event instanceof DataUploadEvent) && $this->supported_ext($event->type)) {
|
||||
public function onDataUpload($event) {
|
||||
if($this->supported_ext($event->type)) {
|
||||
global $config;
|
||||
$tmp = sys_get_temp_dir();
|
||||
$tmpdir = "$tmp/shimmie-archive-{$event->hash}";
|
||||
@ -38,6 +38,7 @@ class ArchiveFileHandler implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function supported_ext($ext) {
|
||||
$exts = array("zip");
|
||||
return array_contains($exts, strtolower($ext));
|
||||
@ -100,5 +101,4 @@ class ArchiveFileHandler implements Extension {
|
||||
// $this->theme->add_status("Adding $subdir", $list);
|
||||
}
|
||||
}
|
||||
add_event_listener(new ArchiveFileHandler());
|
||||
?>
|
||||
|
@ -5,13 +5,9 @@
|
||||
* Description: Handle Flash files
|
||||
*/
|
||||
|
||||
class FlashFileHandler implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof DataUploadEvent) && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||
class FlashFileHandler extends SimpleExtension {
|
||||
public function onDataUpload($event) {
|
||||
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||
$hash = $event->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
if(!move_upload_to_archive($event)) return;
|
||||
@ -24,19 +20,25 @@ class FlashFileHandler implements Extension {
|
||||
}
|
||||
send_event(new ImageAdditionEvent($event->user, $image));
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) {
|
||||
public function onThumbnailGeneration($event) {
|
||||
if($this->supported_ext($event->type)) {
|
||||
$hash = $event->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
// FIXME: scale image, as not all boards use 192x192
|
||||
copy("ext/handle_flash/thumb.jpg", "thumbs/$ha/$hash");
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) {
|
||||
public function onDisplayingImage($event) {
|
||||
global $page;
|
||||
if($this->supported_ext($event->image->ext)) {
|
||||
$this->theme->display_image($event->page, $event->image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function supported_ext($ext) {
|
||||
$exts = array("swf");
|
||||
return array_contains($exts, strtolower($ext));
|
||||
@ -127,5 +129,4 @@ class FlashFileHandler implements Extension {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
add_event_listener(new FlashFileHandler());
|
||||
?>
|
||||
|
@ -5,13 +5,9 @@
|
||||
* Description: Handle windows icons
|
||||
*/
|
||||
|
||||
class IcoFileHandler implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof DataUploadEvent) && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||
class IcoFileHandler extends SimpleExtension {
|
||||
public function onDataUpload($event) {
|
||||
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||
$hash = $event->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
if(!move_upload_to_archive($event)) return;
|
||||
@ -22,29 +18,35 @@ class IcoFileHandler implements Extension {
|
||||
}
|
||||
send_event(new ImageAdditionEvent($event->user, $image));
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) {
|
||||
public function onThumbnailGeneration($event) {
|
||||
if($this->supported_ext($event->type)) {
|
||||
$this->create_thumb($event->hash);
|
||||
}
|
||||
|
||||
if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) {
|
||||
$this->theme->display_image($event->page, $event->image);
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("get_ico")) {
|
||||
global $config;
|
||||
global $database;
|
||||
public function onDisplayingImage($event) {
|
||||
if($this->supported_ext($event->image->ext)) {
|
||||
$this->theme->display_image($event->page, $event->image);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $config, $database;
|
||||
if($event->page_matches("get_ico")) {
|
||||
$id = int_escape($event->get_arg(0));
|
||||
$image = Image::by_id($id);
|
||||
$hash = $image->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
|
||||
$event->page->set_type("image/x-icon");
|
||||
$event->page->set_mode("data");
|
||||
$event->page->set_data(file_get_contents("images/$ha/$hash"));
|
||||
$page->set_type("image/x-icon");
|
||||
$page->set_mode("data");
|
||||
$page->set_data(file_get_contents("images/$ha/$hash"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function supported_ext($ext) {
|
||||
$exts = array("ico", "ani", "cur");
|
||||
return array_contains($exts, strtolower($ext));
|
||||
@ -106,5 +108,4 @@ class IcoFileHandler implements Extension {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
add_event_listener(new IcoFileHandler());
|
||||
?>
|
||||
|
@ -14,20 +14,22 @@
|
||||
* alongside the default choices.
|
||||
*/
|
||||
|
||||
class Home implements Extension {
|
||||
var $theme;
|
||||
class Home extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
global $config, $page;
|
||||
if($event->page_matches("home")) {
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$sitename = $config->get_string('title');
|
||||
$theme_name = $config->get_string('theme');
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
$body = $this->get_body();
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("home"))
|
||||
{
|
||||
// this is a request to display this page so output the page.
|
||||
$this->output_pages($page);
|
||||
$this->theme->display_page($page, $sitename, $data_href, $theme_name, $body);
|
||||
}
|
||||
if($event instanceof SetupBuildingEvent)
|
||||
{
|
||||
}
|
||||
|
||||
public function onSetupBuilding($event) {
|
||||
$counters = array();
|
||||
foreach(glob("ext/home/counters/*") as $counter_dirname) {
|
||||
$name = str_replace("ext/home/counters/", "", $counter_dirname);
|
||||
@ -41,7 +43,7 @@ class Home implements Extension {
|
||||
$sb->add_label("<br>Note: page accessed via /home");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function get_body()
|
||||
{
|
||||
@ -75,21 +77,5 @@ class Home implements Extension {
|
||||
|
||||
return $this->theme->build_body($sitename, $main_links, $contact_link, $num_comma, $counter_text);
|
||||
}
|
||||
|
||||
private function output_pages($page)
|
||||
{
|
||||
// output a sectionalised list of all the main pages on the site.
|
||||
global $config;
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$sitename = $config->get_string('title');
|
||||
$theme_name = $config->get_string('theme');
|
||||
|
||||
$body = $this->get_body();
|
||||
|
||||
$this->theme->display_page($page, $sitename, $data_href, $theme_name, $body);
|
||||
}
|
||||
|
||||
}
|
||||
add_event_listener(new Home());
|
||||
?>
|
||||
|
@ -8,25 +8,18 @@
|
||||
* Any HTML is allowed
|
||||
*/
|
||||
|
||||
class News implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof PostListBuildingEvent) {
|
||||
class News extends SimpleExtension {
|
||||
public function onPostListBuilding($event) {
|
||||
global $config, $page;
|
||||
if(strlen($config->get_string("news_text")) > 0) {
|
||||
$this->theme->display_news($page, $config->get_string("news_text"));
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("News");
|
||||
$sb->add_longtext_option("news_text");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new News());
|
||||
?>
|
||||
|
@ -20,29 +20,39 @@ class SendPMEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
class PM implements Extension {
|
||||
var $theme;
|
||||
class PM extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof InitExtEvent) {
|
||||
// shortcut to latest
|
||||
if($config->get_int("pm_version") < 1) {
|
||||
$this->install();
|
||||
$database->create_table("private_message", "
|
||||
id SCORE_AIPK,
|
||||
from_id INTEGER NOT NULL,
|
||||
from_ip SCORE_INET NOT NULL,
|
||||
to_id INTEGER NOT NULL,
|
||||
sent_date DATETIME NOT NULL,
|
||||
subject VARCHAR(64) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
INDEX (to_id)
|
||||
");
|
||||
$config->set_int("pm_version", 1);
|
||||
log_info("pm", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if($event instanceof UserBlockBuildingEvent) {
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if(!$user->is_anonymous()) {
|
||||
$event->add_link("Private Messages", make_link("pm"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if($event instanceof UserPageBuildingEvent) {
|
||||
public function onUserPageBuilding($event) {
|
||||
global $page, $user;
|
||||
$duser = $event->display_user;
|
||||
if(!$user->is_anonymous() && !$duser->is_anonymous()) {
|
||||
if(($user->id == $duser->id) || $user->is_admin()) {
|
||||
@ -54,7 +64,8 @@ class PM implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("pm")) {
|
||||
public function onPageRequest($event) {
|
||||
if($event->page_matches("pm")) {
|
||||
if(!$user->is_anonymous()) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "read":
|
||||
@ -100,8 +111,9 @@ class PM implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof SendPMEvent) {
|
||||
public function onSendPM($event) {
|
||||
$database->execute("
|
||||
INSERT INTO private_message(
|
||||
from_id, from_ip, to_id,
|
||||
@ -112,29 +124,7 @@ class PM implements Extension {
|
||||
);
|
||||
log_info("pm", "Sent PM to User #$to_id");
|
||||
}
|
||||
}
|
||||
|
||||
protected function install() {
|
||||
global $config, $database;
|
||||
|
||||
// shortcut to latest
|
||||
if($config->get_int("pm_version") < 1) {
|
||||
$database->create_table("private_message", "
|
||||
id SCORE_AIPK,
|
||||
from_id INTEGER NOT NULL,
|
||||
from_ip SCORE_INET NOT NULL,
|
||||
to_id INTEGER NOT NULL,
|
||||
sent_date DATETIME NOT NULL,
|
||||
subject VARCHAR(64) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
INDEX (to_id)
|
||||
");
|
||||
$config->set_int("pm_version", 1);
|
||||
}
|
||||
|
||||
log_info("pm", "extension installed");
|
||||
}
|
||||
|
||||
private function get_pms(User $user) {
|
||||
global $database;
|
||||
@ -147,5 +137,4 @@ class PM implements Extension {
|
||||
", array($user->id));
|
||||
}
|
||||
}
|
||||
add_event_listener(new PM());
|
||||
?>
|
||||
|
@ -6,29 +6,18 @@
|
||||
* Description: Self explanitory
|
||||
*/
|
||||
|
||||
class RSS_Comments implements Extension {
|
||||
// event handling {{{
|
||||
public function receive_event(Event $event) {
|
||||
if($event instanceof PostListBuildingEvent) {
|
||||
global $page;
|
||||
global $config;
|
||||
class RSS_Comments extends SimpleExtension {
|
||||
public function onPostListBuilding($event) {
|
||||
global $config, $page;
|
||||
$title = $config->get_string('title');
|
||||
|
||||
$page->add_header("<link rel=\"alternate\" type=\"application/rss+xml\" ".
|
||||
"title=\"$title - Comments\" href=\"".make_link("rss/comments")."\" />");
|
||||
}
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("rss")) {
|
||||
if($event->get_arg(0) == 'comments') {
|
||||
global $database;
|
||||
$this->do_rss($database);
|
||||
}
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
// output {{{
|
||||
private function do_rss($database) {
|
||||
global $page;
|
||||
global $config;
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $config, $database, $page;
|
||||
if($event->page_matches("rss/comments")) {
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/rss+xml");
|
||||
|
||||
@ -83,7 +72,6 @@ class RSS_Comments implements Extension {
|
||||
EOD;
|
||||
$page->set_data($xml);
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
}
|
||||
add_event_listener(new RSS_Comments());
|
||||
?>
|
||||
|
@ -6,12 +6,9 @@
|
||||
* Description: Self explanitory
|
||||
*/
|
||||
|
||||
class RSS_Images implements Extension {
|
||||
// event handling {{{
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
|
||||
if($event instanceof PostListBuildingEvent) {
|
||||
class RSS_Images extends SimpleExtension {
|
||||
public function onPostListBuilding($event) {
|
||||
global $config, $page;
|
||||
$title = $config->get_string('title');
|
||||
|
||||
if(count($event->search_terms) > 0) {
|
||||
@ -25,7 +22,8 @@ class RSS_Images implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("rss/images")) {
|
||||
public function onPageRequest($event) {
|
||||
if($event->page_matches("rss/images")) {
|
||||
$page_number = 0;
|
||||
$search_terms = array();
|
||||
|
||||
@ -46,8 +44,8 @@ class RSS_Images implements Extension {
|
||||
$this->do_rss($images, $search_terms, $page_number);
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
// output {{{
|
||||
|
||||
|
||||
private function do_rss($images, $search_terms, $page_number) {
|
||||
global $page;
|
||||
global $config;
|
||||
@ -113,7 +111,5 @@ class RSS_Images implements Extension {
|
||||
</rss>";
|
||||
$page->set_data($xml);
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
add_event_listener(new RSS_Images());
|
||||
?>
|
||||
|
@ -21,14 +21,10 @@ class TestFinder extends TestSuite {
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleSCoreTest implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("test")) {
|
||||
class SimpleSCoreTest extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
global $page;
|
||||
if($event->page_matches("test")) {
|
||||
$page->set_title("Test Results");
|
||||
$page->set_heading("Test Results");
|
||||
$page->add_block(new NavBlock());
|
||||
@ -36,13 +32,13 @@ class SimpleSCoreTest implements Extension {
|
||||
$all = new TestFinder($event->get_arg(0));
|
||||
$all->run(new SCoreReporter($page));
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof UserBlockBuildingEvent) {
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Run Tests", make_link("test/all"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new SimpleSCoreTest());
|
||||
?>
|
||||
|
@ -6,24 +6,16 @@
|
||||
* Description: Scales down too-large images using browser based scaling
|
||||
*/
|
||||
|
||||
class Zoom implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if($this->theme == null) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof DisplayingImageEvent) {
|
||||
class Zoom extends SimpleExtension {
|
||||
public function onDisplayingImage($event) {
|
||||
global $config, $page;
|
||||
$this->theme->display_zoomer($page, $event->image, $config->get_bool("image_zoom", false));
|
||||
}
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Image Zoom");
|
||||
$sb->add_bool_option("image_zoom", "Zoom by default: ");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
add_event_listener(new Zoom());
|
||||
?>
|
||||
|
@ -1,14 +1,7 @@
|
||||
<?php
|
||||
|
||||
class BBCode implements Extension {
|
||||
public function receive_event(Event $event) {
|
||||
if($event instanceof TextFormattingEvent) {
|
||||
$event->formatted = $this->bbcode_to_html($event->formatted);
|
||||
$event->stripped = $this->bbcode_to_text($event->stripped);
|
||||
}
|
||||
}
|
||||
|
||||
private function bbcode_to_html($text) {
|
||||
class BBCode extends FormatterExtension {
|
||||
public function format($text) {
|
||||
$text = $this->extract_code($text);
|
||||
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
|
||||
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
|
||||
@ -42,7 +35,7 @@ class BBCode implements Extension {
|
||||
return $text;
|
||||
}
|
||||
|
||||
private function bbcode_to_text($text) {
|
||||
public function strip($text) {
|
||||
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text);
|
||||
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text);
|
||||
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text);
|
||||
@ -65,6 +58,7 @@ class BBCode implements Extension {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
private function filter_spoiler($text) {
|
||||
return str_replace(
|
||||
array("[spoiler]","[/spoiler]"),
|
||||
|
@ -68,14 +68,10 @@ class ExtensionInfo { // {{{
|
||||
}
|
||||
} // }}}
|
||||
|
||||
class ExtManager implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("ext_manager")) {
|
||||
class ExtManager extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
if($event->page_matches("ext_manager")) {
|
||||
if($user->is_admin()) {
|
||||
if($event->get_arg(0) == "set") {
|
||||
if(is_writable("ext")) {
|
||||
@ -97,18 +93,20 @@ class ExtManager implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("ext_doc")) {
|
||||
if($event->page_matches("ext_doc")) {
|
||||
$ext = $event->get_arg(0);
|
||||
$info = new ExtensionInfo("contrib/$ext/main.php");
|
||||
$this->theme->display_doc($page, $info);
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof UserBlockBuildingEvent) {
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Extension Manager", make_link("ext_manager"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function get_extensions() {
|
||||
$extensions = array();
|
||||
@ -152,5 +150,4 @@ class ExtManager implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new ExtManager());
|
||||
?>
|
||||
|
@ -74,10 +74,8 @@ class ParseLinkTemplateEvent extends Event {
|
||||
* A class to handle adding / getting / removing image
|
||||
* files from the disk
|
||||
*/
|
||||
class ImageIO implements Extension {
|
||||
// event handling {{{
|
||||
public function receive_event(Event $event) {
|
||||
if($event instanceof InitExtEvent) {
|
||||
class ImageIO extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config;
|
||||
$config->set_default_int('thumb_width', 192);
|
||||
$config->set_default_int('thumb_height', 192);
|
||||
@ -90,7 +88,7 @@ class ImageIO implements Extension {
|
||||
$config->set_default_string('upload_collision_handler', 'error');
|
||||
}
|
||||
|
||||
if($event instanceof PageRequestEvent) {
|
||||
public function onPageRequest($event) {
|
||||
$num = $event->get_arg(0);
|
||||
$matches = array();
|
||||
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
|
||||
@ -105,16 +103,16 @@ class ImageIO implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof ImageAdditionEvent) {
|
||||
public function onImageAddition($event) {
|
||||
$error = $this->add_image($event->image);
|
||||
if(!empty($error)) throw new UploadException($error);
|
||||
}
|
||||
|
||||
if($event instanceof ImageDeletionEvent) {
|
||||
public function onImageDeletion($event) {
|
||||
$event->image->delete();
|
||||
}
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Image Options");
|
||||
$sb->position = 30;
|
||||
// advanced only
|
||||
@ -143,8 +141,8 @@ class ImageIO implements Extension {
|
||||
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
|
||||
// add image {{{
|
||||
private function add_image($image) {
|
||||
global $page;
|
||||
@ -247,5 +245,4 @@ class ImageIO implements Extension {
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
add_event_listener(new ImageIO());
|
||||
?>
|
||||
|
@ -34,20 +34,17 @@ class PostListBuildingEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
class Index implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof InitExtEvent) {
|
||||
class Index extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config;
|
||||
$config->set_default_int("index_width", 3);
|
||||
$config->set_default_int("index_height", 4);
|
||||
$config->set_default_bool("index_tips", true);
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("post/list")) {
|
||||
public function onPageRequest($event) {
|
||||
global $config, $database, $page, $user;
|
||||
if($event->page_matches("post/list")) {
|
||||
if(isset($_GET['search'])) {
|
||||
$search = url_escape(trim($_GET['search']));
|
||||
if(empty($search)) {
|
||||
@ -92,8 +89,9 @@ class Index implements Extension {
|
||||
$this->theme->display_page($page, $images);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Index Options");
|
||||
$sb->position = 20;
|
||||
|
||||
@ -106,7 +104,7 @@ class Index implements Extension {
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
if($event instanceof SearchTermParseEvent) {
|
||||
public function onSearchTermParse($event) {
|
||||
$matches = array();
|
||||
if(preg_match("/^size(<|>|<=|>=|=)(\d+)x(\d+)$/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
@ -141,7 +139,5 @@ class Index implements Extension {
|
||||
$img_search->append(new Querylet("images.posted LIKE '%$val%'"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Index());
|
||||
?>
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
class LoadExtData implements Extension {
|
||||
public function receive_event(Event $event) {
|
||||
if($event instanceof PageRequestEvent) {
|
||||
global $page, $config;
|
||||
|
||||
class LoadExtData extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
global $page;
|
||||
$data_href = get_base_href();
|
||||
|
||||
$css_files = glob("ext/*/style.css");
|
||||
@ -20,7 +18,5 @@ class LoadExtData implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new LoadExtData());
|
||||
?>
|
||||
|
@ -135,14 +135,9 @@ class SetupBlock extends Block {
|
||||
}
|
||||
// }}}
|
||||
|
||||
class Setup implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof InitExtEvent) {
|
||||
class Setup extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config;
|
||||
$config->set_default_string("title", "Shimmie");
|
||||
$config->set_default_string("front_page", "post/list");
|
||||
$config->set_default_string("main_page", "post/list");
|
||||
@ -150,12 +145,15 @@ class Setup implements Extension {
|
||||
$config->set_default_string("theme", "default");
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("nicetest")) {
|
||||
public function onPageRequest($event) {
|
||||
global $config, $page, $user;
|
||||
|
||||
if($event->page_matches("nicetest")) {
|
||||
$page->set_mode("data");
|
||||
$page->set_data("ok");
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("setup")) {
|
||||
if($event->page_matches("setup")) {
|
||||
if(!$user->is_admin()) {
|
||||
$this->theme->display_permission_denied($page);
|
||||
}
|
||||
@ -177,8 +175,9 @@ class Setup implements Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof SetupBuildingEvent) {
|
||||
public function onSetupBuilding($event) {
|
||||
$themes = array();
|
||||
foreach(glob("themes/*") as $theme_dirname) {
|
||||
$name = str_replace("themes/", "", $theme_dirname);
|
||||
@ -229,7 +228,7 @@ class Setup implements Extension {
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
if($event instanceof ConfigSaveEvent) {
|
||||
public function onConfigSave($event) {
|
||||
global $config;
|
||||
foreach($_POST as $_name => $junk) {
|
||||
if(substr($_name, 0, 6) == "_type_") {
|
||||
@ -245,12 +244,11 @@ class Setup implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof UserBlockBuildingEvent) {
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Board Config", make_link("setup"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Setup());
|
||||
?>
|
||||
|
@ -101,6 +101,7 @@ class TagEdit implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function can_tag() {
|
||||
global $config, $user;
|
||||
return $config->get_bool("tag_edit_anon") || !$user->is_anonymous();
|
||||
|
@ -59,6 +59,7 @@ class ImageAdminBlockBuildingEvent extends Event {
|
||||
$this->parts[$position] = $html;
|
||||
}
|
||||
}
|
||||
|
||||
class ViewImage implements Extension {
|
||||
var $theme;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user