Last active
August 29, 2015 13:56
-
-
Save phuedx/8941767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/wmgUseGettingStarted.php'; // Modified to initialise $wmgUseGettingStarted | |
function getSitelinksByID( $id ) { | |
$url = "https://www.wikidata.org/w/api.php?format=json&action=wbgetentities&props=sitelinks&ids={$id}"; | |
$responseBodyRaw = file_get_contents( $url ); | |
$responseBody = json_decode( $responseBodyRaw, true ); | |
$entity = $responseBody[ 'entities' ][ $id ]; | |
$result = array(); | |
foreach ( $entity[ 'sitelinks' ] as $wgDBname => $sitelink ) { | |
$result[ $wgDBname ] = $sitelink[ 'title' ]; | |
} | |
return $result; | |
} | |
$taskToWikidataCategoryIDMap = array( | |
'copyedit' => 'Q9137504', // Category:Wikipedia articles needing copy edit | |
'clarify' => 'Q8235653', // Category:All Wikipedia articles needing clarification | |
'addlinks' => 'Q8235714', // Category:All articles with too few wikilinks | |
); | |
$config = array(); | |
foreach ( $taskToWikidataCategoryIDMap as $task => $id ) { | |
$sitelinks = getSitelinksByID( $id ); | |
foreach ( $sitelinks as $wgDBname => $category ) { | |
if ( isset( $wmgUseGettingStarted[ $wgDBname ] ) && $wmgUseGettingStarted[ $wgDBname ] ) { | |
$config[ $wgDBname ][ $task ] = $category; | |
} | |
} | |
} | |
$contents = var_export( $config, true ); | |
file_put_contents( 'wmgGettingStartedCategoriesForTaskTypes.php', $contents ); | |
$config = getSitelinksByID( 'Q5312304' ); // Category:Living people | |
$contents = var_export( $config, true ); | |
file_put_contents( 'wmgGettingStartedExcludedCategories.php', $contents ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment