]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/doc.php
uiredesign and phpdocs
[quix0rs-gnu-social.git] / actions / doc.php
1 <?php
2
3 /**
4  * Documentation action.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  Laconica
10  * @author   Evan Prodromou <evan@controlyourself.ca>
11  * @author   Robin Millette <millette@controlyourself.ca>
12  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13  * @link     http://laconi.ca/
14  *
15  * Laconica - a distributed open-source microblogging tool
16  * Copyright (C) 2008, Controlez-Vous, Inc.
17  *
18  * This program is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU Affero General Public License as published by
20  * the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU Affero General Public License for more details.
27  *
28  * You should have received a copy of the GNU Affero General Public License
29  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
30  */
31
32 if (!defined('LACONICA')) {
33     exit(1);
34 }
35
36 /**
37  * Documentation class.
38  *
39  * @category Action
40  * @package  Laconica
41  * @author   Evan Prodromou <evan@controlyourself.ca>
42  * @author   Robin Millette <millette@controlyourself.ca>
43  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
44  * @link     http://laconi.ca/
45
46
47 */
48 class DocAction extends Action
49 {
50     var $filename;
51     var $title;
52
53     /**
54      * Class handler.
55      * 
56      * @param array $args array of arguments
57      *
58      * @return nothing
59     */
60     function handle($args)
61     {
62         parent::handle($args);
63         $this->title    = $this->trimmed('title');
64         $this->filename = INSTALLDIR.'/doc/'.$this->title;
65         if (!file_exists($this->filename)) {
66             $this->clientError(_('No such document.'));
67             return;
68         }
69         $this->showPage();
70     }
71
72     /**
73      * Display content.
74      * 
75      * @return nothing
76     */
77     function showContent()
78     {
79         $c      = file_get_contents($this->filename);
80         $output = common_markup_to_html($c);
81         $this->raw($output);
82     }
83
84     /**
85      * Page title.
86      * 
87      * @return page title
88     */
89     function title()
90     {
91         return ucfirst($this->title);
92     }
93 }
94