#!/usr/bin/php -q | | Gabor Hojtsy | | Mark Kronsbein | | Jan Fabry | | André L F S Bacci | +----------------------------------------------------------------------+ */ require_once __DIR__ . '/translation/lib/all.php'; if ( $argc != 2 ) { print <<revData; print_html_all( $data ); // Output function print_html_all( RevcheckData $data ) { print_html_header( $data ); print_html_translators( $data ); print_html_oldwip( $data ); print_html_notinen( $data ); print_html_revtag( $data ); print_html_untranslated( $data ); print_html_footer(); } function print_html_header( RevcheckData $data ) { $lang = $data->lang; $date = $data->date; print << HTML; } function print_html_menu( string $href ) { print <<

Introduction | Translators | File summary | Outdated Files | Not in EN tree | Missing or invalid revtag | Untranslated files

HTML; } function print_html_translators( RevcheckData $data ) { $translators = $data->translators; if ( count( $translators ) == 0 ) return; print_html_menu("intro"); print << {$data->intro}

HTML; foreach( $translators as $person ) { // Unknown or untracked on translations.xml if ( $person->name == "" && $person->email == "" && $person->vcs == "" ) continue; $personSum = $person->countOk + $person->countOld + $person->countOther; print << HTML; } print "
Translator's name Contact email Nick V
C
S
Files maintained
ok old misc sum
{$person->name} {$person->email} {$person->nick} {$person->vcs} {$person->countOk} {$person->countOld} {$person->countOther} {$personSum}
\n"; print_html_menu("filesummary"); print << File status type Number of files Percent of files HTML; $filesTotal = 0; foreach ( $data->fileSummary as $count ) $filesTotal += $count; foreach( RevcheckStatus::cases() as $key ) { $label = ""; $count = $data->fileSummary[ $key->value ]; $perc = number_format( $count / $filesTotal * 100 , 2 ) . "%"; switch( $key ) { case RevcheckStatus::TranslatedOk: $label = "Up to date files"; break; case RevcheckStatus::TranslatedOld: $label = "Outdated files"; break; case RevcheckStatus::TranslatedWip: $label = "Work in progress"; break; case RevcheckStatus::RevTagProblem: $label = "Revision tag missing/problem"; break; case RevcheckStatus::NotInEnTree: $label = "Not in EN tree"; break; case RevcheckStatus::Untranslated: $label = "Available for translation"; break; } print << $label $count $perc HTML; } print << Files total $filesTotal 100% HTML; } function print_html_oldwip( RevcheckData $data ) { print_html_menu("files"); $total = $data->fileSummary[ RevcheckStatus::TranslatedOld->value ]; $total += $data->fileSummary[ RevcheckStatus::TranslatedWip->value ]; if ( $total == 0 ) { print "

Hooray! There is no files to update, nice work!

\n\n"; return; } print << Translated file Changes Hash Maintainer Status Days en {$data->lang} \n HTML; $now = new DateTime( 'now' ); $path = null; foreach( $data->fileDetail as $key => $file ) { switch ( $file->status ) { case RevcheckStatus::TranslatedOld: case RevcheckStatus::TranslatedWip: break; default: continue 2; } if ( $path !== $file->path ) { $path = $file->path; $path2 = $path == '' ? '/' : $path; print " $path2"; } $ma = $file->maintainer; $st = $file->completion; $ll = strtolower( $data->lang ); $kh = hash( 'sha256' , $key ); $d1 = "https://doc.php.net/revcheck.php?p=plain&lang={$ll}&hbp={$file->hashRvtg}&f=$key"; $d2 = "https://doc.php.net/revcheck.php?p=plain&lang={$ll}&hbp={$file->hashRvtg}&f=$key&c=on"; $nm = "{$file->name} [colored]"; $h1 = "{$file->hashLast}"; $h2 = "{$file->hashRvtg}"; if ( $file->adds > 0 || $file->dels > 0 ) $ch = "+{$file->adds} -{$file->dels}"; else $ch = ""; $bgdays = ''; if ( $file->days > 90 ) $bgdays = 'bgorange'; print << $nm $ch $h1 $h2 $ma $st {$file->days} \n HTML; } print "

\n\n"; } function print_html_notinen( RevcheckData $data ) { print_html_menu("notinen"); if ( $data->fileSummary[ RevcheckStatus::NotInEnTree->value ] == 0 ) { print "

Good, it seems that this translation doesn't contain any file which is not present in source tree.

\n\n"; return; } print << Files which is not present in source tree Size kB HTML; $header = null; foreach ( $data->fileDetail as $file ) { if ( $file->status != RevcheckStatus::NotInEnTree ) continue; if ( $header !== $file->path ) { $header = $file->path; print " $header"; } $name = $file->name; $size = round( $file->size / 1024 ); print << {$name} {$size} HTML; } print "

\n\n"; } function print_html_revtag( RevcheckData $data ) { print_html_menu("revtag"); if ( $data->fileSummary[ RevcheckStatus::RevTagProblem->value ] == 0 ) { echo "

Good, all files contain valid revtags.

\n\n"; return; } echo << Files with invalid or missing revision tags Size kB HTML; $last_path = null; foreach ( $data->fileDetail as $file ) { if ( $file->status != RevcheckStatus::RevTagProblem ) continue; if ( $last_path != $file->path ) { $path = $file->path == '' ? '/' : $file->path; echo "$path"; $last_path = $file->path; } $size = round( $file->size / 1024 ); echo "{$file->name}{$size}"; } echo ''; } function print_html_untranslated( RevcheckData $data ) { print_html_menu("untranslated"); if ( $data->fileSummary[ RevcheckStatus::Untranslated->value ] == 0 ) { echo "

No file left untranslated!

\n\n"; return; } print << Untranslated files Last hash kb HTML; $path = null; foreach ( $data->fileDetail as $key => $file ) { if ( $file->status != RevcheckStatus::Untranslated ) continue; if ( $path !== $file->path ) { $path = $file->path; $header = $path == '' ? '/' : $path; print " $header"; } $name = $file->name; $hash = $file->hashLast; $href = "https://github.com/php/doc-en/blob/{$hash}/$key"; $size = round( $file->size / 1024 ); print << $name $hash $size HTML; } print "\n\n"; } function print_html_footer() { print_html_menu(""); print << HTML; } function print_debug_list( RevcheckData $data ) { foreach( $data->fileDetail as $key => $file ) print "f:$key m:{$file->maintainer} s:{$file->status->value}\n"; die(); }