C:\xampp\php\pear\PHP\UML\Output\HtmlNew\DocClassifier.php


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
<?php
/**
 * PHP_UML
 *
 * PHP version 5
 *
 * @category PHP
 * @package  PHP_UML
 * @author   Baptiste Autin <ohlesbeauxjours@yahoo.fr> 
 * @license  http://www.gnu.org/licenses/lgpl.html LGPL License 3
 * @version  SVN: $Revision: 169 $
 * @link     http://pear.php.net/package/PHP_UML
 * @since    $Date: 2011-09-12 01:28:43 +0200 (lun., 12 sept. 2011) $
 */

/**
 * Implementation of the HTML renderer for a classifier (class, interface, datatype)
 *
 * @category   PHP
 * @package    PHP_UML
 * @subpackage Output
 * @subpackage HtmlNew
 * @author     Baptiste Autin <ohlesbeauxjours@yahoo.fr> 
 * @license    http://www.gnu.org/licenses/lgpl.html LGPL License 3
 */
abstract class PHP_UML_Output_HtmlNew_DocClassifier extends PHP_UML_Output_HtmlNew_DocElement
{
    
/**
     * Return the type name of the classifier
     * 
     * @return string
     */
    
abstract protected function getTypeName();
    
    
/**
     * Return the CSS style name of the classifier
     * 
     * @return string
     */
    
abstract protected function getStyleName();
    
    
/**
     * Return the prefix (filename scheme)
     * 
     * @return string
     */
    
abstract protected function getPrefix();
    
    
/**
     * Return the current object
     * 
     * @param int $i Current index in all the elements of the package
     * 
     * @return PHP_UML_Metamodel_Classifier
     */
    
abstract protected function getCurrentElement($i);
    
    
/**
     * Return the next object
     * 
     * @param int $i Current index in all the elements of the package
     * 
     * @return PHP_UML_Metamodel_Classifier
     */
    
abstract protected function getNextElement($i);
    
    
/**
     * Return the previous object
     * 
     * @param int $i Previous index in all the elements of the package
     * 
     * @return PHP_UML_Metamodel_Classifier
     */
    
abstract protected function getPreviousElement($i);

    
/**
     * Generates and saves the HTML code for a classifier
     * 
     * @param int $i Index of the element (to be found in the Context object)
     */
    
public function render($i)
    {
        
$p $this->getCurrentElement($i);

        
$nav $this->getNavigationBlock($i);

        
$tit $this->getTitleBlock($i);

        
$this->ignoredTag = array('var');    // we ignore all 'var' docblocks
        
        
$str  $this->getDescriptionBlock($p);
        
$str .= $this->getPropertyBlock($p);
        
$str .= $this->getFunctionBlock($p);

        
$str $this->replaceInTpl($str$nav$tit$p->name);

        
$this->save($this->getPrefix().$p->name$str);
    }

    
/**
     * Return the HTML code for the navigation bar
     * 
     * @param int $i Index of the current element in the the array containing all
     *               the elements of the current package
     *
     * @return string A list of HTML LI
     */
    
private function getNavigationBlock($i)
    {
        
$prev $this->getPreviousElement($i);
        
$next $this->getNextElement($i);
        
$type $this->getTypeName();

        
$str $this->getCommonLinks();
        if (!empty(
$prev))
            
$str .= '<li><a href="'.$this->getPrefix().$prev->name.'.'.self::FILE_EXT.'" class="left">Prev '.$type.'</a></li>';
        
$str .= $this->getNavigParentPackage();
        if (!empty(
$next))
            
$str .= '<li><a href="'.$this->getPrefix().$next->name.'.'.self::FILE_EXT.'" class="right">Next '.$type.'</a></li>';

        return 
$str;
    }

    private function 
getTitleBlock($i)
    {
        
$elem $this->getCurrentElement($i);
        
$str  '<h1 class="'.$this->getStyleName();
        if (
$elem->isAbstract)
            
$str .= ' abstract';
        return 
$str.'">'.$elem->name.'</h1>';
    }

