return wfMsg( 'noarticletext' );
} else {
$this->loadContent( $noredir );
-
- if(
- # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
- ( $this->mTitle->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
- preg_match('/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/',$this->mTitle->getText()) &&
- $action=='view'
- )
- {
+ # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
+ if ( $this->mTitle->getNamespace() == NS_USER_TALK &&
+ preg_match('/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/',$this->mTitle->getText()) &&
+ $action=='view'
+ ) {
wfProfileOut( $fname );
- return $this->mContent . "\n" .wfMsg('anontalkpagetext'); }
- else {
+ return $this->mContent . "\n" .wfMsg('anontalkpagetext');
+ } else {
if($action=='edit') {
if($section!='') {
if($section=='new') {
}
return $wgArticleOldContentFields;
}
-
+
# Load the revision (including cur_text) into this object
function loadContent( $noredir = false )
{
# If we got a redirect, follow it (unless we've been told
# not to by either the function parameter or the query
- if ( ( 'no' != $redirect ) && ( false == $noredir ) &&
- ( $wgMwRedir->matchStart( $s->cur_text ) ) ) {
- if ( preg_match( '/\\[\\[([^\\]\\|]+)[\\]\\|]/',
- $s->cur_text, $m ) ) {
- $rt = Title::newFromText( $m[1] );
- if( $rt ) {
- # Gotta hand redirects to special pages differently:
- # Fill the HTTP response "Location" header and ignore
- # the rest of the page we're on.
-
- if ( $rt->getInterwiki() != '' ) {
- $wgOut->redirect( $rt->getFullURL() ) ;
- return;
- }
- if ( $rt->getNamespace() == Namespace::getSpecial() ) {
- $wgOut->redirect( $rt->getFullURL() );
- return;
- }
- $rid = $rt->getArticleID();
- if ( 0 != $rid ) {
- $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
-
- if ( $redirRow !== false ) {
- $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
- $this->mTitle = $rt;
- $s = $redirRow;
- }
+ if ( ( 'no' != $redirect ) && ( false == $noredir ) ) {
+ $rt = Title::newFromRedirect( $s->cur_text );
+ if ( $rt ) {
+ # Gotta hand redirects to special pages differently:
+ # Fill the HTTP response "Location" header and ignore
+ # the rest of the page we're on.
+
+ if ( $rt->getInterwiki() != '' ) {
+ $wgOut->redirect( $rt->getFullURL() ) ;
+ return;
+ }
+ if ( $rt->getNamespace() == NS_SPECIAL ) {
+ $wgOut->redirect( $rt->getFullURL() );
+ return;
+ }
+ $rid = $rt->getArticleID();
+ if ( 0 != $rid ) {
+ $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
+
+ if ( $redirRow !== false ) {
+ $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
+ $this->mTitle = $rt;
+ $s = $redirRow;
}
}
}
# If we got a redirect, follow it (unless we've been told
# not to by either the function parameter or the query
- if ( !$noredir && $wgMwRedir->matchStart( $s->cur_text ) ) {
- if ( preg_match( '/\\[\\[([^\\]\\|]+)[\\]\\|]/',
- $s->cur_text, $m ) ) {
- $rt = Title::newFromText( $m[1] );
- if( $rt && $rt->getInterwiki() == '' && $rt->getNamespace() != Namespace::getSpecial() ) {
- $rid = $rt->getArticleID();
- if ( 0 != $rid ) {
- $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
-
- if ( $redirRow !== false ) {
- $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
- $this->mTitle = $rt;
- $s = $redirRow;
- }
+ if ( !$noredir ) {
+ $rt = Title::newFromRedirect( $s->cur_text );
+ if( $rt && $rt->getInterwiki() == '' && $rt->getNamespace() != NS_SPECIAL ) {
+ $rid = $rt->getArticleID();
+ if ( 0 != $rid ) {
+ $redirRow = $dbr->getArray( 'cur', $this->getCurContentFields(), array( 'cur_id' => $rid ), $fname );
+
+ if ( $redirRow !== false ) {
+ $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
+ $this->mTitle = $rt;
+ $s = $redirRow;
}
}
}
function view()
{
- global $wgUser, $wgOut, $wgLang, $wgRequest;
- global $wgLinkCache, $IP, $wgEnableParserCache;
+ global $wgUser, $wgOut, $wgLang, $wgRequest, $wgMwRedir;
+ global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath;
$fname = 'Article::view';
wfProfileIn( $fname );
# wrap user css and user js in pre and don't parse
# XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found
if (
- $this->mTitle->getNamespace() == Namespace::getUser() &&
+ $this->mTitle->getNamespace() == NS_USER &&
preg_match('/\\/[\\w]+\\.(css|js)$/', $this->mTitle->getDBkey())
) {
$wgOut->addWikiText( wfMsg('clearyourcache'));
$wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" );
+ } else if ( $rt = Title::newFromRedirect( $text ) ) {
+ # Display redirect
+ $sk = $wgUser->getSkin();
+ $imageUrl = "$wgStylePath/images/redirect.png";
+ $targetUrl = $rt->escapeLocalURL();
+ $titleText = htmlspecialchars( $rt->getPrefixedText() );
+ $link = $sk->makeLinkObj( $rt );
+ $wgOut->addHTML( "<img valign=\"center\" src=\"$imageUrl\">" .
+ "<span class=\"redirectText\">$link</span>" );
} else if ( $pcache ) {
+ # Display content and save to parser cache
$wgOut->addWikiText( $text, true, $this );
} else {
+ # Display content, don't attempt to save to parser cache
$wgOut->addWikiText( $text );
}
}
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$sk = $wgUser->getSkin();
- $loglink = $sk->makeKnownLink( $wgLang->getNsText(
- Namespace::getWikipedia() ) .
+ $loglink = $sk->makeKnownLink( $wgLang->getNsText( NS_WIKIPEDIA ) .
':' . wfMsg( 'dellogpage' ), wfMsg( 'deletionlog' ) );
$text = wfMsg( "deletedtext", $deleted, $loglink );
and ($this->getID() != 0)
and ($wgUser->getId() == 0)
and (!$wgUser->getNewtalk())
- and ($this->mTitle->getNamespace() != Namespace::getSpecial())
+ and ($this->mTitle->getNamespace() != NS_SPECIAL )
and ($action == 'view' || empty( $action ))
and (!isset($oldid))
and (!isset($diff))
if ( !$this->mOptions->getUseCategoryMagic() ) return ; # Doesn't use categories at all
- $cns = Namespace::getCategory() ;
- if ( $this->mTitle->getNamespace() != $cns ) return "" ; # This ain't a category page
+ if ( $this->mTitle->getNamespace() != NS_CATEGORY ) return "" ; # This ain't a category page
$r = "<br style=\"clear:both;\"/>\n";
if ( $t != "" ) $t .= ":" ;
$t .= $x->cur_title ;
- if ( $x->cur_namespace == $cns ) {
+ if ( $x->cur_namespace == NS_CATEGORY ) {
array_push ( $children , $sk->makeLink ( $t ) ) ; # Subcategory
} else {
array_push ( $articles , $sk->makeLink ( $t ) ) ; # Page in this category
global $wgLang , $wgUser ;
if ( !$this->mOptions->getUseCategoryMagic() ) return ; # Doesn't use categories at all
- $cns = Namespace::getCategory() ;
- if ( $this->mTitle->getNamespace() != $cns ) return '' ; # This ain't a category page
+ if ( $this->mTitle->getNamespace() != NS_CATEGORY ) return '' ; # This ain't a category page
$r = "<br style=\"clear:both;\"/>\n";
if ( $t != '' ) $t .= ':' ;
$t .= $x->cur_title ;
- if ( $x->cur_namespace == $cns ) {
+ if ( $x->cur_namespace == NS_CATEGORY ) {
$ctitle = str_replace( '_',' ',$x->cur_title );
array_push ( $children, $sk->makeKnownLink ( $t, $ctitle ) ) ; # Subcategory
$sk =& $this->mOptions->getSkin();
$redirect = MagicWord::get ( MAG_REDIRECT ) ;
- $isRedirect = $redirect->matchStart ( strtoupper ( substr ( $s , 0 , 10 ) ) ) ;
$a = explode( '[[', ' ' . $s );
$s = array_shift( $a );
$useLinkPrefixExtension = $wgLang->linkPrefixExtension();
# Special and Media are pseudo-namespaces; no pages actually exist in them
- static $image = FALSE;
- static $special = FALSE;
- static $media = FALSE;
- static $category = FALSE;
- if ( !$image ) { $image = Namespace::getImage(); }
- if ( !$special ) { $special = Namespace::getSpecial(); }
- if ( !$media ) { $media = Namespace::getMedia(); }
- if ( !$category ) { $category = Namespace::getCategory(); }
$nottalk = !Namespace::isTalk( $this->mTitle->getNamespace() );
$s .= (trim($tmp) == '')? '': $tmp;
continue;
}
- if ( $ns == $image ) {
+ if ( $ns == NS_IMAGE ) {
$s .= $prefix . $sk->makeImageLinkObj( $nt, $text ) . $trail;
$wgLinkCache->addImageLinkObj( $nt );
continue;
}
- if ( $ns == $category && !$isRedirect ) {
+ if ( $ns == NS_CATEGORY ) {
$t = $nt->getText() ;
- $nnt = Title::newFromText ( Namespace::getCanonicalName($category).":".$t ) ;
+ $nnt = Title::newFromText ( Namespace::getCanonicalName(NS_CATEGORY).":".$t ) ;
$wgLinkCache->suspend(); # Don't save in links/brokenlinks
$pPLC=$sk->postParseLinkColour();
continue;
}
- if( $ns == $media ) {
+ if( $ns == NS_MEDIA ) {
$s .= $prefix . $sk->makeMediaLinkObj( $nt, $text ) . $trail;
$wgLinkCache->addImageLinkObj( $nt );
continue;
- } elseif( $ns == $special ) {
+ } elseif( $ns == NS_SPECIAL ) {
$s .= $prefix . $sk->makeKnownLinkObj( $nt, $text, '', $trail );
continue;
}
if(isset($wgLocaltimezone)) putenv('TZ='.$oldtzs);
$text = preg_replace( '/~~~~~/', $d, $text );
- $text = preg_replace( '/~~~~/', '[[' . $wgLang->getNsText(
- Namespace::getUser() ) . ":$n|$k]] $d", $text );
- $text = preg_replace( '/~~~/', '[[' . $wgLang->getNsText(
- Namespace::getUser() ) . ":$n|$k]]", $text );
+ $text = preg_replace( '/~~~~/', '[[' . $wgLang->getNsText( NS_USER ) . ":$n|$k]] $d", $text );
+ $text = preg_replace( '/~~~/', '[[' . $wgLang->getNsText( NS_USER ) . ":$n|$k]]", $text );
# Context links: [[|name]] and [[name (context)|]]
#