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