MediaWiki 1.42.1
ExtensionInfo.php
Go to the documentation of this file.
1<?php
2
4
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
67class_alias( ExtensionInfo::class, 'MediaWiki\\ExtensionInfo' );
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
static getAuthorsFileName( $dir)
Obtains the full path of a AUTHORS or CREDITS file if one exists.
static getLicenseFileNames(string $extDir)
Obtains the full paths of COPYING or LICENSE files if they exist.