    private function 
getDescriptionBlock(PHP_UML_Metamodel_Classifier $p)
    {
        
$allInherited   $this->getAllInherited($p);
        
$nbAllInherited count($allInherited);

        
$allImplemented   $this->getAllImplemented($p);
        
$nbAllImplemented count($allImplemented);
 
        
$allInheriting   $this->getAllInheriting($p);
        
$nbAllInheriting count($allInheriting);

        
$allImplementing   $this->getAllImplementing($p);
        
$nbAllImplementing count($allImplementing);

        
$typeName $this->getTypeName();
        if (
$p->isAbstract)
            
$typeName 'abstract '.$typeName;
        if (
$p->isReadOnly)
            
$typeName 'final '.$typeName;

        
$str '<div class="description"><p>'.ucfirst($typeName).
            
' <span class="title">'.$this->getQualifiedName($p).'</span>';
        
$css 'link2';
        if (!empty(
$p->superClass[0])) {
            
$str .= ' extends ';
            if (
is_object($p->superClass[0]))
                
$str .= $this->getLinkTo($p->superClass[0], $css);
            else
                
$str .= $this->displayUnresolved($p->superClass[0]);
        }
        if (isset(
$p->implements)) {    
            
$nbImpl count($p->implements);
            if (
$nbImpl>0) {
                
$str .= ' implements ';
                for (
$i=0$i<$nbImpl$i++) {
                    if (!empty(
$p->implements[$i])) {
                        if (
is_object($p->implements[$i]))
                            
$str .= $this->getLinkTo($p->implements[$i], $css);
                        else
                            
$str .= $this->displayUnresolved($p->implements[$i]);
                        if (
$i<$nbImpl-1)
                            
$str .= ', ';
                    }
                }
            }
        }
        
$str .= '</p>';

        
$str .= '<ul class="description">';

        if (!
is_null($p->description)) {
            
$str .= $this->getTagsAsList($p->description);
        }

        if (
$nbAllImplemented>0) {
            
$str .= '<li>All implemented interfaces: ';
            foreach (
$allImplemented as $ai) {
                
$str .= $this->getLinkTo($ai$css).', ';
            }
            
$str  substr($str0, -2);
            
$str .= '</li>';
        }

        if (
$nbAllInheriting>0) {
            
$str .= '<li>All subclasses: ';
            foreach (
$allInheriting as $ai) {
                
$str .= $this->getLinkTo($ai$css).', ';
            }
            
$str  substr($str0, -2);
            
$str .= '</li>';
        }

        if (
$nbAllImplementing>0) {
            
$str .= '<li>All implementing classes: ';
            foreach (
$allImplementing as $ai) {
                
$str .= $this->getLinkTo($ai$css).', ';
            }
            
$str  substr($str0, -2);
            
$str .= '</li>';
        }

        
$str .= $this->getFileInfo($p);

        
$str .= '</ul></div>';

        if (
$nbAllInherited>0) {
            
$str .= '<dl class="inheritTree">';
            
$sum  = -15;
            
$img  '<img src="'.$this->getContextPackage()->rpt.self::RESOURCES_DIRNAME.'/inherit.gif" alt="extended by "/>';
            foreach (
$allInherited as $ai) {
                
$str     .= '<dd style="padding-left:'.$sum.'px">';
                
$fullName $this->getLinkTo($ai$css);
                if (
$sum>0)
                    
$str .= $img;
                
$sum += 15 2*(strlen(strstr($fullName'>'))-5);
                
$str .= $fullName.'</dd>';
            }
            
$str .= '<dd style="padding-left:'.$sum.'px" class="current">'.$img;
            
$str .= $this->getAbsPath($p->packageself::T_NAMESPACE).$p->name.'</dd>';
            
$str .= '</dl>';
        }
        return 
$str;
    }
}
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586