if( $wgRightsPage && ( $nt = Title::newFromText( $wgRightsPage ) )
&& ($nt->getArticleID() != 0)) {
$this->page('rights', $nt);
- } else if( $wgRightsUrl ){
+ } elseif( $wgRightsUrl ){
$this->url('rights', $wgRightsUrl);
- } else if( $wgRightsText ){
+ } elseif( $wgRightsText ){
$this->element( 'rights', $wgRightsText );
}
}
#Try a couple of headers
if( isset( $set[$index] ) ) {
return $set[$index];
- } else if( isset( $set[$index2] ) ) {
+ } elseif( isset( $set[$index2] ) ) {
return $set[$index2];
} else {
return null;
$sk->initPage( $wgOut );
if( $this->mGen == 'css' ) {
return $sk->generateUserStylesheet();
- } else if( $this->mGen == 'js' ) {
+ } elseif( $this->mGen == 'js' ) {
return $sk->generateUserJs();
}
} else {
if ( isset( $skinNames[$key] ) ) {
return $key;
- } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
+ } elseif ( isset( $skinNames[$wgDefaultSkin] ) ) {
return $wgDefaultSkin;
} else {
return 'vector';
*/
function preloadExistence() {
$user = $this->getContext()->getUser();
-
+
// User/talk link
$titles = array( $user->getUserPage(), $user->getTalkPage() );
);
} else {
return '';
- }
+ }
}
/**
$url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
$text = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
- wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
+ wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
return $text;
}
'id' => 'n-' . strtr( $line[1], ' ', '-' ),
'active' => false
);
- } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
+ } elseif ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
global $wgParser;
$line = substr( $line, 2, strlen( $line ) - 4 );
// only apply to the dc:Creator prop, not the
// exif:Artist prop.
- $data['xmp-general']['Artist'][0] =
+ $data['xmp-general']['Artist'][0] =
$data['xmp-special']['AuthorsPosition'] . ', '
. $data['xmp-general']['Artist'][0];
}
if ( !$this->charset ) {
$bom = array();
if ( preg_match( '/\xEF\xBB\xBF|\xFE\xFF|\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFF\xFE/',
- $content, $bom )
+ $content, $bom )
) {
switch ( $bom[0] ) {
case "\xFE\xFF":
* property value, and now have to save the result to the
* results array
*
- * For example, when processing:
+ * For example, when processing:
* <exif:DigitalZoomRatio>0/10</exif:DigitalZoomRatio>
* this deals with when we hit </exif:DigitalZoomRatio>.
*
*
* generally just calls a helper function depending on what
* mode we're in.
- *
+ *
* Ignores the outer wrapping elements that are optional in
* xmp and have no meaning.
*
private function startElementModeSeq( $elm ) {
if ( $elm === self::NS_RDF . ' Seq' ) {
array_unshift( $this->mode, self::MODE_LI );
- } else if ( $elm === self::NS_RDF . ' Bag' ) {
+ } elseif ( $elm === self::NS_RDF . ' Bag' ) {
# bug 27105
wfDebugLog( 'XMP', __METHOD__ . ' Expected an rdf:Seq, but got an rdf:Bag. Pretending'
. ' it is a Seq, since some buggy software is known to screw this up.' );
* <exif:Mode>1</exif:Mode></rdf:Description></exif:Flash>
*
* or:
- *
+ *
* <exif:Flash rdf:parseType='Resource'> <exif:Fired>True</exif:Fired>
- * <exif:Mode>1</exif:Mode></exif:Flash>
+ * <exif:Mode>1</exif:Mode></exif:Flash>
*
* @param $ns String namespace
* @param $tag String tag name (no ns)
* This method is called when we hit the <rdf:li> element.
*
* @param $elm String: namespace . ' ' . tagname
- * @param $attribs Array: Attributes. (needed for BAGSTRUCTS)
+ * @param $attribs Array: Attributes. (needed for BAGSTRUCTS)
* @throws MWException if gets a tag other than <rdf:li>
*/
private function startElementModeLi( $elm, $attribs ) {
function startElement( $parser, $elm, $attribs ) {
if ( $elm === self::NS_RDF . ' RDF'
- || $elm === 'adobe:ns:meta/ xmpmeta'
+ || $elm === 'adobe:ns:meta/ xmpmeta'
|| $elm === 'adobe:ns:meta/ xapmeta')
{
/* ignore. */
* @param $attribs Array attribute=>value array.
*/
private function doAttribs( $attribs ) {
-
+
// first check for rdf:parseType attribute, as that can change
// how the attributes are interperted.
function unichr($c) {
if ($c <= 0x7F) {
return chr($c);
- } else if ($c <= 0x7FF) {
+ } elseif ($c <= 0x7FF) {
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
- } else if ($c <= 0xFFFF) {
+ } elseif ($c <= 0xFFFF) {
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
- } else if ($c <= 0x10FFFF) {
+ } elseif ($c <= 0x10FFFF) {
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
if ( $attributes !== '' ) {
$table['attributes'] = $attributes;
}
- } else if ( !isset( $tables[0] ) ) {
+ } elseif ( !isset( $tables[0] ) ) {
// we're outside the table
$out .= $outLine . "\n";
- } else if ( $firstChars === '|}' ) {
+ } elseif ( $firstChars === '|}' ) {
// trim the |} code from the line
$line = substr ( $line , 2 );
$output .= $o;
- } else if ( $firstChars === '|-' ) {
+ } elseif ( $firstChars === '|-' ) {
// start a new row element
// but only when we haven't started one already
if ( count( $currentRow ) != 0 ) {
$currentRow['attributes'] = $attributes;
}
- } else if ( $firstChars === '|+' ) {
+ } elseif ( $firstChars === '|+' ) {
// a table caption, but only proceed if there isn't one already
if ( !isset ( $table['caption'] ) ) {
$line = substr ( $line , 2 );
unset( $c );
$output =& $table['caption']['content'];
}
- } else if ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) {
+ } elseif ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) {
// Which kind of cells are we dealing with
$currentTag = 'td';
$line = substr ( $line , 1 );
// decide whether thead to tbody
if ( !array_key_exists( 'type', $currentRow ) ) {
$currentRow['type'] = ( $firstChars === '!' ) ? 'thead' : 'tbody' ;
- } else if ( $firstChars === '|' ) {
+ } elseif ( $firstChars === '|' ) {
$currentRow['type'] = 'tbody';
}
if ( strpos( $cellData[0], '[[' ) !== false ) {
$content = trim ( $cell );
}
- else if ( count ( $cellData ) == 1 ) {
+ elseif ( count ( $cellData ) == 1 ) {
$content = trim ( $cellData[0] );
} else {
$attributes = $this->mStripState->unstripBoth( $cellData[0] );
if ( !isset( $table[$i]['type'] ) ) $table[$i]['type'] = 'tbody';
if ( !$lastSection ) {
$lastSection = $table[$i]['type'];
- } else if ( $lastSection != $table[$i]['type'] ) {
+ } elseif ( $lastSection != $table[$i]['type'] ) {
$simple = false;
break;
}
$args = ( null == $piece['parts'] ) ? array() : $piece['parts'];
wfProfileOut( __METHOD__.'-setup' );
wfProfileIn( __METHOD__."-title-$originalTitle" );
-
+
# SUBST
wfProfileIn( __METHOD__.'-modifiers' );
if ( !$found ) {
/**
* Loads information stored in the database about modules.
- *
- * This method grabs modules dependencies from the database and updates modules
+ *
+ * This method grabs modules dependencies from the database and updates modules
* objects.
- *
- * This is not inside the module code because it is much faster to
- * request all of the information at once than it is to have each module
+ *
+ * This is not inside the module code because it is much faster to
+ * request all of the information at once than it is to have each module
* requests its own information. This sacrifice of modularity yields a substantial
* performance improvement.
- *
+ *
* @param $modules Array: List of module names to preload information for
* @param $context ResourceLoaderContext: Context to load the information within
*/
$dbr = wfGetDB( DB_SLAVE );
$skin = $context->getSkin();
$lang = $context->getLanguage();
-
+
// Get file dependency information
$res = $dbr->select( 'module_deps', array( 'md_module', 'md_deps' ), array(
'md_module' => $modules,
foreach ( array_diff( $modules, $modulesWithDeps ) as $name ) {
$this->getModule( $name )->setFileDependencies( $skin, array() );
}
-
+
// Get message blob mtimes. Only do this for modules with messages
$modulesWithMessages = array();
foreach ( $modules as $name ) {
), __METHOD__
);
foreach ( $res as $row ) {
- $this->getModule( $row->mr_resource )->setMsgBlobMtime( $lang,
+ $this->getModule( $row->mr_resource )->setMsgBlobMtime( $lang,
wfTimestamp( TS_UNIX, $row->mr_timestamp ) );
unset( $modulesWithoutMessages[$row->mr_resource] );
}
- }
+ }
foreach ( array_keys( $modulesWithoutMessages ) as $name ) {
$this->getModule( $name )->setMsgBlobMtime( $lang, 0 );
}
/**
* Runs JavaScript or CSS data through a filter, caching the filtered result for future calls.
- *
+ *
* Available filters are:
* - minify-js \see JavaScriptMinifier::minify
* - minify-css \see CSSMin::minify
- *
- * If $data is empty, only contains whitespace or the filter was unknown,
+ *
+ * If $data is empty, only contains whitespace or the filter was unknown,
* $data is returned unmodified.
- *
+ *
* @param $filter String: Name of filter to run
* @param $data String: Text to filter, such as JavaScript or CSS text
* @return String: Filtered data, or a comment containing an error message
global $wgResourceLoaderMinifierStatementsOnOwnLine, $wgResourceLoaderMinifierMaxLineLength;
wfProfileIn( __METHOD__ );
- // For empty/whitespace-only data or for unknown filters, don't perform
+ // For empty/whitespace-only data or for unknown filters, don't perform
// any caching or processing
- if ( trim( $data ) === ''
- || !in_array( $filter, array( 'minify-js', 'minify-css' ) ) )
+ if ( trim( $data ) === ''
+ || !in_array( $filter, array( 'minify-js', 'minify-css' ) ) )
{
wfProfileOut( __METHOD__ );
return $data;
}
wfProfileOut( __METHOD__ );
-
+
return $result;
}
*/
public function __construct() {
global $IP, $wgResourceModules;
-
+
wfProfileIn( __METHOD__ );
-
+
// Register core modules
$this->register( include( "$IP/resources/Resources.php" ) );
// Register extension modules
wfRunHooks( 'ResourceLoaderRegisterModules', array( &$this ) );
$this->register( $wgResourceModules );
-
+
wfProfileOut( __METHOD__ );
}
/**
* Registers a module with the ResourceLoader system.
- *
+ *
* @param $name Mixed: Name of module as a string or List of name/object pairs as an array
- * @param $info Module info array. For backwards compatibility with 1.17alpha,
- * this may also be a ResourceLoaderModule object. Optional when using
+ * @param $info Module info array. For backwards compatibility with 1.17alpha,
+ * this may also be a ResourceLoaderModule object. Optional when using
* multiple-registration calling style.
* @throws MWException: If a duplicate module registration is attempted
* @throws MWException: If a module name contains illegal characters (pipes or commas)
if ( isset( $this->moduleInfos[$name] ) ) {
// A module has already been registered by this name
throw new MWException(
- 'ResourceLoader duplicate registration error. ' .
+ 'ResourceLoader duplicate registration error. ' .
'Another module has already been registered as ' . $name
);
}
-
+
// Check $name for illegal characters
if ( preg_match( '/[|,!]/', $name ) ) {
throw new MWException( "ResourceLoader module name '$name' is invalid. Names may not contain pipes (|), commas (,) or exclamation marks (!)" );
// Old calling convention
// Validate the input
if ( !( $info instanceof ResourceLoaderModule ) ) {
- throw new MWException( 'ResourceLoader invalid module error. ' .
+ throw new MWException( 'ResourceLoader invalid module error. ' .
'Instances of ResourceLoaderModule expected.' );
}
*/
public function respond( ResourceLoaderContext $context ) {
global $wgResourceLoaderMaxage, $wgCacheEpoch;
-
+
// Buffer output to catch warnings. Normally we'd use ob_clean() on the
// top-level output buffer to clear warnings, but that breaks when ob_gzhandler
// is used: ob_clean() will clear the GZIP header in that case and it won't come
}
}
- // If a version wasn't specified we need a shorter expiry time for updates
+ // If a version wasn't specified we need a shorter expiry time for updates
// to propagate to clients quickly
if ( is_null( $context->getVersion() ) ) {
$maxage = $wgResourceLoaderMaxage['unversioned']['client'];
$smaxage = $wgResourceLoaderMaxage['unversioned']['server'];
}
- // If a version was specified we can use a longer expiry time since changing
+ // If a version was specified we can use a longer expiry time since changing
// version numbers causes cache misses
else {
$maxage = $wgResourceLoaderMaxage['versioned']['client'];
wfProfileIn( __METHOD__.'-getModifiedTime' );
$private = false;
- // To send Last-Modified and support If-Modified-Since, we need to detect
+ // To send Last-Modified and support If-Modified-Since, we need to detect
// the last modified time
$mtime = wfTimestamp( TS_UNIX, $wgCacheEpoch );
foreach ( $modules as $module ) {
for ( $i = 0; $i < ob_get_level(); $i++ ) {
ob_end_clean();
}
-
+
header( 'HTTP/1.0 304 Not Modified' );
header( 'Status: 304 Not Modified' );
wfProfileOut( __METHOD__ );
return;
}
}
-
+
// Generate a response
$response = $this->makeModuleResponse( $context, $modules, $missing );
-
+
// Prepend comments indicating exceptions
$response = $exceptions . $response;
/**
* Generates code for a response
- *
+ *
* @param $context ResourceLoaderContext: Context in which to generate a response
* @param $modules Array: List of module objects keyed by module name
* @param $missing Array: List of unavailable modules (optional)
* @return String: Response data
*/
- public function makeModuleResponse( ResourceLoaderContext $context,
- array $modules, $missing = array() )
+ public function makeModuleResponse( ResourceLoaderContext $context,
+ array $modules, $missing = array() )
{
$out = '';
$exceptions = '';
if ( $modules === array() && $missing === array() ) {
return '/* No modules requested. Max made me put this here */';
}
-
+
wfProfileIn( __METHOD__ );
// Pre-fetch blobs
if ( $context->shouldIncludeMessages() ) {
case 'scripts':
if ( is_string( $scripts ) ) {
$out .= $scripts;
- } else if ( is_array( $scripts ) ) {
+ } elseif ( is_array( $scripts ) ) {
$out .= self::makeLoaderImplementScript( $name, $scripts, array(), array() );
}
break;
// Update module states
if ( $context->shouldIncludeScripts() ) {
// Set the state of modules loaded as only scripts to ready
- if ( count( $modules ) && $context->getOnly() === 'scripts'
- && !isset( $modules['startup'] ) )
+ if ( count( $modules ) && $context->getOnly() === 'scripts'
+ && !isset( $modules['startup'] ) )
{
- $out .= self::makeLoaderStateScript(
+ $out .= self::makeLoaderStateScript(
array_fill_keys( array_keys( $modules ), 'ready' ) );
}
// Set the state of modules which were requested but unavailable as missing
$out = $this->filter( 'minify-js', $out );
}
}
-
+
wfProfileOut( __METHOD__ );
return $exceptions . $out;
}
/* Static Methods */
/**
- * Returns JS code to call to mw.loader.implement for a module with
+ * Returns JS code to call to mw.loader.implement for a module with
* given properties.
*
* @param $name Module name
* @param $scripts Mixed: List of URLs to JavaScript files or String of JavaScript code
* @param $styles Mixed: List of CSS strings keyed by media type, or list of lists of URLs to
* CSS files keyed by media type
- * @param $messages Mixed: List of messages associated with this module. May either be an
+ * @param $messages Mixed: List of messages associated with this module. May either be an
* associative array mapping message key to value, or a JSON-encoded message blob containing
* the same data, wrapped in an XmlJsCode object.
*
public static function makeLoaderImplementScript( $name, $scripts, $styles, $messages ) {
if ( is_string( $scripts ) ) {
$scripts = new XmlJsCode( "function( $ ) {{$scripts}}" );
- } else if ( !is_array( $scripts ) ) {
+ } elseif ( !is_array( $scripts ) ) {
throw new MWException( 'Invalid scripts error. Array of URLs or string of code expected.' );
}
- return Xml::encodeJsCall(
- 'mw.loader.implement',
+ return Xml::encodeJsCall(
+ 'mw.loader.implement',
array(
$name,
$scripts,
}
/**
- * Combines an associative array mapping media type to CSS into a
+ * Combines an associative array mapping media type to CSS into a
* single stylesheet with @media blocks.
*
* @param $styles Array: List of CSS strings keyed by media type
// Transform the media type based on request params and config
// The way that this relies on $wgRequest to propagate request params is slightly evil
$media = OutputPage::transformCssMedia( $media );
-
+
if ( $media === null ) {
// Skip
- } else if ( $media === '' || $media == 'all' ) {
+ } elseif ( $media === '' || $media == 'all' ) {
// Don't output invalid or frivolous @media statements
$out .= "$style\n";
} else {
}
/**
- * Returns a JS call to mw.loader.state, which sets the state of a
+ * Returns a JS call to mw.loader.state, which sets the state of a
* module or modules to a given value. Has two calling conventions:
*
* - ResourceLoader::makeLoaderStateScript( $name, $state ):
/**
* Returns JS code which calls the script given by $script. The script will
- * be called with local variables name, version, dependencies and group,
- * which will have values corresponding to $name, $version, $dependencies
- * and $group as supplied.
+ * be called with local variables name, version, dependencies and group,
+ * which will have values corresponding to $name, $version, $dependencies
+ * and $group as supplied.
*
* @param $name String: Module name
* @param $version Integer: Module version number as a timestamp
*/
public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $script ) {
$script = str_replace( "\n", "\n\t", trim( $script ) );
- return Xml::encodeJsCall(
+ return Xml::encodeJsCall(
"( function( name, version, dependencies, group ) {\n\t$script\n} )",
array( $name, $version, $dependencies, $group ) );
}
/**
- * Returns JS code which calls mw.loader.register with the given
+ * Returns JS code which calls mw.loader.register with the given
* parameters. Has three calling conventions:
*
* - ResourceLoader::makeLoaderRegisterScript( $name, $version, $dependencies, $group ):
*
* @return string
*/
- public static function makeLoaderRegisterScript( $name, $version = null,
- $dependencies = null, $group = null )
+ public static function makeLoaderRegisterScript( $name, $version = null,
+ $dependencies = null, $group = null )
{
if ( is_array( $name ) ) {
return Xml::encodeJsCall( 'mw.loader.register', array( $name ) );
} else {
$version = (int) $version > 1 ? (int) $version : 1;
- return Xml::encodeJsCall( 'mw.loader.register',
+ return Xml::encodeJsCall( 'mw.loader.register',
array( $name, $version, $dependencies, $group ) );
}
}
/**
- * Returns JS code which runs given JS code if the client-side framework is
+ * Returns JS code which runs given JS code if the client-side framework is
* present.
*
* @param $script String: JavaScript code
}
/**
- * Returns JS code which will set the MediaWiki configuration array to
+ * Returns JS code which will set the MediaWiki configuration array to
* the given value.
*
* @param $configuration Array: List of configuration values keyed by variable name
/**
* Convert an array of module names to a packed query string.
- *
+ *
* For example, array( 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' )
* becomes 'foo.bar,baz|bar.baz,quux'
* @param $modules array of module names (strings)
/**
* Constructs a new module from an options array.
- *
+ *
* @param $options Array: List of options; if not given or empty, an empty module will be
* constructed
* @param $localBasePath String: Base path to prepend to all local paths in $options. Defaults
* @param $remoteBasePath String: Base path to prepend to all remote paths in $options. Defaults
* to $wgScriptPath
*
- * Below is a description for the $options array:
+ * Below is a description for the $options array:
* @code
* array(
* // Base path to prepend to all local paths in $options. Defaults to $IP
* )
* @endcode
*/
- public function __construct( $options = array(), $localBasePath = null,
- $remoteBasePath = null )
+ public function __construct( $options = array(), $localBasePath = null,
+ $remoteBasePath = null )
{
global $IP, $wgScriptPath;
$this->localBasePath = $localBasePath === null ? $IP : $localBasePath;
case 'skinStyles':
if ( !is_array( $option ) ) {
throw new MWException(
- "Invalid collated file path list error. " .
+ "Invalid collated file path list error. " .
"'$option' given, array expected."
);
}
foreach ( $option as $key => $value ) {
if ( !is_string( $key ) ) {
throw new MWException(
- "Invalid collated file path list key error. " .
+ "Invalid collated file path list key error. " .
"'$key' given, string expected."
);
}
/**
* Gets all scripts for a given context concatenated together.
- *
+ *
* @param $context ResourceLoaderContext: Context in which to generate script
* @return String: JavaScript code for $context
*/
/**
* Gets loader script.
- *
+ *
* @return String: JavaScript code to be added to startup module
*/
public function getLoaderScript() {
/**
* Gets all styles for a given context concatenated together.
- *
+ *
* @param $context ResourceLoaderContext: Context in which to generate styles
* @return String: CSS code for $context
*/
/**
* Gets list of message keys used by this module.
- *
+ *
* @return Array: List of message keys
*/
public function getMessages() {
/**
* Gets the name of the group this module should be loaded in.
- *
+ *
* @return String: Group name
*/
public function getGroup() {
/**
* Gets list of names of modules this module depends on.
- *
+ *
* @return Array: List of module names
*/
public function getDependencies() {
/**
* Get the last modified timestamp of this module.
- *
- * Last modified timestamps are calculated from the highest last modified
- * timestamp of this module's constituent files as well as the files it
- * depends on. This function is context-sensitive, only performing
- * calculations on files relevant to the given language, skin and debug
+ *
+ * Last modified timestamps are calculated from the highest last modified
+ * timestamp of this module's constituent files as well as the files it
+ * depends on. This function is context-sensitive, only performing
+ * calculations on files relevant to the given language, skin and debug
* mode.
- *
- * @param $context ResourceLoaderContext: Context in which to calculate
+ *
+ * @param $context ResourceLoaderContext: Context in which to calculate
* the modified time
* @return Integer: UNIX timestamp
* @see ResourceLoaderModule::getFileDependencies
return $this->modifiedTime[$context->getHash()];
}
wfProfileIn( __METHOD__ );
-
+
$files = array();
-
+
// Flatten style files into $files
$styles = self::collateFilePathListByOption( $this->styles, 'media', 'all' );
foreach ( $styles as $styleFiles ) {
$files = array_merge( $files, $styleFiles );
}
$skinFiles = self::tryForKey(
- self::collateFilePathListByOption( $this->skinStyles, 'media', 'all' ),
- $context->getSkin(),
+ self::collateFilePathListByOption( $this->skinStyles, 'media', 'all' ),
+ $context->getSkin(),
'default'
);
foreach ( $skinFiles as $styleFiles ) {
$files = array_merge( $files, $styleFiles );
}
-
+
// Final merge, this should result in a master list of dependent files
$files = array_merge(
$files,
$files = array_map( array( $this, 'getLocalPath' ), $files );
// File deps need to be treated separately because they're already prefixed
$files = array_merge( $files, $this->getFileDependencies( $context->getSkin() ) );
-
- // If a module is nothing but a list of dependencies, we need to avoid
+
+ // If a module is nothing but a list of dependencies, we need to avoid
// giving max() an empty array
if ( count( $files ) === 0 ) {
wfProfileOut( __METHOD__ );
return $this->modifiedTime[$context->getHash()] = 1;
}
-
+
wfProfileIn( __METHOD__.'-filemtime' );
$filesMtime = max( array_map( 'filemtime', $files ) );
wfProfileOut( __METHOD__.'-filemtime' );
- $this->modifiedTime[$context->getHash()] = max(
- $filesMtime,
+ $this->modifiedTime[$context->getHash()] = max(
+ $filesMtime,
$this->getMsgBlobMtime( $context->getLanguage() ) );
wfProfileOut( __METHOD__ );
/**
* Collates file paths by option (where provided).
- *
- * @param $list Array: List of file paths in any combination of index/path
+ *
+ * @param $list Array: List of file paths in any combination of index/path
* or path/options pairs
* @param $option String: option name
* @param $default Mixed: default value if the option isn't set
$collatedFiles[$default] = array();
}
$collatedFiles[$default][] = $value;
- } else if ( is_array( $value ) ) {
+ } elseif ( is_array( $value ) ) {
// File name as the key, options array as the value
$optionValue = isset( $value[$option] ) ? $value[$option] : $default;
if ( !isset( $collatedFiles[$optionValue] ) ) {
/**
* Gets a list of element that match a key, optionally using a fallback key.
- *
+ *
* @param $list Array: List of lists to select from
* @param $key String: Key to look for in $map
* @param $fallback String: Key to look for in $list if $key doesn't exist
- * @return Array: List of elements from $map which matched $key or $fallback,
+ * @return Array: List of elements from $map which matched $key or $fallback,
* or an empty list in case of no match
*/
protected static function tryForKey( array $list, $key, $fallback = null ) {
if ( isset( $list[$key] ) && is_array( $list[$key] ) ) {
return $list[$key];
- } else if ( is_string( $fallback )
- && isset( $list[$fallback] )
- && is_array( $list[$fallback] ) )
+ } elseif ( is_string( $fallback )
+ && isset( $list[$fallback] )
+ && is_array( $list[$fallback] ) )
{
return $list[$fallback];
}
/**
* Gets a list of file paths for all scripts in this module, in order of propper execution.
- *
+ *
* @param $context ResourceLoaderContext: Context
* @return Array: List of file paths
*/
/**
* Gets a list of file paths for all styles in this module, in order of propper inclusion.
- *
+ *
* @param $context ResourceLoaderContext: Context
* @return Array: List of file paths
*/
/**
* Gets the contents of a list of JavaScript files.
- *
+ *
* @param $scripts Array: List of file paths to scripts to read, remap and concetenate
* @return String: Concatenated and remapped JavaScript data from $scripts
*/
/**
* Gets the contents of a list of CSS files.
- *
+ *
* @param $styles Array: List of media type/list of file paths pairs, to read, remap and
* concetenate
*
* @param $flip bool
*
- * @return Array: List of concatenated and remapped CSS data from $styles,
+ * @return Array: List of concatenated and remapped CSS data from $styles,
* keyed by media type
*/
protected function readStyleFiles( array $styles, $flip ) {
/**
* Reads a style file.
- *
+ *
* This method can be used as a callback for array_map()
- *
+ *
* @param $path String: File path of script file to read
* @param $flip bool
*
* @return String: CSS data in script file
*/
- protected function readStyleFile( $path, $flip ) {
+ protected function readStyleFile( $path, $flip ) {
$localPath = $this->getLocalPath( $path );
$style = file_get_contents( $localPath );
if ( $style === false ) {
$dir = $this->getLocalPath( $dirname );
$remoteDir = $this->getRemotePath( $dirname );
// Get and register local file references
- $this->localFileRefs = array_merge(
- $this->localFileRefs,
+ $this->localFileRefs = array_merge(
+ $this->localFileRefs,
CSSMin::getLocalFileReferences( $style, $dir ) );
return CSSMin::remap(
$style, $dir, $remoteDir, true
*/
class ResourceLoaderStartUpModule extends ResourceLoaderModule {
-
+
/* Protected Members */
protected $modifiedTime = array();
protected function getConfig( $context ) {
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
$wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
- $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion,
+ $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion,
$wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest,
$wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
$wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgLegacyJavaScriptGlobals;
if ( $wgUseAjax && $wgEnableMWSuggest ) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
}
-
+
wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) );
-
+
return $vars;
}
-
+
/**
* Gets registration code for all modules
*
public static function getModuleRegistrations( ResourceLoaderContext $context ) {
global $wgCacheEpoch;
wfProfileIn( __METHOD__ );
-
+
$out = '';
$registrations = array();
$resourceLoader = $context->getResourceLoader();
if ( $loader !== false ) {
$deps = $module->getDependencies();
$group = $module->getGroup();
- $version = wfTimestamp( TS_ISO_8601_BASIC,
+ $version = wfTimestamp( TS_ISO_8601_BASIC,
$module->getModifiedTime( $context ) );
$out .= ResourceLoader::makeCustomLoaderScript( $name, $version, $deps, $group, $loader );
}
// seem to do that, and custom implementations might forget. Coerce it to TS_UNIX
$moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) );
$mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
- // Modules without dependencies or a group pass two arguments (name, timestamp) to
+ // Modules without dependencies or a group pass two arguments (name, timestamp) to
// mw.loader.register()
if ( !count( $module->getDependencies() && $module->getGroup() === null ) ) {
$registrations[] = array( $name, $mtime );
}
- // Modules with dependencies but no group pass three arguments
+ // Modules with dependencies but no group pass three arguments
// (name, timestamp, dependencies) to mw.loader.register()
- else if ( $module->getGroup() === null ) {
+ elseif ( $module->getGroup() === null ) {
$registrations[] = array(
$name, $mtime, $module->getDependencies() );
}
- // Modules with dependencies pass four arguments (name, timestamp, dependencies, group)
+ // Modules with dependencies pass four arguments (name, timestamp, dependencies, group)
// to mw.loader.register()
else {
$registrations[] = array(
}
}
$out .= ResourceLoader::makeLoaderRegisterScript( $registrations );
-
+
wfProfileOut( __METHOD__ );
return $out;
}
// The core modules:
$modules = array( 'jquery', 'mediawiki' );
wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$modules ) );
-
+
// Get the latest version
- $version = 0;
+ $version = 0;
foreach ( $modules as $moduleName ) {
$version = max( $version,
$context->getResourceLoader()->getModule( $moduleName )->getModifiedTime( $context )
);
}
- // Build load query for StartupModules
+ // Build load query for StartupModules
$query = array(
'modules' => ResourceLoader::makePackedModulesString( $modules ),
'only' => 'scripts',
$this->modifiedTime[$hash] = filemtime( "$IP/resources/startup.js" );
// ATTENTION!: Because of the line above, this is not going to cause
- // infinite recursion - think carefully before making changes to this
+ // infinite recursion - think carefully before making changes to this
// code!
$time = wfTimestamp( TS_UNIX, $wgCacheEpoch );
foreach ( $loader->getModuleNames() as $name ) {
if ( $archived->numRows() == 0 ) {
return $live;
- } else if ( $live->numRows() == 0 ) {
+ } elseif ( $live->numRows() == 0 ) {
return $archived;
} else {
// Combine the two! Whee
$status->successCount++;
if( $item->getAuthorId() > 0 ) {
$authorIds[] = $item->getAuthorId();
- } else if( IP::isIPAddress( $item->getAuthorName() ) ) {
+ } elseif( IP::isIPAddress( $item->getAuthorName() ) ) {
$authorIPs[] = $item->getAuthorName();
}
} else {
* enabled / disabled.
* @param $field Integer: the bitmask describing the single option.
* @param $diff Integer: the xor of the old and new bitfields.
- * @param $new Integer: the new bitfield
+ * @param $new Integer: the new bitfield
* @param $arr Array: the array to update.
*/
protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
/**
* Gets an array of message keys describing the changes made to the visibility
- * of the revision. If the resulting array is $arr, then $arr[0] will contain an
- * array of strings describing the items that were hidden, $arr[2] will contain
- * an array of strings describing the items that were unhidden, and $arr[3] will
- * contain an array with a single string, which can be one of "applied
+ * of the revision. If the resulting array is $arr, then $arr[0] will contain an
+ * array of strings describing the items that were hidden, $arr[2] will contain
+ * an array of strings describing the items that were unhidden, and $arr[3] will
+ * contain an array with a single string, which can be one of "applied
* restrictions to sysops", "removed restrictions from sysops", or null.
*
* @param $n Integer: the new bitfield.
*/
public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false, $forContent = false ) {
global $wgLang, $wgContLang;
-
+
$lang = $forContent ? $wgContLang : $wgLang;
$msgFunc = $forContent ? "wfMsgForContent" : "wfMsg";
-
+
$changes = self::getChanges( $nbitfield, $obitfield );
array_walk( $changes, array( __CLASS__, 'expandMessageArray' ), $forContent );
-
+
$changesText = array();
-
+
if( count( $changes[0] ) ) {
$changesText[] = $msgFunc( 'revdelete-hid', $lang->commaList( $changes[0] ) );
}
if( count( $changes[1] ) ) {
$changesText[] = $msgFunc( 'revdelete-unhid', $lang->commaList( $changes[1] ) );
}
-
+
$s = $lang->semicolonList( $changesText );
if( count( $changes[2] ) ) {
$s .= $s ? ' (' . $changes[2][0] . ')' : ' ' . $changes[2][0];
}
-
+
$msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message';
return wfMsgExt( $msg, $forContent ? array( 'parsemag', 'content' ) : array( 'parsemag' ), $s, $lang->formatNum($count) );
}
-
+
private static function expandMessageArray(& $msg, $key, $forContent) {
if ( is_array ( $msg ) ) {
array_walk( $msg, array( __CLASS__, 'expandMessageArray' ), $forContent );
}
}
}
-
+
// Get DB field name for URL param...
// Future code for other things may also track
// other types of revision-specific changes.
$dbr = wfGetDB( DB_SLAVE );
$exists = $dbr->selectField( 'revision', '1',
array( 'rev_id' => $revid ), __METHOD__ );
-
+
if ( $exists ) {
return true;
}
-
+
$timestamp = $dbr->selectField( 'archive', 'ar_timestamp',
array( 'ar_namespace' => $title->getNamespace(),
'ar_title' => $title->getDBkey(),
'ar_rev_id' => $revid ), __METHOD__ );
-
+
return $timestamp;
}
*/
public static function getLogLinks( $title, $paramArray, $skin, $messages ) {
global $wgLang;
-
+
if( count($paramArray) >= 2 ) {
// Different revision types use different URL params...
$originalKey = $key = $paramArray[0];
$Ids = explode( ',', $paramArray[1] );
$revert = array();
-
+
// For if undeleted revisions are found amidst deleted ones.
$undeletedRevisions = array();
-
+
// This is not going to work if some revs are deleted and some
// aren't.
if ($key == 'revision') {
// Nothing to do; deleted revisions can still be looked up by ID.
}
-
+
// Diff link for single rev deletions
if( count($Ids) == 1 && !count($undeletedRevisions) ) {
// Live revision diffs...
array( 'known', 'noclasses' )
);
// Deleted revision diffs...
- } else if( in_array( $key, array( 'artimestamp','archive' ) ) ) {
+ } elseif( in_array( $key, array( 'artimestamp','archive' ) ) ) {
$revert[] = $skin->link(
SpecialPage::getTitleFor( 'Undelete' ),
- $messages['diff'],
+ $messages['diff'],
array(),
array(
'target' => $title->getPrefixedDBKey(),
);
}
}
-
+
// View/modify link...
if ( count( $undeletedRevisions ) ) {
// @todo FIXME: THIS IS A HORRIBLE HORRIBLE HACK AND SHOULD DIE
// undeleted revisions to SpecialRevisionDelete, so we're
// stuck with two links. See bug 23363.
$restoreLinks = array();
-
+
$restoreLinks[] = $skin->link(
SpecialPage::getTitleFor( 'Revisiondelete' ),
$messages['revdel-restore-visible'],
),
array( 'known', 'noclasses' )
);
-
+
$restoreLinks[] = $skin->link(
SpecialPage::getTitleFor( 'Revisiondelete' ),
$messages['revdel-restore-deleted'],
),
array( 'known', 'noclasses' )
);
-
+
$revert[] = $messages['revdel-restore'] . ' [' .
$wgLang->pipeList( $restoreLinks ) . ']';
} else {
array( 'known', 'noclasses' )
);
}
-
+
// Pipe links
return wfMsg( 'parentheses', $wgLang->pipeList( $revert ) );
}
wfRunHooks( 'SearchGetNearMatchComplete', array( $searchterm, &$title ) );
return $title;
}
-
+
/**
- * Do a near match (see SearchEngine::getNearMatch) and wrap it into a
+ * Do a near match (see SearchEngine::getNearMatch) and wrap it into a
* SearchResultSet.
- *
+ *
* @param $searchterm string
* @return SearchResultSet
*/
if ( strncmp( $query, $allkeyword, strlen( $allkeyword ) ) == 0 ) {
$this->namespaces = null;
$parsed = substr( $query, strlen( $allkeyword ) );
- } else if ( strpos( $query, ':' ) !== false ) {
+ } elseif ( strpos( $query, ':' ) !== false ) {
$prefix = substr( $query, 0, strpos( $query, ':' ) );
$index = $wgContLang->getNsIndex( $prefix );
if ( $index !== false ) {
$row = $this->mResultSet->fetchObject();
if ( $row === false )
return false;
-
+
return SearchResult::newFromRow( $row );
}
/**
* Return a new SearchResult and initializes it with a title.
- *
- * @param $title Title
+ *
+ * @param $title Title
* @return SearchResult
*/
public static function newFromTitle( $title ) {
}
/**
* Return a new SearchResult and initializes it with a row.
- *
+ *
* @param $row object
* @return SearchResult
*/
$result->initFromRow( $row );
return $result;
}
-
+
public function __construct( $row = null ) {
if ( !is_null( $row ) ) {
// Backwards compatibility with pre-1.17 callers
$this->initFromRow( $row );
}
}
-
+
/**
* Initialize from a database row. Makes a Title and passes that to
* initFromTitle.
- *
+ *
* @param $row object
*/
protected function initFromRow( $row ) {
$this->initFromTitle( Title::makeTitle( $row->page_namespace, $row->page_title ) );
}
-
+
/**
* Initialize from a Title and if possible initializes a corresponding
* Revision and File.
- *
+ *
* @param $title Title
*/
protected function initFromTitle( $title ) {
function getTimestamp() {
if ( $this->mRevision )
return $this->mRevision->getTimestamp();
- else if ( $this->mImage )
+ elseif ( $this->mImage )
return $this->mImage->getTimestamp();
return '';
}
if (strtolower($terms[2]) === 'and') {
$searchstring .= ' & ';
}
- else if (strtolower($terms[2]) === 'or' or $terms[2] === '|') {
+ elseif (strtolower($terms[2]) === 'or' or $terms[2] === '|') {
$searchstring .= ' | ';
}
- else if (strtolower($terms[2]) === 'not') {
+ elseif (strtolower($terms[2]) === 'not') {
$searchstring .= ' & !';
}
else {
} elseif( isset( $xNames[$s->page_title] ) ) {
$pageFlags[$s->page_title] = true;
}
- } else if( $s->page_namespace == NS_MEDIAWIKI_TALK ){
+ } elseif( $s->page_namespace == NS_MEDIAWIKI_TALK ){
$talkFlags[$s->page_title] = true;
}
}
$t = Title::makeTitleSafe($ns, $text);
if ( $t && $t->isLocal() ) {
return array( $t->getNamespace(), $t->getDBkey(), $t->getText() );
- } else if ( $t ) {
+ } elseif ( $t ) {
return null;
}
}
$tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
-
+
$fNS = '';
$fShowDiff = '';
if ( !$wgMiserMode ) {
// Paranoia: avoid brute force searches (bug 17342)
if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
$conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
- } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) {
$conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
' != ' . Revision::SUPPRESSED_USER;
}
$join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
-
+
$fields = array(
'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
return $queryInfo;
}
-
+
function getUserCond() {
$condition = array();
$join_conds = array();
}
$diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
-
-
+
+
$diffOut = ( $this->showSizeDiff ) ? ' . . '.ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len ) : ' . . '.Linker::formatRevisionSize( $row->rev_len );
$ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$diffOut}{$userlink} {$comment} {$topmarktext}";
// Paranoia: avoid brute force searches (bug 17792)
if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
$conds[] = $this->mDb->bitAnd('ar_deleted',Revision::DELETED_USER) . ' = 0';
- } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) {
$conds[] = $this->mDb->bitAnd('ar_deleted',Revision::SUPPRESSED_USER) .
' != ' . Revision::SUPPRESSED_USER;
}
}
}
}
- else if( $wgRequest->getCheck( 'addns' ) && $wgExportFromNamespaces ) {
+ elseif( $wgRequest->getCheck( 'addns' ) && $wgExportFromNamespaces ) {
$page = $wgRequest->getText( 'pages' );
$nsindex = $wgRequest->getText( 'nsindex', '' );
}
}
}
- else if( $wgRequest->wasPosted() && $par == '' ) {
+ elseif( $wgRequest->wasPosted() && $par == '' ) {
$page = $wgRequest->getText( 'pages' );
$this->curonly = $wgRequest->getCheck( 'curonly' );
$rawOffset = $wgRequest->getVal( 'offset' );
sort( $r );
if( $add === true ){
$r[] = wfMsgExt( 'listgrouprights-addgroup-all', array( 'escape' ) );
- } else if( is_array( $add ) && count( $add ) ) {
+ } elseif( is_array( $add ) && count( $add ) ) {
$add = array_values( array_unique( $add ) );
$r[] = wfMsgExt( 'listgrouprights-addgroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $add ) ), count( $add ) );
}
if( $remove === true ){
$r[] = wfMsgExt( 'listgrouprights-removegroup-all', array( 'escape' ) );
- } else if( is_array( $remove ) && count( $remove ) ) {
+ } elseif( is_array( $remove ) && count( $remove ) ) {
$remove = array_values( array_unique( $remove ) );
$r[] = wfMsgExt( 'listgrouprights-removegroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ), count( $remove ) );
}
if( $addSelf === true ){
$r[] = wfMsgExt( 'listgrouprights-addgroup-self-all', array( 'escape' ) );
- } else if( is_array( $addSelf ) && count( $addSelf ) ) {
+ } elseif( is_array( $addSelf ) && count( $addSelf ) ) {
$addSelf = array_values( array_unique( $addSelf ) );
$r[] = wfMsgExt( 'listgrouprights-addgroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ), count( $addSelf ) );
}
if( $removeSelf === true ){
$r[] = wfMsgExt( 'listgrouprights-removegroup-self-all', array( 'escape' ) );
- } else if( is_array( $removeSelf ) && count( $removeSelf ) ) {
+ } elseif( is_array( $removeSelf ) && count( $removeSelf ) ) {
$removeSelf = array_values( array_unique( $removeSelf ) );
$r[] = wfMsgExt( 'listgrouprights-removegroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ), count( $removeSelf ) );
}
if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) {
$this->requestedGroup = $par;
$un = $wgRequest->getText( 'username' );
- } else if ( count( $parms ) == 2 ) {
+ } elseif ( count( $parms ) == 2 ) {
$this->requestedGroup = $parms[0];
$un = $parms[1];
} else {
if ( $action == 'success' ) {
$this->showSuccess();
- } else if ( $action == 'submit' && $wgRequest->wasPosted() &&
+ } elseif ( $action == 'submit' && $wgRequest->wasPosted() &&
$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
$this->doSubmit();
} else {
if( $this->sizetype=='min' ) {
$conds[] = 'page_len>=' . $this->size;
- } else if( $this->sizetype=='max' ) {
+ } elseif( $this->sizetype=='max' ) {
$conds[] = 'page_len<=' . $this->size;
}
// imagelinks and categorylinks tables have no xx_namespace field, and have xx_to instead of xx_title
if( $link_table == 'imagelinks' ) $link_ns = NS_FILE;
- else if( $link_table == 'categorylinks' ) $link_ns = NS_CATEGORY;
+ elseif( $link_table == 'categorylinks' ) $link_ns = NS_CATEGORY;
else $link_ns = 0;
if( $showlinkedto ) {