Approve link
[lhc/web/wiklou.git] / includes / Skin.php
index 91e59b9..1cbddf6 100644 (file)
@@ -87,7 +87,7 @@ class Skin {
 
        function getUserStyles()
        {
-               $s = "<style type='text/css' media='screen,projection'><!--\n";
+               $s = "<style type='text/css'><!--\n";
                $s .= $this->doGetUserStyles();
                $s .= "//--></style>\n";
                return $s;
@@ -277,19 +277,20 @@ class Skin {
        function afterContent()
        {
                global $wgUser, $wgOut, $wgServer, $HTTP_SERVER_VARS;
-
+               global $wgTitle;
+               
                if ( $wgOut->isPrintable() ) {
                        $s = "\n</div>\n";
 
-                       $u = $wgServer . $HTTP_SERVER_VARS['REQUEST_URI'];
-                       $u = preg_replace( "/[?&]printable=yes/", "", $u );
-                       $rf = str_replace( "$1", $u, wfMsg( "retrievedfrom" ) );
+                       $u = $wgServer . $wgTitle->getFullURL();
+                       $rf = wfMsg( "retrievedfrom", $u );
 
                        if ( $wgOut->isArticle() ) {
                                $lm = "<br>" . $this->lastModified();
                        } else { $lm = ""; }
 
-                       $s .= "<p><em>{$rf}{$lm}</em>\n";
+                       $cr = wfMsg( "gnunote" );
+                       $s .= "<p><em>{$rf}{$lm} {$cr}</em>\n";
                        return $s;
                }
                return $this->doAfterContent();
@@ -336,7 +337,7 @@ class Skin {
 
        function pageTitleLinks()
        {
-               global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang;
+               global $wgOut, $wgTitle, $oldid, $action, $diff, $wgUser, $wgLang, $wgUseApproval ;
 
                $s = $this->printableLink();
 
@@ -347,7 +348,16 @@ class Skin {
                                $style = $this->getInternalLinkAttributes( $link, $name );
                                $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
                        }
-               }
+# This will show the "Approve" link if $wgUseApproval=true;
+if ( isset ( $wgUseApproval ) && $wgUseApproval )
+{
+  $t = $wgTitle->getDBkey();
+  $name = "Approve this article" ; 
+  $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
+#wfEscapeHTML( wfImageUrl( $name ) );
+  $style = $this->getExternalLinkAttributes( $link, $name );
+  $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
+}              }
                if ( "history" == $action || isset( $diff ) || isset( $oldid ) ) {
                        $s .= " | " . $this->makeKnownLink( $wgTitle->getPrefixedText(),
                          wfMsg( "currentrev" ) );
@@ -366,6 +376,14 @@ class Skin {
                                $s.=" | <strong>". str_replace( "$1", $tl, wfMsg("newmessages") ) . "</strong>";
                        }
                }
+               if( $wgUser->isSysop() &&
+                       (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
+                       ($n = $wgTitle->isDeleted() ) ) {
+                               $s .= " | " . wfMsg( "thisisdeleted",
+                                       $this->makeKnownLink(
+                                       $wgLang->SpecialPage( "Undelete/" . $wgTitle->getPrefixedDBkey() ),
+                                       wfMsg( "restorelink", $n ) ) );
+               }
                return $s;
        }
 
@@ -383,9 +401,10 @@ class Skin {
 
        function pageTitle()
        {
-               global $wgOut, $wgTitle;
+               global $wgOut, $wgTitle, $wgUser;
 
                $s = "<h1 class='pagetitle'>" . $wgOut->getPageTitle() . "</h1>";
+               if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
                return $s;
        }
 
@@ -514,8 +533,7 @@ class Skin {
                if ( $wgOut->isArticle() ) {
                        $s .= "<strong>" . $this->editThisPage() . "</strong>";
                        if ( 0 != $wgUser->getID() ) {
-                               $s .= $sep . $this->watchThisPage() .
-                                       $sep . $this->moveThisPage();
+                               $s .= $sep . $this->watchThisPage();
                        }
                        $s .= $sep . $this->talkLink()
                          . $sep . $this->historyLink()
@@ -540,7 +558,8 @@ class Skin {
                        }
                        if ( $wgUser->isSysop() && $wgTitle->getArticleId() ) {
                                $s .= "\n<br>" . $this->deleteThisPage() .
-                               $sep . $this->protectThisPage();
+                               $sep . $this->protectThisPage() .
+                               $sep . $this->moveThisPage();
                        }
                        $s .= "<br>\n" . $this->otherLanguages();
                }
@@ -1084,31 +1103,31 @@ class Skin {
                        return $this->makeKnownLink( $title, $text, $query, $trail );
                }
                if ( ( -1 == $nt->getNamespace() ) ||
-          ( Namespace::getImage() == $nt->getNamespace() ) ) {
+                               ( Namespace::getImage() == $nt->getNamespace() ) ) {
                        return $this->makeKnownLink( $title, $text, $query, $trail );
                }
-                $aid = $nt->getArticleID() ;
-                if ( 0 == $aid ) {
-                        return $this->makeBrokenLink( $title, $text, $query, $trail );
-                } else {
-                        $threshold = $wgUser->getOption("stubthreshold") ;
-                        if ( $threshold > 0 ) {
-                                $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
-
-                                if ( wfNumRows( $res ) > 0 ) {
-                                        $s = wfFetchObject( $res );
-                                        $size = $s->x;
-                                        if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
-                                                $size = $threshold*2 ; # Really big
-                                        wfFreeResult( $res );
-                                } else $size = $threshold*2 ; # Really big
-                        } else $size = 1 ;
-
-                        if ( $size < $threshold )
-                                return $this->makeStubLink( $title, $text, $query, $trail );
-                        return $this->makeKnownLink( $title, $text, $query, $trail );
-                }
-        }
+               $aid = $nt->getArticleID() ;
+               if ( 0 == $aid ) {
+                       return $this->makeBrokenLink( $title, $text, $query, $trail );
+               } else {
+                       $threshold = $wgUser->getOption("stubthreshold") ;
+                       if ( $threshold > 0 ) {
+                               $res = wfQuery ( "SELECT HIGH_PRIORITY length(cur_text) AS x, cur_namespace, cur_is_redirect FROM cur WHERE cur_id='{$aid}'" ) ;
+
+                               if ( wfNumRows( $res ) > 0 ) {
+                                       $s = wfFetchObject( $res );
+                                       $size = $s->x;
+                                       if ( $s->cur_is_redirect OR $s->cur_namespace != 0 )
+                                               $size = $threshold*2 ; # Really big
+                                                       wfFreeResult( $res );
+                               } else $size = $threshold*2 ; # Really big
+                       } else $size = 1 ;
+
+                       if ( $size < $threshold )
+                               return $this->makeStubLink( $title, $text, $query, $trail );
+                       return $this->makeKnownLink( $title, $text, $query, $trail );
+               }
+       }
 
        function makeKnownLink( $title, $text = "", $query = "", $trail = "" )
        {
@@ -1657,7 +1676,7 @@ class Skin {
                        $url = wfImageUrl( $img );
                        $rlink = $cur;
                        if ( $wgUser->isSysop() ) {
-                               $link = wfLocalUrlE( "", "image=" . $wgTitle->getURL() .
+                               $link = wfLocalUrlE( $wgTitle->getPrefixedText(), "image=" . $wgTitle->getURL() .
                                  "&action=delete" );
                                $style = $this->getInternalLinkAttributes( $link, $del );
 
@@ -1726,29 +1745,35 @@ class Skin {
        }
 
        function tocTable($toc) {
-       // note to CSS fanatics: putting this in a div does not works -- div won't auto-expand
+       // note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
+       global $printable;
+
+       if (!$printable) {
+               $hideline = " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>";
+       }
        return
        "<p><table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
        "<b>".wfMsg("toc")."</b>" .
-       " <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
+       $hideline .
        "</td></tr><tr id='tocinside'><td align=\"left\">\n".
        $toc."</td></tr></table><P>\n";
        }
 
+       # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
        function editSectionScript($section,$head) {
 
                global $wgTitle,$wgUser,$oldid;
-               if($wgTitle->isProtected() && !$wgUser->isSysop()) return $head;
                if($oldid) return $head;
-               $url = wfLocalUrlE($wgTitle->getPrefixedText(),"action=edit&section=$section");
+               $url = wfLocalUrlE(urlencode($wgTitle->getPrefixedText()),"action=edit&section=$section");
                return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
        }
 
        function editSectionLink($section) {
 
+               global $printable;
                global $wgTitle,$wgUser,$oldid;
-               if($wgTitle->isProtected() && !$wgUser->isSysop()) return "";
                if($oldid) return "";
+               if ($printable) return "";
                $editurl="&section={$section}";
                $url=$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg("editsection"),"action=edit".$editurl);
                return "<div style=\"float:right;margin-left:5px;\"><small>[".$url."]</small></div>";