forked from Nikerabbit/mediawiki-extensions-Termbank
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexportContent.php
54 lines (46 loc) · 1.42 KB
/
exportContent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* ...
*
* @author Antti Kanner
* @copyright Copyright © 2011-2012, Antti Kanner
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
* @file
*/
// Standard boilerplate to define $IP
if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
$IP = getenv( 'MW_INSTALL_PATH' );
} else {
$dir = dirname( __FILE__ ); $IP = "$dir/../..";
}
require_once( "$IP/maintenance/Maintenance.php" );
class TBExportExternalDatabase extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = '...';
$this->addOption( 'pagename', '.', true, true );
$this->addOption( 'namespace', '.', true, true );
}
public function execute() {
$pagename = $this -> getOption( 'pagename' );
$namespace = $this -> getOption( 'namespace' );
global $wgContLang;
$namespaceId = $wgContLang->getNsIndex( $namespace );
if ( $namespaceId == false) {
echo "Ei nimiavaruuden nimikoodia";
die();
}
$this->getContent( $pagename, $namespaceId, $namespace );
}
protected function getContent($pagename, $namespaceId, $namespace) {
$title = Title::makeTitleSafe( $namespaceId, $pagename );
$page = new WikiPage( $title );
$content = $page->getContent();
$native = "pagename=$namespace:$pagename\n";
$native .= $content->getNativeData();
echo "$native";
file_put_contents( $pagename, $native );
}
}
$maintClass = 'TBExportExternalDatabase';
require_once( DO_MAINTENANCE );