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('STATUSNET') && !defined('LACONICA')) {
36 * Documentation class.
40 * @author Evan Prodromou <evan@status.net>
41 * @author Robin Millette <millette@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://status.net/
45 class DocAction extends Action
51 function prepare($args)
53 parent::prepare($args);
55 $this->title = $this->trimmed('title');
56 if (!preg_match('/^[a-zA-Z0-9_-]*$/', $this->title)) {
57 $this->title = 'help';
68 * @param array $args array of arguments
72 function handle($args)
74 parent::handle($args);
81 * Gives the page title of the document. Override default for hAtom entry.
85 function showPageTitle()
87 $this->element('h1', array('class' => 'entry-title'), $this->title());
93 * Overrides default from Action to wrap everything in an hAtom entry.
97 function showContentBlock()
99 $this->elementStart('div', array('id' => 'content', 'class' => 'h-entry'));
100 $this->showPageTitle();
101 $this->showPageNoticeBlock();
102 $this->elementStart('div', array('id' => 'content_inner',
103 'class' => 'e-content'));
104 // show the actual content (forms, lists, whatever)
105 $this->showContent();
106 $this->elementEnd('div');
107 $this->elementEnd('div');
113 * Shows the content of the document.
117 function showContent()
119 $this->raw($this->output);
125 * Uses the title of the document.
131 return ucfirst($this->title);
135 * These pages are read-only.
137 * @param array $args unused.
139 * @return boolean read-only flag (false)
141 function isReadOnly($args)
148 if (Event::handle('StartLoadDoc', array(&$this->title, &$this->output))) {
150 $paths = DocFile::defaultPaths();
152 $docfile = DocFile::forTitle($this->title, $paths);
154 if (empty($docfile)) {
155 // TRANS: Client exception thrown when requesting a document from the documentation that does not exist.
156 // TRANS: %s is the non-existing document.
157 throw new ClientException(sprintf(_('No such document "%s".'), $this->title), 404);
160 $this->output = $docfile->toHTML();
162 Event::handle('EndLoadDoc', array($this->title, &$this->output));
166 function showLocalNav()
168 $menu = new DocNav($this);
173 class DocNav extends Menu
177 if (Event::handle('StartDocNav', array($this))) {
178 $stub = new HomeStubNav($this->action);
179 $this->submenu(_m('MENU','Home'), $stub);
181 $docs = new DocListNav($this->action);
182 $this->submenu(_m('MENU','Docs'), $docs);
184 Event::handle('EndDocNav', array($this));
189 class DocListNav extends Menu
195 if (Event::handle('StartDocsMenu', array(&$items))) {
197 $items = array(array('doc',
198 array('title' => 'help'),
200 _('Getting started'),
203 array('title' => 'about'),
205 _('About this site'),
208 array('title' => 'faq'),
210 _('Frequently asked questions'),
213 array('title' => 'contact'),
214 _m('MENU', 'Contact'),
218 array('title' => 'tags'),
223 array('title' => 'groups'),
224 _m('MENU', 'Groups'),
228 array('title' => 'api'),
233 Event::handle('EndDocsMenu', array(&$items));