Index: trunk/extensions/DataTransclusion/ImportMAB2.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | $this->addOption( "create", "create database tables if they do not exist", false, false ); |
27 | 27 | $this->addOption( "truncate", "truncate (empty) database tables", false, false ); |
28 | 28 | $this->addOption( "prefix", "database table prefix. May contain a period (\".\") to reference tables in another database. If not given, the wiki's table prefix will be used", false, true ); |
| 29 | + $this->addOption( "recursive", "recurse into subdirectories while importing MAB files", false, false ); |
29 | 30 | $this->addOption( "noblob", "don't write blob data, import index fields only", false, false ); |
30 | 31 | $this->addOption( "limit", "max number of files to process", false, true ); |
31 | 32 | $this->addOption( "debug", "don't write to the database, dump to console instead", false, false ); |
— | — | @@ -68,6 +69,7 @@ |
69 | 70 | |
70 | 71 | $this->debug = $this->hasOption( 'debug' ); |
71 | 72 | $this->noblob = $this->hasOption( 'noblob' ); |
| 73 | + $recursive = $this->hasOption( 'recursive' ); |
72 | 74 | $limit = (int)$this->getOption( 'limit' ); |
73 | 75 | |
74 | 76 | $src = $this->mArgs[0]; |
— | — | @@ -109,9 +111,14 @@ |
110 | 112 | } |
111 | 113 | } |
112 | 114 | |
| 115 | + $this->importDir( $dir, $recursive, $limit ); |
| 116 | + } |
| 117 | + |
| 118 | + public function importDir( $dir, $recursive = false, $limit = 0 ) { |
113 | 119 | $dir = "$dir/"; |
114 | 120 | |
115 | 121 | $this->output( "scanning directory $dir\n" ); |
| 122 | + |
116 | 123 | $d = opendir( $dir ); |
117 | 124 | if ( !$d ) { |
118 | 125 | $this->error( "unable to open directory $dir!\n" ); |
— | — | @@ -123,6 +130,14 @@ |
124 | 131 | continue; |
125 | 132 | } |
126 | 133 | |
| 134 | + if ( is_dir( $dir . $file ) && $recursive ) { |
| 135 | + $this->importDir( $dir . $file ); |
| 136 | + continue; |
| 137 | + } else if ( !is_file( $dir . $file ) ) { |
| 138 | + $this->output( "not a file: $dir/$file\n" ); |
| 139 | + continue; |
| 140 | + } |
| 141 | + |
127 | 142 | $rec = $this->readMabFile( $dir . $file ); |
128 | 143 | |
129 | 144 | if ( !$rec ) { |