MediaWiki
REL1_31
updateCredits.php
Go to the documentation of this file.
1
<?php
25
if
( PHP_SAPI !=
'cli'
) {
26
die(
"This script can only be run from the command line.\n"
);
27
}
28
29
$CREDITS
=
'CREDITS'
;
30
$START_CONTRIBUTORS
=
'<!-- BEGIN CONTRIBUTOR LIST -->'
;
31
$END_CONTRIBUTORS
=
'<!-- END CONTRIBUTOR LIST -->'
;
32
33
$inHeader
=
true
;
34
$inFooter
=
false
;
35
$header
= [];
36
$contributors
= [];
37
$footer
= [];
38
39
if
( !file_exists(
$CREDITS
) ) {
40
exit(
'No CREDITS file found. Are you running this script in the right directory?'
);
41
}
42
43
$lines
= explode(
"\n"
, file_get_contents(
$CREDITS
) );
44
foreach
(
$lines
as
$line
) {
45
if
(
$inHeader
) {
46
$header
[] =
$line
;
47
$inHeader
=
$line
!==
$START_CONTRIBUTORS
;
48
} elseif (
$inFooter
) {
49
$footer
[] =
$line
;
50
} elseif (
$line
==
$END_CONTRIBUTORS
) {
51
$inFooter
=
true
;
52
$footer
[] =
$line
;
53
}
else
{
54
$name = substr(
$line
, 2 );
55
$contributors
[
$name
] =
true
;
56
}
57
}
58
unset(
$lines
);
59
60
$lines
= explode(
"\n"
, shell_exec(
'git log --format="%aN"'
) );
61
foreach
(
$lines
as
$line
) {
62
if
( empty(
$line
) ) {
63
continue
;
64
}
65
if
( substr(
$line
, 0, 5 ) ===
'[BOT]'
) {
66
continue
;
67
}
68
$contributors
[
$line
] =
true
;
69
}
70
71
$contributors
= array_keys(
$contributors
);
72
$collator
= Collator::create(
'root'
);
73
$collator
->setAttribute( Collator::NUMERIC_COLLATION, Collator::ON );
74
$collator
->sort(
$contributors
);
75
array_walk(
$contributors
,
function
( &$v, $k ) {
76
$v =
"* {$v}"
;
77
} );
78
79
file_put_contents(
$CREDITS
,
80
implode(
"\n"
, array_merge(
$header
,
$contributors
,
$footer
) ) );
$line
$line
Definition
cdb.php:59
$name
Allows to change the fields on the form that will be generated $name
Definition
hooks.txt:302
$lines
if(!file_exists( $CREDITS)) $lines
Definition
updateCredits.php:43
$header
$header
Definition
updateCredits.php:35
$collator
$collator
Definition
updateCredits.php:72
$END_CONTRIBUTORS
$END_CONTRIBUTORS
Definition
updateCredits.php:31
$CREDITS
if(PHP_SAPI !='cli') $CREDITS
Update the CREDITS list by merging in the list of git commit authors.
Definition
updateCredits.php:29
$contributors
$contributors
Definition
updateCredits.php:36
$inHeader
$inHeader
Definition
updateCredits.php:33
$inFooter
$inFooter
Definition
updateCredits.php:34
$footer
$footer
Definition
updateCredits.php:37
$START_CONTRIBUTORS
$START_CONTRIBUTORS
Definition
updateCredits.php:30
maintenance
updateCredits.php
Generated on Mon Nov 25 2024 15:36:08 for MediaWiki by
1.10.0