MediaWiki
master
Toggle main menu visibility
ExtensionInfo.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Utils;
4
8
class
ExtensionInfo
{
9
20
public
static
function
getAuthorsFileName
( $dir ) {
21
if
( !$dir ) {
22
return
false
;
23
}
24
25
foreach
( scandir( $dir ) as $file ) {
26
$fullPath = $dir . DIRECTORY_SEPARATOR . $file;
27
if
( preg_match(
'/^(AUTHORS|CREDITS)(\.txt|\.wiki|\.mediawiki)?$/'
, $file ) &&
28
is_readable( $fullPath ) &&
29
is_file( $fullPath )
30
) {
31
return
$fullPath;
32
}
33
}
34
35
return
false
;
36
}
37
45
public
static
function
getLicenseFileNames
(
string
$extDir ): array {
46
if
( !$extDir ) {
47
return
[];
48
}
49
50
$licenseFiles = [];
51
foreach
( scandir( $extDir ) as $file ) {
52
$fullPath = $extDir . DIRECTORY_SEPARATOR . $file;
53
// Allow files like GPL-COPYING and MIT-LICENSE
54
if
( preg_match(
'/^([\w\.-]+)?(COPYING|LICENSE)(\.txt)?$/'
, $file ) &&
55
is_readable( $fullPath ) &&
56
is_file( $fullPath )
57
) {
58
$licenseFiles[] = $fullPath;
59
}
60
}
61
62
return
$licenseFiles;
63
}
64
}
65
67
class_alias( ExtensionInfo::class,
'MediaWiki\\ExtensionInfo'
);
if
if(!defined('MW_SETUP_CALLBACK'))
Definition
WebStart.php:72
MediaWiki\Utils\ExtensionInfo
Definition
ExtensionInfo.php:8
MediaWiki\Utils\ExtensionInfo\getAuthorsFileName
static getAuthorsFileName( $dir)
Obtains the full path of a AUTHORS or CREDITS file if one exists.
Definition
ExtensionInfo.php:20
MediaWiki\Utils\ExtensionInfo\getLicenseFileNames
static getLicenseFileNames(string $extDir)
Obtains the full paths of COPYING or LICENSE files if they exist.
Definition
ExtensionInfo.php:45
includes
Utils
ExtensionInfo.php
Generated on
for MediaWiki by
1.18.0