$this->mDefaultStripList = $this->mStripList = array();
$this->mUrlProtocols = wfUrlProtocols();
$this->mExtLinkBracketedRegex = '/\[(\b(' . wfUrlProtocols() . ')'.
- '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x0a\\x0d]*?)\]/S';
+ '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S';
$this->mVarCache = array();
if ( isset( $conf['preprocessorClass'] ) ) {
$this->mPreprocessorClass = $conf['preprocessorClass'];
* to internalParse() which does all the real work.
*/
- global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion;
+ global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
$fname = __METHOD__.'-' . wfGetCaller();
wfProfileIn( __METHOD__ );
wfProfileIn( $fname );
/**
* The page doesn't get language converted if
* a) It's disabled
- * b) Titles aren't converted
- * c) Content isn't converted and this is not a talk page
- * d) It's a conversion table
+ * b) Content isn't converted
+ * c) It's a conversion table
*/
if ( !( $wgDisableLangConversion
- || isset( $this->mDoubleUnderscores['notitleconvert'] )
- || ( isset( $this->mDoubleUnderscores['nocontentconvert'] ) && !$this->mTitle->isTalkPage() )
+ || isset( $this->mDoubleUnderscores['nocontentconvert'] )
|| $this->mTitle->isConversionTable() ) ) {
# The position of the convert() call should not be changed. it
$text = $wgContLang->convert( $text );
}
- # A title may have been set in a conversion rule.
- # Note that if a user tries to set a title in a conversion
- # rule but content conversion was not done, then the parser
- # won't pick it up. This is probably expected behavior.
- if ( $wgContLang->getConvRuleTitle() ) {
- $this->mOutput->setTitleText( $wgContLang->getConvRuleTitle() );
+ /**
+ * A page get its title converted except:
+ * a) Language conversion is globally disabled
+ * b) Title convert is globally disabled
+ * c) The page is a redirect page
+ * d) User request with a "linkconvert" set to "no"
+ * e) A "nocontentconvert" magic word has been set
+ * f) A "notitleconvert" magic word has been set
+ * g) User sets "noconvertlink" in his/her preference
+ *
+ * Note that if a user tries to set a title in a conversion
+ * rule but content conversion was not done, then the parser
+ * won't pick it up. This is probably expected behavior.
+ */
+ if ( !( $wgDisableLangConversion
+ || $wgDisableTitleConversion
+ || isset( $this->mDoubleUnderscores['nocontentconvert'] )
+ || isset( $this->mDoubleUnderscores['notitleconvert'] )
+ || $this->mOutput->getDisplayTitle() !== false ) )
+ {
+ $convruletitle = $wgContLang->getConvRuleTitle();
+ if ( $convruletitle ) {
+ $this->mOutput->setTitleText( $convruletitle );
+ } else {
+ $titleText = $wgContLang->convertTitle( $title );
+ $this->mOutput->setTitleText( $titleText );
+ }
}
$text = $this->mStripState->unstripNoWiki( $text );
/**
* Process the wikitext for the ?preload= feature. (bug 5210)
*
- * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
+ * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
* comments, templates, arguments, tags hooks and parser functions are untouched.
*/
public function getPreloadText( $text, $title, $options ) {
$this->clearState();
$this->setOutputType( self::OT_PLAIN );
$this->mOptions = $options;
- $this->setTitle( $title );
+ $this->setTitle( $title );
$flags = PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES;
$dom = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION );
$flag = 0;
} else {
$flag = Parser::PTD_FOR_INCLUSION;
+ }
$dom = $this->preprocessToDom( $text, $flag );
$text = $frame->expand( $dom );
- }
} else {
# if $frame is not provided, then use old-style replaceVariables
$text = $this->replaceVariables( $text );
}
# Count the number of occurrences of bold and italics mark-ups.
# We are not counting sequences of five apostrophes.
- if ( strlen( $arr[$i] ) == 2 ) {
+ if ( strlen( $arr[$i] ) == 2 ) {
$numitalics++;
- } elseif ( strlen( $arr[$i] ) == 3 ) {
+ } elseif ( strlen( $arr[$i] ) == 3 ) {
$numbold++;
- } elseif ( strlen( $arr[$i] ) == 5 ) {
- $numitalics++;
+ } elseif ( strlen( $arr[$i] ) == 5 ) {
+ $numitalics++;
$numbold++;
}
}
$firstspace = $i;
}
} elseif ( $x2 === ' ') {
- if ( $firstsingleletterword == -1 ) {
+ if ( $firstsingleletterword == -1 ) {
$firstsingleletterword = $i;
}
} else {
# [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,
# the real problem is with the $e1 regex
# See bug 1300.
- #
+ #
# Still some problems for cases where the ] is meant to be outside punctuation,
# and no image is in sight. See bug 2095.
- #
+ #
if ( $text !== '' &&
substr( $m[3], 0, 1 ) === ']' &&
strpos( $text, '[' ) !== false
wfProfileIn( __METHOD__."-always_known" );
# Some titles, such as valid special pages or files in foreign repos, should
# be shown as bluelinks even though they're not included in the page table
- #
+ #
# FIXME: isAlwaysKnown() can be expensive for file links; we should really do
# batch file existence checks for NS_FILE and NS_MEDIA
if ( $iw == '' && $nt->isAlwaysKnown() ) {
/**
* getCommon() returns the length of the longest common substring
* of both arguments, starting at the beginning of both.
- * @private
- */
+ * @private
+ */
function getCommon( $st1, $st2 ) {
$fl = strlen( $st1 );
$shorter = strlen( $st2 );
- if ( $fl < $shorter ) {
- $shorter = $fl;
+ if ( $fl < $shorter ) {
+ $shorter = $fl;
}
for ( $i = 0; $i < $shorter; ++$i ) {
- if ( $st1{$i} != $st2{$i} ) {
- break;
+ if ( $st1{$i} != $st2{$i} ) {
+ break;
}
}
return $i;
/**
* These next three functions open, continue, and close the list
* element appropriate to the prefix character passed into them.
- * @private
+ * @private
*/
function openList( $char ) {
$result = $this->closeParagraph();
- if ( '*' === $char ) {
- $result .= '<ul><li>';
- } elseif ( '#' === $char ) {
- $result .= '<ol><li>';
- } elseif ( ':' === $char ) {
- $result .= '<dl><dd>';
+ if ( '*' === $char ) {
+ $result .= '<ul><li>';
+ } elseif ( '#' === $char ) {
+ $result .= '<ol><li>';
+ } elseif ( ':' === $char ) {
+ $result .= '<dl><dd>';
} elseif ( ';' === $char ) {
$result .= '<dl><dt>';
$this->mDTopen = true;
- } else {
- $result = '<!-- ERR 1 -->';
+ } else {
+ $result = '<!-- ERR 1 -->';
}
return $result;
* @private
*/
function nextItem( $char ) {
- if ( '*' === $char || '#' === $char ) {
- return '</li><li>';
+ if ( '*' === $char || '#' === $char ) {
+ return '</li><li>';
} elseif ( ':' === $char || ';' === $char ) {
$close = '</dd>';
- if ( $this->mDTopen ) {
- $close = '</dt>';
+ if ( $this->mDTopen ) {
+ $close = '</dt>';
}
if ( ';' === $char ) {
$this->mDTopen = true;
* @private
*/
function closeList( $char ) {
- if ( '*' === $char ) {
- $text = '</li></ul>';
- } elseif ( '#' === $char ) {
- $text = '</li></ol>';
+ if ( '*' === $char ) {
+ $text = '</li></ul>';
+ } elseif ( '#' === $char ) {
+ $text = '</li></ol>';
} elseif ( ':' === $char ) {
if ( $this->mDTopen ) {
$this->mDTopen = false;
} else {
$text = '</dd></dl>';
}
- } else {
- return '<!-- ERR 3 -->';
+ } else {
+ return '<!-- ERR 3 -->';
}
return $text."\n";
}
# Parsing through the text line by line. The main thing
# happening here is handling of block-level elements p, pre,
# and making lists from lines starting with * # : etc.
- #
+ #
$textLines = StringUtils::explode( "\n", $text );
$lastPrefix = $output = '';
# *after* a revision ID has been assigned. This is for null edits.
$this->mOutput->setFlag( 'vary-revision' );
wfDebug( __METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n" );
+ $value = substr( $this->getRevisionTimestamp(), 4, 2 );
+ break;
+ case 'revisionmonth1':
+ # Let the edit saving system know we should parse the page
+ # *after* a revision ID has been assigned. This is for null edits.
+ $this->mOutput->setFlag( 'vary-revision' );
+ wfDebug( __METHOD__ . ": {{REVISIONMONTH1}} used, setting vary-revision...\n" );
$value = intval( substr( $this->getRevisionTimestamp(), 4, 2 ) );
break;
case 'revisionyear':
}
/**
- * initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
+ * initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
*
* @private
*/
* Will warn at most once the user per limitation type
*
* @param string $limitationType, should be one of:
- * 'expensive-parserfunction' (corresponding messages:
- * 'expensive-parserfunction-warning',
+ * 'expensive-parserfunction' (corresponding messages:
+ * 'expensive-parserfunction-warning',
* 'expensive-parserfunction-category')
- * 'post-expand-template-argument' (corresponding messages:
- * 'post-expand-template-argument-warning',
+ * 'post-expand-template-argument' (corresponding messages:
+ * 'post-expand-template-argument-warning',
* 'post-expand-template-argument-category')
- * 'post-expand-template-inclusion' (corresponding messages:
- * 'post-expand-template-inclusion-warning',
+ * 'post-expand-template-inclusion' (corresponding messages:
+ * 'post-expand-template-inclusion-warning',
* 'post-expand-template-inclusion-category')
* @params int $current, $max When an explicit limit has been
* exceeded, provide the values (optional)
$limit = $this->mOptions->getMaxTemplateDepth();
if ( $frame->depth >= $limit ) {
$found = true;
- $text = '<span class="error">'
- . wfMsgForContent( 'parser-template-recursion-depth-warning', $limit )
+ $text = '<span class="error">'
+ . wfMsgForContent( 'parser-template-recursion-depth-warning', $limit )
. '</span>';
}
}
if ( !$found && $title ) {
wfProfileIn( __METHOD__ . '-loadtpl' );
if ( !$title->isExternal() ) {
- if ( $title->getNamespace() == NS_SPECIAL
- && $this->mOptions->getAllowSpecialInclusion()
- && $this->ot['html'] )
+ if ( $title->getNamespace() == NS_SPECIAL
+ && $this->mOptions->getAllowSpecialInclusion()
+ && $this->ot['html'] )
{
$text = SpecialPage::capturePath( $title );
if ( is_string( $text ) ) {
# Escape nowiki-style return values
$text = wfEscapeWikiText( $text );
} elseif ( is_string( $text )
- && !$piece['lineStart']
+ && !$piece['lineStart']
&& preg_match( '/^(?:{\\||:|;|#|\*)/', $text ) )
{
# Bug 529: if the template begins with a table or block-level
if ( is_string( $text ) && !$this->incrementIncludeSize( 'post-expand', strlen( $text ) ) ) {
# Error, oversize inclusion
- $text = "[[$originalTitle]]" .
- $this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
+ if ( $titleText !== false ) {
+ # Make a working, properly escaped link if possible (bug 23588)
+ $text = "[[:$titleText]]";
+ } else {
+ # This will probably not be a working link, but at least it may
+ # provide some hint of where the problem is
+ preg_replace( '/^:/', '', $originalTitle );
+ $text = "[[:$originalTitle]]";
+ }
+ $text .= $this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
$this->limitationWarn( 'post-expand-template-inclusion' );
}
$this->addTrackingCategory( 'hidden-category-category' );
}
# (bug 8068) Allow control over whether robots index a page.
- #
+ #
# FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This
# is not desirable, the last one on the page should win.
if ( isset( $this->mDoubleUnderscores['noindex'] ) && $this->mTitle->canUseNoindex() ) {
if ( $wgHtml5 && $wgExperimentalHtmlIds ) {
# For reverse compatibility, provide an id that's
# HTML4-compatible, like we used to.
- #
+ #
# It may be worth noting, academically, that it's possible for
# the legacy anchor to conflict with a non-legacy headline
# anchor on the page. In this case likely the "correct" thing
$ts = date( 'YmdHis', $unixts );
$tzMsg = date( 'T', $unixts ); # might vary on DST changeover!
- # Allow translation of timezones trough wiki. date() can return
+ # Allow translation of timezones through wiki. date() can return
# whatever crap the system uses, localised or not, so we cannot
# ship premade translations.
$key = 'timezone-' . strtolower( trim( $tzMsg ) );
# came to also set the caption, ordinary text after the image -- which
# makes no sense, because that just repeats the text multiple times in
# screen readers. It *also* came to set the title attribute.
- #
+ #
# Now that we have an alt attribute, we should not set the alt text to
# equal the caption: that's worse than useless, it just repeats the
# text. This is the framed/thumbnail case. If there's no caption, we
# use the unnamed parameter for alt text as well, just for the time be-
# ing, if the unnamed param is set and the alt param is not.
- #
+ #
# For the future, we need to figure out if we want to tweak this more,
# e.g., introducing a title= parameter for the title; ignoring the un-
# named parameter entirely for images without a caption; adding an ex-
/**#@+
* Accessor
*/
- function getTags() {
- return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) );
+ function getTags() {
+ return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) );
}
/**#@-*/
# The cryptic '' timezone parameter tells to use the site-default
# timezone offset instead of the user settings.
- #
+ #
# Since this value will be saved into the parser cache, served
# to other users, and potentially even used inside links and such,
# it needs to be consistent for all visitors.
if ( $this->mDefaultSort !== false ) {
return $this->mDefaultSort;
} elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ||
- !$wgCategoryPrefixedDefaultSortkey )
+ !$wgCategoryPrefixedDefaultSortkey )
{
return $this->mTitle->getText();
} else {
# data in an array.
$stripState = new StripState;
$pos = 0;
- while ( ( $start_pos = strpos( $text, $this->mUniqPrefix, $pos ) )
- && ( $end_pos = strpos( $text, self::MARKER_SUFFIX, $pos ) ) )
+ while ( ( $start_pos = strpos( $text, $this->mUniqPrefix, $pos ) )
+ && ( $end_pos = strpos( $text, self::MARKER_SUFFIX, $pos ) ) )
{
$end_pos += strlen( self::MARKER_SUFFIX );
$marker = substr( $text, $start_pos, $end_pos-$start_pos );