C:\xampp\php\pear\PHP\UML\Output\HtmlNew\DocPackage.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
<?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 Package
 * 
 * @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
 */
class PHP_UML_Output_HtmlNew_DocPackage extends PHP_UML_Output_HtmlNew_DocElement
{
    
/**
     * Generates and saves the HTML code for a package
     * 
     * @param PHP_UML_Metamodel_Package $p Starting package
     */
    
public function render($p)
    {
        if (
$this->getContextPackage()->dir=='') {
            
$fullName $p->name;
        } else {
            
$fullName rtrim($this->getAbsPath($pself::T_NAMESPACE), self::T_NAMESPACE);
        }

        
$nav $this->getNavigationBlock();

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

        
$str  $this->getDescriptionBlock($p);
        
$str .= $this->getPropertyBlock($p);
        
$str .= $this->getFunctionBlock($p);

        
$str $this->replaceInTpl($str$nav$tit$fullName);

        
$this->save(self::PACKAGE_FILENAME$str);
    }

    private function 
getDescriptionBlock($p)
    {
        
$str '';

        if (!
is_null($p->description)) {
            
$str .= '<div class="descriptionPkg"><p><ul class="single">'.$this->getTagsAsList($p->description).'</ul></p></div>';
        }

        if (
count($p->nestedPackage)>0) {
            
$str .= '<h2>Packages</h2>';
            
$str .= '<ul class="summary">';
            foreach (
$p->nestedPackage as $np) {
                
$str .= '<li>';
                
$str .= '<a href="'.$np->name.'/'.self::PACKAGE_FILENAME.'.'.self::FILE_EXT.'" class="package" target="main">'.$np->name.'</a>';
                
$str .= '</li>';
            }
            
$str .= '</ul>';
        }

        
$display false;
        
$tmp     '<h2>Classes</h2>';
        
$tmp    .= '<ul class="summary">';
        foreach (
$this->getContextPackage()->classes as $o) {
            if (
$this->getContextPackage()->dir!='' || !in_array($o->name$this->hiddenClasses)) {
                
$display true;
                
$tmp    .= '<li>'.
                    
'<a href="'.self::getObjPrefix($o).$o->name.'.'.self::FILE_EXT.'" class="'.self::getObjStyle($o).'" target="main">'.$o->name.'</a>'.
                    
'</li>';
            }
        }
        
$tmp .= '</ul>';
        if (
$display)
            
$str .= $tmp;

        
$display false;
        
$tmp     '<h2>Interfaces</h2>';
        
$tmp    .= '<ul class="summary">';
        foreach (
$this->getContextPackage()->interfaces as $o) {
            if (
$this->getContextPackage()->dir!='' || !in_array($o->name$this->hiddenInterfaces)) {
                
$display true;
                
$tmp    .= '<li>'.
                    
'<a href="'.self::getObjPrefix($o).$o->name.'.'.self::FILE_EXT.'" class="'.self::getObjStyle($o).'" target="main">'.$o->name.'</a>'.
                    
'</li>';
            }
        }
        
$tmp .= '</ul>';
        if (
$display)
            
$str .= $tmp;

        return 
$str;
    }

    
/**
     * Return the HTML code for the navigation bar
     * 
     * @return string
     */
    
private function getNavigationBlock()
    {
        
$str $this->getCommonLinks();
        if (!empty(
$this->getContextPackage()->rpt))
            
$str .= $this->getNavigParentPackage('../');
        return 
$str;
    }

    private function 
getTitleBlock($name)
    {
        return 
'<h1 class="'.$this->getStyleName().'">'.$name.'</h1>';
    }

    private function 
getStyleName()
    {
        return 
$this->getContextPackage()->dir=='' 'model' 'package';
    }

    protected function 
getTypeName()
    {
        return 
$this->getStyleName();
    }

    protected function 
getPropertyStyle($visibility)
    {
        return 
'property';
    }

    protected function 
getFunctionStyle($visibility)
    {
        return 
'method';
    }
}
?>
x

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