Index: trunk/extensions/Wikidata/Database scripts/Convenience/Create wikidata.php |
— | — | @@ -2,17 +2,22 @@ |
3 | 3 | |
4 | 4 | # this module create a wikidata extension for mediawiki |
5 | 5 | # it generates the tables in a database (passed as parameter) with a defined prefix (passed as parameter) |
6 | | - |
| 6 | +
|
7 | 7 | $wgUseMasterForMaintenance = true; |
8 | | -require_once( "../../../../maintenance/commandLine.inc"); |
9 | | -#require_once( "../../../../LocalSettings.php"); |
10 | | -#require_once( "install-utils.inc" ); |
11 | | -#require_once( "AdminSettings.php"); |
12 | | -#require_once( "GlobalFunctions.php" ); |
13 | | -#require_once( "ProfilerStub.php"); |
14 | | -#require_once( "Exception.php" ); |
15 | | -#require_once( "Database.php" ); |
16 | | - |
| 8 | +
|
| 9 | +$sep = PATH_SEPARATOR;
|
| 10 | +$IP = realpath( dirname( __FILE__ ) . "../../../../../" );
|
| 11 | +$currentdir = dirname( __FILE__ );
|
| 12 | +chdir( $IP );
|
| 13 | +
|
| 14 | +ini_set( 'include_path', ".$sepIP$sep$IP/includes$sep$IP/languages$sep$IP/maintenance" );
|
| 15 | +
|
| 16 | +require_once( "StartProfiler.php" );
|
| 17 | +require_once( "includes/Exception.php");
|
| 18 | +require_once( "includes/GlobalFunctions.php");
|
| 19 | +require_once( "includes/Database.php");
|
| 20 | +
|
| 21 | +
|
17 | 22 | function ReadSQLFile( $database, $pattern, $prefix, $filename ){ |
18 | 23 | $fp = fopen( $filename, 'r' ); |
19 | 24 | if ( false === $fp ) { |
— | — | @@ -60,7 +65,7 @@ |
61 | 66 | $user = $wgDBadminuser; |
62 | 67 | $password = $wgDBadminpassword; |
63 | 68 | $server = $wgDBserver; |
64 | | - |
| 69 | +
|
65 | 70 | # Parse arguments |
66 | 71 | for( $arg = reset( $argv ); $arg !== false; $arg = next( $argv ) ) { |
67 | 72 | if ( substr( $arg, 0, 7 ) == '-prefix' ) { |
— | — | @@ -110,7 +115,6 @@ |
111 | 116 | echo( "AdminSettings.sample for more details.\n\n" ); |
112 | 117 | exit(); |
113 | 118 | } |
114 | | - |
115 | 119 | # Attempt to connect to the database as a privileged user |
116 | 120 | # This will vomit up an error if there are permissions problems |
117 | 121 | $wdDatabase = new $dbclass( $server, $user, $password, $database, 1 ); |
— | — | @@ -121,8 +125,8 @@ |
122 | 126 | echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" ); |
123 | 127 | exit(); |
124 | 128 | } |
125 | | - |
126 | | -ReadSQLFile( $wdDatabase, "/*\$wgWDprefix*/", $wgWDprefix, $wgWDtemplate ); |
| 129 | +
|
| 130 | +ReadSQLFile( $wdDatabase, "/*\$wgWDprefix*/", $wgWDprefix, $currentdir . DIRECTORY_SEPARATOR . $wgWDtemplate ); |
127 | 131 | $wdDatabase->query( "DELETE FROM wikidata_sets WHERE set_prefix = '$prefix'" ); |
128 | 132 | $wdDatabase->query( "INSERT INTO wikidata_sets (set_prefix,set_fallback_name,set_dmid) VALUES ('$prefix','$comment',0)" );
|
129 | 133 | |