return array( 'found' => false );
}
}
-
+
static function formatDate( $parser, $date, $defaultPref = null ) {
$df = DateFormatter::getInstance();
-
+
$date = trim($date);
-
+
$pref = $parser->mOptions->getDateFormat();
-
+
// Specify a different default date format other than the the normal default
- // iff the user has 'default' for their setting
+ // iff the user has 'default' for their setting
if ($pref == 'default' && $defaultPref)
$pref = $defaultPref;
-
+
$date = $df->reformat( $pref, $date, array('match-whole') );
return $date;
}
// default
$gender = User::getDefaultOption( 'gender' );
-
+
// allow prefix.
$title = Title::newFromText( $user );
-
+
if (is_object( $title ) && $title->getNamespace() == NS_USER)
$user = $title->getText();
*/
static function displaytitle( $parser, $text = '' ) {
global $wgRestrictDisplayTitle;
-
+
+ #parse a limited subset of wiki markup (just the single quote items)
+ $text = $parser->doQuotes( $text );
+
+ #remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever
+ $text = preg_replace( '/' . preg_quote( $parser->uniqPrefix(), '/' ) . '.*?'
+ . preg_quote( Parser::MARKER_SUFFIX, '/' ) . '/', '', $text );
+
#list of disallowed tags for DISPLAYTITLE
#these will be escaped even though they are allowed in normal wiki text
- $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li',
- 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rp' );
-
+ $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
+ 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rp', 'br' );
+
#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, null, array(), array(), $bad ) );
$title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
}
static function numberingroup( $parser, $name = '', $raw = null) {
return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), $raw );
- }
+ }
+
-
/**
* Given a title, return the namespace name that would be given by the
* corresponding magic word
if ( is_null($t) )
return '';
return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) );
- }
+ }
static function talkpagename( $parser, $title = null ) {
$t = Title::newFromText( $title );
if ( is_null($t) || !$t->canTalk() )
return '';
return $t->getSubjectPage()->getPrefixedUrl();
}
-
+
/**
* Return the number of pages in the given category, or 0 if it's nonexis-
* tent. This is an expensive parser function and can't be called too many
$rev = Revision::newFromTitle($title);
$id = $rev ? $rev->getPage() : 0;
$length = $cache[$page] = $rev ? $rev->getSize() : 0;
-
+
// Register dependency in templatelinks
$parser->mOutput->addTemplate( $title, $id, $rev ? $rev->getId() : 0 );
- }
+ }
return self::formatRaw( $length, $raw );
}
-
+
/**
* Returns the requested protection level for the current page
*/
* Unicode-safe str_pad with the restriction that $length is forced to be <= 500
*/
static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
- $lengthOfPadding = mb_strlen( $padding );
+ $lengthOfPadding = mb_strlen( $padding );
if ( $lengthOfPadding == 0 ) return $string;
-
+
# The remaining length to add counts down to 0 as padding is added
$length = min( $length, 500 ) - mb_strlen( $string );
- # $finalPadding is just $padding repeated enough times so that
+ # $finalPadding is just $padding repeated enough times so that
# mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length
$finalPadding = '';
while ( $length > 0 ) {
$finalPadding .= mb_substr( $padding, 0, $length );
$length -= $lengthOfPadding;
}
-
+
if ( $direction == STR_PAD_LEFT ) {
return $finalPadding . $string;
} else {