@@ -68,6 +68,9 @@ functionality in the PHP Documentation Howto:
68
68
define ("REV_CREDIT " , 7 ); // only used in translators list
69
69
define ("REV_WIP " , 8 ); // only used in translators list
70
70
71
+ define ('TEMPLATE_HISTORY_URL_BASE_FILE ' , 'https://github.com/phpdoctest/%2$s/commits/master/%1$s ' );
72
+ define ('TEMPLATE_URL_BASE_FILE ' , 'https://github.com/phpdoctest/%2$s/blob/master/%1$s ' );
73
+
71
74
// Colors used to mark files by status (colors for the above types)
72
75
$ CSS = array (
73
76
REV_UPTODATE => "act " ,
@@ -94,6 +97,16 @@ function init_files_by_maint($persons) {
94
97
return $ result ;
95
98
}
96
99
100
+ function get_file_path_identifier ($ file )
101
+ {
102
+ global $ LANG ;
103
+ $ slashPos = 0 ;
104
+ if (strpos ($ file , '. ' ) === 0 ) {
105
+ $ slashPos = strpos ($ file , '/ ' );
106
+ }
107
+ return ltrim (substr ($ file , strlen ($ LANG ) + $ slashPos + 1 ), '/ ' );
108
+ }
109
+
97
110
$ file_sizes_by_mark = $ files_by_mark = init_revisions ();
98
111
99
112
// Initializing variables from parameters
@@ -122,7 +135,14 @@ function init_files_by_maint($persons) {
122
135
} else {
123
136
$ DOCDIR = "../ " ;
124
137
}
125
- $ DOCDIR = "./ " ;
138
+ //$DOCDIR = "./";
139
+
140
+ $ englishRevisions = [];
141
+
142
+ foreach (file ($ DOCDIR . '/ ' . $ LANG . '/.en-revisions.ref ' ) as $ line ) {
143
+ $ colonPos = strpos ($ line , ': ' );
144
+ $ englishRevisions [substr ($ line , 0 , $ colonPos )] = trim (substr ($ line , $ colonPos + 1 ));
145
+ }
126
146
// =========================================================================
127
147
// Functions to get revision info and credits from a file
128
148
// =========================================================================
@@ -142,8 +162,9 @@ function get_original_info($file, $hash)
142
162
// Grabs the revision tag and stores credits from the file given
143
163
function get_tags ($ file , $ val = "en-rev " ) {
144
164
145
- global $ LANG , $ DOCDIR ;
146
- $ basefile = substr ($ file , strlen ($ LANG ) + 3 );
165
+ global $ LANG , $ DOCDIR , $ englishRevisions ;
166
+
167
+ $ basefile = get_file_path_identifier ($ file );
147
168
148
169
// Read the first 500 chars. The comment should be at
149
170
// the begining of the file
@@ -214,6 +235,9 @@ function get_tags($file, $val = "en-rev") {
214
235
215
236
$ match [4 ] = new DateTimeImmutable ();
216
237
$ match [5 ] = 0 ;
238
+
239
+ $ match [1 ] = $ englishRevisions [$ basefile ];
240
+
217
241
if (isset ($ match [1 ]) && $ match [1 ] && $ match [1 ] !== 'n/a ' ) {
218
242
// We have a revision number of the english original and should now see to
219
243
// Get the last change date of that revision…
@@ -316,7 +340,8 @@ function get_file_status($file) {
316
340
// Compute times and diffs
317
341
$ en_date = (new DateTimeImmutable ())->diff ($ en_last_date )->days ;
318
342
$ trans_date = intval ((time () - filemtime ($ trans_file )) / 86400 );
319
- // $trans_date = (new DateTimeImmutable())->diff($this_rev)->days;
343
+ $ trans_date = (new DateTimeImmutable ())->diff (get_tags ($ trans_file ))->days ;
344
+ //$trans_date = (new DateTimeImmutable())->diff($this_rev)->days;
320
345
$ date_diff = $ en_date - $ trans_date ;
321
346
$ date_diff = 0 ;
322
347
if ($ trans_rev instanceof DateTimeInterface) {
@@ -924,21 +949,24 @@ function parse_translation($DOCDIR, $LANG, $MAINT) {
924
949
// make a link to the SVN repository's diff script
925
950
if ($ file ["revision " ][2 ] != "n/a " && $ file ["revision " ][2 ] !== 0 ) {
926
951
$ history_url = sprintf (
927
- 'https://github.com/phpdoctest/en/commits/master/%1$s ' ,
928
- $ file ['full_name ' ]
952
+ TEMPLATE_HISTORY_URL_BASE_FILE ,
953
+ get_file_path_identifier ($ file ['full_name ' ]),
954
+ $ LANG
929
955
);
930
956
931
957
$ url = sprintf (
932
- 'https://github.com/phpdoctest/en/blob/master/%1$s ' ,
933
- $ file ['full_name ' ]
958
+ TEMPLATE_URL_BASE_FILE ,
959
+ get_file_path_identifier ($ file ['full_name ' ]),
960
+ $ LANG
934
961
);
935
962
936
963
$ file ['short_name ' ] = '<a href=" ' . $ url . '"> ' . $ file ["short_name " ] . '</a> ' .
937
964
'<a href=" ' . $ history_url . '">[History]</a> ' ;
938
965
}
939
966
940
967
// Guess the new directory from the full name of the file
941
- $ new_dir = dirname ($ file ["full_name " ]);
968
+ $ new_dir = dirname ($ file ["fu
969
+ ll_name " ]);
942
970
943
971
// If this is a new directory, put out old dir lines
944
972
if ($ new_dir !== $ prev_dir ) {
@@ -1035,7 +1063,7 @@ function parse_translation($DOCDIR, $LANG, $MAINT) {
1035
1063
// If we need the revision column, print it out
1036
1064
if ($ using_rev ) {
1037
1065
echo "<td> $ finfo [revision]</td><td> " .
1038
- $ missing_files [$ finfo ["name " ]][1 ] .
1066
+ $ missing_tags [$ finfo ["name " ]][1 ] .
1039
1067
"</td> " ;
1040
1068
}
1041
1069
@@ -1123,7 +1151,7 @@ function parse_translation($DOCDIR, $LANG, $MAINT) {
1123
1151
$ prev_dir = $ new_dir ;
1124
1152
}
1125
1153
1126
- echo "<tr class=wip><td><a href= \"https://github.com/phpdoctest/en/blob/master/ $ file?view=markup \"> $ short_file</a></td> " .
1154
+ echo "<tr class=wip><td><a href= \"" . sprintf ( TEMPLATE_URL_BASE_FILE , $ file, $ LANG ) . " ?view=markup \"> $ short_file</a></td> " .
1127
1155
"<td class=r> $ info [0 ]</td></tr> \n" ;
1128
1156
}
1129
1157
echo "</table> \n<p> </p> \n$ navbar<p> </p> \n" ;
0 commit comments