|
From: Benjamin C. <bc...@us...> - 2004-09-06 04:54:12
|
Update of /cvsroot/phpbt/phpbt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11307 Modified Files: Tag: htmltemplates index.php Log Message: Added jpgraph error checking. Index: index.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/index.php,v retrieving revision 1.39.2.5 retrieving revision 1.39.2.6 diff -u -r1.39.2.5 -r1.39.2.6 --- index.php 21 May 2004 12:27:32 -0000 1.39.2.5 +++ index.php 6 Sep 2004 04:54:03 -0000 1.39.2.6 @@ -45,8 +45,12 @@ function build_image($restricted_projects) { error_reporting(0); // Force this, just in case - include_once JPGRAPH_PATH.'jpgraph.php'; - include_once JPGRAPH_PATH.'jpgraph_pie.php'; + if (!@include_once(JPGRAPH_PATH.'jpgraph.php')) { + return '<span class="error">'.translate("Unable to load JPGraph").'</span>'; + } + if (!@include_once(JPGRAPH_PATH.'jpgraph_pie.php')) { + return '<span class="error">'.translate("Unable to load JPGraph pie class").'</span>'; + } $stats = grab_data($restricted_projects); $totalbugs = 0; @@ -66,25 +70,31 @@ // Create the Pie Graph. $graph = new PieGraph(350,200,"bug_cat_summary"); - $graph->SetShadow(); - - // Set A title for the plot - $graph->title->Set(translate("Bug Summary")); - $graph->title->SetFont(FF_FONT1,FS_BOLD); - - $graph->legend->Pos(0.03, 0.5, 'right', 'center'); - // Create - $p1 = new PiePlot($data); - $p1->value->SetFormat("%d%%"); - $p1->value->Show(); - $p1->SetLegends($legend); - $p1->SetCSIMTargets($targ,$alts); - $p1->SetCenter(0.25); - $graph->Add($p1); - $graph->Stroke('jpgimages/'.GenImgName()); - - return $graph->GetHTMLImageMap("myimagemap"). - "<img align=\"right\" src=\"jpgimages/".GenImgName()."\" ISMAP USEMAP=\"#myimagemap\" border=0>"; + include('inc/is_a.php'); + // Make sure that the library loaded and we could create the library object + if (is_a($graph,'PieGraph')) { + $graph->SetShadow(); + + // Set A title for the plot + $graph->title->Set(translate("Bug Summary")); + $graph->title->SetFont(FF_FONT1,FS_BOLD); + + $graph->legend->Pos(0.03, 0.5, 'right', 'center'); + // Create + $p1 = new PiePlot($data); + $p1->value->SetFormat("%d%%"); + $p1->value->Show(); + $p1->SetLegends($legend); + $p1->SetCSIMTargets($targ,$alts); + $p1->SetCenter(0.25); + $graph->Add($p1); + $graph->Stroke('jpgimages/'.GenImgName()); + + return $graph->GetHTMLImageMap("myimagemap"). + "<img align=\"right\" src=\"jpgimages/".GenImgName()."\" ISMAP USEMAP=\"#myimagemap\" border=0>"; + } else { + return '<span class="error">'.translate("There was a problem when trying to use the JPGraph library. Please fix or disable by setting 'USE_JPGRAPH' to 'NO' on the Configuration page of the Administration Tools.").'</span>'; + } } |