Add a hidden stub Special:Search to hand search requests to; this fixes
[lhc/web/wiklou.git] / includes / SkinPHPTal.php
index ad1981e..cddc753 100644 (file)
 
                function outputPage( &$out ) {
                        global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgOut;
-                       global $wgScriptPath, $wgStyleSheetPath, $wgLanguageCode, $wgUseNewInterlanguage;
+                       global $wgScript, $wgStyleSheetPath, $wgLanguageCode, $wgUseNewInterlanguage;
                        global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
+                       global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses;
+                       
+                       extract( $wgRequest->getValues( 'oldid', 'diff' ) );
 
                        $this->thispage = $wgTitle->getPrefixedDbKey();
+                       $this->thisurl = $wgTitle->getPrefixedURL();
+                       $this->thisurle = urlencode($this->thisurl);
                        $this->loggedin = $wgUser->getID() != 0;
                        $this->username = $wgUser->getName();
                        $this->userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
                        #}
 
                        $tpl->setRef( "title", &$this->titletxt ); // ?
-                       $tpl->set( "pagetitle", wfMsg( "pagetitle", $this->titletxt ) );
+                       if(!empty($action)) {
+                               $taction =  $this->getPageTitleActionText();
+                               $taction = !empty($taction)?' - '.$taction:'';
+                       } else { $taction = ''; }
+                       $tpl->set( "pagetitle", wfMsg( "pagetitle", $this->titletxt.$taction ) );
                        $tpl->setRef( "thispage", &$this->thispage );
                        $tpl->set( "subtitle", $out->getSubtitle() );
+                       $tpl->set( 'catlinks', getCategories());
+                       if( $wgOut->isSyndicated() ) {
+                               $feeds = array();
+                               foreach( $wgFeedClasses as $format => $class ) {
+                                       $feeds[$format] = array(
+                                               'text' => $format,
+                                               'href' => $wgRequest->appendQuery( "feed=$format" ),
+                                               'ttip' => wfMsg('tooltip-'.$format)
+                                       );
+                               }
+                               $tpl->setRef( 'feeds', &$feeds );
+                       }
                        $tpl->setRef( 'mimetype', &$wgMimeType );
                        $tpl->setRef( 'charset', &$wgOutputEncoding );
                        $tpl->set( 'headlinks', $out->getHeadLinks() );
                        $tpl->set( "helppage", wfMsg('helppage'));
                        $tpl->set( "sysop", $wgUser->isSysop() );
                        */
-                       $tpl->setRef( "searchaction", &$wgScriptPath );
+                       $tpl->set( "searchaction", $this->escapeSearchLink() );
                        $tpl->setRef( "stylepath", &$wgStyleSheetPath );
+                       $tpl->setRef( "logopath", &$wgLogo );
                        $tpl->setRef( "lang", &$wgLanguageCode );
                        $tpl->set( "langname", $wgLang->getLanguageName( $wgLanguageCode ) );
                        $tpl->setRef( "username", &$this->username );
                                        $ntl = wfMsg( "newmessages",
                                        $this->makeKnownLink( 
                                                $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
-                                               . ":" . $wgUser->getName(),
+                                               . ":" . $this->username,
                                                wfMsg("newmessageslink") ) 
                                        );
                                }
                        $tpl->setRef( "newtalk", &$ntl );
                        $tpl->setRef( "skin", &$this);
                        $tpl->set( "logo", $this->logoText() );
-                       $tpl->set( "pagestats", $this->pageStats() );
-                       $tpl->set( "copyright", $this->getCopyrightIcon() );
-                       $tpl->set( "poweredby", $this->getPoweredBy() );
+                       if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
+                               if ( !$wgDisableCounters ) {
+                                       $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
+                                       if ( $viewcount ) {
+                                               $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
+                                       }
+                               }
+                               $tpl->set('lastmod', $this->lastModified());
+                               $tpl->set('copyright',$this->getCopyright());
+                       }
+                       $tpl->set( "copyrightico", $this->getCopyrightIcon() );
+                       $tpl->set( "poweredbyico", $this->getPoweredBy() );
                        $tpl->set( "disclaimer", $this->disclaimerLink() );
                        $tpl->set( "about", $this->aboutLink() );
 
                                'text' => ($wgLang->getLanguageName( $nt->getInterwiki()) != ''?$wgLang->getLanguageName( $nt->getInterwiki()) : $l),
                                'class' => $wgLang->isRTL() ? 'rtl' : 'ltr');
                        }
