do InitExtEvent in bootstrap, before user exists

This commit is contained in:
Shish 2015-08-03 15:40:20 +01:00
parent 83435e3266
commit 7762b2c703
5 changed files with 18 additions and 17 deletions

View File

@ -46,3 +46,4 @@ ctx_log_endok();
// hook up event handlers // hook up event handlers
_load_event_listeners(); _load_event_listeners();
send_event(new InitExtEvent());

View File

@ -13,6 +13,8 @@ abstract class Event {
* A wake-up call for extensions. Upon recieving an InitExtEvent an extension * A wake-up call for extensions. Upon recieving an InitExtEvent an extension
* should check that it's database tables are there and install them if not, * should check that it's database tables are there and install them if not,
* and set any defaults with Config::set_default_int() and such. * and set any defaults with Config::set_default_int() and such.
*
* This event is sent before $user is set to anything
*/ */
class InitExtEvent extends Event {} class InitExtEvent extends Event {}

View File

@ -41,7 +41,6 @@ class Blotter extends Extension {
$config->set_default_int("blotter_recent", 5); $config->set_default_int("blotter_recent", 5);
$config->set_default_string("blotter_color", "FF0000"); $config->set_default_string("blotter_color", "FF0000");
$config->set_default_string("blotter_position", "subheading"); $config->set_default_string("blotter_position", "subheading");
} }
public function onSetupBuilding(SetupBuildingEvent $event) { public function onSetupBuilding(SetupBuildingEvent $event) {

View File

@ -15,22 +15,22 @@
* You can also add your website name as prefix or suffix to the title of each page on your website. * You can also add your website name as prefix or suffix to the title of each page on your website.
*/ */
class custom_html_headers extends Extension { class custom_html_headers extends Extension {
# Adds setup block for custom <head> content # Adds setup block for custom <head> content
public function onSetupBuilding(SetupBuildingEvent $event) { public function onSetupBuilding(SetupBuildingEvent $event) {
global $config; global $config;
$sb = new SetupBlock("Custom HTML Headers"); $sb = new SetupBlock("Custom HTML Headers");
// custom headers // custom headers
$sb->add_longtext_option("custom_html_headers", $sb->add_longtext_option("custom_html_headers",
"HTML Code to place within &lt;head&gt;&lt;/head&gt; on all pages<br>"); "HTML Code to place within &lt;head&gt;&lt;/head&gt; on all pages<br>");
// modified title // modified title
$sb->add_choice_option("sitename_in_title", array( $sb->add_choice_option("sitename_in_title", array(
"none" => 0, "none" => 0,
"as prefix" => 1, "as prefix" => 1,
"as suffix" => 2 "as suffix" => 2
), "<br>Add website name in title"); ), "<br>Add website name in title");
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }

View File

@ -54,7 +54,6 @@ try {
// start the page generation waterfall // start the page generation waterfall
$user = _get_user(); $user = _get_user();
send_event(new InitExtEvent());
if(PHP_SAPI === 'cli') { if(PHP_SAPI === 'cli') {
send_event(new CommandEvent($argv)); send_event(new CommandEvent($argv));
} }