Index: trunk/extensions/Distribution/maintenance/getSvnMetadata.php |
— | — | @@ -22,8 +22,10 @@ |
23 | 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 | 24 | * http://www.gnu.org/copyleft/gpl.html |
25 | 25 | * |
| 26 | + * @since 0.1 |
| 27 | + * |
26 | 28 | * @author Jeroen De Dauw |
27 | | - * @author Yaron Koren |
| 29 | + * |
28 | 30 | * @ingroup Maintenance |
29 | 31 | */ |
30 | 32 | |
— | — | @@ -31,20 +33,78 @@ |
32 | 34 | |
33 | 35 | class GetSvnMetadata extends Maintenance { |
34 | 36 | |
| 37 | + /** |
| 38 | + * @var array or false |
| 39 | + */ |
| 40 | + protected $extensionList = false; |
| 41 | + |
| 42 | + /** |
| 43 | + * @see Maintenance::execute |
| 44 | + * |
| 45 | + * @since 0.1 |
| 46 | + */ |
35 | 47 | public function __construct() { |
36 | 48 | parent::__construct(); |
37 | 49 | |
38 | 50 | $this->mDescription = "Scrapes the WMF SVN repo for package meta-data and stores it so it can be queried via the API."; |
39 | 51 | } |
40 | 52 | |
| 53 | + /** |
| 54 | + * @see Maintenance::execute |
| 55 | + * |
| 56 | + * @since 0.1 |
| 57 | + */ |
41 | 58 | public function execute() { |
42 | 59 | $dbr = wfGetDB( DB_SLAVE ); |
43 | 60 | |
44 | | - // TODO |
| 61 | + $extensions = $this->getExtensionList(); |
45 | 62 | |
46 | 63 | $this->output( "..." ); |
47 | 64 | } |
48 | 65 | |
| 66 | + /** |
| 67 | + * Goes through a local checkout of the svn repository and returns a list |
| 68 | + * with all found extensions. Based on getExtensionList from ExtensionDistributor. |
| 69 | + * |
| 70 | + * @since 0.1 |
| 71 | + * |
| 72 | + * @return array |
| 73 | + */ |
| 74 | + protected function getExtensionList() { |
| 75 | + global $wgExtDistWorkingCopy, $wgExtDistBranches; |
| 76 | + |
| 77 | + if ( $this->extensionList !== false ) { |
| 78 | + return $this->extensionList; |
| 79 | + } |
| 80 | + |
| 81 | + $this->extensionList = array(); |
| 82 | + |
| 83 | + foreach ( $wgExtDistBranches as $branchPath => $branch ) { |
| 84 | + $wc = "$wgExtDistWorkingCopy/$branchPath/extensions"; |
| 85 | + $dir = opendir( $wc ); |
| 86 | + |
| 87 | + if ( !$dir ) { |
| 88 | + return array(); |
| 89 | + } |
| 90 | + |
| 91 | + $this->extensionList[$branchPath] = array(); |
| 92 | + |
| 93 | + while ( false !== ( $file = readdir( $dir ) ) ) { |
| 94 | + if ( substr( $file, 0, 1 ) == '.' |
| 95 | + || !is_dir( "$wc/$file" ) |
| 96 | + || file_exists( "$wc/$file/NO-DIST" ) ) { |
| 97 | + continue; |
| 98 | + } |
| 99 | + |
| 100 | + $this->extensionList[$branchPath][] = $file; |
| 101 | + } |
| 102 | + |
| 103 | + natcasesort( $this->extensionList[$branchPath] ); |
| 104 | + } |
| 105 | + |
| 106 | + return $this->extensionList; |
| 107 | + } |
| 108 | + |
49 | 109 | } |
50 | 110 | |
51 | 111 | $maintClass = "GetSvnMetadata"; |