X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2FimportSiteScripts.php;h=65ac65afd8fbbcad79635d7fc9dbe2fac17f3e96;hb=96c5ca47255fca62c3d8fec95aa411699650ce0a;hp=0ce93881bd4ceb8af6c65b70178bee3069356b3a;hpb=bb52be9f3da314361cdb90642f941aea669a1d3e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importSiteScripts.php b/maintenance/importSiteScripts.php index 0ce93881bd..65ac65afd8 100644 --- a/maintenance/importSiteScripts.php +++ b/maintenance/importSiteScripts.php @@ -1,7 +1,6 @@ addArg( 'index', 'index.php base url' ); $this->addOption( 'username', 'User name of the script importer' ); } - + public function execute() { global $wgUser; $user = User::newFromName( $this->getOption( 'username', 'ScriptImporter' ) ); $wgUser = $user; - + $baseUrl = $this->getArg( 1 ); $pageList = $this->fetchScriptList(); $this->output( 'Importing ' . count( $pageList ) . " pages\n" ); - + foreach ( $pageList as $page ) { $title = Title::makeTitleSafe( NS_MEDIAWIKI, $page ); if ( !$title ) { @@ -51,34 +56,34 @@ class ImportSiteScripts extends Maintenance { } $this->output( "Importing $page\n" ); - $url = wfAppendQuery( $baseUrl, array( - 'action' => 'raw', + $url = wfAppendQuery( $baseUrl, array( + 'action' => 'raw', 'title' => "MediaWiki:{$page}" ) ); $text = Http::get( $url ); $wikiPage = WikiPage::factory( $title ); $wikiPage->doEdit( $text, "Importing from $url", 0, false, $user ); } - + } - + protected function fetchScriptList() { - $data = array( + $data = array( 'action' => 'query', 'format' => 'php',//'json', 'list' => 'allpages', 'apnamespace' => '8', - 'aplimit' => '500', + 'aplimit' => '500', ); $baseUrl = $this->getArg( 0 ); $pages = array(); - + do { $url = wfAppendQuery( $baseUrl, $data ); $strResult = Http::get( $url ); //$result = FormatJson::decode( $strResult ); // Still broken $result = unserialize( $strResult ); - + if ( !empty( $result['query']['allpages'] ) ) { foreach ( $result['query']['allpages'] as $page ) { if ( substr( $page['title'], -3 ) === '.js' ) { @@ -92,9 +97,9 @@ class ImportSiteScripts extends Maintenance { $this->output( "Fetching new batch from {$data['apfrom']}\n" ); } } while ( isset( $result['query-continue'] ) ); - + return $pages; - + } }