git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

doc.php 3.03 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Robin Millette's avatar
Robin Millette committed
2 3 4 5 6 7 8

/**
 * Documentation action.
 *
 * PHP version 5
 *
 * @category Action
9
 * @package  StatusNet
Robin Millette's avatar
Robin Millette committed
10 11 12 13 14
 * @author   Evan Prodromou <evan@controlyourself.ca>
 * @author   Robin Millette <millette@controlyourself.ca>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://laconi.ca/
 *
15
 * StatusNet - the distributed open-source microblogging tool
16
 * Copyright (C) 2008, 2009, StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 *
 * 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
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

Robin Millette's avatar
Robin Millette committed
32 33 34 35 36 37 38 39
if (!defined('LACONICA')) {
    exit(1);
}

/**
 * Documentation class.
 *
 * @category Action
40
 * @package  StatusNet
Robin Millette's avatar
Robin Millette committed
41 42 43 44
 * @author   Evan Prodromou <evan@controlyourself.ca>
 * @author   Robin Millette <millette@controlyourself.ca>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://laconi.ca/
Robin Millette's avatar
Robin Millette committed
45
 */
46 47
class DocAction extends Action
{
Robin Millette's avatar
Robin Millette committed
48 49
    var $filename;
    var $title;
Evan Prodromou's avatar
Evan Prodromou committed
50

Robin Millette's avatar
Robin Millette committed
51 52
    /**
     * Class handler.
53
     *
Robin Millette's avatar
Robin Millette committed
54 55 56
     * @param array $args array of arguments
     *
     * @return nothing
Robin Millette's avatar
Robin Millette committed
57
     */
58 59
    function handle($args)
    {
60
        parent::handle($args);
Robin Millette's avatar
Robin Millette committed
61
        $this->title    = $this->trimmed('title');
62
        $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
Robin Millette's avatar
Robin Millette committed
63
        if (!file_exists($this->filename)) {
64
            $this->clientError(_('No such document.'));
65 66
            return;
        }
Robin Millette's avatar
Robin Millette committed
67 68 69
        $this->showPage();
    }

70 71 72 73
    // overrrided to add entry-title class
    function showPageTitle() {
        $this->element('h1', array('class' => 'entry-title'), $this->title());
    }
74

75 76 77 78 79 80
    // overrided to add hentry, and content-inner classes
    function showContentBlock()
     {
         $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
         $this->showPageTitle();
         $this->showPageNoticeBlock();
81
         $this->elementStart('div', array('id' => 'content_inner',
82 83 84 85 86 87 88
             'class' => 'entry-content'));
         // show the actual content (forms, lists, whatever)
         $this->showContent();
         $this->elementEnd('div');
         $this->elementEnd('div');
     }

Robin Millette's avatar
Robin Millette committed
89 90
    /**
     * Display content.
91
     *
Robin Millette's avatar
Robin Millette committed
92
     * @return nothing
Robin Millette's avatar
Robin Millette committed
93
     */
Robin Millette's avatar
Robin Millette committed
94 95 96
    function showContent()
    {
        $c      = file_get_contents($this->filename);
97
        $output = common_markup_to_html($c);
98
        $this->raw($output);
Robin Millette's avatar
Robin Millette committed
99 100 101 102
    }

    /**
     * Page title.
103
     *
Robin Millette's avatar
Robin Millette committed
104
     * @return page title
Robin Millette's avatar
Robin Millette committed
105
     */
Robin Millette's avatar
Robin Millette committed
106 107 108
    function title()
    {
        return ucfirst($this->title);
109
    }
110

111
    function isReadOnly($args)
112 113 114
    {
        return true;
    }
115
}