Exemplo n.º 1
0
/**
 * Load dataset definitions from the database if necessary.
 *
 * @return an array of all available datasets
**/
function &wdGetDataSets() {

	static $datasets, $wgGroupPermissions;
	if ( empty( $datasets ) ) {
		// Load defs from the DB
		$dbs = wfGetDB( DB_SLAVE );
		$res = $dbs->select( 'wikidata_sets', array( 'set_prefix' ) );

		while ( $row = $dbs->fetchObject( $res ) ) {

			$dc = new DataSet();
			$dc->setPrefix( $row->set_prefix );
			if ( $dc->isValidPrefix() ) {
				$datasets[$row->set_prefix] = $dc;
				wfDebug( "Imported data set: " . $dc->fetchName() . "\n" );
			} else {
				wfDebug( $row->set_prefix . " does not appear to be a valid dataset!\n" );
			}
		}
	}
	return $datasets;
}