3 * Documentation action.
9 * @author Evan Prodromou <evan@status.net>
10 * @author Robin Millette <millette@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008-2010, StatusNet, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('GNUSOCIAL')) { exit(1); }
34 * Documentation class.
38 * @author Evan Prodromou <evan@status.net>
39 * @author Robin Millette <millette@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
41 * @link http://status.net/
43 class DocAction extends ManagedAction
49 protected function doPreparation()
51 $this->title = $this->trimmed('title');
52 if (!preg_match('/^[a-zA-Z0-9_-]*$/', $this->title)) {
53 $this->title = 'help';
60 public function title()
62 return ucfirst($this->title);
68 * Shows the content of the document.
72 function showContent()
74 $this->raw($this->output);
77 function showNoticeForm()
83 * These pages are read-only.
85 * @param array $args unused.
87 * @return boolean read-only flag (false)
89 function isReadOnly($args)
96 if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) {
98 $paths = DocFile::defaultPaths();
100 $docfile = DocFile::forTitle($this->title, $paths);
102 if (empty($docfile)) {
103 // TRANS: Client exception thrown when requesting a document from the documentation that does not exist.
104 // TRANS: %s is the non-existing document.
105 throw new ClientException(sprintf(_('No such document "%s".'), $this->title), 404);
108 $this->output = $docfile->toHTML();
110 Event::handle('EndLoadDoc', array($this->title, &$this->output));
114 function showLocalNav()
116 $menu = new DocNav($this);
121 class DocNav extends Menu
125 if (Event::handle('StartDocNav', array($this))) {
126 $stub = new HomeStubNav($this->action);
127 $this->submenu(_m('MENU','Home'), $stub);
129 $docs = new DocListNav($this->action);
130 $this->submenu(_m('MENU','Docs'), $docs);
132 Event::handle('EndDocNav', array($this));
137 class DocListNav extends Menu
143 if (Event::handle('StartDocsMenu', array(&$items))) {
145 $items = array(array('doc',
146 array('title' => 'help'),
148 _('Getting started'),
151 array('title' => 'about'),
153 _('About this site'),
156 array('title' => 'faq'),
158 _('Frequently asked questions'),
161 array('title' => 'contact'),
162 _m('MENU', 'Contact'),
166 array('title' => 'tags'),
171 array('title' => 'groups'),
172 _m('MENU', 'Groups'),
176 array('title' => 'api'),
181 Event::handle('EndDocsMenu', array(&$items));