From 60bf87bb34c4c0216fbbe42458d194e1e76c0aaa Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 9 Feb 2009 08:11:52 -0500 Subject: notes about existing events; should probably put this in a separate doc --- EVENTS.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 EVENTS.txt (limited to 'EVENTS.txt') diff --git a/EVENTS.txt b/EVENTS.txt new file mode 100644 index 000000000..bd511d75e --- /dev/null +++ b/EVENTS.txt @@ -0,0 +1,11 @@ +StartPrimaryNav: Showing the primary nav menu +- $action: the current action + +EndPrimaryNav: At the end of the primary nav menu +- $action: the current action + +StartSecondaryNav: Showing the secondary nav menu +- $action: the current action + +EndSecondaryNav: At the end of the secondary nav menu +- $action: the current action -- cgit v1.2.3-54-g00ecf From 5d246299b630c55d98cc03eeb650561defbeeff4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 9 Feb 2009 08:24:23 -0500 Subject: add hooks for JavaScript handling --- EVENTS.txt | 20 ++++++++++++++++++++ lib/action.php | 33 +++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 12 deletions(-) (limited to 'EVENTS.txt') diff --git a/EVENTS.txt b/EVENTS.txt index bd511d75e..68e25fa3b 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -9,3 +9,23 @@ StartSecondaryNav: Showing the secondary nav menu EndSecondaryNav: At the end of the secondary nav menu - $action: the current action + +StartShowScripts: Showing JavaScript links +- $action: the current action + +EndShowScripts: End showing JavaScript links; good place to add custom + links like Google Analytics +- $action: the current action + +StartShowJQueryScripts: Showing JQuery script links (use this to link to e.g. Google mirrors) +- $action: the current action + +EndShowJQueryScripts: End showing JQuery script links +- $action: the current action + +StartShowLaconicaScripts: Showing Laconica script links (use this to link to a CDN or something) +- $action: the current action + +EndShowLaconicaScripts: End showing Laconica script links +- $action: the current action + diff --git a/lib/action.php b/lib/action.php index 36f598c57..0628dc70d 100644 --- a/lib/action.php +++ b/lib/action.php @@ -179,18 +179,27 @@ class Action extends HTMLOutputter // lawsuit */ function showScripts() { - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.min.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.form.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/xbImportNode.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/util.js?version='.LACONICA_VERSION)), - ' '); + if (Event::handle('StartShowScripts', array($this))) { + if (Event::handle('StartShowJQueryScripts', array($this))) { + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/jquery.min.js')), + ' '); + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/jquery.form.js')), + ' '); + Event::handle('EndShowJQueryScripts', array($this)); + } + if (Event::handle('StartShowLaconicaScripts', array($this))) { + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/xbImportNode.js')), + ' '); + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/util.js?version='.LACONICA_VERSION)), + ' '); + Event::handle('EndShowLaconicaScripts', array($this)); + } + Event::handle('EndShowScripts', array($this)); + } } /** -- cgit v1.2.3-54-g00ecf From f4e8cc6d9f88e78876baa54d0ffba77694c56a1b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 9 Feb 2009 08:44:30 -0500 Subject: Add InitializePlugin and CleanupPlugin events We add two events to allow plugins to initialize and cleanup. --- EVENTS.txt | 5 +++++ index.php | 5 +++++ lib/common.php | 4 ++++ 3 files changed, 14 insertions(+) (limited to 'EVENTS.txt') diff --git a/EVENTS.txt b/EVENTS.txt index 68e25fa3b..4b8260b3c 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1,3 +1,8 @@ +InitializePlugin: a chance to initialize a plugin in a complete + environment + +CleanupPlugin: a chance to cleanup a plugin at the end of a program + StartPrimaryNav: Showing the primary nav menu - $action: the current action diff --git a/index.php b/index.php index dac5a8071..0a79b9731 100644 --- a/index.php +++ b/index.php @@ -85,3 +85,8 @@ if (!file_exists($actionfile)) { $sac->showPage(); } } + +// XXX: cleanup exit() calls or add an exit handler so +// this always gets called + +Event::handle('CleanupPlugin'); diff --git a/lib/common.php b/lib/common.php index 64c7f2410..2f85eb7c5 100644 --- a/lib/common.php +++ b/lib/common.php @@ -212,3 +212,7 @@ function __autoload($class) require_once(INSTALLDIR.'/lib/' . strtolower($class) . '.php'); } } + +// Give plugins a chance to initialize in a fully-prepared environment + +Event::handle('InitializePlugin'); -- cgit v1.2.3-54-g00ecf