Standard.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?php
  2. /**
  3. * See docs/skin.txt
  4. *
  5. * @todo document
  6. * @file
  7. * @ingroup Skins
  8. */
  9. if( !defined( 'MEDIAWIKI' ) )
  10. die( -1 );
  11. /**
  12. * @todo document
  13. * @ingroup Skins
  14. */
  15. class SkinStandard extends Skin {
  16. /**
  17. *
  18. */
  19. function getHeadScripts( $allowUserJs ) {
  20. global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
  21. $s = parent::getHeadScripts( $allowUserJs );
  22. if ( 3 == $this->qbSetting() ) { # Floating left
  23. $s .= "<script language='javascript' type='$wgJsMimeType' " .
  24. "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'></script>\n";
  25. }
  26. return $s;
  27. }
  28. /**
  29. *
  30. */
  31. function setupSkinUserCss( OutputPage $out ){
  32. if ( 3 == $this->qbSetting() ) { # Floating left
  33. $out->addStyle( 'common/quickbar.css' );
  34. } else if ( 4 == $this->qbSetting() ) { # Floating right
  35. $out->addStyle( 'common/quickbar-right.css' );
  36. }
  37. parent::setupSkinUserCss( $out );
  38. }
  39. /**
  40. *
  41. */
  42. function reallyGenerateUserStylesheet() {
  43. $s = parent::reallyGenerateUserStylesheet();
  44. $qb = $this->qbSetting();
  45. if ( 2 == $qb ) { # Right
  46. $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
  47. "border-left: 2px solid #000000; }\n" .
  48. "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }\n";
  49. } else if ( 1 == $qb || 3 == $qb ) {
  50. $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
  51. "border-right: 1px solid gray; }\n" .
  52. "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }\n";
  53. } else if ( 4 == $qb) {
  54. $s .= "#quickbar { border-right: 1px solid gray; }\n" .
  55. "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }\n";
  56. }
  57. return $s;
  58. }
  59. /**
  60. *
  61. */
  62. function getBodyOptions() {
  63. $a = parent::getBodyOptions();
  64. if ( 3 == $this->qbSetting() ) { # Floating left
  65. $qb = "setup(\"quickbar\")";
  66. if($a["onload"]) {
  67. $a["onload"] .= ";$qb";
  68. } else {
  69. $a["onload"] = $qb;
  70. }
  71. }
  72. return $a;
  73. }
  74. function doAfterContent() {
  75. global $wgContLang, $wgLang;
  76. $fname = 'SkinStandard::doAfterContent';
  77. wfProfileIn( $fname );
  78. wfProfileIn( $fname.'-1' );
  79. $s = "\n</div><br style=\"clear:both\" />\n";
  80. $s .= "\n<div id='footer'>";
  81. $s .= '<table border="0" cellspacing="0"><tr>';
  82. wfProfileOut( $fname.'-1' );
  83. wfProfileIn( $fname.'-2' );
  84. $qb = $this->qbSetting();
  85. $shove = ($qb != 0);
  86. $left = ($qb == 1 || $qb == 3);
  87. if($wgContLang->isRTL()) $left = !$left;
  88. if ( $shove && $left ) { # Left
  89. $s .= $this->getQuickbarCompensator();
  90. }
  91. wfProfileOut( $fname.'-2' );
  92. wfProfileIn( $fname.'-3' );
  93. $l = $wgContLang->isRTL() ? 'right' : 'left';
  94. $s .= "<td class='bottom' align='$l' valign='top'>";
  95. $s .= $this->bottomLinks();
  96. $s .= "\n<br />" . $wgLang->pipeList( array(
  97. $this->mainPageLink(),
  98. $this->aboutLink(),
  99. $this->specialLink( 'recentchanges' ),
  100. $this->searchForm() ) )
  101. . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
  102. $s .= "</td>";
  103. if ( $shove && !$left ) { # Right
  104. $s .= $this->getQuickbarCompensator();
  105. }
  106. $s .= "</tr></table>\n</div>\n</div>\n";
  107. wfProfileOut( $fname.'-3' );
  108. wfProfileIn( $fname.'-4' );
  109. if ( 0 != $qb ) { $s .= $this->quickBar(); }
  110. wfProfileOut( $fname.'-4' );
  111. wfProfileOut( $fname );
  112. return $s;
  113. }
  114. function quickBar() {
  115. global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
  116. global $wgEnableUploads, $wgRemoteUploads;
  117. $fname = 'Skin::quickBar';
  118. wfProfileIn( $fname );
  119. $action = $wgRequest->getText( 'action' );
  120. $wpPreview = $wgRequest->getBool( 'wpPreview' );
  121. $tns=$wgTitle->getNamespace();
  122. $s = "\n<div id='quickbar'>";
  123. $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
  124. $sep = "\n<br />";
  125. # Use the first heading from the Monobook sidebar as the "browse" section
  126. $bar = $this->buildSidebar();
  127. unset( $bar['SEARCH'] );
  128. unset( $bar['LANGUAGES'] );
  129. unset( $bar['TOOLBOX'] );
  130. $browseLinks = reset( $bar );
  131. foreach ( $browseLinks as $link ) {
  132. if ( $link['text'] != '-' ) {
  133. $s .= "<a href=\"{$link['href']}\">" .
  134. htmlspecialchars( $link['text'] ) . '</a>' . $sep;
  135. }
  136. }
  137. if( $wgUser->isLoggedIn() ) {
  138. $s.= $this->specialLink( 'watchlist' ) ;
  139. $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
  140. wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
  141. }
  142. // only show watchlist link if logged in
  143. $s .= "\n<hr class='sep' />";
  144. $articleExists = $wgTitle->getArticleId();
  145. if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
  146. if($wgOut->isArticle()) {
  147. $s .= '<strong>' . $this->editThisPage() . '</strong>';
  148. } else { # backlink to the article in edit or history mode
  149. if($articleExists){ # no backlink if no article
  150. switch($tns) {
  151. case NS_TALK:
  152. case NS_USER_TALK:
  153. case NS_PROJECT_TALK:
  154. case NS_FILE_TALK:
  155. case NS_MEDIAWIKI_TALK:
  156. case NS_TEMPLATE_TALK:
  157. case NS_HELP_TALK:
  158. case NS_CATEGORY_TALK:
  159. $text = wfMsg('viewtalkpage');
  160. break;
  161. case NS_MAIN:
  162. $text = wfMsg( 'articlepage' );
  163. break;
  164. case NS_USER:
  165. $text = wfMsg( 'userpage' );
  166. break;
  167. case NS_PROJECT:
  168. $text = wfMsg( 'projectpage' );
  169. break;
  170. case NS_FILE:
  171. $text = wfMsg( 'imagepage' );
  172. break;
  173. case NS_MEDIAWIKI:
  174. $text = wfMsg( 'mediawikipage' );
  175. break;
  176. case NS_TEMPLATE:
  177. $text = wfMsg( 'templatepage' );
  178. break;
  179. case NS_HELP:
  180. $text = wfMsg( 'viewhelppage' );
  181. break;
  182. case NS_CATEGORY:
  183. $text = wfMsg( 'categorypage' );
  184. break;
  185. default:
  186. $text= wfMsg( 'articlepage' );
  187. }
  188. $link = $wgTitle->getText();
  189. if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
  190. $link = $nstext . ':' . $link ;
  191. }
  192. $s .= $this->makeLink( $link, $text );
  193. } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
  194. # we just throw in a "New page" text to tell the user that he's in edit mode,
  195. # and to avoid messing with the separator that is prepended to the next item
  196. $s .= '<strong>' . wfMsg('newpage') . '</strong>';
  197. }
  198. }
  199. # "Post a comment" link
  200. if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
  201. $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit&section=new' );
  202. #if( $tns%2 && $action!='edit' && !$wpPreview) {
  203. #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
  204. #}
  205. /*
  206. watching could cause problems in edit mode:
  207. if user edits article, then loads "watch this article" in background and then saves
  208. article with "Watch this article" checkbox disabled, the article is transparently
  209. unwatched. Therefore we do not show the "Watch this page" link in edit mode
  210. */
  211. if ( $wgUser->isLoggedIn() && $articleExists) {
  212. if($action!='edit' && $action != 'submit' )
  213. {
  214. $s .= $sep . $this->watchThisPage();
  215. }
  216. if ( $wgTitle->userCan( 'edit' ) )
  217. $s .= $sep . $this->moveThisPage();
  218. }
  219. if ( $wgUser->isAllowed('delete') and $articleExists ) {
  220. $s .= $sep . $this->deleteThisPage() .
  221. $sep . $this->protectThisPage();
  222. }
  223. $s .= $sep . $this->talkLink();
  224. if ($articleExists && $action !='history') {
  225. $s .= $sep . $this->historyLink();
  226. }
  227. $s.=$sep . $this->whatLinksHere();
  228. if($wgOut->isArticleRelated()) {
  229. $s .= $sep . $this->watchPageLinksLink();
  230. }
  231. if ( NS_USER == $wgTitle->getNamespace()
  232. || $wgTitle->getNamespace() == NS_USER_TALK ) {
  233. $id=User::idFromName($wgTitle->getText());
  234. $ip=User::isIP($wgTitle->getText());
  235. if( $id || $ip ){
  236. $s .= $sep . $this->userContribsLink();
  237. }
  238. if( $this->showEmailUser( $id ) ) {
  239. $s .= $sep . $this->emailUserLink();
  240. }
  241. }
  242. $s .= "\n<br /><hr class='sep' />";
  243. }
  244. if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
  245. $s .= $this->specialLink( 'upload' ) . $sep;
  246. }
  247. $s .= $this->specialLink( 'specialpages' );
  248. global $wgSiteSupportPage;
  249. if( $wgSiteSupportPage ) {
  250. $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
  251. '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
  252. }
  253. $s .= "\n<br /></div>\n";
  254. wfProfileOut( $fname );
  255. return $s;
  256. }
  257. }