make things use SimpleExtension
This commit is contained in:
parent
8dd3f8cbc0
commit
389eed5867
@ -13,27 +13,25 @@
|
|||||||
* tagged "holiday 2008")
|
* tagged "holiday 2008")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BulkAdd implements Extension {
|
class BulkAdd extends SimpleExtension {
|
||||||
var $theme;
|
public function onPageRequest($event) {
|
||||||
|
global $page, $user;
|
||||||
public function receive_event(Event $event) {
|
if($event->page_matches("bulk_add")) {
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
if($user->is_admin() && isset($_POST['dir'])) {
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("bulk_add")) {
|
|
||||||
if($event->user->is_admin() && isset($_POST['dir'])) {
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
$this->add_dir($_POST['dir']);
|
$this->add_dir($_POST['dir']);
|
||||||
$this->theme->display_upload_results($event->page);
|
$this->theme->display_upload_results($page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof AdminBuildingEvent) {
|
|
||||||
global $page;
|
|
||||||
$this->theme->display_admin_block($page);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onAdminBuilding($event) {
|
||||||
|
global $page;
|
||||||
|
$this->theme->display_admin_block($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function add_image($tmpname, $filename, $tags) {
|
private function add_image($tmpname, $filename, $tags) {
|
||||||
if(file_exists($tmpname)) {
|
if(file_exists($tmpname)) {
|
||||||
global $user;
|
global $user;
|
||||||
@ -97,5 +95,4 @@ class BulkAdd implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new BulkAdd());
|
|
||||||
?>
|
?>
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
* <br>7-zip: <code>7zr x -o"%d" "%f"</code>
|
* <br>7-zip: <code>7zr x -o"%d" "%f"</code>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ArchiveFileHandler implements Extension {
|
class ArchiveFileHandler extends SimpleExtension {
|
||||||
public function receive_event(Event $event) {
|
public function onInitExt($event) {
|
||||||
if($event instanceof InitExtEvent) {
|
global $config;
|
||||||
global $config;
|
$config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"');
|
||||||
$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 = new SetupBlock("Archive Handler Options");
|
||||||
$sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
|
$sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
|
||||||
$sb->add_text_option("archive_extract_command", "<br>Extraction command: ");
|
$sb->add_text_option("archive_extract_command", "<br>Extraction command: ");
|
||||||
$sb->add_label("<br>%f for archive, %d for temporary directory");
|
$sb->add_label("<br>%f for archive, %d for temporary directory");
|
||||||
$event->panel->add_block($sb);
|
$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;
|
global $config;
|
||||||
$tmp = sys_get_temp_dir();
|
$tmp = sys_get_temp_dir();
|
||||||
$tmpdir = "$tmp/shimmie-archive-{$event->hash}";
|
$tmpdir = "$tmp/shimmie-archive-{$event->hash}";
|
||||||
@ -38,6 +38,7 @@ class ArchiveFileHandler implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function supported_ext($ext) {
|
private function supported_ext($ext) {
|
||||||
$exts = array("zip");
|
$exts = array("zip");
|
||||||
return array_contains($exts, strtolower($ext));
|
return array_contains($exts, strtolower($ext));
|
||||||
@ -100,5 +101,4 @@ class ArchiveFileHandler implements Extension {
|
|||||||
// $this->theme->add_status("Adding $subdir", $list);
|
// $this->theme->add_status("Adding $subdir", $list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new ArchiveFileHandler());
|
|
||||||
?>
|
?>
|
||||||
|
@ -5,13 +5,9 @@
|
|||||||
* Description: Handle Flash files
|
* Description: Handle Flash files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FlashFileHandler implements Extension {
|
class FlashFileHandler extends SimpleExtension {
|
||||||
var $theme;
|
public function onDataUpload($event) {
|
||||||
|
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
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)) {
|
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
if(!move_upload_to_archive($event)) return;
|
if(!move_upload_to_archive($event)) return;
|
||||||
@ -24,19 +20,25 @@ class FlashFileHandler implements Extension {
|
|||||||
}
|
}
|
||||||
send_event(new ImageAdditionEvent($event->user, $image));
|
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;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
// FIXME: scale image, as not all boards use 192x192
|
// FIXME: scale image, as not all boards use 192x192
|
||||||
copy("ext/handle_flash/thumb.jpg", "thumbs/$ha/$hash");
|
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);
|
$this->theme->display_image($event->page, $event->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function supported_ext($ext) {
|
private function supported_ext($ext) {
|
||||||
$exts = array("swf");
|
$exts = array("swf");
|
||||||
return array_contains($exts, strtolower($ext));
|
return array_contains($exts, strtolower($ext));
|
||||||
@ -127,5 +129,4 @@ class FlashFileHandler implements Extension {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new FlashFileHandler());
|
|
||||||
?>
|
?>
|
||||||
|
@ -5,13 +5,9 @@
|
|||||||
* Description: Handle windows icons
|
* Description: Handle windows icons
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class IcoFileHandler implements Extension {
|
class IcoFileHandler extends SimpleExtension {
|
||||||
var $theme;
|
public function onDataUpload($event) {
|
||||||
|
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
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)) {
|
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
if(!move_upload_to_archive($event)) return;
|
if(!move_upload_to_archive($event)) return;
|
||||||
@ -22,29 +18,35 @@ class IcoFileHandler implements Extension {
|
|||||||
}
|
}
|
||||||
send_event(new ImageAdditionEvent($event->user, $image));
|
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);
|
$this->create_thumb($event->hash);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) {
|
public function onDisplayingImage($event) {
|
||||||
|
if($this->supported_ext($event->image->ext)) {
|
||||||
$this->theme->display_image($event->page, $event->image);
|
$this->theme->display_image($event->page, $event->image);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("get_ico")) {
|
public function onPageRequest($event) {
|
||||||
global $config;
|
global $config, $database;
|
||||||
global $database;
|
if($event->page_matches("get_ico")) {
|
||||||
$id = int_escape($event->get_arg(0));
|
$id = int_escape($event->get_arg(0));
|
||||||
$image = Image::by_id($id);
|
$image = Image::by_id($id);
|
||||||
$hash = $image->hash;
|
$hash = $image->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
|
|
||||||
$event->page->set_type("image/x-icon");
|
$page->set_type("image/x-icon");
|
||||||
$event->page->set_mode("data");
|
$page->set_mode("data");
|
||||||
$event->page->set_data(file_get_contents("images/$ha/$hash"));
|
$page->set_data(file_get_contents("images/$ha/$hash"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function supported_ext($ext) {
|
private function supported_ext($ext) {
|
||||||
$exts = array("ico", "ani", "cur");
|
$exts = array("ico", "ani", "cur");
|
||||||
return array_contains($exts, strtolower($ext));
|
return array_contains($exts, strtolower($ext));
|
||||||
@ -106,5 +108,4 @@ class IcoFileHandler implements Extension {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new IcoFileHandler());
|
|
||||||
?>
|
?>
|
||||||
|
@ -14,35 +14,37 @@
|
|||||||
* alongside the default choices.
|
* alongside the default choices.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Home implements Extension {
|
class Home extends SimpleExtension {
|
||||||
var $theme;
|
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) {
|
$body = $this->get_body();
|
||||||
global $config, $database, $page, $user;
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("home"))
|
$this->theme->display_page($page, $sitename, $data_href, $theme_name, $body);
|
||||||
{
|
|
||||||
// this is a request to display this page so output the page.
|
|
||||||
$this->output_pages($page);
|
|
||||||
}
|
|
||||||
if($event instanceof SetupBuildingEvent)
|
|
||||||
{
|
|
||||||
$counters = array();
|
|
||||||
foreach(glob("ext/home/counters/*") as $counter_dirname) {
|
|
||||||
$name = str_replace("ext/home/counters/", "", $counter_dirname);
|
|
||||||
$counters[ucfirst($name)] = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sb = new SetupBlock("Home Page");
|
|
||||||
$sb->add_label("Page Links - Example: [$"."base/index|Posts]");
|
|
||||||
$sb->add_longtext_option("home_links", "<br>");
|
|
||||||
$sb->add_choice_option("home_counter", $counters, "<br>Counter: ");
|
|
||||||
$sb->add_label("<br>Note: page accessed via /home");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onSetupBuilding($event) {
|
||||||
|
$counters = array();
|
||||||
|
foreach(glob("ext/home/counters/*") as $counter_dirname) {
|
||||||
|
$name = str_replace("ext/home/counters/", "", $counter_dirname);
|
||||||
|
$counters[ucfirst($name)] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sb = new SetupBlock("Home Page");
|
||||||
|
$sb->add_label("Page Links - Example: [$"."base/index|Posts]");
|
||||||
|
$sb->add_longtext_option("home_links", "<br>");
|
||||||
|
$sb->add_choice_option("home_counter", $counters, "<br>Counter: ");
|
||||||
|
$sb->add_label("<br>Note: page accessed via /home");
|
||||||
|
$event->panel->add_block($sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function get_body()
|
private function get_body()
|
||||||
{
|
{
|
||||||
// returns just the contents of the body
|
// returns just the contents of the body
|
||||||
@ -75,21 +77,5 @@ class Home implements Extension {
|
|||||||
|
|
||||||
return $this->theme->build_body($sitename, $main_links, $contact_link, $num_comma, $counter_text);
|
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
|
* Any HTML is allowed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class News implements Extension {
|
class News extends SimpleExtension {
|
||||||
var $theme;
|
public function onPostListBuilding($event) {
|
||||||
|
global $config, $page;
|
||||||
public function receive_event(Event $event) {
|
if(strlen($config->get_string("news_text")) > 0) {
|
||||||
global $config, $database, $page, $user;
|
$this->theme->display_news($page, $config->get_string("news_text"));
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
|
||||||
|
|
||||||
if($event instanceof PostListBuildingEvent) {
|
|
||||||
if(strlen($config->get_string("news_text")) > 0) {
|
|
||||||
$this->theme->display_news($page, $config->get_string("news_text"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($event instanceof SetupBuildingEvent) {
|
|
||||||
$sb = new SetupBlock("News");
|
|
||||||
$sb->add_longtext_option("news_text");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onSetupBuilding($event) {
|
||||||
|
$sb = new SetupBlock("News");
|
||||||
|
$sb->add_longtext_option("news_text");
|
||||||
|
$event->panel->add_block($sb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new News());
|
|
||||||
?>
|
?>
|
||||||
|
@ -14,47 +14,58 @@ class SendPMEvent extends Event {
|
|||||||
public function __construct($from_id, $from_ip, $to_id, $subject, $message) {
|
public function __construct($from_id, $from_ip, $to_id, $subject, $message) {
|
||||||
$this->from_id = $from_id;
|
$this->from_id = $from_id;
|
||||||
$this->from_ip = $from_ip;
|
$this->from_ip = $from_ip;
|
||||||
$this->to_id = $to_id;
|
$this->to_id = $to_id;
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PM implements Extension {
|
class PM extends SimpleExtension {
|
||||||
var $theme;
|
public function onInitExt($event) {
|
||||||
|
global $config, $database;
|
||||||
|
|
||||||
public function receive_event(Event $event) {
|
// shortcut to latest
|
||||||
global $config, $database, $page, $user;
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
/*
|
||||||
|
public function onUserBlockBuilding($event) {
|
||||||
|
global $user;
|
||||||
|
if(!$user->is_anonymous()) {
|
||||||
|
$event->add_link("Private Messages", make_link("pm"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if($event instanceof InitExtEvent) {
|
public function onUserPageBuilding($event) {
|
||||||
if($config->get_int("pm_version") < 1) {
|
global $page, $user;
|
||||||
$this->install();
|
$duser = $event->display_user;
|
||||||
|
if(!$user->is_anonymous() && !$duser->is_anonymous()) {
|
||||||
|
if(($user->id == $duser->id) || $user->is_admin()) {
|
||||||
|
$this->theme->display_pms($page, $this->get_pms($duser));
|
||||||
|
}
|
||||||
|
if($user->id != $duser->id) {
|
||||||
|
$this->theme->display_composer($page, $user, $duser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
public function onPageRequest($event) {
|
||||||
if($event instanceof UserBlockBuildingEvent) {
|
if($event->page_matches("pm")) {
|
||||||
if(!$user->is_anonymous()) {
|
|
||||||
$event->add_link("Private Messages", make_link("pm"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($event instanceof UserPageBuildingEvent) {
|
|
||||||
$duser = $event->display_user;
|
|
||||||
if(!$user->is_anonymous() && !$duser->is_anonymous()) {
|
|
||||||
if(($user->id == $duser->id) || $user->is_admin()) {
|
|
||||||
$this->theme->display_pms($page, $this->get_pms($duser));
|
|
||||||
}
|
|
||||||
if($user->id != $duser->id) {
|
|
||||||
$this->theme->display_composer($page, $user, $duser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("pm")) {
|
|
||||||
if(!$user->is_anonymous()) {
|
if(!$user->is_anonymous()) {
|
||||||
switch($event->get_arg(0)) {
|
switch($event->get_arg(0)) {
|
||||||
case "read":
|
case "read":
|
||||||
@ -100,42 +111,21 @@ class PM implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof SendPMEvent) {
|
|
||||||
$database->execute("
|
|
||||||
INSERT INTO private_message(
|
|
||||||
from_id, from_ip, to_id,
|
|
||||||
sent_date, subject, message)
|
|
||||||
VALUES(?, ?, ?, now(), ?, ?)",
|
|
||||||
array($event->from_id, $event->from_ip,
|
|
||||||
$event->to_id, $event->subject, $event->message)
|
|
||||||
);
|
|
||||||
log_info("pm", "Sent PM to User #$to_id");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function install() {
|
public function onSendPM($event) {
|
||||||
global $config, $database;
|
$database->execute("
|
||||||
|
INSERT INTO private_message(
|
||||||
// shortcut to latest
|
from_id, from_ip, to_id,
|
||||||
if($config->get_int("pm_version") < 1) {
|
sent_date, subject, message)
|
||||||
$database->create_table("private_message", "
|
VALUES(?, ?, ?, now(), ?, ?)",
|
||||||
id SCORE_AIPK,
|
array($event->from_id, $event->from_ip,
|
||||||
from_id INTEGER NOT NULL,
|
$event->to_id, $event->subject, $event->message)
|
||||||
from_ip SCORE_INET NOT NULL,
|
);
|
||||||
to_id INTEGER NOT NULL,
|
log_info("pm", "Sent PM to User #$to_id");
|
||||||
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) {
|
private function get_pms(User $user) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
@ -147,5 +137,4 @@ class PM implements Extension {
|
|||||||
", array($user->id));
|
", array($user->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new PM());
|
|
||||||
?>
|
?>
|
||||||
|
@ -6,74 +6,63 @@
|
|||||||
* Description: Self explanitory
|
* Description: Self explanitory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RSS_Comments implements Extension {
|
class RSS_Comments extends SimpleExtension {
|
||||||
// event handling {{{
|
public function onPostListBuilding($event) {
|
||||||
public function receive_event(Event $event) {
|
global $config, $page;
|
||||||
if($event instanceof PostListBuildingEvent) {
|
|
||||||
global $page;
|
|
||||||
global $config;
|
|
||||||
$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;
|
|
||||||
$page->set_mode("data");
|
|
||||||
$page->set_type("application/rss+xml");
|
|
||||||
|
|
||||||
$comments = $database->get_all("
|
|
||||||
SELECT
|
|
||||||
users.id as user_id, users.name as user_name,
|
|
||||||
comments.comment as comment, comments.id as comment_id,
|
|
||||||
comments.image_id as image_id, comments.owner_ip as poster_ip,
|
|
||||||
UNIX_TIMESTAMP(posted) AS posted_timestamp
|
|
||||||
FROM comments
|
|
||||||
LEFT JOIN users ON comments.owner_id=users.id
|
|
||||||
ORDER BY comments.id DESC
|
|
||||||
LIMIT 10
|
|
||||||
");
|
|
||||||
|
|
||||||
$data = "";
|
|
||||||
foreach($comments as $comment) {
|
|
||||||
$image_id = $comment['image_id'];
|
|
||||||
$comment_id = $comment['comment_id'];
|
|
||||||
$link = make_link("post/view/$image_id");
|
|
||||||
$owner = html_escape($comment['user_name']);
|
|
||||||
$posted = date(DATE_RSS, $comment['posted_timestamp']);
|
|
||||||
$comment = html_escape($comment['comment']);
|
|
||||||
$content = html_escape("$owner: $comment");
|
|
||||||
|
|
||||||
$data .= "
|
|
||||||
<item>
|
|
||||||
<title>$owner comments on $image_id</title>
|
|
||||||
<link>$link</link>
|
|
||||||
<guid isPermaLink=\"false\">$comment_id</guid>
|
|
||||||
<pubDate>$posted</pubDate>
|
|
||||||
<description>$content</description>
|
|
||||||
</item>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = $config->get_string('title');
|
$title = $config->get_string('title');
|
||||||
$base_href = $config->get_string('base_href');
|
|
||||||
$version = $config->get_string('version');
|
$page->add_header("<link rel=\"alternate\" type=\"application/rss+xml\" ".
|
||||||
$xml = <<<EOD
|
"title=\"$title - Comments\" href=\"".make_link("rss/comments")."\" />");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onPageRequest($event) {
|
||||||
|
global $config, $database, $page;
|
||||||
|
if($event->page_matches("rss/comments")) {
|
||||||
|
$page->set_mode("data");
|
||||||
|
$page->set_type("application/rss+xml");
|
||||||
|
|
||||||
|
$comments = $database->get_all("
|
||||||
|
SELECT
|
||||||
|
users.id as user_id, users.name as user_name,
|
||||||
|
comments.comment as comment, comments.id as comment_id,
|
||||||
|
comments.image_id as image_id, comments.owner_ip as poster_ip,
|
||||||
|
UNIX_TIMESTAMP(posted) AS posted_timestamp
|
||||||
|
FROM comments
|
||||||
|
LEFT JOIN users ON comments.owner_id=users.id
|
||||||
|
ORDER BY comments.id DESC
|
||||||
|
LIMIT 10
|
||||||
|
");
|
||||||
|
|
||||||
|
$data = "";
|
||||||
|
foreach($comments as $comment) {
|
||||||
|
$image_id = $comment['image_id'];
|
||||||
|
$comment_id = $comment['comment_id'];
|
||||||
|
$link = make_link("post/view/$image_id");
|
||||||
|
$owner = html_escape($comment['user_name']);
|
||||||
|
$posted = date(DATE_RSS, $comment['posted_timestamp']);
|
||||||
|
$comment = html_escape($comment['comment']);
|
||||||
|
$content = html_escape("$owner: $comment");
|
||||||
|
|
||||||
|
$data .= "
|
||||||
|
<item>
|
||||||
|
<title>$owner comments on $image_id</title>
|
||||||
|
<link>$link</link>
|
||||||
|
<guid isPermaLink=\"false\">$comment_id</guid>
|
||||||
|
<pubDate>$posted</pubDate>
|
||||||
|
<description>$content</description>
|
||||||
|
</item>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = $config->get_string('title');
|
||||||
|
$base_href = $config->get_string('base_href');
|
||||||
|
$version = $config->get_string('version');
|
||||||
|
$xml = <<<EOD
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<rss version="2.0">
|
<rss version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<title>$title</title>
|
<title>$title</title>
|
||||||
<description>The latest comments on the image board</description>
|
<description>The latest comments on the image board</description>
|
||||||
<link>$base_href</link>
|
<link>$base_href</link>
|
||||||
<generator>$version</generator>
|
<generator>$version</generator>
|
||||||
<copyright>(c) 2007 Shish</copyright>
|
<copyright>(c) 2007 Shish</copyright>
|
||||||
@ -81,9 +70,8 @@ class RSS_Comments implements Extension {
|
|||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
EOD;
|
EOD;
|
||||||
$page->set_data($xml);
|
$page->set_data($xml);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
}
|
}
|
||||||
add_event_listener(new RSS_Comments());
|
|
||||||
?>
|
?>
|
||||||
|
@ -6,26 +6,24 @@
|
|||||||
* Description: Self explanitory
|
* Description: Self explanitory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RSS_Images implements Extension {
|
class RSS_Images extends SimpleExtension {
|
||||||
// event handling {{{
|
public function onPostListBuilding($event) {
|
||||||
public function receive_event(Event $event) {
|
global $config, $page;
|
||||||
global $config, $database, $page, $user;
|
$title = $config->get_string('title');
|
||||||
|
|
||||||
if($event instanceof PostListBuildingEvent) {
|
if(count($event->search_terms) > 0) {
|
||||||
$title = $config->get_string('title');
|
$search = implode(' ', $event->search_terms);
|
||||||
|
$page->add_header("<link id=\"images\" rel=\"alternate\" type=\"application/rss+xml\" ".
|
||||||
if(count($event->search_terms) > 0) {
|
"title=\"$title - Images with tags: $search\" href=\"".make_link("rss/images/$search/1")."\" />");
|
||||||
$search = implode(' ', $event->search_terms);
|
|
||||||
$page->add_header("<link id=\"images\" rel=\"alternate\" type=\"application/rss+xml\" ".
|
|
||||||
"title=\"$title - Images with tags: $search\" href=\"".make_link("rss/images/$search/1")."\" />");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$page->add_header("<link id=\"images\" rel=\"alternate\" type=\"application/rss+xml\" ".
|
|
||||||
"title=\"$title - Images\" href=\"".make_link("rss/images/1")."\" />");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$page->add_header("<link id=\"images\" rel=\"alternate\" type=\"application/rss+xml\" ".
|
||||||
|
"title=\"$title - Images\" href=\"".make_link("rss/images/1")."\" />");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("rss/images")) {
|
public function onPageRequest($event) {
|
||||||
|
if($event->page_matches("rss/images")) {
|
||||||
$page_number = 0;
|
$page_number = 0;
|
||||||
$search_terms = array();
|
$search_terms = array();
|
||||||
|
|
||||||
@ -46,8 +44,8 @@ class RSS_Images implements Extension {
|
|||||||
$this->do_rss($images, $search_terms, $page_number);
|
$this->do_rss($images, $search_terms, $page_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
// output {{{
|
|
||||||
private function do_rss($images, $search_terms, $page_number) {
|
private function do_rss($images, $search_terms, $page_number) {
|
||||||
global $page;
|
global $page;
|
||||||
global $config;
|
global $config;
|
||||||
@ -113,7 +111,5 @@ class RSS_Images implements Extension {
|
|||||||
</rss>";
|
</rss>";
|
||||||
$page->set_data($xml);
|
$page->set_data($xml);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
}
|
}
|
||||||
add_event_listener(new RSS_Images());
|
|
||||||
?>
|
?>
|
||||||
|
@ -21,14 +21,10 @@ class TestFinder extends TestSuite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SimpleSCoreTest implements Extension {
|
class SimpleSCoreTest extends SimpleExtension {
|
||||||
var $theme;
|
public function onPageRequest($event) {
|
||||||
|
global $page;
|
||||||
public function receive_event(Event $event) {
|
if($event->page_matches("test")) {
|
||||||
global $config, $database, $page, $user;
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("test")) {
|
|
||||||
$page->set_title("Test Results");
|
$page->set_title("Test Results");
|
||||||
$page->set_heading("Test Results");
|
$page->set_heading("Test Results");
|
||||||
$page->add_block(new NavBlock());
|
$page->add_block(new NavBlock());
|
||||||
@ -36,13 +32,13 @@ class SimpleSCoreTest implements Extension {
|
|||||||
$all = new TestFinder($event->get_arg(0));
|
$all = new TestFinder($event->get_arg(0));
|
||||||
$all->run(new SCoreReporter($page));
|
$all->run(new SCoreReporter($page));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof UserBlockBuildingEvent) {
|
public function onUserBlockBuilding($event) {
|
||||||
if($user->is_admin()) {
|
global $user;
|
||||||
$event->add_link("Run Tests", make_link("test/all"));
|
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
|
* Description: Scales down too-large images using browser based scaling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Zoom implements Extension {
|
class Zoom extends SimpleExtension {
|
||||||
var $theme;
|
public function onDisplayingImage($event) {
|
||||||
|
global $config, $page;
|
||||||
public function receive_event(Event $event) {
|
$this->theme->display_zoomer($page, $event->image, $config->get_bool("image_zoom", false));
|
||||||
global $config, $database, $page, $user;
|
|
||||||
if($this->theme == null) $this->theme = get_theme_object($this);
|
|
||||||
|
|
||||||
if($event instanceof DisplayingImageEvent) {
|
|
||||||
$this->theme->display_zoomer($page, $event->image, $config->get_bool("image_zoom", false));
|
|
||||||
}
|
|
||||||
|
|
||||||
if($event instanceof SetupBuildingEvent) {
|
|
||||||
$sb = new SetupBlock("Image Zoom");
|
|
||||||
$sb->add_bool_option("image_zoom", "Zoom by default: ");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
<?php
|
||||||
|
|
||||||
class BBCode implements Extension {
|
class BBCode extends FormatterExtension {
|
||||||
public function receive_event(Event $event) {
|
public function format($text) {
|
||||||
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) {
|
|
||||||
$text = $this->extract_code($text);
|
$text = $this->extract_code($text);
|
||||||
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
|
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
|
||||||
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
|
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
|
||||||
@ -42,7 +35,7 @@ class BBCode implements Extension {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function bbcode_to_text($text) {
|
public function strip($text) {
|
||||||
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text);
|
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text);
|
||||||
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text);
|
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text);
|
||||||
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text);
|
$text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text);
|
||||||
@ -65,6 +58,7 @@ class BBCode implements Extension {
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function filter_spoiler($text) {
|
private function filter_spoiler($text) {
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array("[spoiler]","[/spoiler]"),
|
array("[spoiler]","[/spoiler]"),
|
||||||
|
@ -68,14 +68,10 @@ class ExtensionInfo { // {{{
|
|||||||
}
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
class ExtManager implements Extension {
|
class ExtManager extends SimpleExtension {
|
||||||
var $theme;
|
public function onPageRequest($event) {
|
||||||
|
global $page, $user;
|
||||||
public function receive_event(Event $event) {
|
if($event->page_matches("ext_manager")) {
|
||||||
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")) {
|
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
if($event->get_arg(0) == "set") {
|
if($event->get_arg(0) == "set") {
|
||||||
if(is_writable("ext")) {
|
if(is_writable("ext")) {
|
||||||
@ -97,19 +93,21 @@ class ExtManager implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("ext_doc")) {
|
if($event->page_matches("ext_doc")) {
|
||||||
$ext = $event->get_arg(0);
|
$ext = $event->get_arg(0);
|
||||||
$info = new ExtensionInfo("contrib/$ext/main.php");
|
$info = new ExtensionInfo("contrib/$ext/main.php");
|
||||||
$this->theme->display_doc($page, $info);
|
$this->theme->display_doc($page, $info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof UserBlockBuildingEvent) {
|
public function onUserBlockBuilding($event) {
|
||||||
if($user->is_admin()) {
|
global $user;
|
||||||
$event->add_link("Extension Manager", make_link("ext_manager"));
|
if($user->is_admin()) {
|
||||||
}
|
$event->add_link("Extension Manager", make_link("ext_manager"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function get_extensions() {
|
private function get_extensions() {
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
foreach(glob("contrib/*/main.php") as $main) {
|
foreach(glob("contrib/*/main.php") as $main) {
|
||||||
@ -152,5 +150,4 @@ class ExtManager implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new ExtManager());
|
|
||||||
?>
|
?>
|
||||||
|
@ -74,77 +74,75 @@ class ParseLinkTemplateEvent extends Event {
|
|||||||
* A class to handle adding / getting / removing image
|
* A class to handle adding / getting / removing image
|
||||||
* files from the disk
|
* files from the disk
|
||||||
*/
|
*/
|
||||||
class ImageIO implements Extension {
|
class ImageIO extends SimpleExtension {
|
||||||
// event handling {{{
|
public function onInitExt($event) {
|
||||||
public function receive_event(Event $event) {
|
global $config;
|
||||||
if($event instanceof InitExtEvent) {
|
$config->set_default_int('thumb_width', 192);
|
||||||
global $config;
|
$config->set_default_int('thumb_height', 192);
|
||||||
$config->set_default_int('thumb_width', 192);
|
$config->set_default_int('thumb_quality', 75);
|
||||||
$config->set_default_int('thumb_height', 192);
|
$config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB'));
|
||||||
$config->set_default_int('thumb_quality', 75);
|
|
||||||
$config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB'));
|
|
||||||
|
|
||||||
$config->set_default_string('image_ilink', '');
|
$config->set_default_string('image_ilink', '');
|
||||||
$config->set_default_string('image_tlink', '');
|
$config->set_default_string('image_tlink', '');
|
||||||
$config->set_default_string('image_tip', '$tags // $size // $filesize');
|
$config->set_default_string('image_tip', '$tags // $size // $filesize');
|
||||||
$config->set_default_string('upload_collision_handler', 'error');
|
$config->set_default_string('upload_collision_handler', 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof PageRequestEvent) {
|
public function onPageRequest($event) {
|
||||||
$num = $event->get_arg(0);
|
$num = $event->get_arg(0);
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
|
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
|
||||||
$num = $matches[1];
|
$num = $matches[1];
|
||||||
|
|
||||||
if($event->page_matches("image")) {
|
if($event->page_matches("image")) {
|
||||||
$this->send_file($num, "image");
|
$this->send_file($num, "image");
|
||||||
}
|
}
|
||||||
else if($event->page_matches("thumb")) {
|
else if($event->page_matches("thumb")) {
|
||||||
$this->send_file($num, "thumb");
|
$this->send_file($num, "thumb");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof ImageAdditionEvent) {
|
|
||||||
$error = $this->add_image($event->image);
|
|
||||||
if(!empty($error)) throw new UploadException($error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($event instanceof ImageDeletionEvent) {
|
|
||||||
$event->image->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
if($event instanceof SetupBuildingEvent) {
|
|
||||||
$sb = new SetupBlock("Image Options");
|
|
||||||
$sb->position = 30;
|
|
||||||
// advanced only
|
|
||||||
//$sb->add_text_option("image_ilink", "Image link: ");
|
|
||||||
//$sb->add_text_option("image_tlink", "<br>Thumbnail link: ");
|
|
||||||
$sb->add_text_option("image_tip", "Image tooltip: ");
|
|
||||||
$sb->add_choice_option("upload_collision_handler", array('Error'=>'error', 'Merge'=>'merge'), "<br>Upload collision handler: ");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
|
|
||||||
$thumbers = array();
|
|
||||||
$thumbers['Built-in GD'] = "gd";
|
|
||||||
$thumbers['ImageMagick'] = "convert";
|
|
||||||
|
|
||||||
$sb = new SetupBlock("Thumbnailing");
|
|
||||||
$sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
|
|
||||||
|
|
||||||
$sb->add_label("<br>Size ");
|
|
||||||
$sb->add_int_option("thumb_width");
|
|
||||||
$sb->add_label(" x ");
|
|
||||||
$sb->add_int_option("thumb_height");
|
|
||||||
$sb->add_label(" px at ");
|
|
||||||
$sb->add_int_option("thumb_quality");
|
|
||||||
$sb->add_label(" % quality ");
|
|
||||||
|
|
||||||
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
|
|
||||||
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
public function onImageAddition($event) {
|
||||||
|
$error = $this->add_image($event->image);
|
||||||
|
if(!empty($error)) throw new UploadException($error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onImageDeletion($event) {
|
||||||
|
$event->image->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onSetupBuilding($event) {
|
||||||
|
$sb = new SetupBlock("Image Options");
|
||||||
|
$sb->position = 30;
|
||||||
|
// advanced only
|
||||||
|
//$sb->add_text_option("image_ilink", "Image link: ");
|
||||||
|
//$sb->add_text_option("image_tlink", "<br>Thumbnail link: ");
|
||||||
|
$sb->add_text_option("image_tip", "Image tooltip: ");
|
||||||
|
$sb->add_choice_option("upload_collision_handler", array('Error'=>'error', 'Merge'=>'merge'), "<br>Upload collision handler: ");
|
||||||
|
$event->panel->add_block($sb);
|
||||||
|
|
||||||
|
$thumbers = array();
|
||||||
|
$thumbers['Built-in GD'] = "gd";
|
||||||
|
$thumbers['ImageMagick'] = "convert";
|
||||||
|
|
||||||
|
$sb = new SetupBlock("Thumbnailing");
|
||||||
|
$sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
|
||||||
|
|
||||||
|
$sb->add_label("<br>Size ");
|
||||||
|
$sb->add_int_option("thumb_width");
|
||||||
|
$sb->add_label(" x ");
|
||||||
|
$sb->add_int_option("thumb_height");
|
||||||
|
$sb->add_label(" px at ");
|
||||||
|
$sb->add_int_option("thumb_quality");
|
||||||
|
$sb->add_label(" % quality ");
|
||||||
|
|
||||||
|
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
|
||||||
|
|
||||||
|
$event->panel->add_block($sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// add image {{{
|
// add image {{{
|
||||||
private function add_image($image) {
|
private function add_image($image) {
|
||||||
global $page;
|
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 {
|
class Index extends SimpleExtension {
|
||||||
var $theme;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
public function receive_event(Event $event) {
|
public function onPageRequest($event) {
|
||||||
global $config, $database, $page, $user;
|
global $config, $database, $page, $user;
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
if($event->page_matches("post/list")) {
|
||||||
|
|
||||||
if($event instanceof InitExtEvent) {
|
|
||||||
$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")) {
|
|
||||||
if(isset($_GET['search'])) {
|
if(isset($_GET['search'])) {
|
||||||
$search = url_escape(trim($_GET['search']));
|
$search = url_escape(trim($_GET['search']));
|
||||||
if(empty($search)) {
|
if(empty($search)) {
|
||||||
@ -92,56 +89,55 @@ class Index implements Extension {
|
|||||||
$this->theme->display_page($page, $images);
|
$this->theme->display_page($page, $images);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof SetupBuildingEvent) {
|
public function onSetupBuilding($event) {
|
||||||
$sb = new SetupBlock("Index Options");
|
$sb = new SetupBlock("Index Options");
|
||||||
$sb->position = 20;
|
$sb->position = 20;
|
||||||
|
|
||||||
$sb->add_label("Index table size ");
|
$sb->add_label("Index table size ");
|
||||||
$sb->add_int_option("index_width");
|
$sb->add_int_option("index_width");
|
||||||
$sb->add_label(" x ");
|
$sb->add_label(" x ");
|
||||||
$sb->add_int_option("index_height");
|
$sb->add_int_option("index_height");
|
||||||
$sb->add_label(" images");
|
$sb->add_label(" images");
|
||||||
|
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onSearchTermParse($event) {
|
||||||
|
$matches = array();
|
||||||
|
if(preg_match("/^size(<|>|<=|>=|=)(\d+)x(\d+)$/", $event->term, $matches)) {
|
||||||
|
$cmp = $matches[1];
|
||||||
|
$args = array(int_escape($matches[2]), int_escape($matches[3]));
|
||||||
|
$event->add_querylet(new Querylet("width $cmp ? AND height $cmp ?", $args));
|
||||||
}
|
}
|
||||||
|
else if(preg_match("/^ratio(<|>|<=|>=|=)(\d+):(\d+)$/", $event->term, $matches)) {
|
||||||
if($event instanceof SearchTermParseEvent) {
|
$cmp = $matches[1];
|
||||||
$matches = array();
|
$args = array(int_escape($matches[2]), int_escape($matches[3]));
|
||||||
if(preg_match("/^size(<|>|<=|>=|=)(\d+)x(\d+)$/", $event->term, $matches)) {
|
$event->add_querylet(new Querylet("width / height $cmp ? / ?", $args));
|
||||||
$cmp = $matches[1];
|
}
|
||||||
$args = array(int_escape($matches[2]), int_escape($matches[3]));
|
else if(preg_match("/^(filesize|id)(<|>|<=|>=|=)(\d+[kmg]?b?)$/i", $event->term, $matches)) {
|
||||||
$event->add_querylet(new Querylet("width $cmp ? AND height $cmp ?", $args));
|
$col = $matches[1];
|
||||||
}
|
$cmp = $matches[2];
|
||||||
else if(preg_match("/^ratio(<|>|<=|>=|=)(\d+):(\d+)$/", $event->term, $matches)) {
|
$val = parse_shorthand_int($matches[3]);
|
||||||
$cmp = $matches[1];
|
$event->add_querylet(new Querylet("images.$col $cmp ?", array($val)));
|
||||||
$args = array(int_escape($matches[2]), int_escape($matches[3]));
|
}
|
||||||
$event->add_querylet(new Querylet("width / height $cmp ? / ?", $args));
|
else if(preg_match("/^hash=([0-9a-fA-F]*)$/i", $event->term, $matches)) {
|
||||||
}
|
$hash = strtolower($matches[2]);
|
||||||
else if(preg_match("/^(filesize|id)(<|>|<=|>=|=)(\d+[kmg]?b?)$/i", $event->term, $matches)) {
|
$event->add_querylet(new Querylet("images.hash = '$hash'"));
|
||||||
$col = $matches[1];
|
}
|
||||||
$cmp = $matches[2];
|
else if(preg_match("/^(filetype|ext)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
||||||
$val = parse_shorthand_int($matches[3]);
|
$ext = strtolower($matches[2]);
|
||||||
$event->add_querylet(new Querylet("images.$col $cmp ?", array($val)));
|
$event->add_querylet(new Querylet("images.ext = '$ext'"));
|
||||||
}
|
}
|
||||||
else if(preg_match("/^hash=([0-9a-fA-F]*)$/i", $event->term, $matches)) {
|
else if(preg_match("/^(filename|name)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
||||||
$hash = strtolower($matches[2]);
|
$filename = strtolower($matches[2]);
|
||||||
$event->add_querylet(new Querylet("images.hash = '$hash'"));
|
$event->add_querylet(new Querylet("images.filename LIKE '%$filename%'"));
|
||||||
}
|
}
|
||||||
else if(preg_match("/^(filetype|ext)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
else if(preg_match("/^posted=(([0-9\*]*)?(-[0-9\*]*)?(-[0-9\*]*)?)$/", $event->term, $matches)) {
|
||||||
$ext = strtolower($matches[2]);
|
$val = str_replace("*", "%", $matches[1]);
|
||||||
$event->add_querylet(new Querylet("images.ext = '$ext'"));
|
$img_search->append(new Querylet("images.posted LIKE '%$val%'"));
|
||||||
}
|
|
||||||
else if(preg_match("/^(filename|name)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
|
||||||
$filename = strtolower($matches[2]);
|
|
||||||
$event->add_querylet(new Querylet("images.filename LIKE '%$filename%'"));
|
|
||||||
}
|
|
||||||
else if(preg_match("/^posted=(([0-9\*]*)?(-[0-9\*]*)?(-[0-9\*]*)?)$/", $event->term, $matches)) {
|
|
||||||
$val = str_replace("*", "%", $matches[1]);
|
|
||||||
$img_search->append(new Querylet("images.posted LIKE '%$val%'"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new Index());
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,26 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
class LoadExtData implements Extension {
|
class LoadExtData extends SimpleExtension {
|
||||||
public function receive_event(Event $event) {
|
public function onPageRequest($event) {
|
||||||
if($event instanceof PageRequestEvent) {
|
global $page;
|
||||||
global $page, $config;
|
$data_href = get_base_href();
|
||||||
|
|
||||||
$data_href = get_base_href();
|
$css_files = glob("ext/*/style.css");
|
||||||
|
if($css_files) {
|
||||||
$css_files = glob("ext/*/style.css");
|
foreach($css_files as $css_file) {
|
||||||
if($css_files) {
|
$page->add_header("<link rel='stylesheet' href='$data_href/$css_file' type='text/css'>");
|
||||||
foreach($css_files as $css_file) {
|
|
||||||
$page->add_header("<link rel='stylesheet' href='$data_href/$css_file' type='text/css'>");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$js_files = glob("ext/*/script.js");
|
$js_files = glob("ext/*/script.js");
|
||||||
if($js_files) {
|
if($js_files) {
|
||||||
foreach($js_files as $js_file) {
|
foreach($js_files as $js_file) {
|
||||||
$page->add_header("<script src='$data_href/$js_file' type='text/javascript'></script>");
|
$page->add_header("<script src='$data_href/$js_file' type='text/javascript'></script>");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_event_listener(new LoadExtData());
|
|
||||||
?>
|
?>
|
||||||
|
@ -135,27 +135,25 @@ class SetupBlock extends Block {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
class Setup implements Extension {
|
class Setup extends SimpleExtension {
|
||||||
var $theme;
|
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");
|
||||||
|
$config->set_default_string("base_href", "./index.php?q=");
|
||||||
|
$config->set_default_string("theme", "default");
|
||||||
|
}
|
||||||
|
|
||||||
public function receive_event(Event $event) {
|
public function onPageRequest($event) {
|
||||||
global $config, $database, $page, $user;
|
global $config, $page, $user;
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
|
||||||
|
|
||||||
if($event instanceof InitExtEvent) {
|
if($event->page_matches("nicetest")) {
|
||||||
$config->set_default_string("title", "Shimmie");
|
|
||||||
$config->set_default_string("front_page", "post/list");
|
|
||||||
$config->set_default_string("main_page", "post/list");
|
|
||||||
$config->set_default_string("base_href", "./index.php?q=");
|
|
||||||
$config->set_default_string("theme", "default");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("nicetest")) {
|
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
$page->set_data("ok");
|
$page->set_data("ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("setup")) {
|
if($event->page_matches("setup")) {
|
||||||
if(!$user->is_admin()) {
|
if(!$user->is_admin()) {
|
||||||
$this->theme->display_permission_denied($page);
|
$this->theme->display_permission_denied($page);
|
||||||
}
|
}
|
||||||
@ -177,80 +175,80 @@ class Setup implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof SetupBuildingEvent) {
|
public function onSetupBuilding($event) {
|
||||||
$themes = array();
|
$themes = array();
|
||||||
foreach(glob("themes/*") as $theme_dirname) {
|
foreach(glob("themes/*") as $theme_dirname) {
|
||||||
$name = str_replace("themes/", "", $theme_dirname);
|
$name = str_replace("themes/", "", $theme_dirname);
|
||||||
$themes[ucfirst($name)] = $name;
|
$themes[ucfirst($name)] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
|
||||||
|
$test_url = str_replace("/index.php", "/nicetest", $full);
|
||||||
|
|
||||||
|
$nicescript = "<script language='javascript'>
|
||||||
|
function getHTTPObject() {
|
||||||
|
if (window.XMLHttpRequest){
|
||||||
|
return new XMLHttpRequest();
|
||||||
|
}
|
||||||
|
else if(window.ActiveXObject){
|
||||||
|
return new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
|
checkbox = document.getElementById('nice_urls');
|
||||||
$test_url = str_replace("/index.php", "/nicetest", $full);
|
out_span = document.getElementById('nicetest');
|
||||||
|
|
||||||
$nicescript = "<script language='javascript'>
|
checkbox.disabled = true;
|
||||||
function getHTTPObject() {
|
out_span.innerHTML = '(testing...)';
|
||||||
if (window.XMLHttpRequest){
|
|
||||||
return new XMLHttpRequest();
|
|
||||||
}
|
|
||||||
else if(window.ActiveXObject){
|
|
||||||
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkbox = document.getElementById('nice_urls');
|
http_request = getHTTPObject();
|
||||||
out_span = document.getElementById('nicetest');
|
http_request.open('GET', '$test_url', false);
|
||||||
|
http_request.send(null);
|
||||||
|
|
||||||
|
if(http_request.status == 200 && http_request.responseText == 'ok') {
|
||||||
|
checkbox.disabled = false;
|
||||||
|
out_span.innerHTML = '(tested ok)';
|
||||||
|
}
|
||||||
|
else {
|
||||||
checkbox.disabled = true;
|
checkbox.disabled = true;
|
||||||
out_span.innerHTML = '(testing...)';
|
out_span.innerHTML = '(test failed)';
|
||||||
|
|
||||||
http_request = getHTTPObject();
|
|
||||||
http_request.open('GET', '$test_url', false);
|
|
||||||
http_request.send(null);
|
|
||||||
|
|
||||||
if(http_request.status == 200 && http_request.responseText == 'ok') {
|
|
||||||
checkbox.disabled = false;
|
|
||||||
out_span.innerHTML = '(tested ok)';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
checkbox.disabled = true;
|
|
||||||
out_span.innerHTML = '(test failed)';
|
|
||||||
}
|
|
||||||
</script>";
|
|
||||||
$sb = new SetupBlock("General");
|
|
||||||
$sb->position = 0;
|
|
||||||
$sb->add_text_option("title", "Site title: ");
|
|
||||||
$sb->add_text_option("front_page", "<br>Front page: ");
|
|
||||||
$sb->add_text_option("main_page", "<br>Main page: ");
|
|
||||||
$sb->add_text_option("contact_link", "<br>Contact URL: ");
|
|
||||||
$sb->add_choice_option("theme", $themes, "<br>Theme: ");
|
|
||||||
$sb->add_bool_option("nice_urls", "<br>Nice URLs: ");
|
|
||||||
$sb->add_label("<span id='nicetest'>(Javascript inactive, can't test!)</span>$nicescript");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($event instanceof ConfigSaveEvent) {
|
|
||||||
global $config;
|
|
||||||
foreach($_POST as $_name => $junk) {
|
|
||||||
if(substr($_name, 0, 6) == "_type_") {
|
|
||||||
$name = substr($_name, 6);
|
|
||||||
$type = $_POST["_type_$name"];
|
|
||||||
$value = isset($_POST["_config_$name"]) ? $_POST["_config_$name"] : null;
|
|
||||||
switch($type) {
|
|
||||||
case "string": $config->set_string($name, $value); break;
|
|
||||||
case "int": $config->set_int($name, $value); break;
|
|
||||||
case "bool": $config->set_bool($name, $value); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
</script>";
|
||||||
|
$sb = new SetupBlock("General");
|
||||||
|
$sb->position = 0;
|
||||||
|
$sb->add_text_option("title", "Site title: ");
|
||||||
|
$sb->add_text_option("front_page", "<br>Front page: ");
|
||||||
|
$sb->add_text_option("main_page", "<br>Main page: ");
|
||||||
|
$sb->add_text_option("contact_link", "<br>Contact URL: ");
|
||||||
|
$sb->add_choice_option("theme", $themes, "<br>Theme: ");
|
||||||
|
$sb->add_bool_option("nice_urls", "<br>Nice URLs: ");
|
||||||
|
$sb->add_label("<span id='nicetest'>(Javascript inactive, can't test!)</span>$nicescript");
|
||||||
|
$event->panel->add_block($sb);
|
||||||
|
}
|
||||||
|
|
||||||
if($event instanceof UserBlockBuildingEvent) {
|
public function onConfigSave($event) {
|
||||||
if($user->is_admin()) {
|
global $config;
|
||||||
$event->add_link("Board Config", make_link("setup"));
|
foreach($_POST as $_name => $junk) {
|
||||||
|
if(substr($_name, 0, 6) == "_type_") {
|
||||||
|
$name = substr($_name, 6);
|
||||||
|
$type = $_POST["_type_$name"];
|
||||||
|
$value = isset($_POST["_config_$name"]) ? $_POST["_config_$name"] : null;
|
||||||
|
switch($type) {
|
||||||
|
case "string": $config->set_string($name, $value); break;
|
||||||
|
case "int": $config->set_int($name, $value); break;
|
||||||
|
case "bool": $config->set_bool($name, $value); break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
private function can_tag() {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
return $config->get_bool("tag_edit_anon") || !$user->is_anonymous();
|
return $config->get_bool("tag_edit_anon") || !$user->is_anonymous();
|
||||||
|
@ -59,6 +59,7 @@ class ImageAdminBlockBuildingEvent extends Event {
|
|||||||
$this->parts[$position] = $html;
|
$this->parts[$position] = $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewImage implements Extension {
|
class ViewImage implements Extension {
|
||||||
var $theme;
|
var $theme;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user