From 388d95d7b8a59421a680237cd3bbe3250aca6d7d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 21 Feb 2005 12:23:52 +0000 Subject: [PATCH] De-cruftification continues. * Replacing Namespace:: functions with NS_ constants * Replacing make*Link() on strings with make*LinkObj() on Title objects * Using more legible convenience methods on User and Title * Start using a common Linker::commentBlock() to wrap the formatComment() bits in the surrounding formatting --- includes/EditPage.php | 7 +++-- includes/ImagePage.php | 22 +++++++-------- includes/Linker.php | 20 +++++++++++++- includes/LinksUpdate.php | 2 +- includes/Skin.php | 46 ++++++++++++++----------------- includes/SkinTemplate.php | 23 ++++++++-------- includes/SpecialContributions.php | 2 +- includes/SpecialImagelist.php | 24 ++++++++-------- includes/SpecialIpblocklist.php | 2 +- includes/SpecialListusers.php | 4 +-- includes/SpecialMovepage.php | 10 +++---- includes/SpecialNewimages.php | 2 +- includes/SpecialUpload.php | 4 +-- includes/User.php | 20 ++++++++++++++ includes/UserTalkUpdate.php | 2 +- languages/LanguageFi.php | 4 --- skins/CologneBlue.php | 23 +++++++++------- skins/Standard.php | 13 ++++----- 18 files changed, 131 insertions(+), 99 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 9c69f48482..2cd0bdc429 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -283,13 +283,14 @@ class EditPage { $sk = $wgUser->getSkin(); $isConflict = false; // css / js subpages of user pages get a special treatment - $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() )); + $isCssJsSubpage = $wgTitle->isCssJsSubpage(); + if(!$this->mTitle->getArticleID()) { # new article $wgOut->addWikiText(wfmsg('newarticletext')); } - if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) { + if( $this->mTitle->isTalkPage() ) { $wgOut->addWikiText(wfmsg('talkpagetext')); } @@ -758,7 +759,7 @@ END } else { $name = $id; } - $link = '[[' . $wgContLang->getNsText( Namespace::getUser() ) . + $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]"; $wgOut->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) ); diff --git a/includes/ImagePage.php b/includes/ImagePage.php index be571836ed..cec8bd0d5d 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -21,7 +21,7 @@ class ImagePage extends Article { // available in doDelete etc. function view() { - if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + if( $this->mTitle->getNamespace() == NS_IMAGE ) { $this->openShowImage(); } @@ -31,7 +31,7 @@ class ImagePage extends Article { # follow it with the history list and link list for the image # it describes. - if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + if( $this->mTitle->getNamespace() == NS_IMAGE ) { $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); @@ -303,7 +303,7 @@ class ImagePage extends Article { # Image itself is now gone, and database is cleaned. # Now we remove the image description page. - $nt = Title::newFromText( $wgContLang->getNsText( Namespace::getImage() ) . ":" . $image ); + $nt = Title::makeTitleSafe( NS_IMAGE, $image ); $article = new Article( $nt ); $article->doDeleteArticle( $reason ); # ignore errors @@ -314,9 +314,9 @@ class ImagePage extends Article { $wgOut->setRobotpolicy( 'noindex,nofollow' ); $sk = $wgUser->getSkin(); - $loglink = $sk->makeKnownLink( $wgContLang->getNsText( - Namespace::getWikipedia() ) . - ':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) ); + $loglink = $sk->makeKnownLinkObj( + Title::makeTitle( NS_SPECIAL, 'Delete/log' ), + wfMsg( 'deletionlog' ) ); $text = wfMsg( 'deletedtext', $deleted, $loglink ); @@ -481,8 +481,9 @@ class ImageHistoryList { if ( 0 == $user ) { $userlink = $usertext; } else { - $userlink = $this->skin->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . - ':'.$usertext, $usertext ); + $userlink = $this->skin->makeLinkObj( + Title::makeTitle( NS_USER, $usertext ), + $usertext ); } $nbytes = wfMsg( 'nbytes', $size ); $style = $this->skin->getInternalLinkAttributes( $url, $datetime ); @@ -490,10 +491,7 @@ class ImageHistoryList { $s = "
  • ({$dlink}) ({$rlink}) {$datetime}" . " . . {$userlink} ({$nbytes})"; - if ( '' != $description && '*' != $description ) { - $sk=$wgUser->getSkin(); - $s .= $wgContLang->emphasize(' (' . $sk->formatComment($description,$wgTitle) . ')'); - } + $s .= $this->skin->commentBlock( $description, $wgTitle ); $s .= "
  • \n"; return $s; } diff --git a/includes/Linker.php b/includes/Linker.php index b02c88b4e6..7f39d4a46a 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -740,7 +740,7 @@ class Linker { # format regular and media links - all other wiki formatting # is ignored - $medians = $wgContLang->getNsText(Namespace::getMedia()).':'; + $medians = $wgContLang->getNsText( NS_MEDIA ) . ':'; while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) { # Handle link renaming [[foo|text]] will show link as "text" if( "" != $match[3] ) { @@ -769,6 +769,24 @@ class Linker { wfProfileOut( $fname ); return $comment; } + + /** + * Wrap a comment in standard punctuation and formatting if + * it's non-empty, otherwise return empty string. + * + * @param string $comment + * @param Title $title + * @return string + * @access public + */ + function commentBlock( $comment, $title = NULL ) { + if( $comment == '' ) { + return ''; + } else { + $formatted = $this->formatComment( $comment, $title ); + return " ($formatted)"; + } + } /** @todo document */ function tocIndent() { diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 8fcca3db65..c4033400d1 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -128,7 +128,7 @@ class LinksUpdate { # Do the insertion $sql = ''; - $image = Namespace::getImage(); + $image = NS_IMAGE; if ( 0 != count ( $add ) ) { $arr = array(); foreach ($add as $iname => $val ) { diff --git a/includes/Skin.php b/includes/Skin.php index 7bc87883cd..46c2cb90be 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -186,9 +186,11 @@ class Skin extends Linker { function getHeadScripts() { global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs; $r = "\n"; - if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in - $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); - $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript')); + if( $wgAllowUserJs && $wgUser->isLoggedIn() ) { + $userpage = $wgUser->getUserPage(); + $userjs = htmlspecialchars( $this->makeUrl( + $userpage->getPrefixedText().'/'.$this->getSkinName().'.js', + 'action=raw&ctype=text/javascript')); $r .= '\n"; } return $r; @@ -225,12 +227,14 @@ class Skin extends Linker { $action = $wgRequest->getText('action'); $s = "@import \"$wgStylePath/$sheet\";\n"; if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n"; - if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in + if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) { $s .= $wgRequest->getText('wpTextbox1'); } else { - $userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); - $s.= '@import "'.$this->makeUrl($userpage.'/'.$this->getSkinName().'.css', 'action=raw&ctype=text/css').'";'."\n"; + $userpage = $wgUser->getUserPage(); + $s.= '@import "'.$this->makeUrl( + $userpage->getPrefixedText().'/'.$this->getSkinName().'.css', + 'action=raw&ctype=text/css').'";'."\n"; } } $s .= $this->doGetUserStyles(); @@ -321,13 +325,11 @@ class Skin extends Linker { * two functions to make it easier to subclass. */ function beforeContent() { - global $wgUser, $wgOut; - return $this->doBeforeContent(); } function doBeforeContent() { - global $wgUser, $wgOut, $wgTitle, $wgContLang, $wgSiteNotice; + global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice; $fname = 'Skin::doBeforeContent'; wfProfileIn( $fname ); @@ -389,7 +391,7 @@ class Skin extends Linker { function getCategoryLinks () { - global $wgOut, $wgTitle, $wgUser, $wgParser; + global $wgOut, $wgTitle, $wgParser; global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang; if( !$wgUseCategoryMagic ) return '' ; @@ -413,8 +415,6 @@ class Skin extends Linker { # Render the array as a serie of links function walkThrough ($tree) { - global $wgUser; - $sk = $wgUser->getSkin(); $return = ''; foreach($tree as $element => $parent) { if(empty($parent)) { @@ -427,7 +427,7 @@ class Skin extends Linker { # add our current element to the list $eltitle = Title::NewFromText($element); # FIXME : should be makeLink() [AV] - $return .= $sk->makeLink($element, $eltitle->getText()).' > '; + $return .= $this->makeLinkObj( $eltitle, $eltitle->getText() ) . ' > '; } return $return; } @@ -452,9 +452,6 @@ class Skin extends Linker { # This gets called immediately before the tag. # function afterContent() { - global $wgUser, $wgOut, $wgServer; - global $wgTitle, $wgLang; - $printfooter = "
    \n" . $this->printFooter() . "
    \n"; return $printfooter . $this->doAfterContent(); } @@ -487,7 +484,7 @@ class Skin extends Linker { } if ( $wgOut->isArticleRelated() ) { - if ( $wgTitle->getNamespace() == Namespace::getImage() ) { + if ( $wgTitle->getNamespace() == NS_IMAGE ) { $name = $wgTitle->getDBkey(); $image = new Image( $wgTitle->getDBkey() ); if( $image->exists() ) { @@ -516,8 +513,7 @@ class Skin extends Linker { # do not show "You have new messages" text when we are viewing our # own talk page - if(!(strcmp($wgTitle->getText(),$wgUser->getName()) == 0 && - $wgTitle->getNamespace()==Namespace::getTalk(Namespace::getUser()))) { + if( $wgTitle->equals( $wgUser->getTalkPage() ) ) { $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsg('newmessageslink') ); $s.= ' | '. wfMsg( 'newmessages', $tl ) . ''; @@ -627,8 +623,8 @@ class Skin extends Linker { $lo = $wgContLang->specialPage( 'Userlogout' ); $s = ''; - if ( 0 == $wgUser->getID() ) { - if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) { + if ( $wgUser->isAnon() ) { + if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) { $n = $wgIP; $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), @@ -728,7 +724,7 @@ class Skin extends Linker { $s = ''; if ( $wgOut->isArticleRelated() ) { $s .= '' . $this->editThisPage() . ''; - if ( 0 != $wgUser->getID() ) { + if ( $wgUser->isLoggedIn() ) { $s .= $sep . $this->watchThisPage(); } $s .= $sep . $this->talkLink() @@ -736,8 +732,8 @@ class Skin extends Linker { . $sep . $this->whatLinksHere() . $sep . $this->watchPageLinksLink(); - if ( $wgTitle->getNamespace() == Namespace::getUser() - || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) ) + if ( $wgTitle->getNamespace() == NS_USER + || $wgTitle->getNamespace() == NS_USER_TALK ) { $id=User::idFromName($wgTitle->getText()); @@ -1077,7 +1073,7 @@ class Skin extends Linker { global $wgEnableEmail, $wgEnableUserEmail, $wgUser; return $wgEnableEmail && $wgEnableUserEmail && - 0 != $wgUser->getID() && # show only to signed in users + $wgUser->isLoggedIn() && # show only to signed in users 0 != $id; # we can only email to non-anons .. # '' != $id->getEmail() && # who must have an email address stored .. # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index d6fa7137d2..45e30827ec 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -171,11 +171,12 @@ class SkinTemplate extends Skin { wfProfileIn( "$fname-stuff" ); $this->thispage = $this->mTitle->getPrefixedDbKey(); $this->thisurl = $this->mTitle->getPrefixedURL(); - $this->loggedin = $wgUser->getID() != 0; - $this->iscontent = ($this->mTitle->getNamespace() != Namespace::getSpecial() ); + $this->loggedin = $wgUser->isLoggedIn(); + $this->iscontent = ($this->mTitle->getNamespace() != NS_SPECIAL ); $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); - $this->userpage = $wgContLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); + $userPage = $wgUser->getUserPage(); + $this->userpage = $userPage->getPrefixedText(); $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage); $this->usercss = $this->userjs = $this->userjsprev = false; @@ -573,10 +574,10 @@ class SkinTemplate extends Skin { 'href' => $this->mTitle->getLocalUrl( 'action=delete' ) ); } - if ( $wgUser->getID() != 0 ) { + if ( $wgUser->isLoggedIn() ) { if ( $this->mTitle->userCanMove()) { $content_actions['move'] = array( - 'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == Namespace::getSpecial()) ? 'selected' : false, + 'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == NS_SPECIAL) ? 'selected' : false, 'text' => wfMsg('move'), 'href' => $this->makeSpecialUrl('Movepage', 'target='. urlencode( $this->thispage ) ) ); @@ -596,7 +597,7 @@ class SkinTemplate extends Skin { } wfProfileOut( "$fname-live" ); - if ( $wgUser->getID() != 0 and $action != 'submit' ) { + if ( $wgUser->isLoggedIn() and $action != 'submit' ) { if( !$this->mTitle->userIsWatching()) { $content_actions['watch'] = array( 'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false, @@ -861,17 +862,17 @@ class SkinTemplate extends Skin { global $wgUser; $s = "/* generated user stylesheet */\n"; - if($wgUser->getID() != 0) { - if ( 1 == $wgUser->getOption( "underline" ) ) { + if( $wgUser->isLoggedIn() ) { + if ( $wgUser->getOption( "underline" ) ) { $s .= "a { text-decoration: underline; }\n"; } else { $s .= "a { text-decoration: none; }\n"; } } - if ( 1 != $wgUser->getOption( "highlightbroken" ) ) { + if ( !$wgUser->getOption( "highlightbroken" ) ) { $s .= "a.new, #quickbar a.new { color: #CC2200; }\n"; } - if ( 1 == $wgUser->getOption( "justify" ) ) { + if ( $wgUser->getOption( "justify" ) ) { $s .= "#bodyContent { text-align: justify; }\n"; } wfProfileOut( $fname ); @@ -885,7 +886,7 @@ class SkinTemplate extends Skin { $fname = 'SkinTemplate::getUserJs'; wfProfileIn( $fname ); - global $wgUser, $wgStylePath; + global $wgStylePath; $s = '/* generated javascript */'; $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';"; $s .= '/* MediaWiki:'.ucfirst($this->skinname)." */\n"; diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index efb4f0ca96..94aa5f5589 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -58,7 +58,7 @@ function wfSpecialContributions( $par = '' ) { } $talk = $nt->getTalkPage(); if( $talk ) { - $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ')'; + $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ) . ')'; } diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php index cc42ad45cf..ae2fe261d1 100644 --- a/includes/SpecialImagelist.php +++ b/includes/SpecialImagelist.php @@ -67,7 +67,7 @@ function wfSpecialImagelist() { htmlspecialchars( $wpIlMatch ) . "\" /> " . "" ); $nums = array( 50, 100, 250, 500 ); - $here = $wgContLang->specialPage( "Imagelist" ); + $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' ); $fill = ""; $first = true; @@ -75,7 +75,7 @@ function wfSpecialImagelist() { if ( ! $first ) { $fill .= " | "; } $first = false; - $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), + $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); } $text = wfMsg( "showlast", $fill, $byname ); @@ -87,7 +87,7 @@ function wfSpecialImagelist() { if ( ! $first ) { $fill .= " | "; } $first = false; - $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), + $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); } $text = wfMsg( "showlast", $fill, $bysize ); @@ -99,7 +99,7 @@ function wfSpecialImagelist() { if ( ! $first ) { $fill .= " | "; } $first = false; - $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), + $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); } $text = wfMsg( "showlast", $fill, $bydate ); @@ -109,23 +109,23 @@ function wfSpecialImagelist() { while ( $s = $dbr->fetchObject( $res ) ) { $name = $s->img_name; $ut = $s->img_user_text; - if ( 0 == $s->img_user ) { $ul = $ut; } - else { $ul = $sk->makeLink( $wgContLang->getNsText( - Namespace::getUser() ) . ":{$ut}", $ut ); } + if ( 0 == $s->img_user ) { + $ul = $ut; + } else { + $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); + } $ilink = "" . htmlspecialchars( $name ) . ""; $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) ); $l = "(" . - $sk->makeKnownLink( $wgContLang->getNsText( - Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) . + $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ), + wfMsg( "imgdesc" ) ) . ") {$ilink} . . {$nb} . . {$ul} . . " . $wgLang->timeanddate( $s->img_timestamp, true ); - if ( "" != $s->img_description ) { - $l .= ' (' . $sk->formatComment( $s->img_description ) . ')'; - } + $l .= $sk->commentBlock( $s->img_description ); $wgOut->addHTML( "{$l}
    \n" ); } $wgOut->addHTML( "

    " ); diff --git a/includes/SpecialIpblocklist.php b/includes/SpecialIpblocklist.php index c186786339..cdc7f8418d 100644 --- a/includes/SpecialIpblocklist.php +++ b/includes/SpecialIpblocklist.php @@ -144,7 +144,7 @@ function wfAddRow( $block, $tag ) { $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress; $name = User::whoIs( $block->mBy ); - $ulink = $sk->makeKnownLink( $wgContLang->getNsText( Namespace::getUser() ). ":{$name}", $name ); + $ulink = $sk->makeKnownLinkObj( Title::makeTitle( NS_USER, $name ), $name ); $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); if ( $block->mExpiry === "" ) { diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index dcb19e25a2..559ef6ae34 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -104,7 +104,7 @@ class ListUsersPage extends QueryPage { $group = $dbr->tableName( 'group' ); $user_groups = $dbr->tableName( 'user_groups' ); - $userspace = Namespace::getUser(); + $userspace = NS_USER; $sql = "SELECT group_name as type, $userspace AS namespace, user_name AS title, user_name as value " . "FROM $user ". "LEFT JOIN $user_groups ON user_id =ug_user " . @@ -171,7 +171,7 @@ class ListUsersPage extends QueryPage { * constructor */ function wfSpecialListusers() { - global $wgUser, $wgOut, $wgLang, $wgRequest; + global $wgRequest; list( $limit, $offset ) = wfCheckLimits(); diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 140b254c3d..a8e2e76fba 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -17,7 +17,7 @@ function wfSpecialMovepage() { global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove; # check rights. We don't want newbies to move pages to prevents possible attack - if ( 0 == $wgUser->getID() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) { + if ( $wgUser->isAnon() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) { $wgOut->errorpage( "movenologin", "movenologintext" ); return; } @@ -76,7 +76,7 @@ class MovePageForm { } $wgOut->addWikiText( wfMsg( 'movepagetext' ) ); - if ( ! Namespace::isTalk( $ot->getNamespace() ) ) { + if ( !$ot->isTalkPage() ) { $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) ); } @@ -108,7 +108,7 @@ class MovePageForm { " ); - if ( ! Namespace::isTalk( $ot->getNamespace() ) ) { + if ( ! $ot->isTalkPage() ) { $wgOut->addHTML( " @@ -211,7 +211,7 @@ class MovePageForm { } function showSuccess() { - global $wgOut, $wgUser, $wgRequest, $wgRawHtml; + global $wgOut, $wgRequest, $wgRawHtml; $wgOut->setPagetitle( wfMsg( 'movepage' ) ); $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) ); @@ -233,7 +233,7 @@ class MovePageForm { $wgOut->addHTML( "\n

    " . wfMsg( 'talkexists' ) . "

    \n" ); } else { $ot = Title::newFromURL( $oldtitle ); - if ( ! Namespace::isTalk( $ot->getNamespace() ) ) { + if ( ! $ot->isTalkPage() ) { $wgOut->addHTML( "\n

    " . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) . "

    \n" ); } } diff --git a/includes/SpecialNewimages.php b/includes/SpecialNewimages.php index f7383482bf..55b43f6e10 100644 --- a/includes/SpecialNewimages.php +++ b/includes/SpecialNewimages.php @@ -86,7 +86,7 @@ function wfSpecialNewimages() { $nt = Title::newFromText( $name, NS_IMAGE ); $img = Image::newFromTitle( $nt ); - $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut ); + $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); $gallery->add( $img, $ul.'
    '.$wgLang->timeanddate( $s->img_timestamp, true ).'
    ' ); diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 75b12a367f..9aa57b8e5d 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -97,7 +97,7 @@ class UploadForm { } /** Various rights checks */ - if( ( $wgUser->getID() == 0 ) + if( ( $wgUser->isAnon() ) OR $wgUser->isBlocked() ) { $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' ); return; @@ -393,7 +393,7 @@ class UploadForm { $sk = $wgUser->getSkin(); $ilink = $sk->makeMediaLink( $this->mUploadSaveName, Image::wfImageUrl( $this->mUploadSaveName ) ); - $dname = $wgContLang->getNsText( Namespace::getImage() ) . ':'.$this->mUploadSaveName; + $dname = $wgContLang->getNsText( NS_IMAGE ) . ':'.$this->mUploadSaveName; $dlink = $sk->makeKnownLink( $dname, $dname ); $wgOut->addHTML( '

    ' . wfMsg( 'successfulupload' ) . "

    \n" ); diff --git a/includes/User.php b/includes/User.php index bcb89344ba..e5aa81fd3f 100644 --- a/includes/User.php +++ b/includes/User.php @@ -681,6 +681,26 @@ class User { $this->invalidateCache(); } + /** + * A more legible check for non-anonymousness. + * Returns true if the user is not an anonymous visitor. + * + * @return bool + */ + function isLoggedIn() { + return( $this->getID() != 0 ); + } + + /** + * A more legible check for anonymousness. + * Returns true if the user is an anonymous visitor. + * + * @return bool + */ + function isAnon() { + return !$this->isLoggedIn(); + } + /** * Check if a user is sysop * Die with backtrace. Use User:isAllowed() instead. diff --git a/includes/UserTalkUpdate.php b/includes/UserTalkUpdate.php index 85613886d2..385275f787 100644 --- a/includes/UserTalkUpdate.php +++ b/includes/UserTalkUpdate.php @@ -56,7 +56,7 @@ class UserTalkUpdate { $this->mTimestamp = $timestamp; # If namespace isn't User_talk:, do nothing. - if ( $this->mNamespace != Namespace::getTalk(Namespace::getUser() ) ) { + if ( $this->mNamespace != NS_USER_TALK ) { return; } diff --git a/languages/LanguageFi.php b/languages/LanguageFi.php index 9a5508f7b3..117f324c80 100644 --- a/languages/LanguageFi.php +++ b/languages/LanguageFi.php @@ -864,10 +864,6 @@ class LanguageFi extends LanguageUtf8 { return false; } - function specialPage( $name ) { - return $this->getNsText( Namespace::getSpecial() ) . ":" . $name; - } - function getQuickbarSettings() { global $wgQuickbarSettingsFi; return $wgQuickbarSettingsFi; diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index a40dd8fb7a..7cf5b28365 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -232,7 +232,7 @@ class SkinCologneBlue extends Skin { . $sep . $this->whatLinksHere() . $sep . $this->watchPageLinksLink(); - if ( Namespace::getUser() == $tns || Namespace::getTalk(Namespace::getUser()) == $tns ) { + if( $tns == NS_USER || $tns == NS_USER_TALK ) { $id=User::idFromName($wgTitle->getText()); if ($id != 0) { $s .= $sep . $this->userContribsLink(); @@ -247,16 +247,17 @@ class SkinCologneBlue extends Skin { $s .= $this->menuHead( "qbmyoptions" ); if ( 0 != $wgUser->getID() ) { $name = $wgUser->getName(); - $tl = $this->makeKnownLink( $wgContLang->getNsText( - Namespace::getTalk( Namespace::getUser() ) ) . ":{$name}", - wfMsg( "mytalk" ) ); - if ( 0 != $wgUser->getNewtalk() ) { $tl .= " *"; } + $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), + wfMsg( 'mytalk' ) ); + if ( $wgUser->getNewtalk() ) { + $tl .= " *"; + } - $s .= $this->makeKnownLink( $wgContLang->getNsText( - Namespace::getUser() ) . ":{$name}", wfMsg( "mypage" ) ) + $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(), + wfMsg( "mypage" ) ) . $sep . $tl . $sep . $this->specialLink( "watchlist" ) - . $sep . $this->makeKnownLink( $wgContLang->specialPage( "Contributions" ), + . $sep . $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, "Contributions" ), wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) ) . $sep . $this->specialLink( "preferences" ) . $sep . $this->specialLink( "userlogout" ); @@ -269,7 +270,7 @@ class SkinCologneBlue extends Skin { . $sep . $this->specialLink( "imagelist" ) . $sep . $this->specialLink( "statistics" ) . $sep . $this->bugReportsLink(); - if ( 0 != $wgUser->getID() && !$wgDisableUploads ) { + if ( $wgUser->isLoggedIn() && !$wgDisableUploads ) { $s .= $sep . $this->specialLink( "upload" ); } global $wgSiteSupportPage; @@ -278,7 +279,9 @@ class SkinCologneBlue extends Skin { .wfMsg( "sitesupport" ).""; } - $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( "Specialpages" ), wfMsg("moredotdotdot") ); + $s .= $sep . $this->makeKnownLinkObj( + Title::makeTitle( NS_SPECIAL, 'Specialpages' ), + wfMsg( 'moredotdotdot' ) ); $s .= $sep . "\n\n"; return $s; diff --git a/skins/Standard.php b/skins/Standard.php index 1bc379ff5d..820b9f4e04 100644 --- a/skins/Standard.php +++ b/skins/Standard.php @@ -156,7 +156,7 @@ class SkinStandard extends Skin { } - if ($wgUser->getID()) { + if( $wgUser->isLoggedIn() ) { $s.= $this->specialLink( 'watchlist' ) ; $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ), wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) ); @@ -204,7 +204,7 @@ class SkinStandard extends Skin { } $s .= $this->makeLink( $link, $text ); - } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) { + } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) { # we just throw in a "New page" text to tell the user that he's in edit mode, # and to avoid messing with the separator that is prepended to the next item $s .= '' . wfMsg('newpage') . ''; @@ -223,7 +223,7 @@ class SkinStandard extends Skin { article with "Watch this article" checkbox disabled, the article is transparently unwatched. Therefore we do not show the "Watch this page" link in edit mode */ - if ( 0 != $wgUser->getID() && $articleExists) { + if ( $wgUser->isLoggedIn() && $articleExists) { if($action!='edit' && $action != 'submit' ) { $s .= $sep . $this->watchThisPage(); @@ -245,9 +245,8 @@ class SkinStandard extends Skin { $s .= $sep . $this->watchPageLinksLink(); } - if ( Namespace::getUser() == $wgTitle->getNamespace() - || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser()) - ) { + if ( NS_USER == $wgTitle->getNamespace() + || $wgTitle->getNamespace() == NS_USER_TALK ) { $id=User::idFromName($wgTitle->getText()); $ip=User::isIP($wgTitle->getText()); @@ -262,7 +261,7 @@ class SkinStandard extends Skin { $s .= "\n

    "; } - if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) { + if ( $wgUser->isLoggedIn() && ( !$wgDisableUploads || $wgRemoteUploads ) ) { $s .= $this->specialLink( 'upload' ) . $sep; } $s .= $this->specialLink( 'specialpages' ) -- 2.20.1