From ff776cad3a587d218b55fc29fa2de10acd59432f Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 23 Oct 2024 10:24:10 -0700 Subject: [PATCH] Generate images for translation status dynamically (#54) --- .gitignore | 1 - include/lib_general.inc.php | 4 +- scripts/gen_picture_info_all_lang.php | 75 ------------------- www/img-status-all.php | 67 +++++++++++++++++ .../img-status-lang.php | 21 ++---- www/revcheck.php | 13 +--- 6 files changed, 80 insertions(+), 101 deletions(-) delete mode 100644 scripts/gen_picture_info_all_lang.php create mode 100644 www/img-status-all.php rename scripts/gen_picture_info.php => www/img-status-lang.php (78%) diff --git a/.gitignore b/.gitignore index f183e07..a156af6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,5 @@ sqlite git log shared -www/images www/robots.txt www/doc diff --git a/include/lib_general.inc.php b/include/lib_general.inc.php index 32156bd..936f48b 100644 --- a/include/lib_general.inc.php +++ b/include/lib_general.inc.php @@ -103,7 +103,7 @@ function nav_tools($lang) $out .= '
  • Missing revision numbers
  • '; $out .= '
  • Untranslated files
  • '; $out .= '
  • Not in EN tree
  • '; - $out .= '
  • Graph
  • '; - $out .= ''; + $out .= ''; + $out .= ''; return $out; } diff --git a/scripts/gen_picture_info_all_lang.php b/scripts/gen_picture_info_all_lang.php deleted file mode 100644 index 03ccad6..0000000 --- a/scripts/gen_picture_info_all_lang.php +++ /dev/null @@ -1,75 +0,0 @@ -SetScale("textlin"); - $graph->yaxis->scale->SetGrace(20); - - $graph->xaxis->SetLabelmargin(5); - $graph->xaxis->SetTickLabels($legend); - - $graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5'); - - // Add a drop shadow - $graph->SetShadow(); - - // Adjust the margin a bit to make more room for titles - $graph->img->SetMargin(50,30,20,40); - - // Create a bar pot - $bplot = new BarPlot($percent); - - // Adjust fill color - $bplot->SetFillColor('#9999CC'); - - $bplot->SetShadow(); - $bplot->value->Show(); - $bplot->value->SetFont(FF_ARIAL,FS_BOLD,10); - $bplot->value->SetAngle(45); - $bplot->value->SetFormat('%0.0f'); - - // Width - $bplot->SetWidth(0.6); - - $graph->Add($bplot); - - // Setup the titles - $graph->title->Set("PHP documentation"); - $graph->xaxis->title->Set("Language"); - $graph->yaxis->title->Set("Files up to date (%)"); - - $graph->title->SetFont(FF_FONT1,FS_BOLD); - $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); - $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); - - // Display the graph - $graph->Stroke('../www/images/revcheck/info_revcheck_php_all_lang.png'); -} diff --git a/www/img-status-all.php b/www/img-status-all.php new file mode 100644 index 0000000..6e2f5f8 --- /dev/null +++ b/www/img-status-all.php @@ -0,0 +1,67 @@ +SetScale("textlin"); +$graph->yaxis->scale->SetGrace(20); + +$graph->xaxis->SetLabelmargin(5); +$graph->xaxis->SetTickLabels($legend); + +$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5'); + +// Add a drop shadow +$graph->SetShadow(); + +// Adjust the margin a bit to make more room for titles +$graph->img->SetMargin(50,30,20,40); + +// Create a bar pot +$bplot = new BarPlot($percent); + +// Adjust fill color +$bplot->SetFillColor('#9999CC'); + +$bplot->SetShadow(); +$bplot->value->Show(); +$bplot->value->SetFont(FF_ARIAL,FS_BOLD,10); +$bplot->value->SetAngle(45); +$bplot->value->SetFormat('%0.0f'); + +// Width +$bplot->SetWidth(0.6); + +$graph->Add($bplot); + +// Setup the titles +$graph->title->Set("PHP Translation Status"); +$graph->xaxis->title->Set("Language"); +$graph->yaxis->title->Set("Files up to date (%)"); + +$graph->title->SetFont(FF_FONT1,FS_BOLD); +$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); +$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); + +// Display the graph +$graph->Stroke(); diff --git a/scripts/gen_picture_info.php b/www/img-status-lang.php similarity index 78% rename from scripts/gen_picture_info.php rename to www/img-status-lang.php index c43a9f6..b3c6e25 100644 --- a/scripts/gen_picture_info.php +++ b/www/img-status-lang.php @@ -1,13 +1,12 @@ SetLegends($legend); $graph->Add($p1); - $graph->Stroke("../www/images/revcheck/info_revcheck_php_$lang.png"); + $graph->Stroke(); } diff --git a/www/revcheck.php b/www/revcheck.php index fd0834b..4820bac 100644 --- a/www/revcheck.php +++ b/www/revcheck.php @@ -428,18 +428,9 @@ END_OF_MULTILINE; break; case 'graph': - $path = "images/revcheck/info_revcheck_php_$lang.png"; - if (is_readable(__DIR__ . "/" . $path)) { - echo 'info'; - echo gen_date($DBLANG); - } else { - echo "

    Can't find graph.

    "; - } - break; - default: if ($lang == 'en') { - echo 'Info'; + echo 'Info'; echo '

    This is all what we can show for original manual. To get more tools, please select translation language.

    '; echo gen_date($DBLANG); $sidebar = nav_languages(); @@ -449,6 +440,8 @@ END_OF_MULTILINE; $intro = $intro_result->fetchArray(); echo '

    Intro for language

    '; echo '

    '.$intro[0].'

    '; + echo 'info'; + echo gen_date($DBLANG); echo '

    Links to available tools are placed on the right sidebar.

    '; } break;