CodeDoc/Data/Class.php
[PHP_CodeDoc] / CodeDoc / Data / Class.php
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | PHP Version 4                                                        |
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2002 The PHP Group                                |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license,      |
9 // | that is bundled with this package in the file LICENSE, and is        |
10 // | available at through the world-wide-web at                           |
11 // | http://www.php.net/license/2_02.txt.                                 |
12 // | If you did not receive a copy of the PHP license and are unable to   |
13 // | obtain it through the world-wide-web, please send a note to          |
14 // | license@php.net so we can mail you a copy immediately.               |
15 // +----------------------------------------------------------------------+
16 // | Authors: Alan Knowles <alan@akbkhome.com>                      |
17 // +----------------------------------------------------------------------+
18 //
19 require_once 'PHP/CodeDoc/Data.php';
20 /**
21 *   Class Data Container
22 *
23 *   @package  PHP_CodeDoc
24 *   @access   public
25 *   @author   Alan Knowles <alan@akbkhome.com>
26 *
27 */
28 class PHP_CodeDoc_Data_Class {
29     var $id;                     // id in the big classes array.
30     var $name;                   // the name of the class
31     var $filename;               // original filename
32     var $rfilename;              // relative filename in relation to root directory.
33     var $rdir;                   // relative directory
34     var $Parent;                 // Parent Class (maybe an array in PHP5?)
35     var $Operations =array();    // Array of Method Classes
36     var $Attributes =array();    // Array of Var Classes
37     var $iOperations =array();    // Array of inherited Method Classes
38     var $iAttributes =array();    // Array of inherited Var Classes
39   
40     var $package="";             // package name if any
41     var $copyright;              // copyright
42     var $extends = array();      // Array of Parents (names)
43   
44     var $description;            // phpdoc class
45
46     
47     function output_extends() { // cheesy tree?? = better ideas;
48         $indent=0;
49         $t = count($this->extends) -1;
50         for ($i=0;$i<$t+1;$i++) {
51             echo "\n";
52             if ($i)
53                 echo str_repeat('   ',$i) . "|\n". str_repeat('   --',$i);
54
55             //if ($i != $t) { // last one = no link
56                 echo '<a href="'.$this->extends[$i].'.html">'.$this->extends[$i].'</a>';
57             //} else {
58                 //echo $this->extends[$i];
59             //}
60         }
61     } 
62 // move later to inherited
63     function toJS()
64     {
65         $ret = array();
66         $cats = array();
67         $cls = str_replace('_','-',strtolower($this->name))
68         foreach($this->Operations as $op) {
69             
70             if (!isset($op->description->category)) {
71                 echo "missing Category for {$this->name}::{$op->name}\n";
72             } else {
73                 $cats[$op->description->category] = isset($cats[$op->description->category]) ? $cats[$op->description->category] : array();
74                 $cats[$op->description->category][] =  $op;
75             }
76             $n = $cls . '/'. ($op->name == '__construct' ? 'new' : $op->name;;
77             $ret[$n] = $op->toJS();
78         }
79         foreach($this->Attributes as $op) {
80          //   $ret[$this->name . '.'.$op->name] = $op->toJS();
81         }
82         $ret[ $this->name] = array();
83         foreach($cats as $k=>$v ) {
84             $ret[ $this->name][$k] = $this->catsToJs($v);
85         }
86         
87     
88         return $ret;
89     }
90     
91     function catsToJs($ar)
92     {
93         sort($ar);
94         $ret = array(
95             '|xns' => 'Roo.bootstrap',
96             'xtype' => 'NavGroup',
97             'items' => array(
98                 
99             )
100         );
101         foreach($ar as $op) {
102             $c = $cname = $op->name;
103             if ($c == '__construct') {
104                 $cname = 'new ' . $op->{'class'};
105                 $c = 'new';
106             }
107             $ret['items'][] = array(
108                 '|xns' => 'Roo.bootstrap',
109                 'xtype' => 'NavItem',
110                 'href' => '#' . str_replace('_','-',strtolower($this->name)). '/'.$c,
111                 'html' => $cname
112             );
113         }
114         return $ret;
115         
116         
117     }
118     
119     
120
121 }
122 ?>