/**
* Get an instance of this class
*/
- function &singleton() {
+ static function &singleton() {
static $instance;
if ( !isset( $instance ) ) {
$instance = new LinkCache;
*
* @static
*/
- function splitTrail( $trail ) {
+ static function splitTrail( $trail ) {
static $regex = false;
if ( $regex === false ) {
global $wgContLang;
* Factory: creates an object representing an ID
* @static
*/
- function &get( $id ) {
+ static function &get( $id ) {
global $wgMagicWords;
if ( !is_array( $wgMagicWords ) ) {
return $path;
}
- function renderMath( $tex ) {
+ public static function renderMath( $tex ) {
global $wgUser;
$math = new MathRenderer( $tex );
$math->setOutputMode( $wgUser->getOption('math'));
* Check if the give namespace is a talk page
* @return bool
*/
- function isTalk( $index ) {
+ static function isTalk( $index ) {
return ($index > NS_MAIN) // Special namespaces are negative
&& ($index % 2); // Talk namespaces are odd-numbered
}
* the URL differently; as a workaround, just use the output for
* statistical records, not for actual linking/output.
*/
- function replaceUnusualEscapes( $url ) {
+ static function replaceUnusualEscapes( $url ) {
return preg_replace_callback( '/%[0-9A-Fa-f]{2}/',
array( 'Parser', 'replaceUnusualEscapesCallback' ), $url );
}
* @static
* @private
*/
- function replaceUnusualEscapesCallback( $matches ) {
+ private static function replaceUnusualEscapesCallback( $matches ) {
$char = urldecode( $matches[0] );
$ord = ord( $char );
// Is it an unsafe or HTTP reserved character according to RFC 1738?
/**
* Get an instance of this object
*/
- function &singleton() {
+ public static function &singleton() {
static $instance;
if ( !isset( $instance ) ) {
global $parserMemc;
return( $rc->mAttribs['rc_id'] );
}
- # Makes an entry in the database corresponding to page creation
- # Note: the title object must be loaded with the new id using resetArticleID()
- /*static*/ function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = "default",
+ /**
+ * Makes an entry in the database corresponding to page creation
+ * Note: the title object must be loaded with the new id using resetArticleID()
+ * @todo Document parameters and return
+ * @public
+ * @static
+ */
+ public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = "default",
$ip='', $size = 0, $newId = 0 )
{
if ( !$ip ) {
* @static
* @access public
*/
- function newFromId( $id ) {
+ public static function newFromId( $id ) {
return Revision::newFromConds(
array( 'page_id=rev_page',
'rev_id' => intval( $id ) ) );
* @access public
* @static
*/
- function newFromTitle( &$title, $id = 0 ) {
+ public static function newFromTitle( &$title, $id = 0 ) {
if( $id ) {
$matchId = intval( $id );
} else {
* @return Revision
* @access public
*/
- function loadFromPageId( &$db, $pageid, $id = 0 ) {
+ public static function loadFromPageId( &$db, $pageid, $id = 0 ) {
$conds=array('page_id=rev_page','rev_page'=>intval( $pageid ), 'page_id'=>intval( $pageid ));
if( $id ) {
$conds['rev_id']=intval($id);
* @static
* @access private
*/
- function newFromConds( $conditions ) {
+ private static function newFromConds( $conditions ) {
$db =& wfGetDB( DB_SLAVE );
$row = Revision::loadFromConds( $db, $conditions );
if( is_null( $row ) ) {
* @static
* @access private
*/
- function loadFromConds( &$db, $conditions ) {
+ private static function loadFromConds( &$db, $conditions ) {
$res = Revision::fetchFromConds( $db, $conditions );
if( $res ) {
$row = $res->fetchObject();
* @static
* @access public
*/
- function fetchRevision( &$title ) {
+ public static function fetchRevision( &$title ) {
return Revision::fetchFromConds(
wfGetDB( DB_SLAVE ),
array( 'rev_id=page_latest',
* @static
* @access private
*/
- function fetchFromConds( &$db, $conditions ) {
+ private static function fetchFromConds( &$db, $conditions ) {
$res = $db->select(
array( 'page', 'revision' ),
array( 'page_namespace',
* @param array $args for the processing callback
* @return string
*/
- function removeHTMLtags( $text, $processCallback = null, $args = array() ) {
+ static function removeHTMLtags( $text, $processCallback = null, $args = array() ) {
global $wgUseTidy, $wgUserHtml;
$fname = 'Parser::removeHTMLtags';
wfProfileIn( $fname );
* @param string $text
* @return string
*/
- function removeHTMLcomments( $text ) {
+ static function removeHTMLcomments( $text ) {
$fname='Parser::removeHTMLcomments';
wfProfileIn( $fname );
while (($start = strpos($text, '<!--')) !== false) {
* @todo Check for legal values where the DTD limits things.
* @todo Check for unique id attribute :P
*/
- function validateTagAttributes( $attribs, $element ) {
+ static function validateTagAttributes( $attribs, $element ) {
$whitelist = array_flip( Sanitizer::attributeWhitelist( $element ) );
$out = array();
foreach( $attribs as $attribute => $value ) {
* @param string $element
* @return string
*/
- function fixTagAttributes( $text, $element ) {
+ static function fixTagAttributes( $text, $element ) {
if( trim( $text ) == '' ) {
return '';
}
* @param $text
* @return HTML-encoded text fragment
*/
- function encodeAttribute( $text ) {
+ static function encodeAttribute( $text ) {
$encValue = htmlspecialchars( $text );
// Whitespace is normalized during attribute decoding,
* @param $text
* @return HTML-encoded text fragment
*/
- function safeEncodeAttribute( $text ) {
+ static function safeEncodeAttribute( $text ) {
$encValue = Sanitizer::encodeAttribute( $text );
# Templates and links may be expanded in later parsing,
* @param string $id
* @return string
*/
- function escapeId( $id ) {
+ static function escapeId( $id ) {
static $replace = array(
'%3A' => ':',
'%' => '.'
* @return string
* @private
*/
- function armorLinksCallback( $matches ) {
+ private static function armorLinksCallback( $matches ) {
return str_replace( ':', ':', $matches[1] );
}
* @param string
* @return array
*/
- function decodeTagAttributes( $text ) {
+ static function decodeTagAttributes( $text ) {
$attribs = array();
if( trim( $text ) == '' ) {
* @return string
* @private
*/
- function getTagAttributeCallback( $set ) {
+ private static function getTagAttributeCallback( $set ) {
if( isset( $set[6] ) ) {
# Illegal #XXXXXX color with no quotes.
return $set[6];
* @return string
* @private
*/
- function normalizeAttributeValue( $text ) {
+ private static function normalizeAttributeValue( $text ) {
return str_replace( '"', '"',
preg_replace(
'/\r\n|[\x20\x0d\x0a\x09]/',
* @return string
* @private
*/
- function normalizeCharReferences( $text ) {
+ static function normalizeCharReferences( $text ) {
return preg_replace_callback(
MW_CHAR_REFS_REGEX,
array( 'Sanitizer', 'normalizeCharReferencesCallback' ),
* @param string $matches
* @return string
*/
- function normalizeCharReferencesCallback( $matches ) {
+ static function normalizeCharReferencesCallback( $matches ) {
$ret = null;
if( $matches[1] != '' ) {
$ret = Sanitizer::normalizeEntity( $matches[1] );
*
* @param string $name
* @return string
+ * @static
*/
- function normalizeEntity( $name ) {
+ static function normalizeEntity( $name ) {
global $wgHtmlEntities;
if( isset( $wgHtmlEntities[$name] ) ) {
return "&$name;";
}
}
- function decCharReference( $codepoint ) {
+ static function decCharReference( $codepoint ) {
$point = intval( $codepoint );
if( Sanitizer::validateCodepoint( $point ) ) {
return sprintf( '&#%d;', $point );
}
}
- function hexCharReference( $codepoint ) {
+ static function hexCharReference( $codepoint ) {
$point = hexdec( $codepoint );
if( Sanitizer::validateCodepoint( $point ) ) {
return sprintf( '&#x%x;', $point );
* @param int $codepoint
* @return bool
*/
- function validateCodepoint( $codepoint ) {
+ private static function validateCodepoint( $codepoint ) {
return ($codepoint == 0x09)
|| ($codepoint == 0x0a)
|| ($codepoint == 0x0d)
* @return string
* @private
*/
- function decodeChar( $codepoint ) {
+ static function decodeChar( $codepoint ) {
if( Sanitizer::validateCodepoint( $codepoint ) ) {
return codepointToUtf8( $codepoint );
} else {
* @param string $name
* @return string
*/
- function decodeEntity( $name ) {
+ static function decodeEntity( $name ) {
global $wgHtmlEntities;
if( isset( $wgHtmlEntities[$name] ) ) {
return codepointToUtf8( $wgHtmlEntities[$name] );
* @param string $element
* @return array
*/
- function attributeWhitelist( $element ) {
+ static function attributeWhitelist( $element ) {
static $list;
if( !isset( $list ) ) {
$list = Sanitizer::setupAttributeWhitelist();
}
/**
+ * @todo Document it a bit
* @return array
*/
- function setupAttributeWhitelist() {
+ static function setupAttributeWhitelist() {
$common = array( 'id', 'class', 'lang', 'dir', 'title', 'style' );
$block = array_merge( $common, array( 'align' ) );
$tablealign = array( 'align', 'char', 'charoff', 'valign' );
* @param string $text HTML fragment
* @return string
*/
- function stripAllTags( $text ) {
+ static function stripAllTags( $text ) {
# Actual <tags>
$text = preg_replace( '/ < .*? > /x', '', $text );
* @return string
* @static
*/
- function hackDocType() {
+ static function hackDocType() {
global $wgHtmlEntities;
$out = "<!DOCTYPE html [\n";
foreach( $wgHtmlEntities as $entity => $codepoint ) {
* @return array of strings
* @static
*/
- function &getSkinNames() {
+ static function &getSkinNames() {
global $wgValidSkinNames;
static $skinsInitialised = false;
if ( !$skinsInitialised ) {
* @return string
* @static
*/
- function normalizeKey( $key ) {
+ static function normalizeKey( $key ) {
global $wgDefaultSkin;
$skinNames = Skin::getSkinNames();
* @return Skin
* @static
*/
- function &newFromKey( $key ) {
+ static function &newFromKey( $key ) {
global $wgStyleDirectory;
$key = Skin::normalizeKey( $key );
* @param $title a title object
* @param $including output is being captured for use in {{special:whatever}}
*/
- function executePath( &$title, $including = false ) {
+ static function executePath( &$title, $including = false ) {
global $wgOut, $wgTitle;
$fname = 'SpecialPage::executePath';
wfProfileIn( $fname );
* @static
* @access public
*/
- function makeTitleSafe( $ns, $title ) {
+ public static function makeTitleSafe( $ns, $title ) {
$t = new Title();
$t->mDbkeyform = Title::makeName( $ns, $title );
if( $t->secureAndSplit() ) {
* @return Title the new object
* @access public
*/
- function newMainPage() {
+ public static function newMainPage() {
return Title::newFromText( wfMsgForContent( 'mainpage' ) );
}
* @static
* @access public
*/
- function newFromRedirect( $text ) {
+ public static function newFromRedirect( $text ) {
$mwRedir = MagicWord::get( MAG_REDIRECT );
$rt = NULL;
if ( $mwRedir->matchStart( $text ) ) {
* @static
* @access public
*/
- function legalChars() {
+ public static function legalChars() {
global $wgLegalTitleChars;
return $wgLegalTitleChars;
}
* @param string $title the DB key form the title
* @return string the prefixed form of the title
*/
- /* static */ function makeName( $ns, $title ) {
+ public static function makeName( $ns, $title ) {
global $wgContLang;
$n = $wgContLang->getNsText( $ns );
}\r
\r
// Shortcuts\r
- function openElement( $element, $attribs = null ) { return self::element( $element, $attribs, null ); }\r
- function closeElement( $element ) { return "</$element>"; }\r
+ public static function openElement( $element, $attribs = null ) { return self::element( $element, $attribs, null ); }\r
+ public static function closeElement( $element ) { return "</$element>"; }\r
\r
/**\r
* Create a namespace selector\r
* @param string $string\r
* @return string\r
*/\r
- function escapeJsString( $string ) {\r
+ public static function escapeJsString( $string ) {\r
// See ECMA 262 section 7.8.4 for string literal format\r
$pairs = array(\r
"\\" => "\\\\",\r