]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/doc.php
add hooks to allow loading custom help documentation
[quix0rs-gnu-social.git] / actions / doc.php
index 6957659add3c1bcaa8455b2ffac167ceab952057..7387c162075195b19e6f719234a1ffa84e3fa440 100644 (file)
@@ -13,7 +13,7 @@
  * @link     http://laconi.ca/
  *
  * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -50,7 +50,7 @@ class DocAction extends Action
 
     /**
      * Class handler.
-     * 
+     *
      * @param array $args array of arguments
      *
      * @return nothing
@@ -58,12 +58,24 @@ class DocAction extends Action
     function handle($args)
     {
         parent::handle($args);
-        $this->title    = $this->trimmed('title');
-        $this->filename = INSTALLDIR.'/doc/'.$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();
     }
 
@@ -71,14 +83,14 @@ class DocAction extends Action
     function showPageTitle() {
         $this->element('h1', array('class' => 'entry-title'), $this->title());
     }
-    
+
     // overrided to add hentry, and content-inner classes
     function showContentBlock()
      {
          $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
          $this->showPageTitle();
          $this->showPageNoticeBlock();
-         $this->elementStart('div', array('id' => 'content_inner', 
+         $this->elementStart('div', array('id' => 'content_inner',
              'class' => 'entry-content'));
          // show the actual content (forms, lists, whatever)
          $this->showContent();
@@ -88,19 +100,17 @@ class DocAction extends Action
 
     /**
      * Display content.
-     * 
+     *
      * @return nothing
      */
     function showContent()
     {
-        $c      = file_get_contents($this->filename);
-        $output = common_markup_to_html($c);
-        $this->raw($output);
+        $this->raw($this->output);
     }
 
     /**
      * Page title.
-     * 
+     *
      * @return page title
      */
     function title()
@@ -108,7 +118,7 @@ class DocAction extends Action
         return ucfirst($this->title);
     }
 
-    function isReadOnly()
+    function isReadOnly($args)
     {
         return true;
     }