-                       if(count($language_urls) != 0 ) {
+                       if(count($language_urls)) {
                                $tpl->setRef( 'language_urls', &$language_urls);
                        } else {
                                $tpl->set('language_urls', false);
                        $tpl->set('personal_urls', $this->buildPersonalUrls());
                        $content_actions = $this->buildContentActionUrls();
                        $tpl->setRef('content_actions', &$content_actions);
-                       if(isset($content_actions['edit']['href']) && $wgUser->getOption("editondblclick") ) {
+                       // XXX: attach this from javascript, same with section editing
+                       if(isset($content_actions['edit']['href']) && 
+                       !(isset($content_actions['edit']['class']) && $content_actions['edit']['class'] != '') &&
+                       $wgUser->getOption("editondblclick") ) 
+                       {
                                $tpl->set('body-ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
                        } else {
                                $tpl->set('body-ondblclick', '');
                # build array of urls for personal toolbar
                function buildPersonalUrls() {
                        /* set up the default links for the personal toolbar */
+                       global $wgShowIPinHeader;
                        $personal_urls = array();
                        if ($this->loggedin) {
-                               $personal_urls['userpage'] = array('text' => $this->username,
+                               $personal_urls['userpage'] = array(
+                                       'text' => $this->username,
                                        'href' => $this->makeUrl($this->userpage),
                                        'ttip' => wfMsg('tooltip-userpage'),
-                                       'akey' => wfMsg('accesskey-userpage'));
-                               $personal_urls['mytalk'] = array('text' => wfMsg('mytalk'),
+                                       'akey' => wfMsg('accesskey-userpage')
+                               );
+                               $personal_urls['mytalk'] = array(
+                                       'text' => wfMsg('mytalk'),
                                        'href' => $this->makeTalkUrl($this->userpage),
                                        'ttip' => wfMsg('tooltip-mytalk'),
-                                       'akey' => wfMsg('accesskey-mytalk'));
-                               $personal_urls['preferences'] = array('text' => wfMsg('preferences'),
+                                       'akey' => wfMsg('accesskey-mytalk')
+                               );
+                               $personal_urls['preferences'] = array(
+                                       'text' => wfMsg('preferences'),
                                        'href' => $this->makeSpecialUrl('Preferences'),
                                        'ttip' => wfMsg('tooltip-preferences'),
-                                       'akey' => wfMsg('accesskey-preferences'));
-                               $personal_urls['watchlist'] = array('text' => wfMsg('watchlist'),
+                                       'akey' => wfMsg('accesskey-preferences')
+                               );
+                               $personal_urls['watchlist'] = array(
+                                       'text' => wfMsg('watchlist'),
                                        'href' => $this->makeSpecialUrl('Watchlist'),
                                        'ttip' => wfMsg('tooltip-watchlist'),
-                                       'akey' => wfMsg('accesskey-watchlist'));
-                               $personal_urls['mycontris'] = array('text' => wfMsg('mycontris'),
+                                       'akey' => wfMsg('accesskey-watchlist')
+                               );
+                               $personal_urls['mycontris'] = array(
+                                       'text' => wfMsg('mycontris'),
                                        'href' => $this->makeSpecialUrl('Contributions','target=' . $this->username),
                                        'ttip' => wfMsg('tooltip-mycontris'),
-                                       'akey' => wfMsg('accesskey-mycontris'));
-                               $personal_urls['logout'] = array('text' => wfMsg('userlogout'),
-                                       'href' => $this->makeSpecialUrl('Userlogout','returnpage=' . $this->thispage),
+                                       'akey' => wfMsg('accesskey-mycontris')
+                               );
+                               $personal_urls['logout'] = array(
+                                       'text' => wfMsg('userlogout'),
+                                       'href' => $this->makeSpecialUrl('Userlogout','returnpage=' . $this->thisurle),
                                        'ttip' => wfMsg('tooltip-logout'),
-                                       'akey' => wfMsg('accesskey-logout'));
+                                       'akey' => wfMsg('accesskey-logout')
+                               );
                        } else {
-                               $personal_urls['login'] = array('text' => wfMsg('userlogin'),
-                                       'href' => $this->makeSpecialUrl('Userlogin'),
-                                       'ttip' => wfMsg('tooltip-login'),
-                                       'akey' => wfMsg('accesskey-login'));
+                               if( $wgShowIPinHeader && isset(  $_COOKIE[ini_get("session.name")] ) ) {
+                                       $personal_urls['anonuserpage'] = array(
+                                               'text' => $this->username,
+                                               'href' => $this->makeUrl($this->userpage),
+                                               'ttip' => wfMsg('tooltip-anonuserpage'),
+                                               'akey' => wfMsg('accesskey-anonuserpage')
+                                       );
+                                       $personal_urls['anontalk'] = array(
+                                               'text' => wfMsg('anontalk'),
+                                               'href' => $this->makeTalkUrl($this->userpage),
+                                               'ttip' => wfMsg('tooltip-anontalk'),
+                                               'akey' => wfMsg('accesskey-anontalk')
+                                       );
+                                       $personal_urls['anonlogin'] = array(
+                                               'text' => wfMsg('userlogin'),
+                                               'href' => $this->makeSpecialUrl('Userlogin', 'return='.$this->thisurle),
+                                               'ttip' => wfMsg('tooltip-login'),
+                                               'akey' => wfMsg('accesskey-login')
+                                       );
+                               } else {
+
+                                       $personal_urls['login'] = array(
+                                               'text' => wfMsg('userlogin'),
+                                               'href' => $this->makeSpecialUrl('Userlogin', 'return='.$this->thisurle),
+                                               'ttip' => wfMsg('tooltip-login'),
+                                               'akey' => wfMsg('accesskey-login')
+                                       );
+                               }
                        }
+
                        return $personal_urls;
                }
                
                                $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ? 'selected' : '');                         
                                $talktitle = Title::newFromText( $this->titletxt );
                                $talktitle = $talktitle->getTalkPage();
-                               $this->checkTitle(&$title, &$name);     
-                               $talk_class .= ($talktitle->getArticleId() != 0 ? '':' new'); 
-                               $content_actions['talk'] = array(
-                                       'class' => $talk_class,
-                                       'text' => wfMsg('talk'),
-                                       'href' => $this->makeTalkUrl($this->titletxt),
-                                       'ttip' => wfMsg('tooltip-talk'),
-                                       'akey' => wfMsg('accesskey-talk')
-                               );
+                               $this->checkTitle(&$talktitle, &$this->titletxt);       
+                               if($talktitle->getArticleId() != 0) { 
+                                       $content_actions['talk'] = array(
+                                               'class' => $talk_class,
+                                               'text' => wfMsg('talk'),
+                                               'href' => $this->makeTalkUrl($this->titletxt),
+                                               'ttip' => wfMsg('tooltip-talk'),
+                                               'akey' => wfMsg('accesskey-talk')
+                                       );
+                               } else {
+                                       $content_actions['talk'] = array(
+                                               'class' => $talk_class.' new',
+                                               'text' => wfMsg('talk'),
+                                               'href' => $this->makeTalkUrl($this->titletxt,'action=edit'),
+                                               'ttip' => wfMsg('tooltip-talk'),
+                                               'akey' => wfMsg('accesskey-talk')
+                                       );
+                               }
 
                                if ( $wgTitle->userCanEdit() ) {
                                        $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : '';
 
                                        if($wgUser->isSysop()){
                                                if(!$wgTitle->isProtected()){
-                                                       $content_actions['protect'] = array('class' => ($action == 'protect') ? 'selected' : '',
-                                                       'text' => wfMsg('protect'),
-                                                       'href' => $this->makeUrl($this->thispage, 'action=protect'),
-                                                       'ttip' => wfMsg('tooltip-protect'),
-                                                       'akey' => wfMsg('accesskey-protect'));
+                                                       $content_actions['protect'] = array(
+                                                               'class' => ($action == 'protect') ? 'selected' : '',
+                                                               'text' => wfMsg('protect'),
+                                                               'href' => $this->makeUrl($this->thispage, 'action=protect'),
+                                                               'ttip' => wfMsg('tooltip-protect'),
+                                                               'akey' => wfMsg('accesskey-protect')
+                                                       );
 
                                                } else {
-                                                       $content_actions['unprotect'] = array('class' => ($action == 'unprotect') ? 'selected' : '',
-                                                       'text' => wfMsg('unprotect'),
-                                                       'href' => $this->makeUrl($this->thispage, 'action=unprotect'),
-                                                       'ttip' => wfMsg('tooltip-protect'),
-                                                       'akey' => wfMsg('accesskey-protect'));
+                                                       $content_actions['unprotect'] = array(
+                                                               'class' => ($action == 'unprotect') ? 'selected' : '',
+                                                               'text' => wfMsg('unprotect'),
+                                                               'href' => $this->makeUrl($this->thispage, 'action=unprotect'),
+                                                               'ttip' => wfMsg('tooltip-protect'),
+                                                               'akey' => wfMsg('accesskey-protect')
+                                                       );
                                                }
-                                               $content_actions['delete'] = array('class' => ($action == 'delete') ? 'selected' : '',
-                                               'text' => wfMsg('delete'),
-                                               'href' => $this->makeUrl($this->thispage, 'action=delete'),
-                                               'ttip' => wfMsg('tooltip-delete'),
-                                               'akey' => wfMsg('accesskey-delete'));
+                                               $content_actions['delete'] = array(
+                                                       'class' => ($action == 'delete') ? 'selected' : '',
+                                                       'text' => wfMsg('delete'),
+                                                       'href' => $this->makeUrl($this->thispage, 'action=delete'),
+                                                       'ttip' => wfMsg('tooltip-delete'),
+                                                       'akey' => wfMsg('accesskey-delete')
+                                               );
                                        }
                                        if ( $wgUser->getID() != 0 ) {
                                                if ( $wgTitle->userCanEdit()) {
 
                                                }
                                        }
+                               } else { 
+                                       //article doesn't exist or is deleted
+                                       if($wgUser->isSysop()){
+                                               if( $n = $wgTitle->isDeleted() ) {
+                                                       $content_actions['delete'] = array(
+                                                               'class' => '',
+                                                               'text' => wfMsg( "undelete_short", $n ),
+                                                               'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage),
+                                                               'ttip' => wfMsg('tooltip-undelete', $n),
+                                                               'akey' => wfMsg('accesskey-undelete')
+                                                       );
+                                               }
+                                       }
                                }
 
                                if ( $wgUser->getID() != 0 and $action != 'edit' and $action != 'submit' ) {
                        $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage')));
                        $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload')));
                        $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages')));
+                       
+                       
+                       $id=User::idFromName($wgTitle->getText());
+                       $ip=User::isIP($wgTitle->getText());
+
+                       if($id || $ip) { # both anons and non-anons have contri list
+                               $nav_urls['contributions'] = array(
+                                       'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) )
+                               );
+                       }
+                       if ( 0 != $wgUser->getID() ) { # show only to signed in users
+                               if($id) {       # can only email non-anons
+                                       $nav_urls['emailuser'] = array(
+                                               'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) )
+                                       );
+                               }
+                       }
+
 
                        return $nav_urls;
                }
 
+               function getPageTitleActionText () {
+                       global $action;
+                       switch($action) {
+                               case 'edit':
+                                       return  wfMsg('edit');
+                               case 'history':
+                                       return wfMsg('history_short');
+                               case 'protect':
+                                       return wfMsg('unprotect');
+                               case 'unprotect':
+                                       return wfMsg('unprotect');
+                               case 'delete':
+                                       return wfMsg('delete');
+                               case 'watch':
+                                       return wfMsg('watch');
+                               case 'unwatch':
+                                       return wfMsg('unwatch');
+                               case 'submit':
+                                       return wfMsg('preview');
+                               default:
+                                       return '';
+                       }
+               }
                /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
                        $title = Title::makeTitle( NS_SPECIAL, $name );
                        $this->checkTitle(&$title, &$name);