* Sets an external MIME detector program. The command must print only
* the MIME type to standard output.
* The name of the file to process will be appended to the command given here.
- * If not set or NULL, PHP's fileinfo extension will be used if available.
+ * If not set or NULL, PHP's mime_content_type function will be used.
*
* @par Example:
* @code
if ( !$diff && !$otitle ) {
$header .= "
- <tr style='vertical-align: top;' lang='{$userLang}'>
- <td class='diff-ntitle'>{$ntitle}</td>
+ <tr style=\"vertical-align: top;\" lang=\"{$userLang}\">
+ <td class=\"diff-ntitle\">{$ntitle}</td>
</tr>";
$multiColspan = 1;
} else {
if ( $diff ) { // Safari/Chrome show broken output if cols not used
$header .= "
- <col class='diff-marker' />
- <col class='diff-content' />
- <col class='diff-marker' />
- <col class='diff-content' />";
+ <col class=\"diff-marker\" />
+ <col class=\"diff-content\" />
+ <col class=\"diff-marker\" />
+ <col class=\"diff-content\" />";
$colspan = 2;
$multiColspan = 4;
} else {
}
if ( $otitle || $ntitle ) {
$header .= "
- <tr style='vertical-align: top;' lang='{$userLang}'>
- <td colspan='$colspan' class='diff-otitle'>{$otitle}</td>
- <td colspan='$colspan' class='diff-ntitle'>{$ntitle}</td>
+ <tr style=\"vertical-align: top;\" lang=\"{$userLang}\">
+ <td colspan=\"$colspan\" class=\"diff-otitle\">{$otitle}</td>
+ <td colspan=\"$colspan\" class=\"diff-ntitle\">{$ntitle}</td>
</tr>";
}
}
if ( $multi != '' ) {
- $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
- "class='diff-multi' lang='{$userLang}'>{$multi}</td></tr>";
+ $header .= "<tr><td colspan=\"{$multiColspan}\" style=\"text-align: center;\" " .
+ "class=\"diff-multi\" lang=\"{$userLang}\">{$multi}</td></tr>";
}
if ( $notice != '' ) {
- $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
- "lang='{$userLang}'>{$notice}</td></tr>";
+ $header .= "<tr><td colspan=\"{$multiColspan}\" style=\"text-align: center;\" " .
+ "lang=\"{$userLang}\">{$notice}</td></tr>";
}
return $header . $diff . "</table>";
return self::$mimeTypes[$ext];
}
- $realpath = realpath( $file );
- if (
- $realpath
- && function_exists( 'finfo_file' )
- && function_exists( 'finfo_open' )
- && defined( 'FILEINFO_MIME_TYPE' )
- ) {
- return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath );
- }
-
- return false;
+ return mime_content_type( realpath( $file ) );
}
/**
return call_user_func_array( $this->mimeCallback, func_get_args() );
}
- $mime = null;
- if ( $fsPath !== null && function_exists( 'finfo_file' ) ) {
- $finfo = finfo_open( FILEINFO_MIME_TYPE );
- $mime = finfo_file( $finfo, $fsPath );
- finfo_close( $finfo );
- }
-
- return is_string( $mime ) ? $mime : 'unknown/unknown';
+ $mime = ( $fsPath !== null ) ? mime_content_type( $fsPath ) : false;
+ return $mime ?: 'unknown/unknown';
}
}
$m = null;
if ( $callback ) {
$m = $callback( $file );
- } elseif ( function_exists( "finfo_open" ) && function_exists( "finfo_file" ) ) {
- $mime_magic_resource = finfo_open( FILEINFO_MIME );
-
- if ( $mime_magic_resource ) {
- $m = finfo_file( $mime_magic_resource, $file );
- finfo_close( $mime_magic_resource );
- } else {
- $this->logger->info( __METHOD__ .
- ": finfo_open failed on " . FILEINFO_MIME . "!\n" );
- }
} else {
- $this->logger->info( __METHOD__ . ": no magic mime detector found!\n" );
+ $m = mime_content_type( $file );
}
if ( $m ) {
// is shown on the correct side of the tooltip text.
$durationTooltip = '‎' . htmlspecialchars( $params[4] );
$params[4] = Message::rawParam(
- "<span class='blockExpiry' title='$durationTooltip'>" .
+ "<span class=\"blockExpiry\" title=\"$durationTooltip\">" .
$this->context->getLanguage()->translateBlockExpiry(
$params[4],
$this->context->getUser(),
public function validateOptions( FormOptions $opts ) {
$opts->validateIntBounds( 'limit', 0, 5000 );
+ $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
parent::validateOptions( $opts );
}
$query_options, $join_conds, $opts );
// Calculate cutoff
- $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
+ $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
$cutoff = $dbr->timestamp( $cutoff_unixtime );
$fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
class SpecialWatchlist extends ChangesListSpecialPage {
public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
parent::__construct( $page, $restriction );
+
+ $this->maxDays = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
}
public function doesWrites() {
return $opts;
}
+ public function validateOptions( FormOptions $opts ) {
+ $opts->validateBounds( 'days', 0, $this->maxDays );
+ parent::validateOptions( $opts );
+ }
+
/**
* Get all custom filters
*
// Calculate cutoff
if ( $opts['days'] > 0 ) {
$conds[] = 'rc_timestamp > ' .
- $dbr->addQuotes( $dbr->timestamp( time() - intval( $opts['days'] * 86400 ) ) );
+ $dbr->addQuotes( $dbr->timestamp( time() - $opts['days'] * 3600 * 24 ) );
}
}
if ( $opts['days'] > 0 ) {
$days = $opts['days'];
} else {
- $days = $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 );
+ $days = $this->maxDays;
}
$timestamp = wfTimestampNow();
$wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
$days[] = $userWatchlistOption;
}
- $maxDays = (string)( $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
+ $maxDays = (string)$this->maxDays;
// add the maximum possible value, if it isn't available already
if ( !in_array( $maxDays, $days ) ) {
$days[] = $maxDays;
'value' => $this->requestedUser,
],
'dropdown' => [
- 'label' => $this->msg( 'group' ),
+ 'label' => $this->msg( 'group' )->text(),
'name' => 'group',
'value' => $this->requestedGroup,
'class' => 'HTMLSelectField',