+if (!defined('GNUSOCIAL')) { exit(1); }
+
+/**
+ * Documentation class.
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @author Robin Millette <millette@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
+class DocAction extends ManagedAction
+{
+ var $output = null;
+ var $filename = null;
+ var $title = null;
+
+ protected function doPreparation()
+ {
+ $this->title = $this->trimmed('title');
+ if (!preg_match('/^[a-zA-Z0-9_-]*$/', $this->title)) {
+ $this->title = 'help';
+ }
+ $this->output = null;
+
+ $this->loadDoc();
+ }
+
+ public function title()
+ {
+ return ucfirst($this->title);
+ }
+
+ /**
+ * Display content.
+ *
+ * Shows the content of the document.
+ *
+ * @return void
+ */
+ function showContent()
+ {
+ $this->raw($this->output);
+ }
+
+ function showNoticeForm()
+ {
+ // no notice form
+ }
+
+ /**
+ * These pages are read-only.
+ *
+ * @param array $args unused.
+ *
+ * @return boolean read-only flag (false)
+ */
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ function loadDoc()
+ {
+ if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) {
+
+ $paths = DocFile::defaultPaths();
+
+ $docfile = DocFile::forTitle($this->title, $paths);
+
+ if (empty($docfile)) {
+ // TRANS: Client exception thrown when requesting a document from the documentation that does not exist.
+ // TRANS: %s is the non-existing document.
+ throw new ClientException(sprintf(_('No such document "%s".'), $this->title), 404);
+ }