X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FSkinPHPTal.php;h=cddc7535ca1b555dd73953a516ffcb38c45c42e7;hb=e1e24d2920aeee01e51b500e7d536d27ec0c3c4a;hp=ad1981e7bb21c3561fe4591f08fa408b8477a973;hpb=25c864161d88153374d603be377bfa34214d0f57;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index ad1981e7bb..cddc7535ca 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -62,10 +62,15 @@ 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(); @@ -79,9 +84,25 @@ #} $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() ); @@ -95,8 +116,9 @@ $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 ); @@ -109,7 +131,7 @@ $ntl = wfMsg( "newmessages", $this->makeKnownLink( $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) ) - . ":" . $wgUser->getName(), + . ":" . $this->username, wfMsg("newmessageslink") ) ); } @@ -120,9 +142,18 @@ $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() ); @@ -138,7 +169,7 @@ '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); @@ -146,7 +177,11 @@ $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', ''); @@ -167,38 +202,76 @@ # 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; } @@ -223,15 +296,24 @@ $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}" : ''; @@ -271,24 +353,30 @@ 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()) { @@ -306,6 +394,19 @@ } } + } 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' ) { @@ -360,10 +461,51 @@ $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);