Include short descriptions for extensions bundled in the release

Also fix styling for the list of extensions.

Bug: 43817
Change-Id: I5335225683ec8f1c163bb67f478787ebc52ee3a9
This commit is contained in:
Mark A. Hershberger 2013-10-11 21:13:40 +00:00
parent cf5cb9b79a
commit 96b2c66e24
8 changed files with 181 additions and 84 deletions

View file

@ -35,6 +35,7 @@ class LinkCache {
private $mGoodLinkFields = array();
private $mBadLinks = array();
private $mForUpdate = false;
private $useDatabase = true;
/**
* @var LinkCache
@ -209,6 +210,19 @@ class LinkCache {
}
}
/**
* Enable or disable database use.
* @since 1.22
* @param $value Boolean
* @return Boolean
*/
public function useDatabase( $value = null ) {
if ( $value !== null ) {
$this->useDatabase = (bool)$value;
}
return $this->useDatabase;
}
/**
* Add a title to the link cache, return the page_id or zero if non-existent
*
@ -239,6 +253,10 @@ class LinkCache {
return 0;
}
if( !$this->useDatabase ) {
return 0;
}
# Some fields heavily used for linking...
if ( $this->mForUpdate ) {
$db = wfGetDB( DB_MASTER );

View file

@ -1027,6 +1027,25 @@ class LocalisationCache {
$this->store = new LCStoreNull;
$this->manualRecache = false;
}
/**
* Return an array with initialised languages.
*
* @return array
*/
public function getInitialisedLanguages() {
return $this->initialisedLangs;
}
/**
* Set initialised languages.
*
* @param array $languages Optional array of initialised languages.
*/
public function setInitialisedLanguages( $languages = array() ) {
$this->initialisedLangs = $languages;
}
}
/**

View file

@ -1407,6 +1407,24 @@ abstract class Installer {
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.
@ -1429,13 +1447,22 @@ abstract class Installer {
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;
}
@ -1462,8 +1489,9 @@ abstract class Installer {
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'] ) ?

View file

@ -137,14 +137,21 @@ class LocalSettingsGenerator {
$localSettings = $this->getDefaultText();
if ( count( $this->extensions ) ) {
$extensions = $this->installer->findExtensions();
$localSettings .= "
# Enabled Extensions. Most extensions are enabled by including the base extension file here
# but check specific extension documentation for more details
# The following extensions were automatically enabled:\n";
foreach ( $this->extensions as $extName ) {
$encExtName = self::escapePhpString( $extName );
$localSettings .= "require_once \"\$IP/extensions/$encExtName/$encExtName.php\";\n";
$ip = $this->installer->getVar( 'IP' );
foreach ( $this->extensions as $ext) {
$path = str_replace( $ip, '', $extensions[$ext]['path'] );
$prefix = '';
if ( $path !== $extensions[$ext]['path'] ) {
$prefix = '$IP';
}
$path = $prefix . self::escapePhpString( $path );
$localSettings .= "require_once \"$path\";\n";
}
}

View file

@ -923,8 +923,10 @@ class WebInstaller extends Installer {
}
if ( isset( $params['rawtext'] ) ) {
$labelText = $params['rawtext'];
} else {
} elseif ( isset( $params['label'] ) ) {
$labelText = $this->parse( wfMessage( $params['label'] )->text() );
} else {
$labelText = "";
}
return "<div class=\"config-input-check\">\n" .

View file

@ -948,11 +948,20 @@ class WebInstaller_Options extends WebInstallerPage {
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' ) .
@ -1175,11 +1184,17 @@ class WebInstaller_Options extends WebInstallerPage {
$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 );

View file

@ -280,85 +280,87 @@ class LinkHolderArray {
$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 ) );
}
wfProfileOut( __METHOD__ . '-check' );
}
if ( count( $linkcolour_ids ) ) {
//pass an array of page_ids to an extension
wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) );
}
wfProfileOut( __METHOD__ . '-check' );
# Do a second query for different language variants of links and categories
if ( $wgContLang->hasVariants() ) {

View file

@ -88,7 +88,13 @@
}
.config-input-check {
margin-left: 10em;
margin-left: 3.7em;
margin-right: 2em;
margin-bottom: 0.25em;
}
.config-input-check input {
margin-left: -1em;
}
.error {