C:\xampp\php\pear\PHP\UML\Output\HtmlNew\DocIndex.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
<?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: 176 $
 * @link     http://pear.php.net/package/PHP_UML
 * @since    $Date: 2011-09-19 00:03:11 +0200 (lun., 19 sept. 2011) $
 */

/**
 * Implementation of the HTML renderer for the Index page
 *
 * @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_DocIndex extends PHP_UML_Output_HtmlNew_DocMenu
{
    
/**
     * Temporary structure to store all the elements (in order to sort them)
     * @var array First index: the element, Second index: filepath to detail page, Third index: true only for operations/attributes of a Package (procedural code)
     */
    
private $elements = array();

    
/**
     * Generates and saves the HTML code for the Index page
     * 
     * @param PHP_UML_Metamodel_Package $p Package to render
     */
    
public function render($p)
    {
        
$tpl $this->getTemplate(self::INDEXALL_FILENAME.'.'.self::FILE_EXT);

        
$nav $this->getNavigationBlock();
        
        
$str  '<ul id="MainList" class="indexAll">';
        
$str .= $this->getContent($p);
        
$str .= '</ul>';

        
$tmp str_replace('#NAVIG'$nav$tpl);
        
$str str_replace('#INDEX'$str$tmp);

        
$this->save(self::INDEXALL_FILENAME$str);
    }
    
    
/**
     * Return the HTML code for an Index page
     * 
     * @param PHP_UML_Metamodel_Package $p Starting package
     * 
     * @return string HTML code
     */
    
private function getContent(PHP_UML_Metamodel_Package $p)
    {
        
$this->readPackage($p);
        
$str '';
        
usort($this->elements, array('self''compareElt'));
        foreach (
$this->elements as $x) {
            list(
$elt$path$pkgElt) = $x;
            switch(
get_class($elt)) {
            case 
self::META_CLASS:
            case 
self::META_INTERFACE:
                
$str .= $this->getClassifierItem($elt$path0);
                break;
            case 
self::META_OPERATION:
                if (
$pkgElt)
                    
$str .= $this->getPackageOperationItem($elt$path);
                else
                    
$str .= $this->getOperationItem($elt$path);
                break;
            case 
self::META_PROPERTY:
                if (
$pkgElt)
                    
$str .= $this->getPackagePropertyItem($elt$path);
                else
                    
$str .= $this->getPropertyItem($elt$path);
                break;
            }
        }
        return 
$str;
    }

    static private function 
compareElt($a$b)
    {
        return 
strcasecmp($a[0]->name$b[0]->name);
    }

    
/**
     * Set the elements[] property with the API data of a package
     * 
     * @param PHP_UML_Metamodel_Package $p     Package
     * @param string                    $path  Relative path to the current package
     * @param string                    $level Recursion level
     * 
     * @return void
     */
    
private function readPackage(PHP_UML_Metamodel_Package $p$path=''$level=0)
    {
        foreach (
$p->nestedPackage as $np) {
            
$npDir $path.$np->name;
            
$this->readPackage($np$npDir.'/'$level+1);
        }
        foreach (
$p->ownedType as $c) {
            
$this->elements[] = array($c$pathfalse);
            foreach (
$c->ownedOperation as $o) {
                
$this->elements[] = array($o$pathfalse);
            }
            if (isset(
$c->ownedAttribute)) {
                foreach (
$c->ownedAttribute as $a) {
                    
$this->elements[] = array($a$pathfalse);
                }
            }
        }
        foreach (
$p->ownedOperation as $o) {
            
$this->elements[] = array($o$pathtrue);
        }
        foreach (
$p->ownedAttribute as $a) {
            
$this->elements[] = array($a$pathtrue);
        }
    }

    
/**
     * Return the HTML code for the navigation bar
     * 
     * @return string
     */
    
private function getNavigationBlock()
    {
        
$str  '<ul class="navig">';
        
$str .= $this->getCommonLinks();
        
$str .= '</ul>';
        return 
$str;
    }
    
    protected function 
getPropertyItem(PHP_UML_Metamodel_Property $p$path)
    {
        return 
'<li>'.
            
'<a href="'.$path.self::getObjPrefix($p->class).$p->class->name.'.'.self::FILE_EXT.'#'.$p->name.
            
'" class="'.$this->getPropertyStyle($p->visibility).'" target="main">'.$p->name.'</a>'.
            
'</li>';
    }

    protected function 
getOperationItem(PHP_UML_Metamodel_Operation $o$path)
    {
        return 
'<li>'.
          
'<a href="'.$path.self::getObjPrefix($o->class).$o->class->name.'.'.self::FILE_EXT.'#f'.$o->id.
          
'" class="'.$this->getFunctionStyle($o->visibility).'" target="main">'.$o->name.$this->getParameterList($o).'</a>'.
          
'</li>';
    }
}
?>
x

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