--- /dev/null
+*.sh eol=lf
See the file UPGRADE for more detailed upgrade instructions.
-For notes on 1.21.x and older releases, see HISTORY.
+For notes on 1.22.x and older releases, see HISTORY.
== Online documentation ==
=== New features in 1.24 ===
* Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
WhatLinksHere entries.
+* Added a new hook, "ContentGetParserOutput", to customize parser output for
+ a given content object.
+* Deprecated the hook "ShowRawCssJs", use "ContentGetParserOutput" instead.
* HTMLForm's HTMLTextField now supports the 'url' type.
* HTMLForm fields may now be dynamically hidden based on the values of other
fields in the form.
* HTMLForm now supports multiple copies of an input field or set of input
fields, e.g. the form may request "one or more usernames" without having to
have the user enter delimited list of names into a text field.
+* Added a new hook, "SidebarBeforeOutput", to allow to edit the structure of
+ the sidebar just before its display.
=== Bug fixes in 1.24 ===
* (bug 62258) A bug was fixed in File::getUnscaledThumb when a height
* RevDel_RevisionItem to RevDelRevisionItem
* RevDel_RevisionList to RevDelRevisionList
+==== Removed classes ====
+* IPBlockForm - Use SpecialBlock directly
+* WatchlistEditor - Use SpecialEditWatchlist directly
+
== Compatibility ==
MediaWiki 1.24 requires PHP 5.3.2 or later.
See the file UPGRADE for more detailed upgrade instructions.
-For notes on 1.21.x and older releases, see HISTORY.
+For notes on 1.22.x and older releases, see HISTORY.
== Online documentation ==
Handler functions that modify $ok should generally return false to prevent further
hooks from further modifying $ok.
+'ContentGetParserOutput': Customize parser output for a given content object,
+called by AbstractContent::getParserOutput. May be used to override the normal
+model-specific rendering of page content.
+$content: The Content to render
+$title: Title of the page, as context
+$revId: The revision ID, as context
+$options: ParserOptions for rendering. To avoid confusing the parser cache,
+the output can only depend on parameters provided to this hook function, not on global state.
+$generateHtml: boolean, indicating whether full HTML should be generated. If false,
+generation of HTML may be skipped, but other information should still be present in the
+ParserOutput object.
+&$output: ParserOutput, to manipulate or replace
+
'ConvertContent': Called by AbstractContent::convert when a conversion to another
content model is requested.
$content: The Content object to be converted.
$article: The article object corresponding to the page
'ShowRawCssJs': Customise the output of raw CSS and JavaScript in page views.
-DEPRECATED, use the ContentHandler facility to handle CSS and JavaScript!
+DEPRECATED, use the ContentGetParserOutput hook instead!
$text: Text being shown
$title: Title of the custom script/stylesheet page
$output: Current OutputPage object
&$bar: Sidebar contents
Modify $bar to add or modify sidebar portlets.
+'SidebarBeforeOutput': Allows to edit sidebar just before its output by skins.
+$skin Skin object
+&$bar: Sidebar content
+Modify $bar to add or modify sidebar portlets.
+Warning: This hook is run on each display. You should consider to use 'SkinBuildSidebar' that is aggressively cached.
+
'SkinCopyrightFooter': Allow for site and per-namespace customization of
copyright notice.
$title: displayed page title
* Show a page view for a page formatted as CSS or JavaScript. To be called by
* Article::view() only.
*
- * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
- * page views.
+ * This exists mostly to serve the deprecated ShowRawCssJs hook (used to customize these views).
+ * It has been replaced by the ContentGetParserOutput hook, which lets you do the same but with
+ * more flexibility.
*
* @param bool $showCacheHint Whether to show a message telling the user
* to clear the browser cache (default: true).
'HTMLBlockedUsersItemSelect' => 'includes/specials/SpecialBlockList.php',
'ImageListPager' => 'includes/specials/SpecialListfiles.php',
'ImportReporter' => 'includes/specials/SpecialImport.php',
- 'IPBlockForm' => 'includes/specials/SpecialBlock.php',
'LinkSearchPage' => 'includes/specials/SpecialLinkSearch.php',
'ListredirectsPage' => 'includes/specials/SpecialListredirects.php',
'ListDuplicatedFilesPage' => 'includes/specials/SpecialListDuplicatedFiles.php',
'WantedFilesPage' => 'includes/specials/SpecialWantedfiles.php',
'WantedPagesPage' => 'includes/specials/SpecialWantedpages.php',
'WantedTemplatesPage' => 'includes/specials/SpecialWantedtemplates.php',
- 'WatchlistEditor' => 'includes/specials/SpecialEditWatchlist.php',
'WithoutInterwikiPage' => 'includes/specials/SpecialWithoutinterwiki.php',
# includes/templates
*/
$wgSiteNotice = '';
-/**
- * A subtitle to add to the tagline, for skins that have it/
- */
-$wgExtraSubtitle = '';
-
/**
* If this is set, a "donate" link will appear in the sidebar. Set it to a URL.
*/
* Allow external reads of TTL array
*
* @param int $id
- * @return array
+ * @return int
*/
static function getCacheTTL( $id ) {
if ( array_key_exists( $id, self::$mCacheTTLs ) ) {
if ( $wgEnableSidebarCache ) {
$cachedsidebar = $wgMemc->get( $key );
if ( $cachedsidebar ) {
+ wfRunHooks( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
+
wfProfileOut( __METHOD__ );
return $cachedsidebar;
}
$wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
}
+ wfRunHooks( 'SidebarBeforeOutput', array( $this, &$bar ) );
+
wfProfileOut( __METHOD__ );
return $bar;
}
if ( $this->address ) {
if ( $this->name != '' && !wfIsWindows() ) {
global $wgEnotifUseRealName;
- $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
+ $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name;
$quoted = UserMailer::quotedPrintable( $name );
if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
$quoted = '"' . $quoted . '"';
$keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text();
} else {
- $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
+ $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== ''
+ ? $this->editor->getRealName() : $this->editor->getName();
$emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
$keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
}
array( '$WATCHINGUSERNAME',
'$PAGEEDITDATE',
'$PAGEEDITTIME' ),
- array( $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName(),
+ array( $wgEnotifUseRealName && $watchingUser->getRealName() !== ''
+ ? $watchingUser->getRealName() : $watchingUser->getName(),
$wgContLang->userDate( $this->timestamp, $watchingUser ),
$wgContLang->userTime( $this->timestamp, $watchingUser ) ),
$this->body );
return new FeedItem(
$title->getPrefixedText(),
$this->feedItemDesc( $revision ),
- $title->getFullURL(),
+ $title->getFullURL( array( 'diff' => $revision->getId() ) ),
$date,
$this->feedItemAuthor( $revision ),
$comments
class ApiFeedWatchlist extends ApiBase {
private $watchlistModule = null;
- private $linkToDiffs = false;
private $linkToSections = false;
/**
'meta' => 'siteinfo',
'siprop' => 'general',
'list' => 'watchlist',
- 'wlprop' => 'title|user|comment|timestamp',
+ 'wlprop' => 'title|user|comment|timestamp|ids',
'wldir' => 'older', // reverse order - from newest to oldest
'wlend' => $endTime, // stop at this time
'wllimit' => min( 50, $wgFeedLimit )
$fauxReqArr['wltype'] = $params['wltype'];
}
- // Support linking to diffs instead of article
- if ( $params['linktodiffs'] ) {
- $this->linkToDiffs = true;
- $fauxReqArr['wlprop'] .= '|ids';
- }
-
// Support linking directly to sections when possible
// (possible only if section name is present in comment)
if ( $params['linktosections'] ) {
private function createFeedItem( $info ) {
$titleStr = $info['title'];
$title = Title::newFromText( $titleStr );
- if ( $this->linkToDiffs && isset( $info['revid'] ) ) {
+ if ( isset( $info['revid'] ) ) {
$titleUrl = $title->getFullURL( array( 'diff' => $info['revid'] ) );
} else {
$titleUrl = $title->getFullURL();
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => 72,
),
- 'linktodiffs' => false,
'linktosections' => false,
);
if ( $flags ) {
return array(
'feedformat' => 'The format of the feed',
'hours' => 'List pages modified within this many hours from now',
- 'linktodiffs' => 'Link to change differences instead of article pages',
'linktosections' => 'Link directly to changed sections if possible',
'allrev' => $wldescr['allrev'],
'wlowner' => $wldescr['owner'],
public function getExamples() {
return array(
'api.php?action=feedwatchlist',
- 'api.php?action=feedwatchlist&allrev=&linktodiffs=&hours=6'
+ 'api.php?action=feedwatchlist&allrev=&hours=6'
);
}
return $result;
}
+
+ /**
+ * Returns a ParserOutput object containing information derived from this content.
+ * Most importantly, unless $generateHtml was false, the return value contains an
+ * HTML representation of the content.
+ *
+ * Subclasses that want to control the parser output may override this, but it is
+ * preferred to override fillParserOutput() instead.
+ *
+ * Subclasses that override getParserOutput() itself should take care to call the
+ * ContentGetParserOutput hook.
+ *
+ * @since 1.24
+ *
+ * @param Title $title Context title for parsing
+ * @param int|null $revId Revision ID (for {{REVISIONID}})
+ * @param ParserOptions|null $options Parser options
+ * @param bool $generateHtml Whether or not to generate HTML
+ *
+ * @return ParserOutput Containing information derived from this content.
+ */
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true
+ ) {
+ if ( $options === null ) {
+ $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
+ }
+
+ $po = new ParserOutput();
+
+ if ( wfRunHooks( 'ContentGetParserOutput',
+ array( $this, $title, $revId, $options, $generateHtml, &$po ) ) ) {
+
+ $this->fillParserOutput( $title, $revId, $options, $generateHtml, $po );
+ }
+
+ return $po;
+ }
+
+ /**
+ * Fills the provided ParserOutput with information derived from the content.
+ * Unless $generateHtml was false, this includes an HTML representation of the content.
+ *
+ * This is called by getParserOutput() after consulting the ContentGetParserOutput hook.
+ * Subclasses are expected to override this method (or getParserOutput(), if need be).
+ * Subclasses of TextContent should generally override getHtml() instead.
+ *
+ * This placeholder implementation always throws an exception.
+ *
+ * @since 1.24
+ *
+ * @param Title $title Context title for parsing
+ * @param int|null $revId Revision ID (for {{REVISIONID}})
+ * @param ParserOptions|null $options Parser options
+ * @param bool $generateHtml Whether or not to generate HTML
+ * @param ParserOutput &$output The output object to fill (reference).
+ *
+ * @throws MWException
+ */
+ protected function fillParserOutput( Title $title, $revId,
+ ParserOptions $options, $generateHtml, ParserOutput &$output
+ ) {
+ // Don't make abstract, so subclasses that override getParserOutput() directly don't fail.
+ throw new MWException( 'Subclasses of AbstractContent must override fillParserOutput!' );
+ }
}
}
/**
- * Returns a generic ParserOutput object, wrapping the HTML returned by
- * getHtml().
+ * Fills the provided ParserOutput object with information derived from the content.
+ * Unless $generateHtml was false, this includes an HTML representation of the content
+ * provided by getHtml().
+ *
+ * For content models listed in $wgTextModelsToParse, this method will call the MediaWiki
+ * wikitext parser on the text to extract any (wikitext) links, magic words, etc.
+ *
+ * Subclasses may override this to provide custom content processing.
+ * For custom HTML generation alone, it is sufficient to override getHtml().
*
* @param Title $title Context title for parsing
* @param int $revId Revision ID (for {{REVISIONID}})
* @param ParserOptions $options Parser options
* @param bool $generateHtml Whether or not to generate HTML
- *
- * @return ParserOutput Representing the HTML form of the text.
+ * @param ParserOutput $output The output object to fill (reference).
*/
- public function getParserOutput( Title $title, $revId = null,
- ParserOptions $options = null, $generateHtml = true ) {
+ protected function fillParserOutput( Title $title, $revId,
+ ParserOptions $options, $generateHtml, ParserOutput &$output
+ ) {
global $wgParser, $wgTextModelsToParse;
- if ( !$options ) {
- //NOTE: use canonical options per default to produce cacheable output
- $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
- }
-
if ( in_array( $this->getModel(), $wgTextModelsToParse ) ) {
- // parse just to get links etc into the database
- $po = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
- } else {
- $po = new ParserOutput();
+ // parse just to get links etc into the database, HTML is replaced below.
+ $output = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
}
if ( $generateHtml ) {
$html = '';
}
- $po->setText( $html );
-
- return $po;
+ $output->setText( $html );
}
/**
* Generates an HTML version of the content, for display. Used by
- * getParserOutput() to construct a ParserOutput object.
+ * fillParserOutput() to provide HTML for the ParserOutput object.
*
* Subclasses may override this to provide a custom HTML rendering.
* If further information is to be derived from the content (such as
- * categories), the getParserOutput() method can be overridden instead.
+ * categories), the fillParserOutput() method can be overridden instead.
*
* For backwards-compatibility, this default implementation just calls
* getHighlightHtml().
* Returns a ParserOutput object resulting from parsing the content's text
* using $wgParser.
*
- * @since 1.21
- *
* @param Title $title
* @param int $revId Revision to pass to the parser (default: null)
* @param ParserOptions $options (default: null)
* @param bool $generateHtml (default: true)
- *
- * @return ParserOutput Representing the HTML form of the text
+ * @param &$output ParserOutput representing the HTML form of the text,
+ * may be manipulated or replaced.
*/
- public function getParserOutput( Title $title, $revId = null,
- ParserOptions $options = null, $generateHtml = true ) {
+ protected function fillParserOutput( Title $title, $revId,
+ ParserOptions $options, $generateHtml, ParserOutput &$output
+ ) {
global $wgParser;
- if ( !$options ) {
- //NOTE: use canonical options per default to produce cacheable output
- $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
- }
-
list( $redir, $text ) = $this->getRedirectTargetAndText();
- $po = $wgParser->parse( $text, $title, $options, true, true, $revId );
+ $output = $wgParser->parse( $text, $title, $options, true, true, $revId );
// Add redirect indicator at the top
if ( $redir ) {
// Make sure to include the redirect link in pagelinks
- $po->addLink( $redir );
+ $output->addLink( $redir );
if ( $generateHtml ) {
$chain = $this->getRedirectChain();
- $po->setText(
+ $output->setText(
Article::getRedirectHeaderHtml( $title->getPageLanguage(), $chain, false ) .
- $po->getText()
+ $output->getText()
);
}
}
-
- return $po;
}
/**
parent::__construct( $params );
# Per HTML5 spec, hidden fields cannot be 'required'
- # http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#hidden-state
+ # http://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
unset( $this->mParams['required'] );
}
'_NamespaceType' => 'site-name',
'_AdminName' => '', // will be set later, when the user selects language
'_AdminPassword' => '',
- '_AdminPassword2' => '',
+ '_AdminPasswordConfirm' => '',
'_AdminEmail' => '',
'_Subscribe' => false,
'_SkipOptional' => 'continue',
'label' => 'config-admin-password',
) ) .
$this->parent->getPasswordBox( array(
- 'var' => '_AdminPassword2',
+ 'var' => '_AdminPasswordConfirm',
'label' => 'config-admin-password-confirm'
) ) .
$this->parent->getTextBox( array(
public function submit() {
$retVal = true;
$this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
- '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
+ '_AdminName', '_AdminPassword', '_AdminPasswordConfirm', '_AdminEmail',
'_Subscribe', '_SkipOptional', 'wgMetaNamespace' ) );
// Validate site name
# $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
# This message is more specific and helpful.
$msg = 'config-admin-password-blank';
- } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
+ } elseif ( $pwd !== $this->getVar( '_AdminPasswordConfirm' ) ) {
$msg = 'config-admin-password-mismatch';
} elseif ( $valid !== true ) {
$msg = $valid;
if ( $msg !== false ) {
call_user_func_array( array( $this->parent, 'showError' ), (array)$msg );
$this->setVar( '_AdminPassword', '' );
- $this->setVar( '_AdminPassword2', '' );
+ $this->setVar( '_AdminPasswordConfirm', '' );
$retVal = false;
}
*/
public $mUsedOptions;
- var $mVersion = Parser::VERSION, # Compatibility check
- $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
- $mCacheExpiry = null, # Seconds after which the object should expire, use 0 for uncachable. Used in ParserCache.
- $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}}
- $mCacheRevisionId = null; # Revision ID that was parsed
+ /** @var string Compatibility check */
+ protected $mVersion = Parser::VERSION;
+
+ /** @var string Time when this object was generated, or -1 for uncacheable. Used in ParserCache. */
+ protected $mCacheTime = '';
+
+ /**
+ * @var int Seconds after which the object should expire, use 0 for uncachable.
+ * Used in ParserCache.
+ */
+ protected $mCacheExpiry = null;
+
+ /** @var bool Boolean variable indicating if the input contained variables like {{CURRENTDAY}} */
+ protected $mContainsOldMagic;
+
+ /** @var int Revision ID that was parsed */
+ protected $mCacheRevisionId = null;
/**
* @return string TS_MW timestamp
*/
public function expired( $touched ) {
global $wgCacheEpoch;
- return !$this->isCacheable() || // parser says it's uncacheable
- $this->getCacheTime() < $touched ||
- $this->getCacheTime() <= $wgCacheEpoch ||
- $this->getCacheTime() < wfTimestamp( TS_MW, time() - $this->getCacheExpiry() ) || // expiry period has passed
- !isset( $this->mVersion ) ||
- version_compare( $this->mVersion, Parser::VERSION, "lt" );
+
+ return !$this->isCacheable() // parser says it's uncacheable
+ || $this->getCacheTime() < $touched
+ || $this->getCacheTime() <= $wgCacheEpoch
+ || $this->getCacheTime() <
+ wfTimestamp( TS_MW, time() - $this->getCacheExpiry() ) // expiry period has passed
+ || !isset( $this->mVersion )
+ || version_compare( $this->mVersion, Parser::VERSION, "lt" );
}
/**
$parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH );
}
if ( $wgAllowSlowParserFunctions ) {
- $parser->setFunctionHook( 'pagesinnamespace', array( __CLASS__, 'pagesinnamespace' ), SFH_NO_HASH );
+ $parser->setFunctionHook(
+ 'pagesinnamespace',
+ array( __CLASS__, 'pagesinnamespace' ),
+ SFH_NO_HASH
+ );
}
}
static function intFunction( $parser, $part1 = '' /*, ... */ ) {
if ( strval( $part1 ) !== '' ) {
$args = array_slice( func_get_args(), 2 );
- $message = wfMessage( $part1, $args )->inLanguage( $parser->getOptions()->getUserLangObj() )->plain();
+ $message = wfMessage( $part1, $args )
+ ->inLanguage( $parser->getOptions()->getUserLangObj() )->plain();
+
return array( $message, 'noparse' => false );
} else {
return array( 'found' => false );
// only requested titles that normalize to the actual title are allowed through
// if $wgRestrictDisplayTitle is true (it is by default)
// mimic the escaping process that occurs in OutputPage::setPageTitle
- $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $text, $htmlTagsCallback, array(), array(), $bad ) );
+ $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags(
+ $text,
+ $htmlTagsCallback,
+ array(),
+ array(),
+ $bad
+ ) );
$title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
if ( !$wgRestrictDisplayTitle ) {
$parser->mOutput->setDisplayTitle( $text );
- } elseif ( $title instanceof Title && !$title->hasFragment() && $title->equals( $parser->mTitle ) ) {
+ } elseif ( $title instanceof Title
+ && !$title->hasFragment()
+ && $title->equals( $parser->mTitle )
+ ) {
$parser->mOutput->setDisplayTitle( $text );
}
}
}
- // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}}
- // or {{filepath|300px}}, {{filepath|200x300px}}, {{filepath|nowiki|200x300px}}, {{filepath|200x300px|nowiki}}
+ // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}}
+ // or {{filepath|300|nowiki}} or {{filepath|300px}}, {{filepath|200x300px}},
+ // {{filepath|nowiki|200x300px}}, {{filepath|200x300px|nowiki}}.
public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
$file = wfFindFile( $name );
* @ingroup Parser
*/
class DateFormatter {
- var $mSource, $mTarget;
- var $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
+ protected $mSource;
- var $regexes, $pDays, $pMonths, $pYears;
- var $rules, $xMonths, $preferences;
+ protected $mTarget;
+
+ /** @var string */
+ protected $monthNames = '';
+
+ /** @todo Are these unused? */
+ private $rxDM;
+ private $rxMD;
+ private $rxDMY;
+ private $rxYDM;
+ private $rxMDY;
+ private $rxYMD;
+
+ /** @var array */
+ protected $regexes;
+
+ /** @todo Are these unused? */
+ private $pDays;
+ private $pMonths;
+ private $pYears;
+
+ /** @var array */
+ protected $rules;
+
+ /** @var array */
+ protected $xMonths;
+
+ /** @var array */
+ protected $preferences;
+
+ /** @var bool */
+ protected $mLinked;
protected $lang;
$bits = array();
$key = $this->keys[$this->mSource];
- for ( $p = 0; $p < strlen( $key ); $p++ ) {
+ $keyLength = strlen( $key );
+ for ( $p = 0; $p < $keyLength; $p++ ) {
if ( $key[$p] != ' ' ) {
$bits[$key[$p]] = $matches[$p + 1];
}
$bits['d'] = sprintf( '%02d', $bits['j'] );
}
- for ( $p = 0; $p < strlen( $format ); $p++ ) {
+ $formatLength = strlen( $format );
+ for ( $p = 0; $p < $formatLength; $p++ ) {
$char = $format[$p];
switch ( $char ) {
case 'd': # ISO day of month
* @ingroup Parser
*/
class LinkHolderArray {
- var $internals = array(), $interwikis = array();
- var $size = 0;
- var $parent;
+ /** @var array */
+ public $internals = array();
+
+ /** @var array */
+ public $interwikis = array();
+
+ /** @var int */
+ protected $size = 0;
+
+ /** @var Parser */
+ protected $parent;
+
+ /** @var int */
protected $tempIdOffset;
function __construct( $parent ) {
$res = $dbr->select(
'page',
- array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
+ array( 'page_id', 'page_namespace', 'page_title',
+ 'page_is_redirect', 'page_len', 'page_latest' ),
$dbr->makeList( $where, LIST_OR ),
__METHOD__
);
// construct query
$dbr = wfGetDB( DB_SLAVE );
$varRes = $dbr->select( 'page',
- array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
+ array( 'page_id', 'page_namespace', 'page_title',
+ 'page_is_redirect', 'page_len', 'page_latest' ),
$linkBatch->constructSet( 'page', $dbr ),
__METHOD__
);
const TOC_START = '<mw:toc>';
const TOC_END = '</mw:toc>';
- # Persistent:
- var $mTagHooks = array();
- var $mTransparentTagHooks = array();
- var $mFunctionHooks = array();
- var $mFunctionSynonyms = array( 0 => array(), 1 => array() );
- var $mFunctionTagHooks = array();
- var $mStripList = array();
- var $mDefaultStripList = array();
- var $mVarCache = array();
- var $mImageParams = array();
- var $mImageParamsMagicArray = array();
- var $mMarkerIndex = 0;
- var $mFirstCall = true;
+ # Persistent
- # Initialised by initialiseVariables()
+ /** @var array */
+ public $mTagHooks = array();
- /**
- * @var MagicWordArray
- */
- var $mVariables;
+ /** @var array */
+ public $mTransparentTagHooks = array();
+
+ /** @var array */
+ public $mFunctionHooks = array();
+
+ /** @var array */
+ protected $mFunctionSynonyms = array( 0 => array(), 1 => array() );
+
+ /** @var array */
+ protected $mFunctionTagHooks = array();
+
+ /** @var array */
+ protected $mStripList = array();
/**
- * @var MagicWordArray
+ * @var array
+ * @todo Unused?
*/
- var $mSubstWords;
- var $mConf, $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols; # Initialised in constructor
+ private $mDefaultStripList = array();
+
+ /** @var array */
+ protected $mVarCache = array();
+
+ /** @var array */
+ protected $mImageParams = array();
+
+ /** @var array */
+ protected $mImageParamsMagicArray = array();
+
+ /** @var int */
+ public $mMarkerIndex = 0;
+
+ /** @var bool */
+ protected $mFirstCall = true;
+
+ # Initialised by initialiseVariables()
+
+ /** @var MagicWordArray */
+ public $mVariables;
+
+ /** @var MagicWordArray */
+ protected $mSubstWords;
+
+ # Initialised in constructor
+
+ /** @var array */
+ protected $mConf;
+
+ /** @var Parser */
+ public $mPreprocessor;
+
+ /** @var string */
+ protected $mExtLinkBracketedRegex;
+
+ /** @var string */
+ protected $mUrlProtocols;
# Cleared with clearState():
- /**
- * @var ParserOutput
- */
- var $mOutput;
- var $mAutonumber, $mDTopen;
+
+ /** @var ParserOutput */
+ public $mOutput;
+
+ /** @var int */
+ protected $mAutonumber;
+
+ /** @var bool */
+ protected $mDTopen;
+
+ /** @var StripState */
+ public $mStripState;
/**
- * @var StripState
+ * @var array
+ * @todo Unused?
*/
- var $mStripState;
+ private $mIncludeCount;
- var $mIncludeCount, $mArgStack, $mLastSection, $mInPre;
/**
- * @var LinkHolderArray
+ * @var bool
+ * @todo Unused?
*/
- var $mLinkHolders;
+ private $mArgStack;
- var $mLinkID;
- var $mIncludeSizes, $mPPNodeCount, $mGeneratedPPNodeCount, $mHighestExpansionDepth;
- var $mDefaultSort;
- var $mTplExpandCache; # empty-frame expansion cache
- var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores;
- var $mExpensiveFunctionCount; # number of expensive parser function calls
- var $mShowToc, $mForceTocPosition;
+ /** @var string */
+ protected $mLastSection;
- /**
- * @var User
- */
- var $mUser; # User object; only used when doing pre-save transform
+ /** @var bool */
+ protected $mInPre;
+
+ /** @var LinkHolderArray */
+ protected $mLinkHolders;
+
+ /** @var int */
+ protected $mLinkID;
+
+ /** @var array */
+ protected $mIncludeSizes;
+
+ /** @var int */
+ public $mPPNodeCount;
+
+ /** @var int */
+ public $mGeneratedPPNodeCount;
+
+ /** @var int */
+ public $mHighestExpansionDepth;
+
+ /** @var bool|string */
+ protected $mDefaultSort;
+
+ /** @var array Empty-frame expansion cache */
+ protected $mTplExpandCache;
+
+ /** @var array */
+ protected $mTplRedirCache;
+
+ /** @var array */
+ protected $mTplDomCache;
+
+ /** @var array */
+ public $mHeadings;
+
+ /** @var array */
+ protected $mDoubleUnderscores;
+
+ /** @var int Number of expensive parser function calls */
+ protected $mExpensiveFunctionCount;
+
+ /** @var bool */
+ protected $mShowToc;
+
+ /** @var bool */
+ protected $mForceTocPosition;
+
+ /** @var User User object; only used when doing pre-save transform */
+ protected $mUser;
# Temporary
# These are variables reset at least once per parse regardless of $clearState
- /**
- * @var ParserOptions
- */
- var $mOptions;
+ /** @var ParserOptions */
+ public $mOptions;
- /**
- * @var Title
- */
- var $mTitle; # Title context, used for self-link rendering and similar things
- var $mOutputType; # Output type, one of the OT_xxx constants
- var $ot; # Shortcut alias, see setOutputType()
- var $mRevisionObject; # The revision object of the specified revision ID
- var $mRevisionId; # ID to display in {{REVISIONID}} tags
- var $mRevisionTimestamp; # The timestamp of the specified revision ID
- var $mRevisionUser; # User to display in {{REVISIONUSER}} tag
- var $mRevisionSize; # Size to display in {{REVISIONSIZE}} variable
- var $mRevIdForTs; # The revision ID which was used to fetch the timestamp
- var $mInputSize = false; # For {{PAGESIZE}} on current page.
+ /** @var Title Title context, used for self-link rendering and similar things */
+ public $mTitle;
+
+ /** @var array Shortcut alias, see setOutputType() */
+ public $ot;
+
+ /** @var string The timestamp of the specified revision ID */
+ public $mRevisionTimestamp;
+
+ /** @var string */
+ public $mUniqPrefix;
/**
- * @var string
+ * @var boolean Recursive call protection.
+ * This variable should be treated as if it were private.
*/
- var $mUniqPrefix;
+ public $mInParse = false;
+
+ /** @var int Output type, one of the OT_xxx constants */
+ protected $mOutputType;
+
+ /** @var Revision The revision object of the specified revision ID */
+ protected $mRevisionObject;
+
+ /** @var int ID to display in {{REVISIONID}} tags */
+ protected $mRevisionId;
+
+ /** @var string User to display in {{REVISIONUSER}} tag */
+ protected $mRevisionUser;
+
+ /** @var int Size to display in {{REVISIONSIZE}} variable */
+ protected $mRevisionSize;
+
+ /** @var bool|int For {{PAGESIZE}} on current page. */
+ protected $mInputSize = false;
/**
* @var array Array with the language name of each language link (i.e. the
* interwiki prefix) in the key, value arbitrary. Used to avoid sending
* duplicate language links to the ParserOutput.
*/
- var $mLangLinkLanguages;
+ protected $mLangLinkLanguages;
/**
- * @var boolean Recursive call protection.
- * This variable should be treated as if it were private.
+ * @var int The revision ID which was used to fetch the timestamp
+ * @todo Unused?
*/
- public $mInParse = false;
+ private $mRevIdForTs;
/**
* Constructor
* @param int $revid Number to pass in {{REVISIONID}}
* @return ParserOutput A ParserOutput
*/
- public function parse( $text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null ) {
+ public function parse( $text, Title $title, ParserOptions $options,
+ $linestart = true, $clearState = true, $revid = null
+ ) {
/**
* First pass--just handle <nowiki> sections, pass the rest off
* to internalParse() which does all the real work.
array_push( $tr_history, false );
array_push( $td_history, false );
array_push( $last_tag_history, '' );
- } elseif ( $first_character === '|' || $first_character === '!' || substr( $line, 0, 2 ) === '|+' ) {
+ } elseif ( $first_character === '|'
+ || $first_character === '!'
+ || substr( $line, 0, 2 ) === '|+'
+ ) {
# This might be cell elements, td, th or captions
if ( substr( $line, 0, 2 ) === '|+' ) {
$first_character = '+';
}
wfRunHooks( 'InternalParseBeforeSanitize', array( &$this, &$text, &$this->mStripState ) );
- $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'attributeStripCallback' ), false, array_keys( $this->mTransparentTagHooks ) );
+ $text = Sanitizer::removeHTMLtags(
+ $text,
+ array( &$this, 'attributeStripCallback' ),
+ false,
+ array_keys( $this->mTransparentTagHooks )
+ );
wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState ) );
# Tables need to come after variable replacement for things to work
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
if ( $bits === false ) {
wfProfileOut( __METHOD__ );
- throw new MWException( "PCRE needs to be compiled with --enable-unicode-properties in order for MediaWiki to function" );
+ throw new MWException( "PCRE needs to be compiled with "
+ . "--enable-unicode-properties in order for MediaWiki to function" );
}
$s = array_shift( $bits );
} else {
$imagematch = false;
}
+
if ( $this->mOptions->getAllowExternalImages()
- || ( $imagesexception && $imagematch ) ) {
+ || ( $imagesexception && $imagematch )
+ ) {
if ( preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
# Image found
$text = Linker::makeExternalImage( $url );
}
}
if ( !$text && $this->mOptions->getEnableImageWhitelist()
- && preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
- $whitelist = explode( "\n", wfMessage( 'external_image_whitelist' )->inContentLanguage()->text() );
+ && preg_match( self::EXT_IMAGE_REGEX, $url )
+ ) {
+ $whitelist = explode(
+ "\n",
+ wfMessage( 'external_image_whitelist' )->inContentLanguage()->text()
+ );
+
foreach ( $whitelist as $entry ) {
# Sanitize the regex fragment, make it case-insensitive, ignore blank entries/comments
if ( strpos( $entry, '#' ) === 0 || $entry === '' ) {
$useSubpages = $this->areSubpagesAllowed();
wfProfileOut( __METHOD__ . '-setup' );
+ // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
# Loop for each link
for ( ; $line !== false && $line !== null; $a->next(), $line = $a->current() ) {
+ // @codingStandardsIgnoreStart
+
# Check for excessive memory usage
if ( $holders->isBig() ) {
# Too big
$m[1] = str_replace( array( '<', '>' ), array( '<', '>' ), rawurldecode( $m[1] ) );
}
$trail = $m[3];
- } elseif ( preg_match( $e1_img, $line, $m ) ) { # Invalid, but might be an image with a link in its caption
+ } elseif ( preg_match( $e1_img, $line, $m ) ) {
+ # Invalid, but might be an image with a link in its caption
$might_be_img = true;
$text = $m[2];
if ( strpos( $m[1], '%' ) !== false ) {
if ( $noforce ) {
# Interwikis
wfProfileIn( __METHOD__ . "-interwiki" );
- if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' ) ) {
+ if ( $iw && $this->mOptions->getInterwikiMagic()
+ && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' )
+ ) {
// XXX: the above check prevents links to sites with identifiers that are not language codes
# Bug 24502: filter duplicates
wfProfileIn( __METHOD__ . "-paragraph" );
# No prefix (not in list)--go to paragraph mode
# XXX: use a stack for nestable elements like span, table and div
- $openmatch = preg_match( '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
+ $openmatch = preg_match(
+ '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|'
+ . '<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS',
+ $t
+ );
$closematch = preg_match(
- '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|' .
- '<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|<\\/mw:|' . $this->mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t );
+ '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'
+ . '<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|<\\/mw:|'
+ . $this->mUniqPrefix
+ . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS',
+ $t
+ );
+
if ( $openmatch or $closematch ) {
$paragraphStack = false;
# TODO bug 5718: paragraph closed
}
$inBlockElem = !$closematch;
} elseif ( !$inBlockElem && !$this->mInPre ) {
- if ( ' ' == substr( $t, 0, 1 ) and ( $this->mLastSection === 'pre' || trim( $t ) != '' ) and !$inBlockquote ) {
+ if ( ' ' == substr( $t, 0, 1 )
+ && ( $this->mLastSection === 'pre' || trim( $t ) != '' )
+ && !$inBlockquote
+ ) {
# pre
if ( $this->mLastSection !== 'pre' ) {
$paragraphStack = false;
$value = wfEscapeWikiText( $this->mTitle->getRootText() );
break;
case 'rootpagenamee':
- $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getRootText() ) ) );
+ $value = wfEscapeWikiText( wfUrlEncode( str_replace(
+ ' ',
+ '_',
+ $this->mTitle->getRootText()
+ ) ) );
break;
case 'basepagename':
$value = wfEscapeWikiText( $this->mTitle->getBaseText() );
break;
case 'basepagenamee':
- $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ) );
+ $value = wfEscapeWikiText( wfUrlEncode( str_replace(
+ ' ',
+ '_',
+ $this->mTitle->getBaseText()
+ ) ) );
break;
case 'talkpagename':
if ( $this->mTitle->canTalk() ) {
$value = $this->mTitle->getNamespace();
break;
case 'talkspace':
- $value = $this->mTitle->canTalk() ? str_replace( '_', ' ', $this->mTitle->getTalkNsText() ) : '';
+ $value = $this->mTitle->canTalk()
+ ? str_replace( '_', ' ', $this->mTitle->getTalkNsText() )
+ : '';
break;
case 'talkspacee':
$value = $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : '';
$value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'w' ) );
break;
case 'localdayname':
- $value = $pageLang->getWeekdayName( (int)MWTimestamp::getLocalInstance( $ts )->format( 'w' ) + 1 );
+ $value = $pageLang->getWeekdayName(
+ (int)MWTimestamp::getLocalInstance( $ts )->format( 'w' ) + 1
+ );
break;
case 'localyear':
$value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'Y' ), true );
break;
case 'localtime':
- $value = $pageLang->time( MWTimestamp::getLocalInstance( $ts )->format( 'YmdHis' ), false, false );
+ $value = $pageLang->time(
+ MWTimestamp::getLocalInstance( $ts )->format( 'YmdHis' ),
+ false,
+ false
+ );
break;
case 'localhour':
$value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'H' ), true );
break;
default:
$ret = null;
- wfRunHooks( 'ParserGetVariableValueSwitch', array( &$this, &$this->mVarCache, &$index, &$ret, &$frame ) );
+ wfRunHooks(
+ 'ParserGetVariableValueSwitch',
+ array( &$this, &$this->mVarCache, &$index, &$ret, &$frame )
+ );
+
return $ret;
}
if ( $frame === false ) {
$frame = $this->getPreprocessor()->newFrame();
} elseif ( !( $frame instanceof PPFrame ) ) {
- wfDebug( __METHOD__ . " called using plain parameters instead of a PPFrame instance. Creating custom frame.\n" );
+ wfDebug( __METHOD__ . " called using plain parameters instead of "
+ . "a PPFrame instance. Creating custom frame.\n" );
$frame = $this->getPreprocessor()->newCustomFrame( $frame );
}
wfProfileIn( __METHOD__ );
wfProfileIn( __METHOD__ . '-setup' );
- # Flags
- $found = false; # $text has been filled
- $nowiki = false; # wiki markup in $text should be escaped
- $isHTML = false; # $text is HTML, armour it against wikitext transformation
- $forceRawInterwiki = false; # Force interwiki transclusion to be done in raw mode not rendered
- $isChildObj = false; # $text is a DOM node needing expansion in a child frame
- $isLocalObj = false; # $text is a DOM node needing expansion in the current frame
+ // Flags
+
+ // $text has been filled
+ $found = false;
+ // wiki markup in $text should be escaped
+ $nowiki = false;
+ // $text is HTML, armour it against wikitext transformation
+ $isHTML = false;
+ // Force interwiki transclusion to be done in raw mode not rendered
+ $forceRawInterwiki = false;
+ // $text is a DOM node needing expansion in a child frame
+ $isChildObj = false;
+ // $text is a DOM node needing expansion in the current frame
+ $isLocalObj = false;
# Title object, where $text came from
$title = false;
$originalTitle = $part1;
# $args is a list of argument nodes, starting from index 0, not including $part1
- # @todo FIXME: If piece['parts'] is null then the call to getLength() below won't work b/c this $args isn't an object
+ # @todo FIXME: If piece['parts'] is null then the call to getLength()
+ # below won't work b/c this $args isn't an object
$args = ( null == $piece['parts'] ) ? array() : $piece['parts'];
wfProfileOut( __METHOD__ . '-setup' );
// "uselang" will have no effect since the Language object
// is forced to the one defined in ParserOptions.
$pageArgs = array();
- for ( $i = 0; $i < $args->getLength(); $i++ ) {
+ $argsLength = $args->getLength();
+ for ( $i = 0; $i < $argsLength; $i++ ) {
$bits = $args->item( $i )->splitArg();
if ( strval( $bits['index'] ) === '' ) {
$name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
preg_replace( '/^:/', '', $originalTitle );
$text = "[[:$originalTitle]]";
}
- $text .= $this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
+ $text .= $this->insertStripItem( '<!-- WARNING: template omitted, '
+ . 'post-expand include size too large -->' );
$this->limitationWarn( 'post-expand-template-inclusion' );
}
* @return array ( string or false, Title )
*/
function fetchTemplateAndTitle( $title ) {
- $templateCb = $this->mOptions->getTemplateCallback(); # Defaults to Parser::statelessFetchTemplate()
+ // Defaults to Parser::statelessFetchTemplate()
+ $templateCb = $this->mOptions->getTemplateCallback();
$stuff = call_user_func( $templateCb, $title, $this );
$text = $stuff['text'];
$finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title;
$status = $req->execute(); // Status object
if ( $status->isOK() ) {
$text = $req->getContent();
- } elseif ( $req->getStatus() != 200 ) { // Though we failed to fetch the content, this status is useless.
- return wfMessage( 'scarytranscludefailed-httpstatus', $url, $req->getStatus() /* HTTP status */ )->inContentLanguage()->text();
+ } elseif ( $req->getStatus() != 200 ) {
+ // Though we failed to fetch the content, this status is useless.
+ return wfMessage( 'scarytranscludefailed-httpstatus' )
+ ->params( $url, $req->getStatus() /* HTTP status */ )->inContentLanguage()->text();
} else {
return wfMessage( 'scarytranscludefailed', $url )->inContentLanguage()->text();
}
$name = $frame->expand( $params['name'] );
$attrText = !isset( $params['attr'] ) ? null : $frame->expand( $params['attr'] );
$content = !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] );
- $marker = "{$this->mUniqPrefix}-$name-" . sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX;
+ $marker = "{$this->mUniqPrefix}-$name-"
+ . sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX;
$isFunctionTag = isset( $this->mFunctionTagHooks[strtolower( $name )] ) &&
( $this->ot['html'] || $this->ot['pre'] );
if ( isset( $this->mDoubleUnderscores['notoc'] ) && !$this->mForceTocPosition ) {
$this->mShowToc = false;
}
- if ( isset( $this->mDoubleUnderscores['hiddencat'] ) && $this->mTitle->getNamespace() == NS_CATEGORY ) {
+ if ( isset( $this->mDoubleUnderscores['hiddencat'] )
+ && $this->mTitle->getNamespace() == NS_CATEGORY
+ ) {
$this->addTrackingCategory( 'hidden-category-category' );
}
# (bug 8068) Allow control over whether robots index a page.
# Get all headlines for numbering them and adding funky stuff like [edit]
# links - this is for later, but we need the number of headlines right now
$matches = array();
- $numMatches = preg_match_all( '/<H(?P<level>[1-6])(?P<attrib>.*?' . '>)\s*(?P<header>[\s\S]*?)\s*<\/H[1-6] *>/i', $text, $matches );
+ $numMatches = preg_match_all(
+ '/<H(?P<level>[1-6])(?P<attrib>.*?' . '>)\s*(?P<header>[\s\S]*?)\s*<\/H[1-6] *>/i',
+ $text,
+ $matches
+ );
# if there are fewer than 4 headlines in the article, do not show TOC
# unless it's been explicitly enabled.
# We strip any parameter from accepted tags (second regex), except dir="rtl|ltr" from <span>,
# to allow setting directionality in toc items.
$tocline = preg_replace(
- array( '#<(?!/?(span|sup|sub|i|b)(?: [^>]*)?>).*?' . '>#', '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|i|b))(?: .*?)?' . '>#' ),
+ array(
+ '#<(?!/?(span|sup|sub|i|b)(?: [^>]*)?>).*?' . '>#',
+ '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|i|b))(?: .*?)?' . '>#'
+ ),
array( '', '<$1>' ),
$safeHeadline
);
# Don't number the heading if it is the only one (looks silly)
if ( count( $matches[3] ) > 1 && $this->mOptions->getNumberHeadings() ) {
# the two are different if the line contains a link
- $headline = Html::element( 'span', array( 'class' => 'mw-headline-number' ), $numbering ) . ' ' . $headline;
+ $headline = Html::element(
+ 'span',
+ array( 'class' => 'mw-headline-number' ),
+ $numbering
+ ) . ' ' . $headline;
}
# Create the anchor for linking from the TOC to the section
# that sections inside <includeonly> should be counted.
$editlinkArgs = array( $titleText, "T-$sectionIndex"/*, null */ );
} else {
- $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint );
+ $editlinkArgs = array(
+ $this->mTitle->getPrefixedText(),
+ $sectionIndex,
+ $headlineHint
+ );
}
- // We use a bit of pesudo-xml for editsection markers. The language converter is run later on
- // Using a UNIQ style marker leads to the converter screwing up the tokens when it converts stuff
- // And trying to insert strip tags fails too. At this point all real inputted tags have already been escaped
- // so we don't have to worry about a user trying to input one of these markers directly.
- // We use a page and section attribute to stop the language converter from converting these important bits
- // of data, but put the headline hint inside a content block because the language converter is supposed to
+ // We use a bit of pesudo-xml for editsection markers. The
+ // language converter is run later on. Using a UNIQ style marker
+ // leads to the converter screwing up the tokens when it
+ // converts stuff. And trying to insert strip tags fails too. At
+ // this point all real inputted tags have already been escaped,
+ // so we don't have to worry about a user trying to input one of
+ // these markers directly. We use a page and section attribute
+ // to stop the language converter from converting these
+ // important bits of data, but put the headline hint inside a
+ // content block because the language converter is supposed to
// be able to convert that piece of data.
$editlink = '<mw:editsection page="' . htmlspecialchars( $editlinkArgs[0] );
$editlink .= '" section="' . htmlspecialchars( $editlinkArgs[1] ) . '"';
* @param bool $clearState Whether to clear the parser state first
* @return string The altered wiki markup
*/
- public function preSaveTransform( $text, Title $title, User $user, ParserOptions $options, $clearState = true ) {
+ public function preSaveTransform( $text, Title $title, User $user,
+ ParserOptions $options, $clearState = true
+ ) {
if ( $clearState ) {
$magicScopeVariable = $this->lock();
}
$tc = '[' . Title::legalChars() . ']';
$nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii!
- $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/"; # [[ns:page (context)|]]
- $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/"; # [[ns:page(context)|]] (double-width brackets, added in r40257)
- $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/"; # [[ns:page (context), context|]] (using either single or double-width comma)
- $p2 = "/\[\[\\|($tc+)]]/"; # [[|page]] (reverse pipe trick: add context from page title)
+ // [[ns:page (context)|]]
+ $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";
+ // [[ns:page(context)|]] (double-width brackets, added in r40257)
+ $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";
+ // [[ns:page (context), context|]] (using either single or double-width comma)
+ $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/";
+ // [[|page]] (reverse pipe trick: add context from page title)
+ $p2 = "/\[\[\\|($tc+)]]/";
# try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"
$text = preg_replace( $p1, '[[\\1\\2\\3|\\2]]', $text );
$nickText = wfEscapeWikiText( $nickname );
$msgName = $user->isAnon() ? 'signature-anon' : 'signature';
- return wfMessage( $msgName, $userText, $nickText )->inContentLanguage()->title( $this->getTitle() )->text();
+ return wfMessage( $msgName, $userText, $nickText )->inContentLanguage()
+ ->title( $this->getTitle() )->text();
}
/**
* @param int $outputType
* @param bool $clearState
*/
- public function startExternalParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
+ public function startExternalParse( Title $title = null, ParserOptions $options,
+ $outputType, $clearState = true
+ ) {
$this->startParse( $title, $options, $outputType, $clearState );
}
* @param int $outputType
* @param bool $clearState
*/
- private function startParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
+ private function startParse( Title $title = null, ParserOptions $options,
+ $outputType, $clearState = true
+ ) {
$this->setTitle( $title );
$this->mOptions = $options;
$this->setOutputType( $outputType );
* @return array
*/
function getTags() {
- return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ), array_keys( $this->mFunctionTagHooks ) );
+ return array_merge(
+ array_keys( $this->mTransparentTagHooks ),
+ array_keys( $this->mTagHooks ),
+ array_keys( $this->mFunctionTagHooks )
+ );
}
/**
list( $element, $content, $params, $tag ) = $data;
$tagName = strtolower( $element );
if ( isset( $this->mTransparentTagHooks[$tagName] ) ) {
- $output = call_user_func_array( $this->mTransparentTagHooks[$tagName], array( $content, $params, $this ) );
+ $output = call_user_func_array(
+ $this->mTransparentTagHooks[$tagName],
+ array( $content, $params, $this )
+ );
} else {
$output = $tag;
}
*/
protected function lock() {
if ( $this->mInParse ) {
- throw new MWException( "Parser state cleared while parsing. Did you call Parser::parse recursively?" );
+ throw new MWException( "Parser state cleared while parsing. "
+ . "Did you call Parser::parse recursively?" );
}
$this->mInParse = true;
if ( !$useOutdated && $optionsKey->expired( $article->getTouched() ) ) {
wfIncrStats( "pcache_miss_expired" );
$cacheTime = $optionsKey->getCacheTime();
- wfDebug( "Parser options key expired, touched " . $article->getTouched() . ", epoch $wgCacheEpoch, cached $cacheTime\n" );
+ wfDebug( "Parser options key expired, touched " . $article->getTouched()
+ . ", epoch $wgCacheEpoch, cached $cacheTime\n" );
return false;
} elseif ( $optionsKey->isDifferentRevision( $article->getLatest() ) ) {
wfIncrStats( "pcache_miss_revid" );
$usedOptions = ParserOptions::legacyOptions();
}
- return $this->getParserOutputKey( $article, $popts->optionsHash( $usedOptions, $article->getTitle() ) );
+ return $this->getParserOutputKey(
+ $article,
+ $popts->optionsHash( $usedOptions, $article->getTitle() )
+ );
}
/**
if ( !$useOutdated && $value->expired( $touched ) ) {
wfIncrStats( "pcache_miss_expired" );
$cacheTime = $value->getCacheTime();
- wfDebug( "ParserOutput key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
+ wfDebug( "ParserOutput key expired, touched $touched, "
+ . "epoch $wgCacheEpoch, cached $cacheTime\n" );
$value = false;
} elseif ( $value->isDifferentRevision( $article->getLatest() ) ) {
wfIncrStats( "pcache_miss_revid" );
/**
* \brief Set options of the Parser
*
- * All member variables are supposed to be private in theory, although in practise this is not the case.
+ * All member variables are supposed to be private in theory, although in
+ * practise this is not the case.
*
* @ingroup Parser
*/
class ParserOptions {
+ /** @var bool Parsing the page for a "preview" operation? */
+ public $mIsPreview = false;
- /**
- * Interlanguage links are removed and returned in an array
- */
- var $mInterwikiMagic;
+ /** @var bool Interlanguage links are removed and returned in an array */
+ protected $mInterwikiMagic;
- /**
- * Allow external images inline?
- */
- var $mAllowExternalImages;
+ /** @var bool Allow external images inline? */
+ protected $mAllowExternalImages;
- /**
- * If not, any exception?
- */
- var $mAllowExternalImagesFrom;
+ /** @var string|array If not, any exception? */
+ protected $mAllowExternalImagesFrom;
- /**
- * If not or it doesn't match, should we check an on-wiki whitelist?
- */
- var $mEnableImageWhitelist;
+ /** @var bool If not or it doesn't match, should we check an on-wiki whitelist? */
+ protected $mEnableImageWhitelist;
- /**
- * Date format index
- */
- var $mDateFormat = null;
+ /** @var string Date format index */
+ protected $mDateFormat = null;
- /**
- * Create "edit section" links?
- */
- var $mEditSection = true;
+ /** @var bool Create "edit section" links? */
+ protected $mEditSection = true;
- /**
- * Allow inclusion of special pages?
- */
- var $mAllowSpecialInclusion;
+ /** @var bool Allow inclusion of special pages? */
+ protected $mAllowSpecialInclusion;
- /**
- * Use tidy to cleanup output HTML?
- */
- var $mTidy = false;
+ /** @var bool Use tidy to cleanup output HTML? */
+ protected $mTidy = false;
/**
- * Which lang to call for PLURAL and GRAMMAR
+ * @var bool Which lang to call for PLURAL and GRAMMAR
+ * @todo FIXME: This comment doesn't appear to be correct.
+ * Should be this? Whether this is an interface message.
*/
- var $mInterfaceMessage = false;
+ protected $mInterfaceMessage = false;
- /**
- * Overrides $mInterfaceMessage with arbitrary language
- */
- var $mTargetLanguage = null;
+ /** @var string|Language Overrides $mInterfaceMessage with arbitrary language */
+ protected $mTargetLanguage = null;
- /**
- * Maximum size of template expansions, in bytes
- */
- var $mMaxIncludeSize;
+ /** @var int Maximum size of template expansions, in bytes */
+ protected $mMaxIncludeSize;
- /**
- * Maximum number of nodes touched by PPFrame::expand()
- */
- var $mMaxPPNodeCount;
+ /** @var int Maximum number of nodes touched by PPFrame::expand() */
+ protected $mMaxPPNodeCount;
- /**
- * Maximum number of nodes generated by Preprocessor::preprocessToObj()
- */
- var $mMaxGeneratedPPNodeCount;
+ /** @var int Maximum number of nodes generated by Preprocessor::preprocessToObj() */
+ protected $mMaxGeneratedPPNodeCount;
- /**
- * Maximum recursion depth in PPFrame::expand()
- */
- var $mMaxPPExpandDepth;
+ /** @var int Maximum recursion depth in PPFrame::expand() */
+ protected $mMaxPPExpandDepth;
- /**
- * Maximum recursion depth for templates within templates
- */
- var $mMaxTemplateDepth;
+ /** @var int Maximum recursion depth for templates within templates */
+ protected $mMaxTemplateDepth;
- /**
- * Maximum number of calls per parse to expensive parser functions
- */
- var $mExpensiveParserFunctionLimit;
+ /** @var int Maximum number of calls per parse to expensive parser functions */
+ protected $mExpensiveParserFunctionLimit;
- /**
- * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
- */
- var $mRemoveComments = true;
+ /** @var bool Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS */
+ protected $mRemoveComments = true;
- /**
- * Callback for template fetching. Used as first argument to call_user_func().
- */
- var $mTemplateCallback =
- array( 'Parser', 'statelessFetchTemplate' );
+ /** @var array Callback for template fetching. Used as first argument to call_user_func(). */
+ protected $mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
- /**
- * Enable limit report in an HTML comment on output
- */
- var $mEnableLimitReport = false;
+ /** @var bool Enable limit report in an HTML comment on output */
+ protected $mEnableLimitReport = false;
- /**
- * Timestamp used for {{CURRENTDAY}} etc.
- */
- var $mTimestamp;
+ /** @var string Timestamp used for {{CURRENTDAY}} etc. */
+ protected $mTimestamp;
- /**
- * Target attribute for external links
- */
- var $mExternalLinkTarget;
+ /** @var bool|string Target attribute for external links */
+ protected $mExternalLinkTarget;
/**
- * Clean up signature texts?
+ * @var bool Clean up signature texts?
*
* 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures
* 2) Substitute all transclusions
*/
- var $mCleanSignatures;
+ protected $mCleanSignatures;
- /**
- * Transform wiki markup when saving the page?
- */
- var $mPreSaveTransform = true;
+ /** @var bool Transform wiki markup when saving the page? */
+ protected $mPreSaveTransform = true;
- /**
- * Whether content conversion should be disabled
- */
- var $mDisableContentConversion;
+ /** @var bool Whether content conversion should be disabled */
+ protected $mDisableContentConversion;
- /**
- * Whether title conversion should be disabled
- */
- var $mDisableTitleConversion;
+ /** @var bool Whether title conversion should be disabled */
+ protected $mDisableTitleConversion;
- /**
- * Automatically number headings?
- */
- var $mNumberHeadings;
+ /** @var string Automatically number headings? */
+ protected $mNumberHeadings;
- /**
- * Thumb size preferred by the user.
- */
- var $mThumbSize;
+ /** @var string Thumb size preferred by the user. */
+ protected $mThumbSize;
- /**
- * Maximum article size of an article to be marked as "stub"
- */
+ /** @var Language Language object of the User language. */
+ protected $mUserLang;
+
+ /** @var User Stored user object */
+ protected $mUser;
+
+ /** @var bool Parsing the page for a "preview" operation on a single section? */
+ protected $mIsSectionPreview = false;
+
+ /** @var bool Parsing the printable version of the page? */
+ protected $mIsPrintable = false;
+
+ /** @var string Extra key that should be present in the caching key. */
+ protected $mExtraKey = '';
+
+ /** @var callable Function to be called when an option is accessed. */
+ protected $onAccessCallback = null;
+
+ /** @var int Maximum article size of an article to be marked as "stub" */
private $mStubThreshold;
- /**
- * Language object of the User language.
- */
- var $mUserLang;
+ function getInterwikiMagic() {
+ return $this->mInterwikiMagic;
+ }
- /**
- * @var User
- * Stored user object
- */
- var $mUser;
+ function getAllowExternalImages() {
+ return $this->mAllowExternalImages;
+ }
- /**
- * Parsing the page for a "preview" operation?
- */
- var $mIsPreview = false;
+ function getAllowExternalImagesFrom() {
+ return $this->mAllowExternalImagesFrom;
+ }
- /**
- * Parsing the page for a "preview" operation on a single section?
- */
- var $mIsSectionPreview = false;
+ function getEnableImageWhitelist() {
+ return $this->mEnableImageWhitelist;
+ }
- /**
- * Parsing the printable version of the page?
- */
- var $mIsPrintable = false;
+ function getEditSection() {
+ return $this->mEditSection;
+ }
- /**
- * Extra key that should be present in the caching key.
- */
- var $mExtraKey = '';
+ function getNumberHeadings() {
+ $this->optionUsed( 'numberheadings' );
- /**
- * Function to be called when an option is accessed.
- */
- protected $onAccessCallback = null;
+ return $this->mNumberHeadings;
+ }
+
+ function getAllowSpecialInclusion() {
+ return $this->mAllowSpecialInclusion;
+ }
+
+ function getTidy() {
+ return $this->mTidy;
+ }
+
+ function getInterfaceMessage() {
+ return $this->mInterfaceMessage;
+ }
+
+ function getTargetLanguage() {
+ return $this->mTargetLanguage;
+ }
+
+ function getMaxIncludeSize() {
+ return $this->mMaxIncludeSize;
+ }
+
+ function getMaxPPNodeCount() {
+ return $this->mMaxPPNodeCount;
+ }
+
+ function getMaxGeneratedPPNodeCount() {
+ return $this->mMaxGeneratedPPNodeCount;
+ }
+
+ function getMaxPPExpandDepth() {
+ return $this->mMaxPPExpandDepth;
+ }
+
+ function getMaxTemplateDepth() {
+ return $this->mMaxTemplateDepth;
+ }
- function getInterwikiMagic() { return $this->mInterwikiMagic; }
- function getAllowExternalImages() { return $this->mAllowExternalImages; }
- function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; }
- function getEnableImageWhitelist() { return $this->mEnableImageWhitelist; }
- function getEditSection() { return $this->mEditSection; }
- function getNumberHeadings() { $this->optionUsed( 'numberheadings' );
- return $this->mNumberHeadings; }
- function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
- function getTidy() { return $this->mTidy; }
- function getInterfaceMessage() { return $this->mInterfaceMessage; }
- function getTargetLanguage() { return $this->mTargetLanguage; }
- function getMaxIncludeSize() { return $this->mMaxIncludeSize; }
- function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; }
- function getMaxGeneratedPPNodeCount() { return $this->mMaxGeneratedPPNodeCount; }
- function getMaxPPExpandDepth() { return $this->mMaxPPExpandDepth; }
- function getMaxTemplateDepth() { return $this->mMaxTemplateDepth; }
/* @since 1.20 */
- function getExpensiveParserFunctionLimit() { return $this->mExpensiveParserFunctionLimit; }
- function getRemoveComments() { return $this->mRemoveComments; }
- function getTemplateCallback() { return $this->mTemplateCallback; }
- function getEnableLimitReport() { return $this->mEnableLimitReport; }
- function getCleanSignatures() { return $this->mCleanSignatures; }
- function getExternalLinkTarget() { return $this->mExternalLinkTarget; }
- function getDisableContentConversion() { return $this->mDisableContentConversion; }
- function getDisableTitleConversion() { return $this->mDisableTitleConversion; }
- function getThumbSize() { $this->optionUsed( 'thumbsize' );
- return $this->mThumbSize; }
- function getStubThreshold() { $this->optionUsed( 'stubthreshold' );
- return $this->mStubThreshold; }
-
- function getIsPreview() { return $this->mIsPreview; }
- function getIsSectionPreview() { return $this->mIsSectionPreview; }
- function getIsPrintable() { $this->optionUsed( 'printable' );
- return $this->mIsPrintable; }
- function getUser() { return $this->mUser; }
- function getPreSaveTransform() { return $this->mPreSaveTransform; }
+ function getExpensiveParserFunctionLimit() {
+ return $this->mExpensiveParserFunctionLimit;
+ }
+
+ function getRemoveComments() {
+ return $this->mRemoveComments;
+ }
+
+ function getTemplateCallback() {
+ return $this->mTemplateCallback;
+ }
+
+ function getEnableLimitReport() {
+ return $this->mEnableLimitReport;
+ }
+
+ function getCleanSignatures() {
+ return $this->mCleanSignatures;
+ }
+
+ function getExternalLinkTarget() {
+ return $this->mExternalLinkTarget;
+ }
+
+ function getDisableContentConversion() {
+ return $this->mDisableContentConversion;
+ }
+
+ function getDisableTitleConversion() {
+ return $this->mDisableTitleConversion;
+ }
+
+ function getThumbSize() {
+ $this->optionUsed( 'thumbsize' );
+
+ return $this->mThumbSize;
+ }
+
+ function getStubThreshold() {
+ $this->optionUsed( 'stubthreshold' );
+
+ return $this->mStubThreshold;
+ }
+
+ function getIsPreview() {
+ return $this->mIsPreview;
+ }
+
+ function getIsSectionPreview() {
+ return $this->mIsSectionPreview;
+ }
+
+ function getIsPrintable() {
+ $this->optionUsed( 'printable' );
+
+ return $this->mIsPrintable;
+ }
+
+ function getUser() {
+ return $this->mUser;
+ }
+
+ function getPreSaveTransform() {
+ return $this->mPreSaveTransform;
+ }
function getDateFormat() {
$this->optionUsed( 'dateformat' );
return $this->getUserLangObj()->getCode();
}
- function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic, $x ); }
- function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages, $x ); }
- function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom, $x ); }
- function setEnableImageWhitelist( $x ) { return wfSetVar( $this->mEnableImageWhitelist, $x ); }
- function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
- function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
- function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
- function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
- function setTidy( $x ) { return wfSetVar( $this->mTidy, $x ); }
+ function setInterwikiMagic( $x ) {
+ return wfSetVar( $this->mInterwikiMagic, $x );
+ }
+
+ function setAllowExternalImages( $x ) {
+ return wfSetVar( $this->mAllowExternalImages, $x );
+ }
+
+ function setAllowExternalImagesFrom( $x ) {
+ return wfSetVar( $this->mAllowExternalImagesFrom, $x );
+ }
+
+ function setEnableImageWhitelist( $x ) {
+ return wfSetVar( $this->mEnableImageWhitelist, $x );
+ }
+
+ function setDateFormat( $x ) {
+ return wfSetVar( $this->mDateFormat, $x );
+ }
+
+ function setEditSection( $x ) {
+ return wfSetVar( $this->mEditSection, $x );
+ }
+
+ function setNumberHeadings( $x ) {
+ return wfSetVar( $this->mNumberHeadings, $x );
+ }
+
+ function setAllowSpecialInclusion( $x ) {
+ return wfSetVar( $this->mAllowSpecialInclusion, $x );
+ }
+
+ function setTidy( $x ) {
+ return wfSetVar( $this->mTidy, $x );
+ }
/** @deprecated since 1.19 */
- function setSkin( $x ) { wfDeprecated( __METHOD__, '1.19' ); }
- function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x ); }
- function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage, $x, true ); }
- function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); }
- function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount, $x ); }
- function setMaxGeneratedPPNodeCount( $x ) { return wfSetVar( $this->mMaxGeneratedPPNodeCount, $x ); }
- function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth, $x ); }
+ function setSkin( $x ) {
+ wfDeprecated( __METHOD__, '1.19' );
+ }
+
+ function setInterfaceMessage( $x ) {
+ return wfSetVar( $this->mInterfaceMessage, $x );
+ }
+
+ function setTargetLanguage( $x ) {
+ return wfSetVar( $this->mTargetLanguage, $x, true );
+ }
+
+ function setMaxIncludeSize( $x ) {
+ return wfSetVar( $this->mMaxIncludeSize, $x );
+ }
+
+ function setMaxPPNodeCount( $x ) {
+ return wfSetVar( $this->mMaxPPNodeCount, $x );
+ }
+
+ function setMaxGeneratedPPNodeCount( $x ) {
+ return wfSetVar( $this->mMaxGeneratedPPNodeCount, $x );
+ }
+
+ function setMaxTemplateDepth( $x ) {
+ return wfSetVar( $this->mMaxTemplateDepth, $x );
+ }
+
/* @since 1.20 */
- function setExpensiveParserFunctionLimit( $x ) { return wfSetVar( $this->mExpensiveParserFunctionLimit, $x ); }
- function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments, $x ); }
- function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback, $x ); }
- function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport, $x ); }
- function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp, $x ); }
- function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); }
- function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); }
- function disableContentConversion( $x = true ) { return wfSetVar( $this->mDisableContentConversion, $x ); }
- function disableTitleConversion( $x = true ) { return wfSetVar( $this->mDisableTitleConversion, $x ); }
- function setUserLang( $x ) {
+ function setExpensiveParserFunctionLimit( $x ) {
+ return wfSetVar( $this->mExpensiveParserFunctionLimit, $x );
+ }
+
+ function setRemoveComments( $x ) {
+ return wfSetVar( $this->mRemoveComments, $x );
+ }
+
+ function setTemplateCallback( $x ) {
+ return wfSetVar( $this->mTemplateCallback, $x );
+ }
+
+ function enableLimitReport( $x = true ) {
+ return wfSetVar( $this->mEnableLimitReport, $x );
+ }
+
+ function setTimestamp( $x ) {
+ return wfSetVar( $this->mTimestamp, $x );
+ }
+
+ function setCleanSignatures( $x ) {
+ return wfSetVar( $this->mCleanSignatures, $x );
+ }
+
+ function setExternalLinkTarget( $x ) {
+ return wfSetVar( $this->mExternalLinkTarget, $x );
+ }
+
+ function disableContentConversion( $x = true ) {
+ return wfSetVar( $this->mDisableContentConversion, $x );
+ }
+
+ function disableTitleConversion( $x = true ) {
+ return wfSetVar( $this->mDisableTitleConversion, $x );
+ }
+
+ function setUserLang( $x ) {
if ( is_string( $x ) ) {
$x = Language::factory( $x );
}
+
return wfSetVar( $this->mUserLang, $x );
}
- function setThumbSize( $x ) { return wfSetVar( $this->mThumbSize, $x ); }
- function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold, $x ); }
- function setPreSaveTransform( $x ) { return wfSetVar( $this->mPreSaveTransform, $x ); }
- function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); }
- function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); }
- function setIsPrintable( $x ) { return wfSetVar( $this->mIsPrintable, $x ); }
+ function setThumbSize( $x ) {
+ return wfSetVar( $this->mThumbSize, $x );
+ }
+
+ function setStubThreshold( $x ) {
+ return wfSetVar( $this->mStubThreshold, $x );
+ }
+
+ function setPreSaveTransform( $x ) {
+ return wfSetVar( $this->mPreSaveTransform, $x );
+ }
+
+ function setIsPreview( $x ) {
+ return wfSetVar( $this->mIsPreview, $x );
+ }
+
+ function setIsSectionPreview( $x ) {
+ return wfSetVar( $this->mIsSectionPreview, $x );
+ }
+
+ function setIsPrintable( $x ) {
+ return wfSetVar( $this->mIsPrintable, $x );
+ }
/**
* Extra key that should be present in the parser cache key.
* @return array
*/
public static function legacyOptions() {
- return array( 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' );
+ return array(
+ 'stubthreshold',
+ 'numberheadings',
+ 'userlang',
+ 'thumbsize',
+ 'editsection',
+ 'printable'
+ );
}
/**
* @ingroup Parser
*/
class ParserOutput extends CacheTime {
- var $mText, # The output text
- $mLanguageLinks, # List of the full text of language links, in the order they appear
- $mCategories, # Map of category names to sort keys
- $mTitleText, # title text of the chosen language variant
- $mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
- $mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
- $mTemplateIds = array(), # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
- $mImages = array(), # DB keys of the images used, in the array key only
- $mFileSearchOptions = array(), # DB keys of the images used mapped to sha1 and MW timestamp
- $mExternalLinks = array(), # External link URLs, in the key only
- $mInterwikiLinks = array(), # 2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document.
- $mNewSection = false, # Show a new section link?
- $mHideNewSection = false, # Hide the new section link?
- $mNoGallery = false, # No gallery on category page? (__NOGALLERY__)
- $mHeadItems = array(), # Items to put in the <head> section
- $mModules = array(), # Modules to be loaded by the resource loader
- $mModuleScripts = array(), # Modules of which only the JS will be loaded by the resource loader
- $mModuleStyles = array(), # Modules of which only the CSSS will be loaded by the resource loader
- $mModuleMessages = array(), # Modules of which only the messages will be loaded by the resource loader
- $mJsConfigVars = array(), # JavaScript config variable for mw.config combined with this page
- $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks
- $mWarnings = array(), # Warning text to be returned to the user. Wikitext formatted, in the key only
- $mSections = array(), # Table of contents
- $mEditSectionTokens = false, # prefix/suffix markers if edit sections were output as tokens
- $mProperties = array(), # Name/value pairs to be cached in the DB
- $mTOCHTML = '', # HTML of the TOC
- $mTimestamp, # Timestamp of the revision
- $mTOCEnabled = true; # Whether TOC should be shown, can't override __NOTOC__
- private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
- private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
- private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
- private $mExtensionData = array(); # extra data used by extensions
- private $mLimitReportData = array(); # Parser limit report data
- private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
-
- const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
+ /** @var string The output text */
+ public $mText;
+
+ /** @var array List of the full text of language links; in the order they appear */
+ public $mLanguageLinks;
+
+ /** @var array Map of category names to sort keys */
+ public $mCategories;
+
+ /** @var array DB keys of the images used; in the array key only */
+ public $mImages = array();
+
+ /** @var array Modules to be loaded by the resource loader */
+ public $mModules = array();
+
+ /** @var array Name/value pairs to be cached in the DB */
+ public $mProperties = array();
+
+ /** @var string Title text of the chosen language variant */
+ protected $mTitleText;
+
+ /** @var array 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. */
+ protected $mLinks = array();
+
+ /** @var array 2-D map of NS/DBK to ID for the template references. ID=zero for broken. */
+ protected $mTemplates = array();
+
+ /** @var array 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. */
+ protected $mTemplateIds = array();
+
+ /** @var array DB keys of the images used mapped to sha1 and MW timestamp */
+ protected $mFileSearchOptions = array();
+
+ /** @var array External link URLs; in the key only */
+ protected $mExternalLinks = array();
+
+ /**
+ * @var array 2-D map of prefix/DBK (in keys only) for the inline interwiki
+ * links in the document.
+ */
+ protected $mInterwikiLinks = array();
+
+ /** @var bool Show a new section link? */
+ protected $mNewSection = false;
+
+ /** @var bool Hide the new section link? */
+ protected $mHideNewSection = false;
+
+ /** @var bool No gallery on category page? (__NOGALLERY__) */
+ public $mNoGallery = false;
+
+ /** @var array Items to put in the <head> section */
+ protected $mHeadItems = array();
+
+ /** @var array Modules of which only the JS will be loaded by the resource loader */
+ protected $mModuleScripts = array();
+
+ /** @var array Modules of which only the CSSS will be loaded by the resource loader */
+ protected $mModuleStyles = array();
+
+ /** @var array Modules of which only the messages will be loaded by the resource loader */
+ protected $mModuleMessages = array();
+
+ /** @var array JavaScript config variable for mw.config combined with this page */
+ protected $mJsConfigVars = array();
+
+ /** @var array Hook tags as per $wgParserOutputHooks */
+ protected $mOutputHooks = array();
+
+ /** @var array Warning text to be returned to the user. Wikitext formatted; in the key only */
+ protected $mWarnings = array();
+
+ /** @var array Table of contents */
+ protected $mSections = array();
+
+ /** @var bool Prefix/suffix markers if edit sections were output as tokens */
+ protected $mEditSectionTokens = false;
+
+ /** @var string HTML of the TOC */
+ protected $mTOCHTML = '';
+
+ /** @var string Timestamp of the revision */
+ protected $mTimestamp;
+
+ /** @var bool Whether TOC should be shown, can't override __NOTOC__ */
+ protected $mTOCEnabled = true;
+
+ /** @var string 'index' or 'noindex'? Any other value will result in no change. */
+ private $mIndexPolicy = '';
+
+ /** @var array List of ParserOptions (stored in the keys) */
+ private $mAccessedOptions = array();
+
+ /** @var array List of DataUpdate, used to save info from the page somewhere else. */
+ private $mSecondaryDataUpdates = array();
+
+ /** @var array Extra data used by extensions */
+ private $mExtensionData = array();
+
+ /** @var array Parser limit report data */
+ private $mLimitReportData = array();
+
+ /** @var array Timestamps for getTimeSinceStart() */
+ private $mParseStartTime = array();
+
+ const EDITSECTION_REGEX =
+ '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
$containsOldMagic = false, $titletext = ''
return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args );
}
- function &getLanguageLinks() { return $this->mLanguageLinks; }
- function getInterwikiLinks() { return $this->mInterwikiLinks; }
- function getCategoryLinks() { return array_keys( $this->mCategories ); }
- function &getCategories() { return $this->mCategories; }
- function getTitleText() { return $this->mTitleText; }
- function getSections() { return $this->mSections; }
- function getEditSectionTokens() { return $this->mEditSectionTokens; }
- function &getLinks() { return $this->mLinks; }
- function &getTemplates() { return $this->mTemplates; }
- function &getTemplateIds() { return $this->mTemplateIds; }
- function &getImages() { return $this->mImages; }
- function &getFileSearchOptions() { return $this->mFileSearchOptions; }
- function &getExternalLinks() { return $this->mExternalLinks; }
- function getNoGallery() { return $this->mNoGallery; }
- function getHeadItems() { return $this->mHeadItems; }
- function getModules() { return $this->mModules; }
- function getModuleScripts() { return $this->mModuleScripts; }
- function getModuleStyles() { return $this->mModuleStyles; }
- function getModuleMessages() { return $this->mModuleMessages; }
+ function &getLanguageLinks() {
+ return $this->mLanguageLinks;
+ }
+
+ function getInterwikiLinks() {
+ return $this->mInterwikiLinks;
+ }
+
+ function getCategoryLinks() {
+ return array_keys( $this->mCategories );
+ }
+
+ function &getCategories() {
+ return $this->mCategories;
+ }
+
+ function getTitleText() {
+ return $this->mTitleText;
+ }
+
+ function getSections() {
+ return $this->mSections;
+ }
+
+ function getEditSectionTokens() {
+ return $this->mEditSectionTokens;
+ }
+
+ function &getLinks() {
+ return $this->mLinks;
+ }
+
+ function &getTemplates() {
+ return $this->mTemplates;
+ }
+
+ function &getTemplateIds() {
+ return $this->mTemplateIds;
+ }
+
+ function &getImages() {
+ return $this->mImages;
+ }
+
+ function &getFileSearchOptions() {
+ return $this->mFileSearchOptions;
+ }
+
+ function &getExternalLinks() {
+ return $this->mExternalLinks;
+ }
+
+ function getNoGallery() {
+ return $this->mNoGallery;
+ }
+
+ function getHeadItems() {
+ return $this->mHeadItems;
+ }
+
+ function getModules() {
+ return $this->mModules;
+ }
+
+ function getModuleScripts() {
+ return $this->mModuleScripts;
+ }
+
+ function getModuleStyles() {
+ return $this->mModuleStyles;
+ }
+
+ function getModuleMessages() {
+ return $this->mModuleMessages;
+ }
+
/** @since 1.23 */
- function getJsConfigVars() { return $this->mJsConfigVars; }
- function getOutputHooks() { return (array)$this->mOutputHooks; }
- function getWarnings() { return array_keys( $this->mWarnings ); }
- function getIndexPolicy() { return $this->mIndexPolicy; }
- function getTOCHTML() { return $this->mTOCHTML; }
- function getTimestamp() { return $this->mTimestamp; }
- function getLimitReportData() { return $this->mLimitReportData; }
- function getTOCEnabled() { return $this->mTOCEnabled; }
-
- function setText( $text ) { return wfSetVar( $this->mText, $text ); }
- function setLanguageLinks( $ll ) { return wfSetVar( $this->mLanguageLinks, $ll ); }
- function setCategoryLinks( $cl ) { return wfSetVar( $this->mCategories, $cl ); }
-
- function setTitleText( $t ) { return wfSetVar( $this->mTitleText, $t ); }
- function setSections( $toc ) { return wfSetVar( $this->mSections, $toc ); }
- function setEditSectionTokens( $t ) { return wfSetVar( $this->mEditSectionTokens, $t ); }
- function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy, $policy ); }
- function setTOCHTML( $tochtml ) { return wfSetVar( $this->mTOCHTML, $tochtml ); }
- function setTimestamp( $timestamp ) { return wfSetVar( $this->mTimestamp, $timestamp ); }
- function setTOCEnabled( $flag ) { return wfSetVar( $this->mTOCEnabled, $flag ); }
-
- function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
- function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
- function addWarning( $s ) { $this->mWarnings[$s] = 1; }
+ function getJsConfigVars() {
+ return $this->mJsConfigVars;
+ }
+
+ function getOutputHooks() {
+ return (array)$this->mOutputHooks;
+ }
+
+ function getWarnings() {
+ return array_keys( $this->mWarnings );
+ }
+
+ function getIndexPolicy() {
+ return $this->mIndexPolicy;
+ }
+
+ function getTOCHTML() {
+ return $this->mTOCHTML;
+ }
+
+ function getTimestamp() {
+ return $this->mTimestamp;
+ }
+
+ function getLimitReportData() {
+ return $this->mLimitReportData;
+ }
+
+ function getTOCEnabled() {
+ return $this->mTOCEnabled;
+ }
+
+ function setText( $text ) {
+ return wfSetVar( $this->mText, $text );
+ }
+
+ function setLanguageLinks( $ll ) {
+ return wfSetVar( $this->mLanguageLinks, $ll );
+ }
+
+ function setCategoryLinks( $cl ) {
+ return wfSetVar( $this->mCategories, $cl );
+ }
+
+ function setTitleText( $t ) {
+ return wfSetVar( $this->mTitleText, $t );
+ }
+
+ function setSections( $toc ) {
+ return wfSetVar( $this->mSections, $toc );
+ }
+
+ function setEditSectionTokens( $t ) {
+ return wfSetVar( $this->mEditSectionTokens, $t );
+ }
+
+ function setIndexPolicy( $policy ) {
+ return wfSetVar( $this->mIndexPolicy, $policy );
+ }
+
+ function setTOCHTML( $tochtml ) {
+ return wfSetVar( $this->mTOCHTML, $tochtml );
+ }
+
+ function setTimestamp( $timestamp ) {
+ return wfSetVar( $this->mTimestamp, $timestamp );
+ }
+
+ function setTOCEnabled( $flag ) {
+ return wfSetVar( $this->mTOCEnabled, $flag );
+ }
+
+ function addCategory( $c, $sort ) {
+ $this->mCategories[$c] = $sort;
+ }
+
+ function addLanguageLink( $t ) {
+ $this->mLanguageLinks[] = $t;
+ }
+
+ function addWarning( $s ) {
+ $this->mWarnings[$s] = 1;
+ }
function addOutputHook( $hook, $data = false ) {
$this->mOutputHooks[] = array( $hook, $data );
* extracted from the page's content, including a LinksUpdate object for all links stored in
* this ParserOutput object.
*
- * @note: Avoid using this method directly, use ContentHandler::getSecondaryDataUpdates() instead! The content
- * handler may provide additional update objects.
+ * @note Avoid using this method directly, use ContentHandler::getSecondaryDataUpdates()
+ * instead! The content handler may provide additional update objects.
*
* @since 1.20
*
/**
* @ingroup Parser
*/
-class Parser_DiffTest
-{
- var $parsers, $conf;
- var $shortOutput = false;
+class Parser_DiffTest {
+ /** @var array */
+ protected $parsers;
- var $dtUniqPrefix;
+ /** @var array */
+ protected $conf;
+
+ /** @var bool */
+ protected $shortOutput = false;
+
+ /** @var string */
+ protected $dtUniqPrefix;
function __construct( $conf ) {
if ( !isset( $conf['parsers'] ) ) {
function newFrame();
/**
- * Create a new custom frame for programmatic use of parameter replacement as used in some extensions
+ * Create a new custom frame for programmatic use of parameter replacement
+ * as used in some extensions.
*
* @param array $args
*
function newCustomFrame( $args );
/**
- * Create a new custom node for programmatic use of parameter replacement as used in some extensions
+ * Create a new custom node for programmatic use of parameter replacement
+ * as used in some extensions.
*
* @param array $values
*/
* @ingroup Parser
*/
class Preprocessor_DOM implements Preprocessor {
+ /** @var Parser */
+ public $parser;
- /**
- * @var Parser
- */
- var $parser;
-
- var $memoryLimit;
+ protected $memoryLimit;
const CACHE_VERSION = 1;
foreach ( $values as $k => $val ) {
if ( is_int( $k ) ) {
- $xml .= "<part><name index=\"$k\"/><value>" . htmlspecialchars( $val ) . "</value></part>";
+ $xml .= "<part><name index=\"$k\"/><value>"
+ . htmlspecialchars( $val ) . "</value></part>";
} else {
- $xml .= "<part><name>" . htmlspecialchars( $k ) . "</name>=<value>" . htmlspecialchars( $val ) . "</value></part>";
+ $xml .= "<part><name>" . htmlspecialchars( $k )
+ . "</name>=<value>" . htmlspecialchars( $val ) . "</value></part>";
}
}
*
* @param string $text The text to parse
* @param int $flags Bitwise combination of:
- * Parser::PTD_FOR_INCLUSION Handle "<noinclude>" and "<includeonly>" as if the text is being
- * included. Default is to assume a direct page view.
+ * Parser::PTD_FOR_INCLUSION Handle "<noinclude>" and "<includeonly>"
+ * as if the text is being included. Default
+ * is to assume a direct page view.
*
* The generated DOM tree must depend only on the input text and the flags.
* The DOM tree must be the same in OT_HTML and OT_WIKI mode, to avoid a regression of bug 4899.
if ( !$result ) {
// Try running the XML through UtfNormal to get rid of invalid characters
$xml = UtfNormal::cleanUp( $xml );
- // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
+ // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2
+ // don't barf when the XML is >256 levels deep.
$result = $dom->loadXML( $xml, 1 << 19 );
}
if ( $result ) {
$ignoredTags = array( 'includeonly', '/includeonly' );
$ignoredElements = array( 'noinclude' );
$xmlishElements[] = 'noinclude';
- if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
+ if ( strpos( $text, '<onlyinclude>' ) !== false
+ && strpos( $text, '</onlyinclude>' ) !== false
+ ) {
$enableOnlyinclude = true;
}
} else {
$stack = new PPDStack;
$searchBase = "[{<\n"; #}
- $revText = strrev( $text ); // For fast reverse searches
+ // For fast reverse searches
+ $revText = strrev( $text );
$lengthText = strlen( $text );
- $i = 0; # Input pointer, starts out pointing to a pseudo-newline before the start
- $accum =& $stack->getAccum(); # Current accumulator
+ // Input pointer, starts out pointing to a pseudo-newline before the start
+ $i = 0;
+ // Current accumulator
+ $accum =& $stack->getAccum();
$accum = '<root>';
- $findEquals = false; # True to find equals signs in arguments
- $findPipe = false; # True to take notice of pipe characters
+ // True to find equals signs in arguments
+ $findEquals = false;
+ // True to take notice of pipe characters
+ $findPipe = false;
$headingIndex = 1;
- $inHeading = false; # True if $i is inside a possible heading
- $noMoreGT = false; # True if there are no more greater-than (>) signs right of $i
- $findOnlyinclude = $enableOnlyinclude; # True to ignore all input up to the next <onlyinclude>
- $fakeLineStart = true; # Do a line-start run without outputting an LF character
+ // True if $i is inside a possible heading
+ $inHeading = false;
+ // True if there are no more greater-than (>) signs right of $i
+ $noMoreGT = false;
+ // True to ignore all input up to the next <onlyinclude>
+ $findOnlyinclude = $enableOnlyinclude;
+ // Do a line-start run without outputting an LF character
+ $fakeLineStart = true;
while ( true ) {
//$this->memCheck();
if ( $found == 'angle' ) {
$matches = false;
// Handle </onlyinclude>
- if ( $enableOnlyinclude && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>' ) {
+ if ( $enableOnlyinclude
+ && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>'
+ ) {
$findOnlyinclude = true;
continue;
}
// Handle ignored tags
if ( in_array( $lowerName, $ignoredTags ) ) {
- $accum .= '<ignore>' . htmlspecialchars( substr( $text, $i, $tagEndPos - $i + 1 ) ) . '</ignore>';
+ $accum .= '<ignore>'
+ . htmlspecialchars( substr( $text, $i, $tagEndPos - $i + 1 ) )
+ . '</ignore>';
$i = $tagEndPos + 1;
continue;
}
$count = strspn( $text, '=', $i, 6 );
if ( $count == 1 && $findEquals ) {
- // DWIM: This looks kind of like a name/value separator
- // Let's let the equals handler have it and break the potential heading
- // This is heuristic, but AFAICT the methods for completely correct disambiguation are very complex.
+ // DWIM: This looks kind of like a name/value separator.
+ // Let's let the equals handler have it and break the
+ // potential heading. This is heuristic, but AFAICT the
+ // methods for completely correct disambiguation are very
+ // complex.
} elseif ( $count > 0 ) {
$piece = array(
'open' => "\n",
// A heading must be open, otherwise \n wouldn't have been in the search list
assert( '$piece->open == "\n"' );
$part = $piece->getCurrentPart();
- // Search back through the input to see if it has a proper close
- // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient
+ // Search back through the input to see if it has a proper close.
+ // Do this using the reversed string since the other solutions
+ // (end anchor, etc.) are inefficient.
$wsLength = strspn( $revText, " \t", $lengthText - $i );
$searchStart = $i - $wsLength;
if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) {
* @ingroup Parser
*/
class PPDStack {
- var $stack, $rootAccum;
+ /** @var array */
+ public $stack;
- /**
- * @var PPDStack
- */
- var $top;
- var $out;
- var $elementClass = 'PPDStackElement';
+ /** @var string */
+ public $rootAccum;
+
+ /** @var bool|PPDStack */
+ public $top;
+
+ /** @var */
+ public $out;
- static $false = false;
+ /** @var string */
+ protected $elementClass = 'PPDStackElement';
+
+ protected static $false = false;
function __construct() {
$this->stack = array();
* @ingroup Parser
*/
class PPDStackElement {
- var $open, // Opening character (\n for heading)
- $close, // Matching closing character
- $count, // Number of opening characters found (number of "=" for heading)
- $parts, // Array of PPDPart objects describing pipe-separated parts.
- $lineStart; // True if the open char appeared at the start of the input line. Not set for headings.
+ /** @var string Opening character (\n for heading) */
+ public $open;
+
+ /** @var string Matching closing character */
+ public $close;
+
+ /** @var int Number of opening characters found (number of "=" for heading) */
+ public $count;
+
+ /** @var array PPDPart objects describing pipe-separated parts. */
+ public $parts;
- var $partClass = 'PPDPart';
+ /**
+ * @var bool True if the open char appeared at the start of the input line.
+ * Not set for headings.
+ */
+ public $lineStart;
+
+ /** @var string */
+ protected $partClass = 'PPDPart';
function __construct( $data = array() ) {
$class = $this->partClass;
* @ingroup Parser
*/
class PPDPart {
- var $out; // Output accumulator string
+ /** @var string */
+ public $out;
// Optional member variables:
// eqpos Position of equals sign in output accumulator
* @ingroup Parser
*/
class PPFrame_DOM implements PPFrame {
+ /** @var array */
+ public $titleCache;
/**
- * @var Preprocessor
+ * @var array Hashtable listing templates which are disallowed for expansion
+ * in this frame, having been encountered previously in parent frames.
*/
- var $preprocessor;
+ public $loopCheckHash;
/**
- * @var Parser
+ * @var int Recursion depth of this frame, top = 0.
+ * Note that this is NOT the same as expansion depth in expand()
*/
- var $parser;
+ public $depth;
- /**
- * @var Title
- */
- var $title;
- var $titleCache;
+ /** @var Preprocessor */
+ protected $preprocessor;
- /**
- * Hashtable listing templates which are disallowed for expansion in this frame,
- * having been encountered previously in parent frames.
- */
- var $loopCheckHash;
+ /** @var Parser */
+ protected $parser;
- /**
- * Recursion depth of this frame, top = 0
- * Note that this is NOT the same as expansion depth in expand()
- */
- var $depth;
+ /** @var Title */
+ protected $title;
/**
* Construct a new preprocessor frame.
) {
$out .= '';
} elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) {
- # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
- # Not in RECOVER_COMMENTS mode (extractSections) though
+ # Add a strip marker in PST mode so that pstPass2() can
+ # run some old-fashioned regexes on the result.
+ # Not in RECOVER_COMMENTS mode (extractSections) though.
$out .= $this->parser->insertStripItem( $contextNode->textContent );
} else {
# Recover the literal comment in RECOVER_COMMENTS and pre+no-remove
# OT_WIKI will only respect <ignore> in substed templates.
# The other output types respect it unless NO_IGNORE is set.
# extractSections() sets NO_IGNORE and so never respects it.
- if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] ) || ( $flags & PPFrame::NO_IGNORE ) ) {
+ if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] )
+ || ( $flags & PPFrame::NO_IGNORE )
+ ) {
$out .= $contextNode->textContent;
} else {
$out .= '';
* @ingroup Parser
*/
class PPTemplateFrame_DOM extends PPFrame_DOM {
- var $numberedArgs, $namedArgs;
+ /** @var PPFrame_DOM */
+ public $parent;
- /**
- * @var PPFrame_DOM
- */
- var $parent;
- var $numberedExpansionCache, $namedExpansionCache;
+ /** @var array */
+ protected $numberedArgs;
+
+ /** @var array */
+ protected $namedArgs;
+
+ /** @var array */
+ protected $numberedExpansionCache;
+
+ /** @var string[] */
+ protected $namedExpansionCache;
/**
* @param Preprocessor $preprocessor
* @param array $namedArgs
* @param Title $title
*/
- function __construct( $preprocessor, $parent = false, $numberedArgs = array(), $namedArgs = array(), $title = false ) {
+ function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
+ $namedArgs = array(), $title = false
+ ) {
parent::__construct( $preprocessor );
$this->parent = $parent;
}
if ( !isset( $this->numberedExpansionCache[$index] ) ) {
# No trimming for unnamed arguments
- $this->numberedExpansionCache[$index] = $this->parent->expand( $this->numberedArgs[$index], PPFrame::STRIP_COMMENTS );
+ $this->numberedExpansionCache[$index] = $this->parent->expand(
+ $this->numberedArgs[$index],
+ PPFrame::STRIP_COMMENTS
+ );
}
return $this->numberedExpansionCache[$index];
}
* @ingroup Parser
*/
class PPCustomFrame_DOM extends PPFrame_DOM {
- var $args;
+ protected $args;
function __construct( $preprocessor, $args ) {
parent::__construct( $preprocessor );
* @ingroup Parser
*/
class PPNode_DOM implements PPNode {
+ /** @var DOMElement */
+ public $node;
- /**
- * @var DOMElement
- */
- var $node;
- var $xpath;
+ /** @var DOMXPath */
+ protected $xpath;
function __construct( $node, $xpath = false ) {
$this->node = $node;
* @ingroup Parser
*/
class Preprocessor_Hash implements Preprocessor {
- /**
- * @var Parser
- */
- var $parser;
+ /** @var Parser */
+ public $parser;
const CACHE_VERSION = 1;
// Check cache.
global $wgMemc, $wgPreprocessorCacheThreshold;
- $cacheable = $wgPreprocessorCacheThreshold !== false && strlen( $text ) > $wgPreprocessorCacheThreshold;
+ $cacheable = $wgPreprocessorCacheThreshold !== false
+ && strlen( $text ) > $wgPreprocessorCacheThreshold;
+
if ( $cacheable ) {
wfProfileIn( __METHOD__ . '-cacheable' );
$ignoredTags = array( 'includeonly', '/includeonly' );
$ignoredElements = array( 'noinclude' );
$xmlishElements[] = 'noinclude';
- if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
+ if ( strpos( $text, '<onlyinclude>' ) !== false
+ && strpos( $text, '</onlyinclude>' ) !== false
+ ) {
$enableOnlyinclude = true;
}
} else {
$stack = new PPDStack_Hash;
$searchBase = "[{<\n";
- $revText = strrev( $text ); // For fast reverse searches
+ // For fast reverse searches
+ $revText = strrev( $text );
$lengthText = strlen( $text );
- $i = 0; # Input pointer, starts out pointing to a pseudo-newline before the start
- $accum =& $stack->getAccum(); # Current accumulator
- $findEquals = false; # True to find equals signs in arguments
- $findPipe = false; # True to take notice of pipe characters
+ // Input pointer, starts out pointing to a pseudo-newline before the start
+ $i = 0;
+ // Current accumulator
+ $accum =& $stack->getAccum();
+ // True to find equals signs in arguments
+ $findEquals = false;
+ // True to take notice of pipe characters
+ $findPipe = false;
$headingIndex = 1;
- $inHeading = false; # True if $i is inside a possible heading
- $noMoreGT = false; # True if there are no more greater-than (>) signs right of $i
- $findOnlyinclude = $enableOnlyinclude; # True to ignore all input up to the next <onlyinclude>
- $fakeLineStart = true; # Do a line-start run without outputting an LF character
+ // True if $i is inside a possible heading
+ $inHeading = false;
+ // True if there are no more greater-than (>) signs right of $i
+ $noMoreGT = false;
+ // True to ignore all input up to the next <onlyinclude>
+ $findOnlyinclude = $enableOnlyinclude;
+ // Do a line-start run without outputting an LF character
+ $fakeLineStart = true;
while ( true ) {
//$this->memCheck();
if ( $found == 'angle' ) {
$matches = false;
// Handle </onlyinclude>
- if ( $enableOnlyinclude && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>' ) {
+ if ( $enableOnlyinclude
+ && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>'
+ ) {
$findOnlyinclude = true;
continue;
}
$count = strspn( $text, '=', $i, 6 );
if ( $count == 1 && $findEquals ) {
- // DWIM: This looks kind of like a name/value separator
- // Let's let the equals handler have it and break the potential heading
- // This is heuristic, but AFAICT the methods for completely correct disambiguation are very complex.
+ // DWIM: This looks kind of like a name/value separator.
+ // Let's let the equals handler have it and break the potential
+ // heading. This is heuristic, but AFAICT the methods for
+ // completely correct disambiguation are very complex.
} elseif ( $count > 0 ) {
$piece = array(
'open' => "\n",
// A heading must be open, otherwise \n wouldn't have been in the search list
assert( '$piece->open == "\n"' );
$part = $piece->getCurrentPart();
- // Search back through the input to see if it has a proper close
- // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient
+ // Search back through the input to see if it has a proper close.
+ // Do this using the reversed string since the other solutions
+ // (end anchor, etc.) are inefficient.
$wsLength = strspn( $revText, " \t", $lengthText - $i );
$searchStart = $i - $wsLength;
if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) {
* @ingroup Parser
*/
class PPDAccum_Hash {
- var $firstNode, $lastNode;
+ public $firstNode;
+
+ public $lastNode;
function __construct() {
$this->firstNode = $this->lastNode = false;
* @ingroup Parser
*/
class PPFrame_Hash implements PPFrame {
-
/**
- * @var Parser
+ * @var int Recursion depth of this frame, top = 0
+ * Note that this is NOT the same as expansion depth in expand()
*/
- var $parser;
+ public $depth;
- /**
- * @var Preprocessor
- */
- var $preprocessor;
+ /** @var Parser */
+ protected $parser;
- /**
- * @var Title
- */
- var $title;
- var $titleCache;
+ /** @var Preprocessor */
+ protected $preprocessor;
- /**
- * Hashtable listing templates which are disallowed for expansion in this frame,
- * having been encountered previously in parent frames.
- */
- var $loopCheckHash;
+ /** @var Title */
+ protected $title;
+
+ /** @var array */
+ protected $titleCache;
/**
- * Recursion depth of this frame, top = 0
- * Note that this is NOT the same as expansion depth in expand()
+ * @var array Hashtable listing templates which are disallowed for
+ * expansion in this frame, having been encountered previously in
+ * parent frames.
*/
- var $depth;
+ protected $loopCheckHash;
/**
* Construct a new preprocessor frame.
# Double-brace expansion
$bits = $contextNode->splitTemplate();
if ( $flags & PPFrame::NO_TEMPLATES ) {
- $newIterator = $this->virtualBracketedImplode( '{{', '|', '}}', $bits['title'], $bits['parts'] );
+ $newIterator = $this->virtualBracketedImplode(
+ '{{', '|', '}}',
+ $bits['title'],
+ $bits['parts']
+ );
} else {
$ret = $this->parser->braceSubstitution( $bits, $this );
if ( isset( $ret['object'] ) ) {
# Triple-brace expansion
$bits = $contextNode->splitTemplate();
if ( $flags & PPFrame::NO_ARGS ) {
- $newIterator = $this->virtualBracketedImplode( '{{{', '|', '}}}', $bits['title'], $bits['parts'] );
+ $newIterator = $this->virtualBracketedImplode(
+ '{{{', '|', '}}}',
+ $bits['title'],
+ $bits['parts']
+ );
} else {
$ret = $this->parser->argSubstitution( $bits, $this );
if ( isset( $ret['object'] ) ) {
) {
$out .= '';
} elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) {
- # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
- # Not in RECOVER_COMMENTS mode (extractSections) though
+ # Add a strip marker in PST mode so that pstPass2() can
+ # run some old-fashioned regexes on the result.
+ # Not in RECOVER_COMMENTS mode (extractSections) though.
$out .= $this->parser->insertStripItem( $contextNode->firstChild->value );
} else {
# Recover the literal comment in RECOVER_COMMENTS and pre+no-remove
# OT_WIKI will only respect <ignore> in substed templates.
# The other output types respect it unless NO_IGNORE is set.
# extractSections() sets NO_IGNORE and so never respects it.
- if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] ) || ( $flags & PPFrame::NO_IGNORE ) ) {
+ if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] )
+ || ( $flags & PPFrame::NO_IGNORE )
+ ) {
$out .= $contextNode->firstChild->value;
} else {
//$out .= '';
* @ingroup Parser
*/
class PPTemplateFrame_Hash extends PPFrame_Hash {
- var $numberedArgs, $namedArgs, $parent;
- var $numberedExpansionCache, $namedExpansionCache;
+ /** @var array */
+ protected $numberedArgs;
+
+ /** @var array */
+ protected $namedArgs;
+
+ /** @var bool|PPFrame */
+ protected $parent;
+
+ /** @var array */
+ protected $numberedExpansionCache;
+
+ /** @var */
+ protected $namedExpansionCache;
/**
* @param Preprocessor $preprocessor
* @param array $namedArgs
* @param Title $title
*/
- function __construct( $preprocessor, $parent = false, $numberedArgs = array(), $namedArgs = array(), $title = false ) {
+ function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
+ $namedArgs = array(), $title = false
+ ) {
parent::__construct( $preprocessor );
$this->parent = $parent;
}
if ( !isset( $this->numberedExpansionCache[$index] ) ) {
# No trimming for unnamed arguments
- $this->numberedExpansionCache[$index] = $this->parent->expand( $this->numberedArgs[$index], PPFrame::STRIP_COMMENTS );
+ $this->numberedExpansionCache[$index] = $this->parent->expand(
+ $this->numberedArgs[$index],
+ PPFrame::STRIP_COMMENTS
+ );
}
return $this->numberedExpansionCache[$index];
}
* @ingroup Parser
*/
class PPCustomFrame_Hash extends PPFrame_Hash {
- var $args;
+ /** @var array */
+ protected $args;
function __construct( $preprocessor, $args ) {
parent::__construct( $preprocessor );
* @ingroup Parser
*/
class PPNode_Hash_Tree implements PPNode {
- var $name, $firstChild, $lastChild, $nextSibling;
+ public $name;
+
+ public $firstChild;
+
+ public $lastChild;
+
+ public $nextSibling;
function __construct( $name ) {
$this->name = $name;
* @ingroup Parser
*/
class PPNode_Hash_Text implements PPNode {
- var $value, $nextSibling;
+ public $value;
+
+ public $nextSibling;
function __construct( $value ) {
if ( is_object( $value ) ) {
return $this->nextSibling;
}
- function getChildren() { return false; }
- function getFirstChild() { return false; }
- function getChildrenOfType( $name ) { return false; }
- function getLength() { return false; }
- function item( $i ) { return false; }
- function getName() { return '#text'; }
- function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
- function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
- function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
+ function getChildren() {
+ return false;
+ }
+
+ function getFirstChild() {
+ return false;
+ }
+
+ function getChildrenOfType( $name ) {
+ return false;
+ }
+
+ function getLength() {
+ return false;
+ }
+
+ function item( $i ) {
+ return false;
+ }
+
+ function getName() {
+ return '#text';
+ }
+
+ function splitArg() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
+
+ function splitExt() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
+
+ function splitHeading() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
}
/**
* @ingroup Parser
*/
class PPNode_Hash_Array implements PPNode {
- var $value, $nextSibling;
+ public $value;
+
+ public $nextSibling;
function __construct( $value ) {
$this->value = $value;
return $this->value[$i];
}
- function getName() { return '#nodelist'; }
+ function getName() {
+ return '#nodelist';
+ }
function getNextSibling() {
return $this->nextSibling;
}
- function getChildren() { return false; }
- function getFirstChild() { return false; }
- function getChildrenOfType( $name ) { return false; }
- function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
- function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
- function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
+ function getChildren() {
+ return false;
+ }
+
+ function getFirstChild() {
+ return false;
+ }
+
+ function getChildrenOfType( $name ) {
+ return false;
+ }
+
+ function splitArg() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
+
+ function splitExt() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
+
+ function splitHeading() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
}
/**
* @ingroup Parser
*/
class PPNode_Hash_Attr implements PPNode {
- var $name, $value, $nextSibling;
+ /** @var string */
+ public $name;
+
+ /** @var string */
+ public $value;
+
+ public $nextSibling;
function __construct( $name, $value ) {
$this->name = $name;
return $this->nextSibling;
}
- function getChildren() { return false; }
- function getFirstChild() { return false; }
- function getChildrenOfType( $name ) { return false; }
- function getLength() { return false; }
- function item( $i ) { return false; }
- function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
- function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
- function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
+ function getChildren() {
+ return false;
+ }
+
+ function getFirstChild() {
+ return false;
+ }
+
+ function getChildrenOfType( $name ) {
+ return false;
+ }
+
+ function getLength() {
+ return false;
+ }
+
+ function item( $i ) {
+ return false;
+ }
+
+ function splitArg() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
+
+ function splitExt() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
+
+ function splitHeading() {
+ throw new MWException( __METHOD__ . ': not supported' );
+ }
}
/** @var TransactionProfiler */
protected $trxProfiler;
- /** @var Profiler */
- public static $__instance = null; // do not call this outside Profiler and ProfileSection
+ // @codingStandardsIgnoreStart PSR2.Classes.PropertyDeclaration.Underscore
+ /** @var Profiler Do not call this outside Profiler and ProfileSection */
+ public static $__instance = null;
+ // @codingStandardsIgnoreEnd
/**
* @param array $params
if ( $useTrx ) {
$dbw->commit();
}
- } catch ( DBError $e ) {}
+ } catch ( DBError $e ) {
+ }
}
}
public function isStub() {
return true;
}
+
public function isPersistent() {
return false;
}
- public function profileIn( $fn ) {}
- public function profileOut( $fn ) {}
- public function getOutput() {}
- public function close() {}
- public function logData() {}
- public function getCurrentSection() { return ''; }
- public function transactionWritingIn( $server, $db, $id = '' ) {}
- public function transactionWritingOut( $server, $db, $id = '' ) {}
- public function getRawData() { return array(); }
+
+ public function profileIn( $fn ) {
+ }
+
+ public function profileOut( $fn ) {
+ }
+
+ public function getOutput() {
+ }
+
+ public function close() {
+ }
+
+ public function logData() {
+ }
+
+ public function getCurrentSection() {
+ return '';
+ }
+
+ public function transactionWritingIn( $server, $db, $id = '' ) {
+ }
+
+ public function transactionWritingOut( $server, $db, $id = '' ) {
+ }
+
+ public function getRawData() {
+ return array();
+ }
}
'Target' => array(
'type' => 'text',
'label-message' => 'ipaddressorusername',
- 'tabindex' => '1',
'id' => 'mw-bi-target',
'size' => '45',
'autofocus' => true,
'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
'label-message' => 'ipbexpiry',
'required' => true,
- 'tabindex' => '2',
'options' => $suggestedDurations,
'other' => $this->msg( 'ipbother' )->text(),
'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
return 'users';
}
}
-
-# BC @since 1.18
-class IPBlockForm extends SpecialBlock {
-}
$context->setTitle( $this->getPageTitle() ); // Remove subpage
$form = new EditWatchlistNormalHTMLForm( $fields, $context );
$form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
- # Used message keys: 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
+ # Used message keys:
+ # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
$form->setSubmitTooltip( 'watchlistedit-normal-submit' );
$form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
$form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
);
}
- wfRunHooks( 'WatchlistEditorBuildRemoveLine', array( &$tools, $title, $title->isRedirect(), $this->getSkin() ) );
+ wfRunHooks(
+ 'WatchlistEditorBuildRemoveLine',
+ array( &$tools, $title, $title->isRedirect(), $this->getSkin() )
+ );
return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
}
}
}
-# B/C since 1.18
-class WatchlistEditor extends SpecialEditWatchlist {
-}
-
/**
* Extend HTMLForm purely so we can have a more sane way of getting the section headers
*/
) . '<br />';
}
- // Enable this when we can do something useful exporting/importing image information. :)
- //$form .= Xml::checkLabel( $this->msg( 'export-images' )->text(), 'images', 'wpExportImages', false ) . '<br />';
+ /* Enable this when we can do something useful exporting/importing image information.
+ $form .= Xml::checkLabel(
+ $this->msg( 'export-images' )->text(),
+ 'images',
+ 'wpExportImages',
+ false
+ ) . '<br />';
+ */
$form .= Xml::checkLabel(
$this->msg( 'export-download' )->text(),
'wpDownload',
* @return array
*/
private function getPageLinks( $inputPages, $pageSet, $depth ) {
+ // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for ( ; $depth > 0; --$depth ) {
+ // @codingStandardsIgnoreEnd
$pageSet = $this->getLinks(
$inputPages, $pageSet, 'pagelinks',
array( 'namespace' => 'pl_namespace', 'title' => 'pl_title' ),
$sourceName = $request->getVal( "source" );
$this->logcomment = $request->getText( 'log-comment' );
- $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull( 'pagelink-depth' );
+ $this->pageLinkDepth = $wgExportMaxLinkDepth == 0
+ ? 0
+ : $request->getIntOrNull( 'pagelink-depth' );
$this->rootpage = $request->getText( 'rootpage' );
$user = $this->getUser();
</tr>
<tr>
<td class='mw-label'>" .
- Xml::label( $this->msg( 'import-interwiki-rootpage' )->text(), 'mw-interwiki-rootpage-upload' ) .
+ Xml::label(
+ $this->msg( 'import-interwiki-rootpage' )->text(),
+ 'mw-interwiki-rootpage-upload'
+ ) .
"</td>
<td class='mw-input'>" .
Xml::input( 'rootpage', 50, $this->rootpage,
}
function reportNotice( $msg, array $params ) {
- $this->getOutput()->addHTML( Html::element( 'li', array(), $this->msg( $msg, $params )->text() ) );
+ $this->getOutput()->addHTML(
+ Html::element( 'li', array(), $this->msg( $msg, $params )->text() )
+ );
}
function reportLogItem( /* ... */ ) {
$detail = $this->msg( 'import-logentry-upload-detail' )->numParams(
$successCount )->inContentLanguage()->text();
if ( $this->reason ) {
- $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->reason;
+ $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+ . $this->reason;
}
$log->addEntry( 'upload', $title, $detail, array(), $this->getUser() );
} else {
$detail = $this->msg( 'import-logentry-interwiki-detail' )->numParams(
$successCount )->params( $interwiki )->inContentLanguage()->text();
if ( $this->reason ) {
- $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->reason;
+ $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+ . $this->reason;
}
$log->addEntry( 'interwiki', $title, $detail, array(), $this->getUser() );
}
$comment = $detail; // quick
$dbw = wfGetDB( DB_MASTER );
$latest = $title->getLatestRevID();
- $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleID(), $comment, true, $this->getUser() );
+ $nullRevision = Revision::newNullRevision(
+ $dbw,
+ $title->getArticleID(),
+ $comment,
+ true,
+ $this->getUser()
+ );
+
if ( !is_null( $nullRevision ) ) {
$nullRevision->insertOn( $dbw );
$page = WikiPage::factory( $title );
# Update page record
$page->updateRevisionOn( $dbw, $nullRevision );
- wfRunHooks( 'NewRevisionFromEditComplete', array( $page, $nullRevision, $latest, $this->getUser() ) );
+ wfRunHooks(
+ 'NewRevisionFromEditComplete',
+ array( $page, $nullRevision, $latest, $this->getUser() )
+ );
}
} else {
$this->getOutput()->addHTML( "<li>" . Linker::linkKnown( $title ) . " " .
* @ingroup SpecialPage
*/
class SpecialJavaScriptTest extends SpecialPage {
-
/**
- * @var $frameworks Array: Mapping of framework ids and their initilizer methods
+ * @var array Mapping of framework ids and their initilizer methods
* in this class. If a framework is requested but not in this array,
* the 'unknownframework' error is served.
*/
- static $frameworks = array(
+ private static $frameworks = array(
'qunit' => 'initQUnitTesting',
);
* @ingroup SpecialPage Pager
*/
class ImageListPager extends TablePager {
- var $mFieldNames = null;
+ protected $mFieldNames = null;
+
// Subclasses should override buildQueryConds instead of using $mQueryConds variable.
- var $mQueryConds = array();
- var $mUserName = null;
- var $mSearch = '';
- var $mIncluding = false;
- var $mShowAll = false;
- var $mTableName = 'image';
+ protected $mQueryConds = array();
+
+ protected $mUserName = null;
+
+ protected $mSearch = '';
+
+ protected $mIncluding = false;
+
+ protected $mShowAll = false;
+
+ protected $mTableName = 'image';
function __construct( IContextSource $context, $userName = null, $search = '',
$including = false, $showAll = false
function reallyDoQuery( $offset, $limit, $asc ) {
$prevTableName = $this->mTableName;
$this->mTableName = 'image';
- list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $asc );
+ list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+ $this->buildQueryInfo( $offset, $limit, $asc );
$imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
$this->mTableName = $prevTableName;
}
$this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
- list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $asc );
+ list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+ $this->buildQueryInfo( $offset, $limit, $asc );
$oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
$this->mTableName = $prevTableName;
}
}
}
+
+ // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for ( ; $i < $limit && $topRes1; $i++ ) {
+ // @codingStandardsIgnoreEnd
$resultArray[] = $topRes1;
$topRes1 = $res1->next();
}
+
+ // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for ( ; $i < $limit && $topRes2; $i++ ) {
+ // @codingStandardsIgnoreEnd
$resultArray[] = $topRes2;
$topRes2 = $res2->next();
}
* @author Petr Kadlec <mormegil@centrum.cz>
*/
class SpecialListGroupRights extends SpecialPage {
- /**
- * Constructor
- */
function __construct() {
parent::__construct( 'Listgrouprights' );
}
$addgroups = isset( $wgAddGroups[$group] ) ? $wgAddGroups[$group] : array();
$removegroups = isset( $wgRemoveGroups[$group] ) ? $wgRemoveGroups[$group] : array();
$addgroupsSelf = isset( $wgGroupsAddToSelf[$group] ) ? $wgGroupsAddToSelf[$group] : array();
- $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] ) ? $wgGroupsRemoveFromSelf[$group] : array();
+ $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] )
+ ? $wgGroupsRemoveFromSelf[$group]
+ : array();
$id = $group == '*' ? false : Sanitizer::escapeId( $group );
- $out->addHTML( Html::rawElement( 'tr', array( 'id' => $id ),
- "
+ $out->addHTML( Html::rawElement( 'tr', array( 'id' => $id ), "
<td>$grouppage$grouplink</td>
<td>" .
$this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
* @ingroup SpecialPage
*/
class SpecialLockdb extends FormSpecialPage {
- var $reason = '';
+ protected $reason = '';
public function __construct() {
parent::__construct( 'Lockdb', 'siteadmin' );
$type = $opts->getValue( 'type' );
if ( !LogPage::isLogType( $type ) ) {
$opts->setValue( 'type', '' );
- } elseif ( isset( $wgLogRestrictions[$type] ) && !$this->getUser()->isAllowed( $wgLogRestrictions[$type] ) ) {
+ } elseif ( isset( $wgLogRestrictions[$type] )
+ && !$this->getUser()->isAllowed( $wgLogRestrictions[$type] )
+ ) {
throw new PermissionsError( $wgLogRestrictions[$type] );
}
* @ingroup SpecialPage
*/
class SpecialMergeHistory extends SpecialPage {
- var $mAction, $mTarget, $mDest, $mTimestamp, $mTargetID, $mDestID, $mComment;
+ /** @var string */
+ protected $mAction;
- /**
- * @var Title
- */
- var $mTargetObj, $mDestObj;
+ /** @var string */
+ protected $mTarget;
+
+ /** @var string */
+ protected $mDest;
+
+ /** @var string */
+ protected $mTimestamp;
+
+ /** @var int */
+ protected $mTargetID;
+
+ /** @var int */
+ protected $mDestID;
+
+ /** @var string */
+ protected $mComment;
+
+ /** @var bool Was posted? */
+ protected $mMerge;
+
+ /** @var bool Was submitted? */
+ protected $mSubmitted;
+
+ /** @var Title */
+ protected $mTargetObj;
+
+ /** @var Title */
+ protected $mDestObj;
public function __construct() {
parent::__construct( 'MergeHistory', 'mergehistory' );
}
$this->mComment = $request->getText( 'wpComment' );
- $this->mMerge = $request->wasPosted() && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) );
+ $this->mMerge = $request->wasPosted()
+ && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) );
+
// target page
if ( $this->mSubmitted ) {
$this->mTargetObj = Title::newFromURL( $this->mTarget );
<tr>
<td> </td>
<td class="mw-submit">' .
- Xml::submitButton( $this->msg( 'mergehistory-submit' )->text(), array( 'name' => 'merge', 'id' => 'mw-merge-submit' ) ) .
+ Xml::submitButton(
+ $this->msg( 'mergehistory-submit' )->text(),
+ array( 'name' => 'merge', 'id' => 'mw-merge-submit' )
+ ) .
'</td>
</tr>' .
Xml::closeElement( 'table' ) .
$comment = Linker::revComment( $rev );
return Html::rawElement( 'li', array(),
- $this->msg( 'mergehistory-revisionrow' )->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() );
+ $this->msg( 'mergehistory-revisionrow' )
+ ->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() );
}
function merge() {
}
class MergeHistoryPager extends ReverseChronologicalPager {
- public $mForm, $mConds;
+ /** @var IContextSource */
+ public $mForm;
+
+ /** @var array */
+ public $mConds;
function __construct( $form, $conds = array(), $source, $dest ) {
$this->mForm = $form;
* @ingroup SpecialPage
*/
class MovePageForm extends UnlistedSpecialPage {
- /**
- * Objects
- * @var Title
- */
- var $oldTitle, $newTitle;
- // Text input
- var $reason;
+ /** @var Title */
+ protected $oldTitle;
+
+ /** @var Title */
+ protected $newTitle;
+
+
+ /** @var string Text input */
+ protected $reason;
+
// Checks
- var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared;
+
+ /** @var bool */
+ protected $moveTalk;
+
+ /** @var bool */
+ protected $deleteAndMove;
+
+ /** @var bool */
+ protected $moveSubpages;
+
+ /** @var bool */
+ protected $fixRedirects;
+
+ /** @var bool */
+ protected $leaveRedirect;
+
+ /** @var bool */
+ protected $moveOverShared;
private $watch = false;
);
$newLink = Linker::linkKnown( $newSubpage );
- $extraOutput[] = $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped();
+ $extraOutput[] = $this->msg( 'movepage-page-moved' )
+ ->rawParams( $oldLink, $newLink )->escaped();
++$count;
if ( $count >= $wgMaximumMovedPages ) {
- $extraOutput[] = $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped();
+ $extraOutput[] = $this->msg( 'movepage-max-pages' )
+ ->numParams( $wgMaximumMovedPages )->escaped();
break;
}
} else {
$oldLink = Linker::linkKnown( $oldSubpage );
$newLink = Linker::link( $newSubpage );
- $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped();
+ $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
+ ->rawParams( $oldLink, $newLink )->escaped();
}
}
}
/**
* @var ImageGallery
*/
- var $gallery;
+ protected $gallery;
function __construct( IContextSource $context, $par = null ) {
$this->like = $context->getRequest()->getText( 'like' );
* @ingroup SpecialPage
*/
class SpecialNewpages extends IncludableSpecialPage {
- // Stored objects
-
/**
* @var FormOptions
*/
protected $opts;
protected $customFilters;
- // Some internal settings
protected $showNavigation = false;
public function __construct() {
$oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped();
}
- return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
+ return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} "
+ . "{$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
}
/**
* @ingroup SpecialPage
*/
class SpecialProtectedpages extends SpecialPage {
-
protected $IdLevel = 'level';
protected $IdType = 'type';
);
} else {
$username = UserCache::singleton()->getProp( $value, 'name' );
- if ( LogEventsList::userCanBitfield( $row->log_deleted, LogPage::DELETED_USER, $this->getUser() ) ) {
+ if ( LogEventsList::userCanBitfield(
+ $row->log_deleted,
+ LogPage::DELETED_USER,
+ $this->getUser()
+ ) ) {
if ( $username === false ) {
$formatted = htmlspecialchars( $value );
} else {
$this->msg( 'protectedpages-unknown-reason' )->escaped()
);
} else {
- if ( LogEventsList::userCanBitfield( $row->log_deleted, LogPage::DELETED_COMMENT, $this->getUser() ) ) {
+ if ( LogEventsList::userCanBitfield(
+ $row->log_deleted,
+ LogPage::DELETED_COMMENT,
+ $this->getUser()
+ ) ) {
$formatted = Linker::formatComment( $value !== null ? $value : '' );
} else {
$formatted = $this->msg( 'rev-deleted-comment' )->escaped();
// $this->ids = array_map( 'intval', $this->ids );
$this->ids = array_unique( array_filter( $this->ids ) );
- if ( $request->getVal( 'action' ) == 'historysubmit' || $request->getVal( 'action' ) == 'revisiondelete' ) {
+ if ( $request->getVal( 'action' ) == 'historysubmit'
+ || $request->getVal( 'action' ) == 'revisiondelete'
+ ) {
// For show/hide form submission from history page
// Since we are access through index.php?title=XXX&action=historysubmit
// getFullTitle() will contain the target title and not our title
$this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) );
# Allow the list type to adjust the passed target
- $this->targetObj = RevisionDeleter::suggestTarget( $this->typeName, $this->targetObj, $this->ids );
+ $this->targetObj = RevisionDeleter::suggestTarget(
+ $this->typeName,
+ $this->targetObj,
+ $this->ids
+ );
$this->otherReason = $request->getVal( 'wpReason' );
# We need a target page!
/**
* Show a deleted file version requested by the visitor.
- * TODO Mostly copied from Special:Undelete. Refactor.
+ * @todo Mostly copied from Special:Undelete. Refactor.
* @param string $archiveName
*/
protected function tryShowFile( $archiveName ) {
# a user without appropriate permissions can toddle off and
# nab the image, and Squid will serve it
$this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
- $this->getRequest()->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
+ $this->getRequest()->response()->header(
+ 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate'
+ );
$this->getRequest()->response()->header( 'Pragma: no-cache' );
$key = $oimage->getStorageKey();
$numRevisions = 0;
// Live revisions...
$list = $this->getList();
+ // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $list->reset(); $list->current(); $list->next() ) {
+ // @codingStandardsIgnoreEnd
$item = $list->current();
+
if ( !$item->canView() ) {
if ( !$this->submitClicked ) {
throw new PermissionsError( 'suppressrevision' );
}
$userAllowed = false;
}
+
$numRevisions++;
$this->getOutput()->addHTML( $item->getHTML() );
}
Xml::label( $this->msg( 'revdelete-otherreason' )->text(), 'wpReason' ) .
'</td>' .
'<td class="mw-input">' .
- Xml::input( 'wpReason', 60, $this->otherReason, array( 'id' => 'wpReason', 'maxlength' => 100 ) ) .
+ Xml::input(
+ 'wpReason',
+ 60,
+ $this->otherReason,
+ array( 'id' => 'wpReason', 'maxlength' => 100 )
+ ) .
'</td>' .
"</tr><tr>\n" .
'<td></td>' .
*/
protected function addUsageText() {
// Messages: revdelete-text-text, revdelete-text-file, logdelete-text
- $this->getOutput()->wrapWikiMsg( "<strong>$1</strong>\n$2", $this->typeLabels['text'], 'revdelete-text-others' );
+ $this->getOutput()->wrapWikiMsg(
+ "<strong>$1</strong>\n$2", $this->typeLabels['text'],
+ 'revdelete-text-others'
+ );
+
if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
$this->getOutput()->addWikiMsg( 'revdelete-suppress-text' );
}
+
if ( $this->mIsAllowed ) {
$this->getOutput()->addWikiMsg( 'revdelete-confirm' );
}
if ( $list->length() == 1 ) {
$list->reset();
$bitfield = $list->current()->getBits(); // existing field
+
if ( $this->submitClicked ) {
$bitfield = RevisionDeleter::extractBitfield( $this->extractBitParams(), $bitfield );
}
+
foreach ( $this->checks as $item ) {
// Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name,
// revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted
list( $message, $name, $field ) = $item;
- $innerHTML = Xml::checkLabel( $this->msg( $message )->text(), $name, $name, $bitfield & $field );
+ $innerHTML = Xml::checkLabel(
+ $this->msg( $message )->text(),
+ $name,
+ $name,
+ $bitfield & $field
+ );
+
if ( $field == Revision::DELETED_RESTRICTED ) {
$innerHTML = "<b>$innerHTML</b>";
}
+
$line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
$html .= "<tr>$line</tr>\n";
}
} else {
// Otherwise, use tri-state radios
$html .= '<tr>';
- $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
- $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
- $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
+ $html .= '<th class="mw-revdel-checkbox">'
+ . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
+ $html .= '<th class="mw-revdel-checkbox">'
+ . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
+ $html .= '<th class="mw-revdel-checkbox">'
+ . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
$html .= "<th></th></tr>\n";
foreach ( $this->checks as $item ) {
// Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name,
return false;
}
$bitParams = $this->extractBitParams();
- $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown
+ // from dropdown
+ $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' );
$comment = $listReason;
if ( $comment != 'other' && $this->otherReason != '' ) {
// Entry from drop down menu + additional comment
- $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->otherReason;
+ $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+ . $this->otherReason;
} elseif ( $comment == 'other' ) {
$comment = $this->otherReason;
}
# Can the user set this field?
- if ( $bitParams[Revision::DELETED_RESTRICTED] == 1 && !$this->getUser()->isAllowed( 'suppressrevision' ) ) {
+ if ( $bitParams[Revision::DELETED_RESTRICTED] == 1
+ && !$this->getUser()->isAllowed( 'suppressrevision' )
+ ) {
throw new PermissionsError( 'suppressrevision' );
}
# If the save went through, go to success message...
protected function success() {
// Messages: revdelete-success, logdelete-success
$this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
- $this->getOutput()->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeLabels['success'] );
+ $this->getOutput()->wrapWikiMsg(
+ "<span class=\"success\">\n$1\n</span>",
+ $this->typeLabels['success']
+ );
$this->wasSaved = true;
$this->revDelList->reloadFromMaster();
$this->showForm();
// Constant-time signature verification
// http://www.emerose.com/timing-attacks-explained
- // @todo: make a common method for this
+ // @todo Make a common method for this
if ( !is_string( $rSig ) || strlen( $rSig ) !== strlen( $cSig ) ) {
$verified = false;
} else {
$result = 0;
- for ( $i = 0; $i < strlen( $cSig ); $i++ ) {
+ $cSigLength = strlen( $cSig );
+ for ( $i = 0; $i < $cSigLength; $i++ ) {
$result |= ord( $cSig[$i] ) ^ ord( $rSig[$i] );
}
$verified = ( $result == 0 );
$out->addHTML(
Xml::openElement( 'fieldset' ) .
Xml::element( 'legend', null, $this->msg( 'search-external' )->text() ) .
- Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), $this->msg( 'searchdisabled' )->text() ) .
+ Xml::element(
+ 'p',
+ array( 'class' => 'mw-searchdisabled' ),
+ $this->msg( 'searchdisabled' )->text()
+ ) .
$this->msg( 'googlesearch' )->rawParams(
htmlspecialchars( $term ),
'UTF-8',
$stParams
);
- $this->didYouMeanHtml = '<div class="searchdidyoumean">' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
+ $this->didYouMeanHtml = '<div class="searchdidyoumean">'
+ . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
}
if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
// Show the create link ahead
$this->showCreateLink( $title, $num, $titleMatches, $textMatches );
if ( $totalRes > $this->limit || $this->offset ) {
- $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
+ $prevnext = $this->getLanguage()->viewPrevNext(
+ $this->getPageTitle(),
+ $this->offset,
+ $this->limit,
$this->powerSearchOptions() + array( 'search' => $term ),
max( $titleMatchesNum, $textMatchesNum ) < $this->limit
);
} else {
$messageName = 'searchmenu-new-nocreate';
}
- $params = array( $messageName, wfEscapeWikiText( $title->getPrefixedText() ), Message::numParam( $num ) );
+ $params = array(
+ $messageName,
+ wfEscapeWikiText( $title->getPrefixedText() ),
+ Message::numParam( $num )
+ );
wfRunHooks( 'SpecialSearchCreateLink', array( $title, &$params ) );
// Extensions using the hook might still return an empty $messageName
&$score, &$size, &$date, &$related,
&$html
) ) ) {
- $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
+ $html = "<li><div class='mw-search-result-heading'>" .
+ "{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
"<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
"</li>\n";
}
// work out custom project captions
$customCaptions = array();
- $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); // format per line <iwprefix>:<caption>
+ // format per line <iwprefix>:<caption>
+ $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() );
foreach ( $customLines as $line ) {
$parts = explode( ":", $line, 2 );
if ( count( $parts ) == 2 ) { // validate line
}
}
-
- // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
+ // @todo Should support paging in a non-confusing way (not sure how though, maybe via ajax)..
$out .= "</ul></div>\n";
// convert the whole thing to desired language variant
public function __construct() {
parent::__construct();
$this->mDescription = "Build JSON messages files from a PHP messages file";
- $this->addArg( 'phpfile', 'PHP file defining a $messages array', true );
- $this->addArg( 'jsondir', 'Directory to write JSON files to. ' .
- 'Required unless <phpfile> exists and --shim-only is specified', false );
+
+ $this->addArg( 'phpfile', 'PHP file defining a $messages array', false );
+ $this->addArg( 'jsondir', 'Directory to write JSON files to', false );
$this->addOption( 'langcode', 'Language code; only needed for converting core i18n files',
false, true );
+ $this->addOption( 'extension', 'Perform default conversion on an extension',
+ false, true );
$this->addOption( 'shim-only', 'Only create or update the backward-compatibility shim' );
+ $this->addOption( 'supplementary', 'Find supplementary i18n files in subdirs and convert those',
+ false, false );
}
public function execute() {
+ global $IP;
+
$phpfile = $this->getArg( 0 );
$jsondir = $this->getArg( 1 );
+ $extension = $this->getOption( 'extension' );
+ $convertSupplementaryI18nFiles = $this->hasOption( 'supplementary' );
+
+ if ( $extension ) {
+ if ( $phpfile ) {
+ $this->error( "The phpfile is already specified, conflicts with --extension.\n", 1 );
+ }
+ $phpfile = "$IP/extensions/$extension/$extension.i18n.php";
+ }
+
+ if ( !$phpfile ) {
+ $this->error( "I'm here for an argument!\n" );
+ $this->maybeHelp( true );
+ // dies.
+ }
+
+ if ( $convertSupplementaryI18nFiles ) {
+ if ( is_readable( $phpfile ) ) {
+ $this->transformI18nFile( $phpfile, $jsondir );
+ } else {
+ // This is non-fatal because we might want to continue searching for
+ // i18n files in subdirs even if the extension does not include a
+ // primary i18n.php.
+ $this->error( "Warning: no primary i18n file was found." );
+ }
+ $this->output( "Searching for supplementary i18n files...\n" );
+ $dir_iterator = new RecursiveDirectoryIterator( dirname( $phpfile ) );
+ $iterator = new RecursiveIteratorIterator( $dir_iterator, RecursiveIteratorIterator::LEAVES_ONLY );
+ foreach ( $iterator as $path => $fileObject ) {
+ if ( fnmatch( "*.i18n.php", $fileObject->getFilename() ) ) {
+ $this->output( "Converting $path.\n" );
+ $this->transformI18nFile( $path );
+ }
+ }
+ } else {
+ // Just convert the primary i18n file.
+ $this->transformI18nFile( $phpfile, $jsondir );
+ }
+ }
+
+ public function transformI18nFile( $phpfile, $jsondir = null ) {
+ if ( !$jsondir ) {
+ // Assume the json directory should be in the same directory as the
+ // .i18n.php file.
+ $jsondir = dirname( $phpfile ) . "/i18n";
+ }
+ if ( !is_dir( $jsondir ) ) {
+ $this->output( "Creating directory $jsondir.\n" );
+ $success = mkdir( $jsondir );
+ if ( !$success ) {
+ $this->error( "Could not create directory $jsondir\n", 1 );
+ }
+ }
if ( $this->hasOption( 'shim-only' ) ) {
$this->shimOnly( $phpfile, $jsondir );
--- /dev/null
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * @ingroup Maintenance
+ */
+class PageExists extends Maintenance {
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Report whether a specific page exists";
+ $this->addArg( 'title', 'Page title to check whether it exists' );
+ }
+
+ public function execute() {
+ $titleArg = $this->getArg();
+ $title = Title::newFromText( $titleArg );
+ $pageExists = $title && $title->exists();
+
+ $text = '';
+ $code = 0;
+ if ( $pageExists ) {
+ $text = "{$title} exists.";
+ } else {
+ $text = "{$title} doesn't exist.";
+ $code = 1;
+ }
+ $this->output( $text );
+ $this->error( '', $code );
+ }
+}
+
+$maintClass = "PageExists";
+require_once RUN_MAINTENANCE_IF_MAIN;
+
function doWatchInternal( pages, ok, err, addParams ) {
// XXX: Parameter addParams is undocumented because we inherit this
// documentation in the public method...
- var apiPromise = this.post(
+ var apiPromise = this.postWithToken( 'watch',
$.extend(
{
action: 'watch',
titles: $.isArray( pages ) ? pages.join( '|' ) : String( pages ),
- token: mw.user.tokens.get( 'watchToken' ),
uselang: mw.config.get( 'wgUserLanguage' )
},
addParams
border: 1px solid #dddddd;
}
-/* table standards */
-table.rimage {
- float: right;
- width: 1pt;
- position: relative;
- margin-left: 1em;
- margin-bottom: 1em;
- text-align: center;
-}
-
body {
background: white;
color: black;
/* Galleries (see shared.css for more info) */
li.gallerybox {
vertical-align: top;
- display: -moz-inline-box;
display: inline-block;
}
) {
return new ParserOutput( $this->getNativeData() );
}
+
+ /**
+ * @see AbstractContent::fillParserOutput()
+ *
+ * @param Title $title Context title for parsing
+ * @param int|null $revId Revision ID (for {{REVISIONID}})
+ * @param ParserOptions|null $options Parser options
+ * @param bool $generateHtml Whether or not to generate HTML
+ * @param ParserOutput &$output The output object to fill (reference).
+ */
+ protected function fillParserOutput( Title $title, $revId,
+ ParserOptions $options, $generateHtml, ParserOutput &$output ) {
+ $output = new ParserOutput( $this->getNativeData() );
+ }
}
* @group Database
* ^--- needed, because we do need the database to test link updates
*/
-class CssContentTest extends MediaWikiTestCase {
+class CssContentTest extends JavaScriptContentTest {
protected function setUp() {
parent::setUp();
*/
class TextContentTest extends MediaWikiLangTestCase {
protected $context;
+ protected $savedContentGetParserOutput;
protected function setUp() {
+ global $wgHooks;
+
parent::setUp();
// Anon user
$user = new User();
$user->setName( '127.0.0.1' );
+ $this->context = new RequestContext( new FauxRequest() );
+ $this->context->setTitle( Title::newFromText( 'Test' ) );
+ $this->context->setUser( $user );
+
$this->setMwGlobals( array(
'wgUser' => $user,
'wgTextModelsToParse' => array(
'wgAlwaysUseTidy' => false,
) );
- $this->context = new RequestContext( new FauxRequest() );
- $this->context->setTitle( Title::newFromText( 'Test' ) );
- $this->context->setUser( $user );
+ // bypass hooks that force custom rendering
+ if ( isset( $wgHooks['ContentGetParserOutput'] ) ) {
+ $this->savedContentGetParserOutput = $wgHooks['ContentGetParserOutput'];
+ unset( $wgHooks['ContentGetParserOutput'] );
+ }
+ }
+
+ public function teardown() {
+ global $wgHooks;
+
+ // restore hooks that force custom rendering
+ if ( $this->savedContentGetParserOutput !== null ) {
+ $wgHooks['ContentGetParserOutput'] = $this->savedContentGetParserOutput;
+ }
+
+ parent::teardown();
}
public function newContent( $text ) {