@@ -53,7 +53,7 @@ functionality in the PHP Documentation Howto:
53
53
54
54
// A file is criticaly "outdated' if
55
55
//define("ALERT_REV", 10); // translation is 10 or more revisions behind the en one
56
- define ("ALERT_REV " , 60 ); // translation is 60 days behind the en one
56
+ define ("ALERT_REV " , 5 ); // English original has 5 or more new revisions since the set revision
57
57
define ("ALERT_SIZE " , 3 ); // translation is 3 or more kB smaller than the en one
58
58
define ("ALERT_DATE " , -30 ); // translation is 30 or more days older than the en one
59
59
@@ -96,10 +96,6 @@ function init_files_by_maint($persons) {
96
96
97
97
$ file_sizes_by_mark = $ files_by_mark = init_revisions ();
98
98
99
- // Option for the link to svn.php.net:
100
- define ('SVN_OPT ' , '&view=patch ' );
101
- define ('SVN_OPT_NOWS ' , '' );
102
-
103
99
// Initializing variables from parameters
104
100
$ LANG = $ argv [1 ];
105
101
$ MAINT = "" ;
@@ -131,6 +127,18 @@ function init_files_by_maint($persons) {
131
127
// Functions to get revision info and credits from a file
132
128
// =========================================================================
133
129
130
+ function get_original_info ($ file , $ hash )
131
+ {
132
+ global $ DOCDIR ;
133
+
134
+ exec ('cd ' . $ DOCDIR . '/en/ && git log ' . $ hash . '^.. --pretty=format:"%h %at" -- ' . $ file , $ result , $ output );
135
+ if ($ output || ! $ result ) {
136
+ return [new DateTimeImmutable (), 0 ];
137
+ }
138
+ return [new DateTimeImmutable ('@ ' . explode (' ' , $ result [0 ])[1 ]), count ($ result ) - 1 ];
139
+
140
+ }
141
+
134
142
// Grabs the revision tag and stores credits from the file given
135
143
function get_tags ($ file , $ val = "en-rev " ) {
136
144
@@ -147,9 +155,7 @@ function get_tags($file, $val = "en-rev") {
147
155
// Check for English SVN revision tag (. is for $ in the preg!),
148
156
// Return if this was needed (it should be there)
149
157
if ($ val == "en-rev " ) {
150
- // exec('cd ' . $DOCDIR . '/' . $LANG . ' && git log --pretty=format:"%h %at" ' . $basefile, $result, $output);
151
- // return new DateTimeImmutable('@' . explode(' ', $result[0])[1]);
152
- exec ('cd ' . $ DOCDIR . '/ ' . $ LANG . ' && git log --pretty=format:"%h %at" ' . $ basefile , $ result , $ output );
158
+ exec ('cd ' . $ DOCDIR . '/ ' . $ LANG . ' && git log -1 --pretty=format:"%h %at" ' . $ basefile , $ result , $ output );
153
159
return new DateTimeImmutable ('@ ' . explode (' ' , $ result [0 ])[1 ]);
154
160
}
155
161
@@ -166,6 +172,9 @@ function get_tags($file, $val = "en-rev") {
166
172
167
173
// Store all elements
168
174
foreach ($ credits as $ num => $ credit ) {
175
+ if (! isset ($ files_by_maint [trim ($ credit )][REV_CREDIT ])) {
176
+ $ files_by_maint [trim ($ credit )][REV_CREDIT ] = 0 ;
177
+ }
169
178
$ files_by_maint [trim ($ credit )][REV_CREDIT ]++;
170
179
}
171
180
}
@@ -184,7 +193,8 @@ function get_tags($file, $val = "en-rev") {
184
193
// The tag with revision number is not found so search
185
194
// for anonymous ID revision comment (comment where revision is not known)
186
195
if (count ($ match ) == 0 ) {
187
- preg_match ("'<!--\s*EN-Revision:\s*(n/a)\s*Maintainer:\s*(anonymous\s* "
196
+ preg_match (
197
+ "'<!--\s*EN-Revision:\s*(n/a)\s*Maintainer:\s*(anonymous\s* "
188
198
. $ val . ")\s*Status:\s*(.+)\s*-->'U " ,
189
199
$ line ,
190
200
$ match
@@ -194,23 +204,29 @@ function get_tags($file, $val = "en-rev") {
194
204
// The tag with revision number is not found so search
195
205
// for n/a revision comment (comment where revision is not known)
196
206
if (count ($ match ) == 0 ) {
197
- preg_match ("'<!--\s*EN-Revision:\s*(n/a)\s*Maintainer:\s*( "
207
+ preg_match (
208
+ "'<!--\s*EN-Revision:\s*(n/a)\s*Maintainer:\s*( "
198
209
. $ val . ")\s*Status:\s*(.+)\s*-->'U " ,
199
- $ line ,
200
- $ match
210
+ $ line ,
211
+ $ match
201
212
);
202
213
}
203
214
215
+ $ match [4 ] = new DateTimeImmutable ();
216
+ $ match [5 ] = 0 ;
204
217
if (isset ($ match [1 ]) && $ match [1 ] && $ match [1 ] !== 'n/a ' ) {
205
218
// We have a revision number of the english original and should now see to
206
219
// Get the last change date of that revision…
207
- exec ('cd ' . $ DOCDIR . '/en && git log --pretty=format:"%h %at" ' . $ basefile , $ result , $ output );
208
-
209
- $ match [1 ] = new DateTimeImmutable ('@ ' . (explode (' ' , $ result [0 ]))[1 ]);
210
220
221
+ $ info = get_original_info ($ basefile , $ match [1 ]);
222
+ $ match [4 ] = $ info [0 ];
223
+ $ match [5 ] = $ info [1 ];
211
224
}
212
225
213
- // Return with found revision info (number, maint, status)
226
+ //exec('cd ' . $DOCDIR . '/' . $LANG . ' && git log -1 --pretty=format:"%h %at" ' . $basefile, $result, $output);
227
+ $ match [1 ] = get_tags ($ file , 'en-rev ' );
228
+
229
+ // Return with found revision info (number, maint, status)
214
230
return $ match ;
215
231
216
232
} // get_tags() function end
@@ -281,36 +297,30 @@ function get_file_status($file) {
281
297
}
282
298
283
299
// Distribute values in separate vars for further processing
284
- list (, $ this_rev , $ this_maint , $ this_status ) = $ trans_tag ;
300
+ list (, $ this_rev , $ this_maint , $ this_status, $ en_last_date , $ rev_diff ) = $ trans_tag ;
285
301
286
- if ('n/a ' === $ this_rev ) {
287
- $ this_rev = new DateTimeImmutable ();
288
- }
289
- // Get English file revision
290
- $ en_rev = get_tags ($ file );
302
+ if ('n/a ' === $ this_rev ) {
303
+ $ this_rev = new DateTimeImmutable ();
304
+ }
291
305
292
- // If we have a numeric revision number (not n/a), compute rev. diff
293
306
if (is_numeric ($ this_rev )) {
294
- $ rev_diff = intval ($ en_rev ) - intval ($ this_rev );
295
307
$ trans_rev = $ this_rev ;
296
- $ en_rev = $ en_rev ;
308
+ $ en_rev = $ this_rev ;
297
309
} else {
298
310
// If we have no numeric revision, make all revision
299
311
// columns hold the rev from the translated file
300
312
$ trans_rev = $ this_rev ;
301
- $ rev_diff = 0 ;
302
- $ en_rev = $ en_rev ;
313
+ $ en_rev = 0 ;
303
314
}
304
315
305
316
// Compute times and diffs
306
- $ en_date = intval ((time () - filemtime ($ file )) / 86400 );
307
- $ en_date = (new DateTimeImmutable ())->diff ($ en_rev )->days ;
317
+ $ en_date = (new DateTimeImmutable ())->diff ($ en_last_date )->days ;
308
318
$ trans_date = intval ((time () - filemtime ($ trans_file )) / 86400 );
309
- $ trans_date = (new DateTimeImmutable ())->diff ($ this_rev )->days ;
319
+ // $trans_date = (new DateTimeImmutable())->diff($this_rev)->days;
310
320
$ date_diff = $ en_date - $ trans_date ;
311
321
$ date_diff = 0 ;
312
322
if ($ trans_rev instanceof DateTimeInterface) {
313
- $ date_diff = $ en_rev ->diff ($ trans_rev )->days ;
323
+ $ date_diff = $ en_last_date ->diff ($ trans_rev )->days ;
314
324
}
315
325
316
326
// If the file is up-to-date
@@ -330,6 +340,9 @@ function get_file_status($file) {
330
340
331
341
// Store files by status, and by maintainer too
332
342
$ files_by_mark [$ status_mark ]++;
343
+ if (! isset ($ files_by_maint [$ this_maint ][$ status_mark ])) {
344
+ $ files_by_maint [$ this_maint ][$ status_mark ] = 0 ;
345
+ }
333
346
$ files_by_maint [$ this_maint ][$ status_mark ]++;
334
347
$ file_sizes_by_mark [$ status_mark ] += $ en_size ;
335
348
@@ -340,7 +353,7 @@ function get_file_status($file) {
340
353
return array (
341
354
"full_name " => $ file ,
342
355
"short_name " => basename ($ trans_file ),
343
- "revision " => array ($ en_rev , $ trans_rev , $ rev_diff ),
356
+ "revision " => array ($ en_rev , $ rev_diff , $ trans_rev ),
344
357
"size " => array ($ en_size , $ trans_size , $ size_diff ),
345
358
"date " => array ($ en_date , $ trans_date , $ date_diff ),
346
359
"maintainer " => $ this_maint ,
@@ -369,10 +382,11 @@ function get_dir_status($dir) {
369
382
370
383
// Walk through all names in the directory
371
384
while ($ file = @readdir ($ handle )) {
372
-
373
385
if (
374
386
(!is_dir ($ dir .'/ ' .$ file ) && !in_array (substr ($ file , -3 ), array ('xml ' ,'ent ' )) && substr ($ file , -13 ) != 'PHPEditBackup ' )
375
387
|| strpos ($ file , 'entities. ' ) === 0
388
+ || strpos ($ file , '.git ' ) === 0
389
+ || strpos ($ file , '.idea ' ) === 0
376
390
|| $ dir == $ DOCDIR .'en/chmonly/ ' || $ dir == $ DOCDIR .'en/internals/ ' || $ dir == $ DOCDIR .'en/internals2/ '
377
391
|| $ file == 'contributors.ent ' || $ file == 'contributors.xml '
378
392
|| ($ dir == $ DOCDIR .'en/appendices/ ' && ($ file == 'reserved.constants.xml ' || $ file == 'extensions.xml ' ))
@@ -908,14 +922,18 @@ function parse_translation($DOCDIR, $LANG, $MAINT) {
908
922
// If we have a 'numeric' revision diff and it is not zero,
909
923
// make a link to the SVN repository's diff script
910
924
if ($ file ["revision " ][2 ] != "n/a " && $ file ["revision " ][2 ] !== 0 ) {
911
- $ url = 'http://svn.php.net/viewvc/ ' .
912
- preg_replace ( "'^ " .$ DOCDIR ."en/' " , 'phpdoc/en/trunk/ ' , $ file ['full_name ' ]);
913
- // '?r1=' . $file['revision'][1] . '&r2=' . $file['revision'][0];
914
- $ url_ws = $ url . SVN_OPT_NOWS ;
915
- $ url .= SVN_OPT ;
925
+ $ history_url = sprintf (
926
+ 'https://github.com/phpdoctest/en/commits/master/%1$s ' ,
927
+ $ file ['full_name ' ]
928
+ );
929
+
930
+ $ url = sprintf (
931
+ 'https://github.com/phpdoctest/en/blob/master/%1$s ' ,
932
+ $ file ['full_name ' ]
933
+ );
916
934
917
935
$ file ['short_name ' ] = '<a href=" ' . $ url . '"> ' . $ file ["short_name " ] . '</a> ' .
918
- '<a href=" ' . $ url_ws . '">[NoWS ]</a> ' ;
936
+ '<a href=" ' . $ history_url . '">[History ]</a> ' ;
919
937
}
920
938
921
939
// Guess the new directory from the full name of the file
0 commit comments