summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-08-21 16:54:35 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-08-21 16:54:35 -0400
commit9aa39c757396e66ad959adc9fda63bfd0a869e8b (patch)
tree65aadf3229ade43394fcfd64d829e2ee8f980533
parent8e21e37d707c61b673b0ba2154469d2fae91b90f (diff)
add hooks to allow loading custom help documentation
-rw-r--r--EVENTS.txt8
-rw-r--r--actions/doc.php26
2 files changed, 26 insertions, 8 deletions
diff --git a/EVENTS.txt b/EVENTS.txt
index 25d95fe06..a79687bae 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -227,3 +227,11 @@ StartNewQueueManager: before trying to start a new queue manager; good for plugi
RedirectToLogin: event when we force a redirect to login (like when going to a settings page on a remembered login)
- $action: action object being shown
- $user: current user
+
+StartLoadDoc: before loading a help doc (hook this to show your own documentation)
+- $title: title of the document
+- $output: HTML output to show
+
+EndLoadDoc: after loading a help doc (hook this to modify other documentation)
+- $title: title of the document
+- $output: HTML output to show
diff --git a/actions/doc.php b/actions/doc.php
index 54ae13803..7387c1620 100644
--- a/actions/doc.php
+++ b/actions/doc.php
@@ -58,12 +58,24 @@ class DocAction extends Action
function handle($args)
{
parent::handle($args);
- $this->title = $this->trimmed('title');
- $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
- if (!file_exists($this->filename)) {
- $this->clientError(_('No such document.'));
- return;
+
+ $this->title = $this->trimmed('title');
+ $this->output = null;
+
+ if (Event::handle('StartLoadDoc', &$this->title, &$this->output)) {
+
+ $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
+ if (!file_exists($this->filename)) {
+ $this->clientError(_('No such document.'));
+ return;
+ }
+
+ $c = file_get_contents($this->filename);
+ $this->output = common_markup_to_html($c);
+
+ Event::handle('EndLoadDoc', $this->title, &$this->output);
}
+
$this->showPage();
}
@@ -93,9 +105,7 @@ class DocAction extends Action
*/
function showContent()
{
- $c = file_get_contents($this->filename);
- $output = common_markup_to_html($c);
- $this->raw($output);
+ $this->raw($this->output);
}
/**