return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
}
+ /**
+ * Load the extension credits for i18n strings. Very hacky for
+ * now, but I expect it only be used for 1.22.0 at the most.
+ */
+ public function getExtensionInfo( $file ) {
+ global $wgExtensionCredits, $wgVersion, $wgResourceModules;
+
+ $wgVersion = "1.22";
+ $wgResourceModules = array();
+ require_once $file ;
+ $e = array_values( $wgExtensionCredits );
+ if( $e ) {
+ $ext = array_values( $e[0] );
+ $wgExtensionCredits = array();
+ return $ext[0];
+ }
+ }
+
/**
* Finds extensions that follow the format /extensions/Name/Name.php,
* and returns an array containing the value for 'Name' for each found extension.
if ( !is_dir( "$extDir/$file" ) ) {
continue;
}
- if ( file_exists( "$extDir/$file/$file.php" ) ) {
- $exts[] = $file;
+
+ $extFile = "$extDir/$file/$file.php";
+ $extI18NFile = "$extDir/$file/$file.i18n.php";
+ if ( file_exists( $extFile ) ) {
+ if ( $info = $this->getExtensionInfo( $extFile ) ) {
+ $exts[$info['name']] = $info;
+
+ if ( file_exists( $extI18NFile ) ) {
+ global $wgExtensionMessagesFiles;
+ $wgExtensionMessagesFiles[$file] = $extI18NFile;
+ }
+ }
}
}
closedir( $dh );
- natcasesort( $exts );
-
+ uksort( $exts, 'strnatcasecmp' );
return $exts;
}
require "$IP/includes/DefaultSettings.php";
+ $extensions = $this->findExtensions();
foreach ( $exts as $e ) {
- require_once "$IP/extensions/$e/$e.php";
+ require_once $extensions[$e]['path'];
}
$hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
if ( $extensions ) {
$extHtml = $this->getFieldSetStart( 'config-extensions' );
+ /* Force a recache, so we load extensions descriptions */
+ global $wgLang;
+ $lc = Language::getLocalisationCache();
+ $lc->setInitialisedLanguages( array() );
+ $lc->getItem( $wgLang->mCode, '' );
+ LinkCache::singleton()->useDatabase( false );
+
foreach ( $extensions as $ext ) {
$extHtml .= $this->parent->getCheckBox( array(
- 'var' => "ext-$ext",
- 'rawtext' => $ext,
- ) );
+ 'var' => "ext-{$ext['name']}",
+ 'rawtext' => "<b>{$ext['name']}</b>: " .
+ wfMessage( $ext['descriptionmsg'] )->useDatabase( false )->parse(),
+ ) );
+
}
$extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
$this->setVar( 'wgRightsIcon', '' );
}
- $extsAvailable = $this->parent->findExtensions();
+ $extsAvailable = array_map(
+ function($e) {
+ if( isset($e['name']) ) {
+ return $e['name'];
+ }
+ }, $this->parent->findExtensions() );
$extsToInstall = array();
- foreach ( $extsAvailable as $ext ) {
+ foreach ( $extsAvailable as $key => $ext ) {
+ var_dump("config_ext-$ext");
if ( $this->parent->request->getCheck( 'config_ext-' . $ext ) ) {
- $extsToInstall[] = $ext;
+ $extsToInstall[] = $extsAvailable[ $key ];
}
}
$this->parent->setVar( '_Extensions', $extsToInstall );
$linkCache = LinkCache::singleton();
$output = $this->parent->getOutput();
- wfProfileIn( __METHOD__ . '-check' );
- $dbr = wfGetDB( DB_SLAVE );
- $threshold = $this->parent->getOptions()->getStubThreshold();
+ if( $linkCache->useDatabase() ) {
+ wfProfileIn( __METHOD__ . '-check' );
+ $dbr = wfGetDB( DB_SLAVE );
+ $threshold = $this->parent->getOptions()->getStubThreshold();
- # Sort by namespace
- ksort( $this->internals );
+ # Sort by namespace
+ ksort( $this->internals );
- $linkcolour_ids = array();
+ $linkcolour_ids = array();
- # Generate query
- $queries = array();
- foreach ( $this->internals as $ns => $entries ) {
- foreach ( $entries as $entry ) {
- $title = $entry['title'];
- $pdbk = $entry['pdbk'];
+ # Generate query
+ $queries = array();
+ foreach ( $this->internals as $ns => $entries ) {
+ foreach ( $entries as $entry ) {
+ $title = $entry['title'];
+ $pdbk = $entry['pdbk'];
- # Skip invalid entries.
- # Result will be ugly, but prevents crash.
- if ( is_null( $title ) ) {
- continue;
- }
+ # Skip invalid entries.
+ # Result will be ugly, but prevents crash.
+ if ( is_null( $title ) ) {
+ continue;
+ }
- # Check if it's a static known link, e.g. interwiki
- if ( $title->isAlwaysKnown() ) {
- $colours[$pdbk] = '';
- } elseif ( $ns == NS_SPECIAL ) {
- $colours[$pdbk] = 'new';
- } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) {
- $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
- $output->addLink( $title, $id );
- $linkcolour_ids[$id] = $pdbk;
- } elseif ( $linkCache->isBadLink( $pdbk ) ) {
- $colours[$pdbk] = 'new';
- } else {
- # Not in the link cache, add it to the query
- $queries[$ns][] = $title->getDBkey();
+ # Check if it's a static known link, e.g. interwiki
+ if ( $title->isAlwaysKnown() ) {
+ $colours[$pdbk] = '';
+ } elseif ( $ns == NS_SPECIAL ) {
+ $colours[$pdbk] = 'new';
+ } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) {
+ $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
+ $output->addLink( $title, $id );
+ $linkcolour_ids[$id] = $pdbk;
+ } elseif ( $linkCache->isBadLink( $pdbk ) ) {
+ $colours[$pdbk] = 'new';
+ } else {
+ # Not in the link cache, add it to the query
+ $queries[$ns][] = $title->getDBkey();
+ }
}
}
- }
- if ( $queries ) {
- $where = array();
- foreach ( $queries as $ns => $pages ) {
- $where[] = $dbr->makeList(
- array(
- 'page_namespace' => $ns,
- 'page_title' => $pages,
- ),
- LIST_AND
- );
- }
+ if ( $queries ) {
+ $where = array();
+ foreach ( $queries as $ns => $pages ) {
+ $where[] = $dbr->makeList(
+ array(
+ 'page_namespace' => $ns,
+ 'page_title' => $pages,
+ ),
+ LIST_AND
+ );
+ }
- $res = $dbr->select(
- 'page',
- array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
- $dbr->makeList( $where, LIST_OR ),
- __METHOD__
- );
+ $res = $dbr->select(
+ 'page',
+ array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
+ $dbr->makeList( $where, LIST_OR ),
+ __METHOD__
+ );
- # Fetch data and form into an associative array
- # non-existent = broken
- foreach ( $res as $s ) {
- $title = Title::makeTitle( $s->page_namespace, $s->page_title );
- $pdbk = $title->getPrefixedDBkey();
- $linkCache->addGoodLinkObjFromRow( $title, $s );
- $output->addLink( $title, $s->page_id );
- # @todo FIXME: Convoluted data flow
- # The redirect status and length is passed to getLinkColour via the LinkCache
- # Use formal parameters instead
- $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
- //add id to the extension todolist
- $linkcolour_ids[$s->page_id] = $pdbk;
+ # Fetch data and form into an associative array
+ # non-existent = broken
+ foreach ( $res as $s ) {
+ $title = Title::makeTitle( $s->page_namespace, $s->page_title );
+ $pdbk = $title->getPrefixedDBkey();
+ $linkCache->addGoodLinkObjFromRow( $title, $s );
+ $output->addLink( $title, $s->page_id );
+ # @todo FIXME: Convoluted data flow
+ # The redirect status and length is passed to getLinkColour via the LinkCache
+ # Use formal parameters instead
+ $colours[$pdbk] = Linker::getLinkColour( $title, $threshold );
+ //add id to the extension todolist
+ $linkcolour_ids[$s->page_id] = $pdbk;
+ }
+ unset( $res );
}
- unset( $res );
- }
- if ( count( $linkcolour_ids ) ) {
- //pass an array of page_ids to an extension
- wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) );
+ if ( count( $linkcolour_ids ) ) {
+ //pass an array of page_ids to an extension
+ wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) );
+ }
+ wfProfileOut( __METHOD__ . '-check' );
}
- wfProfileOut( __METHOD__ . '-check' );
# Do a second query for different language variants of links and categories
if ( $wgContLang->hasVariants() ) {