summaryrefslogtreecommitdiff
path: root/buildscripts/PhpDocumentor/phpDocumentor/DescHTML.inc
blob: f4fa31d340e24d074d5abb8f8b15e02922c299cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
//
// +------------------------------------------------------------------------+
// | phpDocumentor                                                          |
// +------------------------------------------------------------------------+
// | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
// | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
// | Web           http://www.phpdoc.org                                    |
// | Mirror        http://phpdocu.sourceforge.net/                          |
// | PEAR          http://pear.php.net/package-info.php?pacid=137           |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License,        |
// | that is available at http://www.php.net/license/3_0.txt.               |
// | If you did not receive a copy of the PHP license and are unable to     |
// | obtain it through the world-wide-web, please send a note to            |
// | license@php.net so we can mail you a copy immediately.                 |
// +------------------------------------------------------------------------+
//

/**
 * All abstract representations of html tags in DocBlocks are handled by the
 * classes in this file
 *
 * Before version 1.2, phpDocumentor simply passed html to converters, without
 * much thought, except the {@link adv_htmlentities()} function was provided
 * along with a list of allowed html.  That list is no longer used, in favor
 * of these classes.
 *
 * The PDF Converter output looked wretched in version 1.1.0 because line breaks
 * in DocBlocks were honored.  This meant that output often had just a few words
 * on every other line!  To fix this problem, DocBlock descriptions are now
 * parsed using the {@link ParserDescParser}, and split into paragraphs.  In
 * addition, html in DocBlocks are parsed into these objects to allow for easy
 * conversion in destination converters.  This design also allows different
 * conversion for different templates within a converter, which separates
 * design from logic almost 100%
 * @package phpDocumentor
 * @subpackage DescHTML
 * @since 1.2
 */
/**
 * Used for <<code>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserCode extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::ProgramExample()
     */
    function Convert(&$c)
    {
        if (!isset($this->value[0])) return '';
        if (is_string($this->value[0]) && $this->value[0]{0} == "\n")
        {
            $this->value[0] = substr($this->value[0],1);
        }
        $linktags = array();
        foreach($this->value as $val) {
            if (phpDocumentor_get_class($val) == 'parserlinkinlinetag' ||
                  phpDocumentor_get_class($val) == 'parsertutorialinlinetag') {
                $linktags[] = array($c->postProcess($val->Convert($c, false, false)), $val);
            }
        }
        $a = $c->ProgramExample(rtrim(ltrim(parent::Convert($c, false, false), "\n\r")));
        foreach ($linktags as $tag) {
            $a = str_replace($tag[0], $tag[1]->Convert($c, false, false), $a);
        }
        return $a;
//        else return $c->PreserveWhiteSpace($this->getString(false));
    }
}

/**
 * Used for <<pre>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserPre extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::PreserveWhiteSpace()
     */
    function Convert(&$c)
    {
        return $c->PreserveWhiteSpace(rtrim(ltrim(parent::Convert($c, false, false), "\n\r")));
    }
}

/**
 * Used for <<b>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserB extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::Bolden()
     */
    function Convert(&$c)
    {
        return $c->Bolden(parent::Convert($c));
    }
}

/**
 * Used for <<i>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserI extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::Italicize()
     */
    function Convert(&$c)
    {
        return $c->Italicize(parent::Convert($c));
    }
}

/**
 * Used for <<var>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserDescVar extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::Varize()
     */
    function Convert(&$c)
    {
        return $c->Varize(parent::Convert($c));
    }
}

/**
 * Used for <<samp>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserSamp extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::Sampize()
     */
    function Convert(&$c)
    {
        return $c->Sampize(parent::Convert($c));
    }
}

/**
 * Used for <<kbd>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserKbd extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::Kbdize()
     */
    function Convert(&$c)
    {
        return $c->Kbdize(parent::Convert($c));
    }
}

/**
 * Used for <<br>> in a description
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserBr extends parserStringWithInlineTags
{
    /**
     * @param Converter
     * @uses Converter::Br()
     */
    function Convert(&$c)
    {
        return $c->Br($this->getString());
    }
}

/**
 * Used for lists <<ol>> and <<ul>>
 * @package phpDocumentor
 * @subpackage DescHTML
 */
class parserList extends parserStringWithInlineTags
{
    /** @var boolean */
    var $numbered;
    /** @var integer */
    var $items = 0;
    /**
     * @param integer
     */
    function parserList($numbered)
    {
        $this->numbered = $numbered;
    }
    
    /** @param parserStringWithInlineTags */
    function addItem($item)
    {
        $this->value[$this->items++] = $item;
    }
    
    /** @param parserList */
    function addList($list)
    {
        $this->value[$this->items++] = $list;
    }
    
    /**
     * @uses Converter::ListItem() enclose each item of the list
     * @uses Converter::EncloseList() enclose the list
     * @param Converter
     */
    function Convert(&$c)
    {
        $list = '';
        foreach($this->value as $item)
        {
            $list .= $c->ListItem(trim($item->Convert($c)));
        }
        return $c->EncloseList($list,$this->numbered);
    }
}

?>