* New functions makeUrlDetails, makeTalkUrlDetails and so on in Skin.php that return...
authorGabriel Wicke <gwicke@users.mediawiki.org>
Thu, 13 May 2004 19:44:13 +0000 (19:44 +0000)
committerGabriel Wicke <gwicke@users.mediawiki.org>
Thu, 13 May 2004 19:44:13 +0000 (19:44 +0000)
* User page link and User talk page link in red if pages don't exist

includes/Skin.php
includes/SkinPHPTal.php
stylesheets/monobook/main.css
templates/xhtml_slim.pt

index 7b53b6e..a7eb604 100644 (file)
@@ -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 ) { 
index fa0dcbf..4e9d8b2 100644 (file)
@@ -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(); }
                        $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);
                        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')
                                );
                                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')
                                        );
index dcf5df0..eb08b80 100644 (file)
@@ -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 
index 773f99d..b109221 100644 (file)
@@ -62,7 +62,7 @@
            <ul>
              <li tal:repeat="item personal_urls" 
              tal:attributes="id string:pt-${repeat/item/key};"><a href="myuserpage"
-               tal:attributes="href item/href; accesskey item/akey|default; title item/ttip|default"
+               tal:attributes="href item/href; accesskey item/akey|default; title item/ttip|default; class item/class|default"
                tal:content="item/text">Log in</a></li>
            </ul>
          </div>