2 //=======================================================================
4 // Description: Main entry for editing information in the doc DB
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 $
10 // Copyright (C) 2002 Johan Persson
11 //=======================================================================
13 include_once "jpdb.php";
14 include "de_utils.php";
15 include 'jpgendb.php';
20 function IndexPage($aDBUtils) {
21 $this->iDBUtils = $aDBUtils;
24 function Run($aProjidx,$aExpandMethods=false,$aCols=3,$aProjName='') {
26 $this->iDBUtils->GetClassListNameKeyPublic($cl);
27 $nc = (count($cl)-3)/3;
28 $ds = new DocStat($this->iDBUtils);
31 $npercol = round($nc / $aCols);
34 for( $c=0; $c < $aCols; ++$c ) {
35 $limit = $c==($aCols-1) ? $nc : $limit+$npercol;
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>';
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];
44 if( $classpublic == 0 ) {
49 $pcolor = round(100*$ap/$tp,1) == 100 ? 'darkgreen' : 'red';
50 $p = round(100*$ap/$tp);
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 ) {
61 // Adjust the title a little bit to make the columns nicer
62 $l = $j+1 < 10 ? ($j+1).' ' : ''.$j+1;
63 $pcolor = round($ma[$j][3]) == 100 ? 'darkgreen' : 'red';
64 $t .= "<tr><td style=\"font-family:arial;font-size:80%;\"> $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>";
69 $ct[] = "<table width=\"100%\" border=0 cellpadding=4>\n$t</table>" ;
72 // Get all global functions
73 list($cname,$nm,$ma,$tp,$ap) = $ds->ClassStat(0);
75 $res=$this->iDBUtils->GetMethodListForClassKey($gfuncs,0);
76 $n = count($gfuncs)/2;
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 ) {
87 $gf .= "<tr><td style=\"font-family:arial;font-size:80%;\"> ".($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>";
94 $avg = round($total/$nc);
97 $w = round(100/$aCols);
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';
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 ";
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";
117 $tt .= "<td width=".$w."% valign=top >$ct[0]</td>";
119 for( $i=1; $i < $aCols; ++$i ) {
120 $tt .= "<td width=".$w."% valign=top style='border-left: black solid 0.5pt;' >$ct[$i]";
126 return $t.$tt.'</table>';
131 class DocEditMainEntry {
134 function DocEditMainEntry($aDBUtils) {
135 $this->iDBUtils = $aDBUtils;
138 function StrokeMeny($aProjname,$aProjidx) {
140 if( !$this->iDBUtils->ExistTableProjects() ) {
142 echo( "First time for this database. Initializing... " );
143 $this->iDBUtils->SetupNewDB();
147 $pl = array(' -- Select project -- ',-1);
148 $this->iDBUtils->GetProjects($pl);
149 $aHTML = new HTMLGenerator();
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>";
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>";
168 class DocEdDriver extends DocEditDriver {
170 function PreAmble($aTitle,$aDesc) {
171 HTMLGenerator::DocHeader($aTitle,$aDesc);
172 HTMLGenerator::DocPreamble();
173 GenJavascript::Stroke();
177 global $HTTP_POST_VARS;
178 global $HTTP_GET_VARS;
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'] ;
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);
193 $this->Preamble(' DDDA Main Meny ',' DDDA Main Meny '.$this->iProjname);
194 $m = new DocEditMainEntry($this->iDBUtils);
195 $m->StrokeMeny($this->iProjname,$this->iProjidx);
200 $driver = new DocEdDriver();