MediaWiki  REL1_19
MonoBook.php
Go to the documentation of this file.
00001 <?php
00013 if( !defined( 'MEDIAWIKI' ) )
00014         die( -1 );
00015 
00021 class SkinMonoBook extends SkinTemplate {
00023         var $skinname = 'monobook', $stylename = 'monobook',
00024                 $template = 'MonoBookTemplate', $useHeadElement = true;
00025 
00029         function setupSkinUserCss( OutputPage $out ) {
00030                 global $wgHandheldStyle;
00031                 parent::setupSkinUserCss( $out );
00032 
00033                 $out->addModuleStyles( 'skins.monobook' );
00034 
00035                 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
00036                 if( $wgHandheldStyle ) {
00037                         // Currently in testing... try 'chick/main.css'
00038                         $out->addStyle( $wgHandheldStyle, 'handheld' );
00039                 }
00040 
00041                 // TODO: Migrate all of these
00042                 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
00043                 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
00044 
00045         }
00046 }
00047 
00052 class MonoBookTemplate extends BaseTemplate {
00053 
00062         function execute() {
00063                 // Suppress warnings to prevent notices about missing indexes in $this->data
00064                 wfSuppressWarnings();
00065 
00066                 $this->html( 'headelement' );
00067 ?><div id="globalWrapper">
00068 <div id="column-content"><div id="content">
00069         <a id="top"></a>
00070         <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
00071 
00072         <h1 id="firstHeading" class="firstHeading"><span dir="auto"><?php $this->html('title') ?></span></h1>
00073         <div id="bodyContent" class="mw-body">
00074                 <div id="siteSub"><?php $this->msg('tagline') ?></div>
00075                 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
00076 <?php if($this->data['undelete']) { ?>
00077                 <div id="contentSub2"><?php $this->html('undelete') ?></div>
00078 <?php } ?><?php if($this->data['newtalk'] ) { ?>
00079                 <div class="usermessage"><?php $this->html('newtalk')  ?></div>
00080 <?php } ?><?php if($this->data['showjumplinks']) { ?>
00081                 <div id="jump-to-nav" class="mw-jump"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
00082 <?php } ?>
00083                 <!-- start content -->
00084 <?php $this->html('bodytext') ?>
00085                 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
00086                 <!-- end content -->
00087                 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
00088                 <div class="visualClear"></div>
00089         </div>
00090 </div></div>
00091 <div id="column-one"<?php $this->html('userlangattributes')  ?>>
00092 <?php $this->cactions(); ?>
00093         <div class="portlet" id="p-personal">
00094                 <h5><?php $this->msg('personaltools') ?></h5>
00095                 <div class="pBody">
00096                         <ul<?php $this->html('userlangattributes') ?>>
00097 <?php           foreach($this->getPersonalTools() as $key => $item) { ?>
00098                                 <?php echo $this->makeListItem($key, $item); ?>
00099 
00100 <?php           } ?>
00101                         </ul>
00102                 </div>
00103         </div>
00104         <div class="portlet" id="p-logo">
00105 <?php
00106                         echo Html::element( 'a', array(
00107                                 'href' => $this->data['nav_urls']['mainpage']['href'],
00108                                 'style' => "background-image: url({$this->data['logopath']});" )
00109                                 + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
00110 
00111         </div>
00112 <?php
00113         $this->renderPortals( $this->data['sidebar'] );
00114 ?>
00115 </div><!-- end of the left (by default at least) column -->
00116 <div class="visualClear"></div>
00117 <?php
00118         $validFooterIcons = $this->getFooterIcons( "icononly" );
00119         $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
00120 
00121         if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
00122 <div id="footer"<?php $this->html('userlangattributes') ?>>
00123 <?php
00124                 $footerEnd = '</div>';
00125         } else {
00126                 $footerEnd = '';
00127         }
00128         foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
00129         <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
00130 <?php foreach ( $footerIcons as $icon ) { ?>
00131                 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
00132 
00133 <?php }
00134 ?>
00135         </div>
00136 <?php }
00137 
00138                 if ( count( $validFooterLinks ) > 0 ) {
00139 ?>      <ul id="f-list">
00140 <?php
00141                         foreach( $validFooterLinks as $aLink ) { ?>
00142                 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
00143 <?php
00144                         }
00145 ?>
00146         </ul>
00147 <?php   }
00148 echo $footerEnd;
00149 ?>
00150 
00151 </div>
00152 <?php
00153                 $this->printTrail();
00154                 echo Html::closeElement( 'body' );
00155                 echo Html::closeElement( 'html' );
00156                 wfRestoreWarnings();
00157         } // end of execute() method
00158 
00159         /*************************************************************************************************/
00160 
00161         protected function renderPortals( $sidebar ) {
00162                 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
00163                 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
00164                 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
00165 
00166                 foreach( $sidebar as $boxName => $content ) {
00167                         if ( $content === false )
00168                                 continue;
00169 
00170                         if ( $boxName == 'SEARCH' ) {
00171                                 $this->searchBox();
00172                         } elseif ( $boxName == 'TOOLBOX' ) {
00173                                 $this->toolbox();
00174                         } elseif ( $boxName == 'LANGUAGES' ) {
00175                                 $this->languageBox();
00176                         } else {
00177                                 $this->customBox( $boxName, $content );
00178                         }
00179                 }
00180         }
00181 
00182         function searchBox() {
00183                 global $wgUseTwoButtonsSearchForm;
00184 ?>
00185         <div id="p-search" class="portlet">
00186                 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
00187                 <div id="searchBody" class="pBody">
00188                         <form action="<?php $this->text('wgScript') ?>" id="searchform">
00189                                 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
00190                                 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
00191 
00192                                 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
00193                                 if ($wgUseTwoButtonsSearchForm): ?>&#160;
00194                                 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
00195                                 else: ?>
00196 
00197                                 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
00198                                 endif; ?>
00199 
00200                         </form>
00201                 </div>
00202         </div>
00203 <?php
00204         }
00205 
00210         function cactions() {
00211 ?>
00212         <div id="p-cactions" class="portlet">
00213                 <h5><?php $this->msg('views') ?></h5>
00214                 <div class="pBody">
00215                         <ul><?php
00216                                 foreach($this->data['content_actions'] as $key => $tab) {
00217                                         echo '
00218                                 ' . $this->makeListItem( $key, $tab );
00219                                 } ?>
00220 
00221                         </ul>
00222                 </div>
00223         </div>
00224 <?php
00225         }
00226         /*************************************************************************************************/
00227         function toolbox() {
00228 ?>
00229         <div class="portlet" id="p-tb">
00230                 <h5><?php $this->msg('toolbox') ?></h5>
00231                 <div class="pBody">
00232                         <ul>
00233 <?php
00234                 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
00235                                 <?php echo $this->makeListItem($key, $tbitem); ?>
00236 
00237 <?php
00238                 }
00239                 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
00240                 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
00241 ?>
00242                         </ul>
00243                 </div>
00244         </div>
00245 <?php
00246         }
00247 
00248         /*************************************************************************************************/
00249         function languageBox() {
00250                 if( $this->data['language_urls'] ) {
00251 ?>
00252         <div id="p-lang" class="portlet">
00253                 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
00254                 <div class="pBody">
00255                         <ul>
00256 <?php           foreach($this->data['language_urls'] as $key => $langlink) { ?>
00257                                 <?php echo $this->makeListItem($key, $langlink); ?>
00258 
00259 <?php           } ?>
00260                         </ul>
00261                 </div>
00262         </div>
00263 <?php
00264                 }
00265         }
00266 
00267         /*************************************************************************************************/
00268         function customBox( $bar, $cont ) {
00269                 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ) );
00270                 $tooltip = Linker::titleAttrib( "p-$bar" );
00271                 if ( $tooltip !== false ) {
00272                         $portletAttribs['title'] = $tooltip;
00273                 }
00274                 echo '  ' . Html::openElement( 'div', $portletAttribs );
00275 ?>
00276 
00277                 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
00278                 <div class='pBody'>
00279 <?php   if ( is_array( $cont ) ) { ?>
00280                         <ul>
00281 <?php                   foreach($cont as $key => $val) { ?>
00282                                 <?php echo $this->makeListItem($key, $val); ?>
00283 
00284 <?php                   } ?>
00285                         </ul>
00286 <?php   } else {
00287                         # allow raw HTML block to be defined by extensions
00288                         print $cont;
00289                 }
00290 ?>
00291                 </div>
00292         </div>
00293 <?php
00294         }
00295 } // end of class
00296 
00297