]> git.llucax.com Git - mecon/meconlib.git/blob - lib/MECON/Graph/external/jpgraph/src/utils/jpdocgen/jpdocedit.php
Se mejora un poco los ALT para navegadores de texto.
[mecon/meconlib.git] / lib / MECON / Graph / external / jpgraph / src / utils / jpdocgen / jpdocedit.php
1 <?php
2 //=======================================================================
3 // File:                JPDOCEDIT.PHP
4 // Description: Main entry for editing information in the doc DB
5 // Created:             2002-04-15
6 // Author:              Johan Persson (johanp@aditus.nu)
7 // Ver:                 $Id: jpdocedit.php,v 1.22.2.2 2003/08/11 12:12:18 aditus Exp $
8 //
9 // License: QPL 1.0
10 // Copyright (C) 2002 Johan Persson
11 //=======================================================================
12
13 include_once "jpdb.php";
14 include "de_utils.php";
15 include 'jpgendb.php';
16
17 class IndexPage {
18     var $iDBUtils;
19         
20     function IndexPage($aDBUtils) {
21         $this->iDBUtils = $aDBUtils;            
22     }
23
24     function Run($aProjidx,$aExpandMethods=false,$aCols=3,$aProjName='') {
25         $cl = array();
26         $this->iDBUtils->GetClassListNameKeyPublic($cl);
27         $nc = (count($cl)-3)/3;
28         $ds = new DocStat($this->iDBUtils);
29         $total = 0;
30         $ct = array();
31         $npercol = round($nc / $aCols);
32         $limit = 0;
33         $start = 1;
34         for( $c=0; $c < $aCols; ++$c ) {                        
35             $limit = $c==($aCols-1) ? $nc : $limit+$npercol;
36             $t = '';
37             $marker1 = '<span style="font-family:arial;font-size:110%;font-weight:bold;color:darkblue;">[</span>';
38             $marker2 = '<span style="font-family:arial;font-size:110%;font-weight:bold;color:darkblue;">]</span>';
39                         
40             for( $i = $start; $i <= $limit; ++$i ) {
41                 list($cname,$nm,$ma,$tp,$ap) = $ds->ClassStat($cl[3*$i+1]);
42                 $classpublic = $cl[3*$i+2];
43                 $mk1=''; $mk2='';
44                 if( $classpublic == 0 ) {
45                     $mk1 = $marker1;
46                     $mk2 = $marker2;
47                 }
48                                 
49                 $pcolor = round(100*$ap/$tp,1) == 100 ? 'darkgreen' : 'red';
50                 $p = round(100*$ap/$tp);
51                 $total += $p;
52                 $t .= "<tr><td style=\"font-family:arial;font-size:80%;\"><b>$i. <font color=".
53                     $pcolor."><b>[".sprintf("%3d",$p)."%]</b> </font>$mk1<a href=\"javascript:openPopup('jpd_editclass.php?key=".$cl[3*$i+1]."',550,590);\">$cname</a>$mk2</b></td></tr>\n";
54                 if( $aExpandMethods ) {
55                     for( $j=0; $j < $nm; ++$j ) {
56                         $mk1=''; $mk2='';
57                         if( $ma[$j][0]==0  ) {
58                             $mk1 = $marker1;
59                             $mk2 = $marker2;
60                         }
61                         // Adjust the title a little bit to make the columns nicer
62                         $l = $j+1 < 10 ? ($j+1).'&nbsp;' : ''.$j+1;
63                         $pcolor = round($ma[$j][3]) == 100 ? 'darkgreen' : 'red';
64                         $t .= "<tr><td style=\"font-family:arial;font-size:80%;\">&nbsp;&nbsp; $i.".$l." <font face=courier color=$pcolor>[".sprintf("%3d",$ma[$j][3])."%]</font> $mk1<a href=\"javascript:openPopup('jpd_editmethod.php?key=".$ma[$j][2]."',560,670);\">".$ma[$j][1]."$mk2</a></td></tr>";
65                     }
66                 }
67             }
68             $start += $npercol;
69             $ct[] = "<table width=\"100%\" border=0 cellpadding=4>\n$t</table>" ;                       
70         }
71                 
72         // Get all global functions
73         list($cname,$nm,$ma,$tp,$ap) = $ds->ClassStat(0);
74         $gfuncs=array();
75         $res=$this->iDBUtils->GetMethodListForClassKey($gfuncs,0);
76         $n = count($gfuncs)/2;
77         $gf='';
78         if( $n > 0 ) {
79             $gf='<p> <table border=0><tr><td style="font-family:arial;font-weight:bold;font-size:90%;">Global functions</td></tr>';
80             for( $i=0; $i<$n; ++$i ) {
81                 $mk1=''; $mk2='';
82                 if( $ma[$i][0]==0  ) {
83                     $mk1 = $marker1;
84                     $mk2 = $marker2;
85                 }
86                                                                 
87                 $gf .= "<tr><td style=\"font-family:arial;font-size:80%;\">&nbsp;&nbsp; ".($i+1).". <a href=\"javascript:openPopup('jpd_editmethod.php?key=".$ma[$i][2]."',560,670);\"><font face=courier color=darkred>[".sprintf("%3d",$ma[$i][3]).'%] </font>'.$mk1.$ma[$i][1]."$mk2</a></td></tr>";
88             }
89             $gf .= '</table>';
90         }
91                 
92
93         if( $nc > 0 )
94             $avg = round($total/$nc);
95         else
96             $avg = 0;
97         $w = round(100/$aCols);
98                 
99
100         $t = "<form name='mainform' method=post action=''>";
101         $t .= "<table border=0 cellspacing=0 width=100%><tr><td  style='border-bottom:solid black 1pt;' valign=top>";                           
102         $projdoc = $this->iDBUtils->GetProjDir($aProjName).'index.html';
103                 
104         $t .= "\n<input name=\"button_gendoc\" type=button value=' Create doc ' onclick=\"openPopup('jpgenhtmldoc.php',400,500,'Update docs');\"> ";                                    
105         $t .= "\n<input name=\"button_opendoc\" type=button value=\" Open doc \" onclick=\"openPopup('$projdoc',800,500,'Documentation:$aProjName');\">";
106         $t .= "</td><td  style='border-bottom:solid black 1pt;'>\n<input name=\"button_regen\" type=button value=\" Update DB \" onclick=\"openPopup('jpgendbdriver.php?force='+mainform.chkbox_timestamp.checked,350,450,'Update DB');\"> ";
107         $t .= "\n<input name=\"chkbox_timestamp\" type=checkbox value=1> Force &nbsp;";
108                                                         
109         $t .= "\n</td><td  style='border-bottom:solid black 1pt;' valign=top align=right>";             
110         $t .= "<input type=button value=' Close ' onclick='window.close();'>";                          
111         $t .= "</td></tr></table></form>";
112         $t .= "\n<table width=100% cellpadding=5 cellspacing=0 class=projectindex>\n" ;
113         $t .= "<tr><td colspan=$aCols class=projindexheader>$aProjName</td></tr>";
114         $t .= "<tr><td colspan=$aCols style=\"background:lightgrey;font-family:arial;color:#400080;\">";
115         $t .= "<b>Documentation status: <span style=\"color:#B01400;\">$avg %</span></b> ($nc classes)</td></tr>\n";
116         $tt = '<tr>';
117         $tt .= "<td width=".$w."% valign=top >$ct[0]</td>";
118
119         for( $i=1; $i < $aCols; ++$i ) {
120             $tt .= "<td width=".$w."% valign=top style='border-left: black solid 0.5pt;' >$ct[$i]";
121             if( $i < $aCols-1 )
122                 $tt .= "</td>";
123             else 
124                 $tt .= "$gf</td>";
125         }               
126         return $t.$tt.'</table>';
127     }   
128 }
129
130
131 class DocEditMainEntry {
132     var $iDBUtils;
133         
134     function DocEditMainEntry($aDBUtils) {
135         $this->iDBUtils = $aDBUtils;
136     }
137         
138     function StrokeMeny($aProjname,$aProjidx) {
139                 
140         if( !$this->iDBUtils->ExistTableProjects() ) {
141                 
142             echo( "First time for this database. Initializing... " );
143             $this->iDBUtils->SetupNewDB();
144             echo( "done.");
145         }
146                                 
147         $pl = array(' -- Select project -- ',-1);
148         $this->iDBUtils->GetProjects($pl);
149         $aHTML = new HTMLGenerator();
150                                 
151         $t = "<form name='mainform' method=POST action=''>";
152         $t .= "<div align=center><table width=100% border=0 cellspacing=0 cellpadding=5 class='mainmeny'>";
153         $t .= '<tr><td colspan=2 class=mainmeny><span class=menytitle>Project meny</span></td></tr>';
154         $t .= "<tr><td>".$aHTML->SelectCode('projidx',$pl,$aProjidx,1,'onchange="setprojcookie();"');
155         $t .= "</td><td align=right><input name=\"button_showidx\" type=button value=\"Show\" onclick=\"openPopup('jpdocedit.php?button_showidx=1&showmethod=1',700,450,'DDDA Project:');\"> ";
156         $t .= "<input type=button value=\"Edit project\" onclick=\"openPopup('jpd_editproject.php',520,540,'Edit current project');\"></form>";
157         $t .= "</td></tr>";                             
158         $t .= "<tr><td><form name='newmainform' method=POST action=''><input type=button value=\"New project\" onclick=\"openPopup('jpd_editproject.php?new=1',470,540,'New project');\">";
159         $t .= "</td><td align=right><input type=button value=\"DB Check\" onclick=\"openPopup('ddda_chkdb.php?idx='+mainform.projidx.value,450,450,'DB Check');\">";
160         $t .= "</form></td></tr>";
161         $t .= "</table></div>";
162                 
163         echo $t;
164     }   
165 }
166
167
168 class DocEdDriver extends DocEditDriver {
169         
170     function PreAmble($aTitle,$aDesc) {
171         HTMLGenerator::DocHeader($aTitle,$aDesc);
172         HTMLGenerator::DocPreamble();
173         GenJavascript::Stroke();                
174     }
175         
176     function Run() {
177         global $HTTP_POST_VARS;
178         global $HTTP_GET_VARS;
179                                 
180         $button_toggle = @$HTTP_POST_VARS['button_toggle'];             
181         $button_showidx = @$HTTP_GET_VARS['button_showidx'];
182         $button_regen  = @$HTTP_POST_VARS['button_regen'];
183         $regen_projidx = @$HTTP_POST_VARS['regen_projidx'];             
184         $showmethod    = @$HTTP_GET_VARS['showmethod'] ;
185                                 
186         if((!empty($button_toggle) || !empty($button_showidx)) && !empty($this->iProjidx) && $this->iProjidx > 0) {
187             $this->Preamble('DDDA Project: '.$this->iProjname,'DDDA Project: '.$this->iProjname);
188             $ip = new IndexPage($this->iDBUtils);
189             $txt = $ip->Run($this->iProjidx,$showmethod,3,$this->iProjname);
190             echo $txt;
191         }
192         else {                          
193             $this->Preamble(' DDDA Main Meny ',' DDDA Main Meny '.$this->iProjname);                    
194             $m = new DocEditMainEntry($this->iDBUtils);
195             $m->StrokeMeny($this->iProjname,$this->iProjidx);
196         }
197     }
198 }
199
200 $driver = new DocEdDriver();
201 $driver->Run();
202 $driver->Close();
203
204 ?>