MonoBook.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <?php
  2. /**
  3. * MonoBook nouveau
  4. *
  5. * Translated from gwicke's previous TAL template version to remove
  6. * dependency on PHPTAL.
  7. *
  8. * @todo document
  9. * @file
  10. * @ingroup Skins
  11. */
  12. if( !defined( 'MEDIAWIKI' ) )
  13. die( -1 );
  14. /**
  15. * Inherit main code from SkinTemplate, set the CSS and template filter.
  16. * @todo document
  17. * @ingroup Skins
  18. */
  19. class SkinMonoBook extends SkinTemplate {
  20. /** Using monobook. */
  21. function initPage( OutputPage $out ) {
  22. parent::initPage( $out );
  23. $this->skinname = 'monobook';
  24. $this->stylename = 'monobook';
  25. $this->template = 'MonoBookTemplate';
  26. }
  27. function setupSkinUserCss( OutputPage $out ) {
  28. global $wgHandheldStyle;
  29. parent::setupSkinUserCss( $out );
  30. // Append to the default screen common & print styles...
  31. $out->addStyle( 'monobook/main.css', 'screen' );
  32. if( $wgHandheldStyle ) {
  33. // Currently in testing... try 'chick/main.css'
  34. $out->addStyle( $wgHandheldStyle, 'handheld' );
  35. }
  36. $out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
  37. $out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
  38. $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
  39. $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
  40. $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
  41. }
  42. }
  43. /**
  44. * @todo document
  45. * @ingroup Skins
  46. */
  47. class MonoBookTemplate extends QuickTemplate {
  48. var $skin;
  49. /**
  50. * Template filter callback for MonoBook skin.
  51. * Takes an associative array of data set from a SkinTemplate-based
  52. * class, and a wrapper for MediaWiki's localization database, and
  53. * outputs a formatted page.
  54. *
  55. * @access private
  56. */
  57. function execute() {
  58. global $wgRequest;
  59. $this->skin = $skin = $this->data['skin'];
  60. $action = $wgRequest->getText( 'action' );
  61. // Suppress warnings to prevent notices about missing indexes in $this->data
  62. wfSuppressWarnings();
  63. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  64. <html xmlns="<?php $this->text('xhtmldefaultnamespace') ?>" <?php
  65. foreach($this->data['xhtmlnamespaces'] as $tag => $ns) {
  66. ?>xmlns:<?php echo "{$tag}=\"{$ns}\" ";
  67. } ?>xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
  68. <head>
  69. <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
  70. <?php $this->html('headlinks') ?>
  71. <title><?php $this->text('pagetitle') ?></title>
  72. <?php $this->html('csslinks') ?>
  73. <!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script>
  74. <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
  75. <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
  76. <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js --></script>
  77. <!-- Head Scripts -->
  78. <?php $this->html('headscripts') ?>
  79. <?php if($this->data['jsvarurl']) { ?>
  80. <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl') ?>"><!-- site js --></script>
  81. <?php } ?>
  82. <?php if($this->data['pagecss']) { ?>
  83. <style type="text/css"><?php $this->html('pagecss') ?></style>
  84. <?php }
  85. if($this->data['usercss']) { ?>
  86. <style type="text/css"><?php $this->html('usercss') ?></style>
  87. <?php }
  88. if($this->data['userjs']) { ?>
  89. <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs' ) ?>"></script>
  90. <?php }
  91. if($this->data['userjsprev']) { ?>
  92. <script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script>
  93. <?php }
  94. if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
  95. </head>
  96. <body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
  97. <?php if($this->data['body_onload']) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
  98. class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
  99. <div id="globalWrapper">
  100. <div id="column-content">
  101. <div id="content">
  102. <a name="top" id="top"></a>
  103. <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
  104. <h1 id="firstHeading" class="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1>
  105. <div id="bodyContent">
  106. <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
  107. <div id="contentSub"><?php $this->html('subtitle') ?></div>
  108. <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
  109. <?php if($this->data['newtalk'] ) { ?><div class="usermessage"><?php $this->html('newtalk') ?></div><?php } ?>
  110. <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
  111. <!-- start content -->
  112. <?php $this->html('bodytext') ?>
  113. <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
  114. <!-- end content -->
  115. <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
  116. <div class="visualClear"></div>
  117. </div>
  118. </div>
  119. </div>
  120. <div id="column-one">
  121. <div id="p-cactions" class="portlet">
  122. <h5><?php $this->msg('views') ?></h5>
  123. <div class="pBody">
  124. <ul>
  125. <?php foreach($this->data['content_actions'] as $key => $tab) {
  126. echo '
  127. <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
  128. if( $tab['class'] ) {
  129. echo ' class="'.htmlspecialchars($tab['class']).'"';
  130. }
  131. echo'><a href="'.htmlspecialchars($tab['href']).'"';
  132. # We don't want to give the watch tab an accesskey if the
  133. # page is being edited, because that conflicts with the
  134. # accesskey on the watch checkbox. We also don't want to
  135. # give the edit tab an accesskey, because that's fairly su-
  136. # perfluous and conflicts with an accesskey (Ctrl-E) often
  137. # used for editing in Safari.
  138. if( in_array( $action, array( 'edit', 'submit' ) )
  139. && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
  140. echo $skin->tooltip( "ca-$key" );
  141. } else {
  142. echo $skin->tooltipAndAccesskey( "ca-$key" );
  143. }
  144. echo '>'.htmlspecialchars($tab['text']).'</a></li>';
  145. } ?>
  146. </ul>
  147. </div>
  148. </div>
  149. <div class="portlet" id="p-personal">
  150. <h5><?php $this->msg('personaltools') ?></h5>
  151. <div class="pBody">
  152. <ul>
  153. <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
  154. <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
  155. if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
  156. echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
  157. if(!empty($item['class'])) { ?> class="<?php
  158. echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
  159. echo htmlspecialchars($item['text']) ?></a></li>
  160. <?php } ?>
  161. </ul>
  162. </div>
  163. </div>
  164. <div class="portlet" id="p-logo">
  165. <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
  166. ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
  167. echo $skin->tooltipAndAccesskey('p-logo') ?>></a>
  168. </div>
  169. <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
  170. <?php
  171. $sidebar = $this->data['sidebar'];
  172. if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
  173. if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
  174. if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
  175. foreach ($sidebar as $boxName => $cont) {
  176. if ( $boxName == 'SEARCH' ) {
  177. $this->searchBox();
  178. } elseif ( $boxName == 'TOOLBOX' ) {
  179. $this->toolbox();
  180. } elseif ( $boxName == 'LANGUAGES' ) {
  181. $this->languageBox();
  182. } else {
  183. $this->customBox( $boxName, $cont );
  184. }
  185. }
  186. ?>
  187. </div><!-- end of the left (by default at least) column -->
  188. <div class="visualClear"></div>
  189. <div id="footer">
  190. <?php
  191. if($this->data['poweredbyico']) { ?>
  192. <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
  193. <?php }
  194. if($this->data['copyrightico']) { ?>
  195. <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div>
  196. <?php }
  197. // Generate additional footer links
  198. $footerlinks = array(
  199. 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
  200. 'privacy', 'about', 'disclaimer', 'tagline',
  201. );
  202. $validFooterLinks = array();
  203. foreach( $footerlinks as $aLink ) {
  204. if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
  205. $validFooterLinks[] = $aLink;
  206. }
  207. }
  208. if ( count( $validFooterLinks ) > 0 ) {
  209. ?> <ul id="f-list">
  210. <?php
  211. foreach( $validFooterLinks as $aLink ) {
  212. if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
  213. ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
  214. <?php }
  215. }
  216. ?>
  217. </ul>
  218. <?php }
  219. ?>
  220. </div>
  221. </div>
  222. <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
  223. <?php $this->html('reporttime') ?>
  224. <?php if ( $this->data['debug'] ): ?>
  225. <!-- Debug output:
  226. <?php $this->text( 'debug' ); ?>
  227. -->
  228. <?php endif; ?>
  229. </body></html>
  230. <?php
  231. wfRestoreWarnings();
  232. } // end of execute() method
  233. /*************************************************************************************************/
  234. function searchBox() {
  235. global $wgUseTwoButtonsSearchForm;
  236. ?>
  237. <div id="p-search" class="portlet">
  238. <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
  239. <div id="searchBody" class="pBody">
  240. <form action="<?php $this->text('wgScript') ?>" id="searchform"><div>
  241. <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
  242. <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
  243. if( isset( $this->data['search'] ) ) {
  244. ?> value="<?php $this->text('search') ?>"<?php } ?> />
  245. <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?>&nbsp;
  246. <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
  247. <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
  248. </div></form>
  249. </div>
  250. </div>
  251. <?php
  252. }
  253. /*************************************************************************************************/
  254. function toolbox() {
  255. ?>
  256. <div class="portlet" id="p-tb">
  257. <h5><?php $this->msg('toolbox') ?></h5>
  258. <div class="pBody">
  259. <ul>
  260. <?php
  261. if($this->data['notspecialpage']) { ?>
  262. <li id="t-whatlinkshere"><a href="<?php
  263. echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
  264. ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
  265. <?php
  266. if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
  267. <li id="t-recentchangeslinked"><a href="<?php
  268. echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
  269. ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked') ?></a></li>
  270. <?php }
  271. }
  272. if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
  273. <li id="t-trackbacklink"><a href="<?php
  274. echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
  275. ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
  276. <?php }
  277. if($this->data['feeds']) { ?>
  278. <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
  279. ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
  280. echo htmlspecialchars($feed['href']) ?>" rel="alternate" type="application/<?php echo $key ?>+xml" class="feedlink"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;
  281. <?php } ?></li><?php
  282. }
  283. foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
  284. if($this->data['nav_urls'][$special]) {
  285. ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
  286. ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
  287. <?php }
  288. }
  289. if(!empty($this->data['nav_urls']['print']['href'])) { ?>
  290. <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
  291. ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
  292. }
  293. if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
  294. <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
  295. ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
  296. } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
  297. <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
  298. }
  299. wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
  300. wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
  301. ?>
  302. </ul>
  303. </div>
  304. </div>
  305. <?php
  306. }
  307. /*************************************************************************************************/
  308. function languageBox() {
  309. if( $this->data['language_urls'] ) {
  310. ?>
  311. <div id="p-lang" class="portlet">
  312. <h5><?php $this->msg('otherlanguages') ?></h5>
  313. <div class="pBody">
  314. <ul>
  315. <?php foreach($this->data['language_urls'] as $langlink) { ?>
  316. <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
  317. ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
  318. <?php } ?>
  319. </ul>
  320. </div>
  321. </div>
  322. <?php
  323. }
  324. }
  325. /*************************************************************************************************/
  326. function customBox( $bar, $cont ) {
  327. ?>
  328. <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
  329. <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
  330. <div class='pBody'>
  331. <?php if ( is_array( $cont ) ) { ?>
  332. <ul>
  333. <?php foreach($cont as $key => $val) { ?>
  334. <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
  335. if ( $val['active'] ) { ?> class="active" <?php }
  336. ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
  337. <?php } ?>
  338. </ul>
  339. <?php } else {
  340. # allow raw HTML block to be defined by extensions
  341. print $cont;
  342. }
  343. ?>
  344. </div>
  345. </div>
  346. <?php
  347. }
  348. } // end of class