r79340 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79339‎ | r79340 | r79341 >
Date:15:26, 31 December 2010
Author:catrope
Status:ok
Tags:
Comment:
Revert changes to skins/Vector.php in r79129, they lead to fatal errors due to a botched merge (BaseTemplate code; see r79129 CR for details).
Modified paths:
  • /branches/REL1_17/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/skins/Vector.php
@@ -73,8 +73,6 @@
7474 $action = $wgRequest->getVal( 'action', 'view' );
7575 $section = $wgRequest->getVal( 'section' );
7676
77 - $userCanRead = $this->mTitle->userCanRead();
78 -
7977 // Checks if page is some kind of content
8078 if( $this->iscontent ) {
8179 // Gets page objects for the related namespaces
@@ -95,16 +93,16 @@
9694
9795 // Adds namespace links
9896 $links['namespaces'][$subjectId] = $this->tabAction(
99 - $subjectPage, 'nstab-' . $subjectId, !$isTalk, '', $userCanRead
 97+ $subjectPage, 'nstab-' . $subjectId, !$isTalk, '', true
10098 );
10199 $links['namespaces'][$subjectId]['context'] = 'subject';
102100 $links['namespaces'][$talkId] = $this->tabAction(
103 - $talkPage, 'talk', $isTalk, '', $userCanRead
 101+ $talkPage, 'talk', $isTalk, '', true
104102 );
105103 $links['namespaces'][$talkId]['context'] = 'talk';
106104
107105 // Adds view view link
108 - if ( $this->mTitle->exists() && $userCanRead ) {
 106+ if ( $this->mTitle->exists() ) {
109107 $links['views']['view'] = $this->tabAction(
110108 $isTalk ? $talkPage : $subjectPage,
111109 'vector-view-view', ( $action == 'view' ), '', true
@@ -115,8 +113,8 @@
116114
117115 // Checks if user can...
118116 if (
119 - // read and edit the current page
120 - $userCanRead && $this->mTitle->quickUserCan( 'edit' ) &&
 117+ // edit the current page
 118+ $this->mTitle->quickUserCan( 'edit' ) &&
121119 (
122120 // if it exists
123121 $this->mTitle->exists() ||
@@ -157,7 +155,7 @@
158156 }
159157 }
160158 // Checks if the page has some kind of viewable content
161 - } elseif ( $this->mTitle->hasSourceText() && $userCanRead ) {
 159+ } elseif ( $this->mTitle->hasSourceText() ) {
162160 // Adds view source view link
163161 $links['views']['viewsource'] = array(
164162 'class' => ( $action == 'edit' ) ? 'selected' : false,
@@ -171,7 +169,7 @@
172170 wfProfileIn( __METHOD__ . '-live' );
173171
174172 // Checks if the page exists
175 - if ( $this->mTitle->exists() && $userCanRead ) {
 173+ if ( $this->mTitle->exists() ) {
176174 // Adds history view link
177175 $links['views']['history'] = array(
178176 'class' => 'collapsible ' . ( ( $action == 'history' ) ? 'selected' : false ),
@@ -341,7 +339,7 @@
342340 * QuickTemplate class for Vector skin
343341 * @ingroup Skins
344342 */
345 -class VectorTemplate extends BaseTemplate {
 343+class VectorTemplate extends QuickTemplate {
346344
347345 /* Members */
348346
@@ -413,6 +411,37 @@
414412 $this->skin->tooltipAndAccesskey('pt-'.$key);
415413 }
416414
 415+ // Generate additional footer links
 416+ $footerlinks = $this->data["footerlinks"];
 417+
 418+ // Reduce footer links down to only those which are being used
 419+ $validFooterLinks = array();
 420+ foreach( $footerlinks as $category => $links ) {
 421+ $validFooterLinks[$category] = array();
 422+ foreach( $links as $link ) {
 423+ if( isset( $this->data[$link] ) && $this->data[$link] ) {
 424+ $validFooterLinks[$category][] = $link;
 425+ }
 426+ }
 427+ }
 428+
 429+ // Generate additional footer icons
 430+ $footericons = $this->data["footericons"];
 431+ // Unset any icons which don't have an image
 432+ foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
 433+ foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
 434+ if ( !is_string($footerIcon) && !isset($footerIcon["src"]) ) {
 435+ unset($footerIconsBlock[$footerIconKey]);
 436+ }
 437+ }
 438+ }
 439+ // Redo removal of any empty blocks
 440+ foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
 441+ if ( count($footerIconsBlock) <= 0 ) {
 442+ unset($footericons[$footerIconsKey]);
 443+ }
 444+ }
 445+
417446 // Reverse horizontally rendered navigation elements
418447 if ( $wgLang->isRTL() ) {
419448 $this->data['view_urls'] =
@@ -504,15 +533,18 @@
505534 <!-- /panel -->
506535 <!-- footer -->
507536 <div id="footer"<?php $this->html('userlangattributes') ?>>
508 - <?php foreach( $this->getFooterLinks() as $category => $links ): ?>
 537+ <?php foreach( $validFooterLinks as $category => $links ): ?>
 538+ <?php if ( count( $links ) > 0 ): ?>
509539 <ul id="footer-<?php echo $category ?>">
510540 <?php foreach( $links as $link ): ?>
 541+ <?php if( isset( $this->data[$link] ) && $this->data[$link] ): ?>
511542 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
 543+ <?php endif; ?>
512544 <?php endforeach; ?>
513545 </ul>
 546+ <?php endif; ?>
514547 <?php endforeach; ?>
515 - <?php $footericons = $this->getFooterIcons("icononly");
516 - if ( count( $footericons ) > 0 ): ?>
 548+<?php if ( count( $footericons ) > 0 ): ?>
517549 <ul id="footer-icons" class="noprint">
518550 <?php foreach ( $footericons as $blockName => $footerIcons ): ?>
519551 <li id="footer-<?php echo htmlspecialchars($blockName); ?>ico">
@@ -555,51 +587,83 @@
556588 case 'SEARCH':
557589 break;
558590 case 'TOOLBOX':
559 - $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
 591+?>
 592+<div class="portal" id="p-tb">
 593+ <h5<?php $this->html('userlangattributes') ?>><?php $this->msg( 'toolbox' ) ?></h5>
 594+ <div class="body">
 595+ <ul>
 596+ <?php if( $this->data['notspecialpage'] ): ?>
 597+ <li id="t-whatlinkshere"><a href="<?php echo htmlspecialchars( $this->data['nav_urls']['whatlinkshere']['href'] ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 't-whatlinkshere' ) ?>><?php $this->msg( 'whatlinkshere' ) ?></a></li>
 598+ <?php if( $this->data['nav_urls']['recentchangeslinked'] ): ?>
 599+ <li id="t-recentchangeslinked"><a href="<?php echo htmlspecialchars( $this->data['nav_urls']['recentchangeslinked']['href'] ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 't-recentchangeslinked' ) ?>><?php $this->msg( 'recentchangeslinked-toolbox' ) ?></a></li>
 600+ <?php endif; ?>
 601+ <?php endif; ?>
 602+ <?php if( isset( $this->data['nav_urls']['trackbacklink'] ) ): ?>
 603+ <li id="t-trackbacklink"><a href="<?php echo htmlspecialchars( $this->data['nav_urls']['trackbacklink']['href'] ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 't-trackbacklink' ) ?>><?php $this->msg( 'trackbacklink' ) ?></a></li>
 604+ <?php endif; ?>
 605+ <?php if( $this->data['feeds']): ?>
 606+ <li id="feedlinks">
 607+ <?php foreach( $this->data['feeds'] as $key => $feed ): ?>
 608+ <a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php 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>
 609+ <?php endforeach; ?>
 610+ </li>
 611+ <?php endif; ?>
 612+ <?php foreach( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ): ?>
 613+ <?php if( $this->data['nav_urls'][$special]): ?>
 614+ <li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars( $this->data['nav_urls'][$special]['href'] ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 't-' . $special ) ?>><?php $this->msg( $special ) ?></a></li>
 615+ <?php endif; ?>
 616+ <?php endforeach; ?>
 617+ <?php if( !empty( $this->data['nav_urls']['print']['href'] ) ): ?>
 618+ <li id="t-print"><a href="<?php echo htmlspecialchars( $this->data['nav_urls']['print']['href'] ) ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey( 't-print' ) ?>><?php $this->msg( 'printableversion' ) ?></a></li>
 619+ <?php endif; ?>
 620+ <?php if ( !empty( $this->data['nav_urls']['permalink']['href'] ) ): ?>
 621+ <li id="t-permalink"><a href="<?php echo htmlspecialchars( $this->data['nav_urls']['permalink']['href'] ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 't-permalink' ) ?>><?php $this->msg( 'permalink' ) ?></a></li>
 622+ <?php elseif ( $this->data['nav_urls']['permalink']['href'] === '' ): ?>
 623+ <li id="t-ispermalink"<?php echo $this->skin->tooltip( 't-ispermalink' ) ?>><?php $this->msg( 'permalink' ) ?></li>
 624+ <?php endif; ?>
 625+ <?php wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); ?>
 626+ </ul>
 627+ </div>
 628+</div>
 629+<?php
560630 break;
561631 case 'LANGUAGES':
562632 if ( $this->data['language_urls'] ) {
563 - $this->renderPortal("lang", $this->data['language_urls'], "otherlanguages");
 633+?>
 634+<div class="portal" id="p-lang">
 635+ <h5<?php $this->html('userlangattributes') ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
 636+ <div class="body">
 637+ <ul>
 638+ <?php foreach ( $this->data['language_urls'] as $langlink ): ?>
 639+ <li class="<?php echo htmlspecialchars( $langlink['class'] ) ?>"><a href="<?php echo htmlspecialchars( $langlink['href'] ) ?>" title="<?php echo htmlspecialchars( $langlink['title'] ) ?>"><?php echo $langlink['text'] ?></a></li>
 640+ <?php endforeach; ?>
 641+ </ul>
 642+ </div>
 643+</div>
 644+<?php
564645 }
565646 break;
566647 default:
567 - $this->renderPortal($name, $content);
568 - break;
569 - }
570 - echo "\n<!-- /{$name} -->\n";
571 - }
572 - }
573 -
574 - private function renderPortal($name, $content, $msg=null, $hook=null) {
575 - if ( !isset($msg) ) {
576 - $msg = $name;
577 - }
578 - ?>
 648+?>
579649 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $name ) ?>>
580 - <h5<?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $msg ); if ( wfEmptyMsg( $msg, $out ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?></h5>
 650+ <h5<?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $name ); if ( wfEmptyMsg( $name, $out ) ) echo htmlspecialchars( $name ); else echo htmlspecialchars( $out ); ?></h5>
581651 <div class="body">
582 -<?php
583 - if ( is_array( $content ) ): ?>
 652+ <?php if ( is_array( $content ) ): ?>
584653 <ul>
585 -<?php
586 - foreach( $content as $key => $val ): ?>
587 - <?php echo $this->makeListItem($key, $val); ?>
588 -
589 -<?php
590 - endforeach;
591 - if ( isset($hook) ) {
592 - wfRunHooks( $hook, array( &$this ) );
593 - }
594 - ?>
 654+ <?php foreach( $content as $val ): ?>
 655+ <li id="<?php echo Sanitizer::escapeId( $val['id'] ) ?>"<?php if ( $val['active'] ): ?> class="active" <?php endif; ?>><a href="<?php echo htmlspecialchars( $val['href'] ) ?>"<?php echo $this->skin->tooltipAndAccesskey( $val['id'] ) ?>><?php echo htmlspecialchars( $val['text'] ) ?></a></li>
 656+ <?php endforeach; ?>
595657 </ul>
596 -<?php
597 - else: ?>
 658+ <?php else: ?>
598659 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
599 -<?php
600 - endif; ?>
 660+ <?php endif; ?>
601661 </div>
602662 </div>
603663 <?php
 664+ break;
 665+ }
 666+ echo "\n<!-- /{$name} -->\n";
 667+ }
604668 }
605669
606670 /**
@@ -702,18 +766,13 @@
703767 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
704768 <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
705769 <div id="simpleSearch">
706 - <?php if ( $this->data['rtl'] ): ?>
707 - <?php echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin->getSkinStylePath('images/search-rtl.png') )); ?>
708 - <?php endif; ?>
709 - <?php echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?>
710 - <?php if ( !$this->data['rtl'] ): ?>
711 - <?php echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin->getSkinStylePath('images/search-ltr.png') )); ?>
712 - <?php endif; ?>
 770+ <input id="searchInput" name="search" type="text" <?php echo $this->skin->tooltipAndAccesskey( 'search' ); ?> <?php if( isset( $this->data['search'] ) ): ?> value="<?php $this->text( 'search' ) ?>"<?php endif; ?> />
 771+ <button id="searchButton" type='submit' name='button' <?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?>><img src="<?php echo $this->skin->getSkinStylePath('images/search-' . ( $this->data['rtl'] ? 'rtl' : 'ltr' ) . '.png'); ?>" alt="<?php $this->msg( 'searchbutton' ) ?>" /></button>
713772 </div>
714773 <?php else: ?>
715 - <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
716 - <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?>
717 - <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?>
 774+ <input id="searchInput" name="search" type="text" <?php echo $this->skin->tooltipAndAccesskey( 'search' ); ?> <?php if( isset( $this->data['search'] ) ): ?> value="<?php $this->text( 'search' ) ?>"<?php endif; ?> />
 775+ <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg( 'searcharticle' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />
 776+ <input type="submit" name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg( 'searchbutton' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
718777 <?php endif; ?>
719778 </form>
720779 </div>

Follow-up revisions

RevisionCommit summaryAuthorDate
r79341Follow-up r79340: merge r78117, r78170, r78172 and r78506 from trunk into ski...catrope15:48, 31 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79129MFT r78011 r78014 r78015 r78016 r78099 r78117 r78161 r78170 r78172 r78199 r78......platonides19:58, 28 December 2010

Status & tagging log