From: Gabriel Wicke Date: Thu, 13 May 2004 19:44:13 +0000 (+0000) Subject: * New functions makeUrlDetails, makeTalkUrlDetails and so on in Skin.php that return... X-Git-Tag: 1.3.0beta1~73 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=dc99a385b6a4be37907b53b4a53e7d549a9f7872;p=lhc%2Fweb%2Fwiklou.git * New functions makeUrlDetails, makeTalkUrlDetails and so on in Skin.php that return an array with keys 'href' (url) and 'exists' (boolean) * User page link and User talk page link in red if pages don't exist --- diff --git a/includes/Skin.php b/includes/Skin.php index 7b53b6ee3e..a7eb604f3e 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1658,6 +1658,42 @@ class Skin { $this->checkTitle(&$title, &$name); return $title->getLocalURL( $urlaction ); } + + /* these return an array with the 'href' and boolean 'exists' */ + /*static*/ function makeUrlDetails ( $name, $urlaction='' ) { + $title = Title::newFromText( $name ); + $this->checkTitle(&$title, &$name); + return array( + 'href' => $title->getLocalURL( $urlaction ), + 'exists' => $title->getArticleID() != 0?true:false + ); + } + /*static*/ function makeTalkUrlDetails ( $name, $urlaction='' ) { + $title = Title::newFromText( $name ); + $title = $title->getTalkPage(); + $this->checkTitle(&$title, &$name); + return array( + 'href' => $title->getLocalURL( $urlaction ), + 'exists' => $title->getArticleID() != 0?true:false + ); + } + /*static*/ function makeArticleUrlDetails ( $name, $urlaction='' ) { + $title = Title::newFromText( $name ); + $title= $title->getSubjectPage(); + $this->checkTitle(&$title, &$name); + return array( + 'href' => $title->getLocalURL( $urlaction ), + 'exists' => $title->getArticleID() != 0?true:false + ); + } + /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) { + $title = Title::newFromText( wfMsg($name) ); + $this->checkTitle(&$title, &$name); + return array( + 'href' => $title->getLocalURL( $urlaction ), + 'exists' => $title->getArticleID() != 0?true:false + ); + } # make sure we have some title to operate on, mind the '&' /*static*/ function &checkTitle ( $title, $name ) { diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index fa0dcbfa5e..4e9d8b2338 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -80,7 +80,7 @@ $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); $this->userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName(); - $this->userpageurl = $this->makeUrl($this->userpage); + $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage); $this->usercss = $this->userjs = $this->userjsprev = false; if( $this->loggedin ) { $this->setupUserCssJs(); } @@ -131,7 +131,7 @@ $tpl->set( "langname", $wgLang->getLanguageName( $wgLanguageCode ) ); $tpl->setRef( "username", &$this->username ); $tpl->setRef( "userpage", &$this->userpage); - $tpl->setRef( "userpageurl", &$this->userpageurl); + $tpl->setRef( "userpageurl", &$this->userpageUrlDetails['href']); $tpl->setRef( "usercss", &$this->usercss); $tpl->setRef( "userjs", &$this->userjs); $tpl->setRef( "userjsprev", &$this->userjsprev); @@ -217,13 +217,16 @@ if ($this->loggedin) { $personal_urls['userpage'] = array( 'text' => $this->username, - 'href' => &$this->userpageurl, + 'href' => &$this->userpageUrlDetails['href'], + 'class' => $this->userpageUrlDetails['exists']?false:'new', 'ttip' => wfMsg('tooltip-userpage'), 'akey' => wfMsg('accesskey-userpage') ); + $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage); $personal_urls['mytalk'] = array( 'text' => wfMsg('mytalk'), - 'href' => $this->makeTalkUrl($this->userpage), + 'href' => &$usertalkUrlDetails['href'], + 'class' => $usertalkUrlDetails['exists']?false:'new', 'ttip' => wfMsg('tooltip-mytalk'), 'akey' => wfMsg('accesskey-mytalk') ); @@ -255,13 +258,16 @@ if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) { $personal_urls['anonuserpage'] = array( 'text' => $this->username, - 'href' => $this->makeUrl($this->userpage), + 'href' => &$this->userpageUrlDetails['href'], + 'class' => $this->userpageUrlDetails['exists']?false:'new', 'ttip' => wfMsg('tooltip-anonuserpage'), 'akey' => wfMsg('accesskey-anonuserpage') ); + $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage); $personal_urls['anontalk'] = array( 'text' => wfMsg('anontalk'), - 'href' => $this->makeTalkUrl($this->userpage), + 'href' => &$this->usertalkUrlDetails['href'], + 'class' => $this->usertalkUrlDetails['exists']?false:'new', 'ttip' => wfMsg('tooltip-anontalk'), 'akey' => wfMsg('accesskey-anontalk') ); diff --git a/stylesheets/monobook/main.css b/stylesheets/monobook/main.css index dcf5df081e..eb08b80f7a 100644 --- a/stylesheets/monobook/main.css +++ b/stylesheets/monobook/main.css @@ -650,6 +650,7 @@ li#pt-login { padding-left: 20px; text-transform: none; } +#p-personal a.new { color:#ba0000; } /* ** the page-related actions- page/talk, edit etc diff --git a/templates/xhtml_slim.pt b/templates/xhtml_slim.pt index 773f99d3f4..b109221a2a 100644 --- a/templates/xhtml_slim.pt +++ b/templates/xhtml_slim.pt @@ -62,7 +62,7 @@