// The canonical name of this special page
// Also used for the default <h1> heading, @see getDescription()
- /*private*/ var $mName;
+ protected $mName;
// The local name of this special page
private $mLocalName;
/**
* Current request context
- * @var RequestContext
+ * @var IContextSource
*/
protected $mContext;
* page, and true if it was successful.
*
* @param $title Title object
- * @param $context RequestContext
+ * @param $context IContextSource
* @param $including Bool output is being captured for use in {{special:whatever}}
* @return Bool
* @deprecated since 1.18 call SpecialPageFactory method directly
*/
- public static function executePath( &$title, RequestContext &$context, $including = false ) {
+ public static function executePath( &$title, IContextSource &$context, $including = false ) {
return SpecialPageFactory::executePath( $title, $context, $including );
}
- /**
- * Just like executePath() except it returns the HTML instead of outputting it
- * Returns false if there was no such special page, or a title object if it was
- * a redirect.
- *
- * @param $title Title
- * @return String: HTML fragment
- * @deprecated since 1.18 call SpecialPageFactory method directly
- */
- static function capturePath( &$title ) {
- return SpecialPageFactory::capturePath( $title );
- }
-
/**
* Get the local name for a specified canonical name
*
if ( $this->userCanExecute( $this->getUser() ) ) {
$func = $this->mFunction;
// only load file if the function does not exist
- if(!is_callable($func) and $this->mFile) {
+ if( !is_callable($func) && $this->mFile ) {
require_once( $this->mFile );
}
$this->outputHeader();
} else {
$msg = $summaryMessageKey;
}
- if ( !wfMessage( $msg )->isBlank() and ! $this->including() ) {
+ if ( !$this->msg( $msg )->isBlank() && !$this->including() ) {
$this->getOutput()->wrapWikiMsg(
"<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
}
* @return String
*/
function getDescription() {
- return wfMsg( strtolower( $this->mName ) );
+ return $this->msg( strtolower( $this->mName ) )->text();
}
/**
/**
* Sets the context this SpecialPage is executed in
*
- * @param $context RequestContext
+ * @param $context IContextSource
* @since 1.18
*/
public function setContext( $context ) {
/**
* Gets the context this SpecialPage is executed in
*
- * @return RequestContext
+ * @return IContextSource
* @since 1.18
*/
public function getContext() {
- if ( $this->mContext instanceof RequestContext ) {
+ if ( $this->mContext instanceof IContextSource ) {
return $this->mContext;
} else {
wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
* Shortcut to get user's language
*
* @return Language
- * @since 1.19
+ * @since 1.18
*/
public function getLang() {
return $this->getContext()->getLang();
* @see wfMessage
*/
public function msg( /* $args */ ) {
- return call_user_func_array( array( $this->getContext(), 'msg' ), func_get_args() );
+ // Note: can't use func_get_args() directly as second or later item in
+ // a parameter list until PHP 5.3 or you get a fatal error.
+ // Works fine as the first parameter, which appears elsewhere in the
+ // code base. Sighhhh.
+ $args = func_get_args();
+ return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
}
/**
* @param $params array
*/
protected function addFeedLinks( $params ) {
- global $wgFeedClasses, $wgOut;
+ global $wgFeedClasses;
$feedTemplate = wfScript( 'api' ) . '?';
foreach( $wgFeedClasses as $format => $class ) {
$theseParams = $params + array( 'feedformat' => $format );
$url = $feedTemplate . wfArrayToCGI( $theseParams );
- $wgOut->addFeedLink( $format, $url );
+ $this->getOutput()->addFeedLink( $format, $url );
}
}
}
protected function getForm() {
$this->fields = $this->getFormFields();
- // Give hooks a chance to alter the form, adding extra fields or text etc
- wfRunHooks( "Special{$this->getName()}ModifyFormFields", array( &$this->fields ) );
-
$form = new HTMLForm( $this->fields, $this->getContext() );
$form->setSubmitCallback( array( $this, 'onSubmit' ) );
- $form->setWrapperLegend( wfMessage( strtolower( $this->getName() ) . '-legend' ) );
+ $form->setWrapperLegend( $this->msg( strtolower( $this->getName() ) . '-legend' ) );
$form->addHeaderText(
- wfMessage( strtolower( $this->getName() ) . '-text' )->parseAsBlock() );
+ $this->msg( strtolower( $this->getName() ) . '-text' )->parseAsBlock() );
// Retain query parameters (uselang etc)
$params = array_diff_key(
function __construct() {
parent::__construct( 'Mypage' );
$this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
- 'section', 'oldid', 'diff', 'dir' );
+ 'section', 'oldid', 'diff', 'dir',
+ // Options for action=raw; missing ctype can break JS or CSS in some browsers
+ 'ctype', 'maxage', 'smaxage' );
}
function getRedirect( $subpage ) {