Test normalizeForSearch and commafy
[lhc/web/wiklou.git] / skins / Vector.php
index 2217de8..4da6bf3 100644 (file)
@@ -37,7 +37,7 @@ class SkinVector extends SkinTemplate {
                $out->addScript(
                        '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
                                htmlspecialchars( $wgLocalStylePath ) .
-                               '/vector/csshover.htc")}</style><![endif]-->'
+                               "/{$this->stylename}/csshover.htc\")}</style><![endif]-->"
                );
        }
 
@@ -47,21 +47,8 @@ class SkinVector extends SkinTemplate {
         * @param $out OutputPage object
         */
        function setupSkinUserCss( OutputPage $out ){
-               global $wgVectorExtraStyles;
-
                parent::setupSkinUserCss( $out );
-
-               // Append skin-specific styles
-               $out->addStyle( 'vector/main-rtl.css', 'screen', '', 'rtl' );
-               $out->addStyle( 'vector/main-ltr.css', 'screen', '', 'ltr' );
-
-               // Add extra stylesheets
-               // THIS IS ONLY USEFUL FOR EXPERIMENTING WITH DIFFERNT STYLE OPTIONS! THIS WILL BE REMOVED IN THE NEAR FUTURE.
-               if ( is_array( $wgVectorExtraStyles ) ) {
-                       foreach ( $wgVectorExtraStyles as $style ) {
-                               $out->addStyle( 'vector/' . $style, 'screen' );
-                       }
-               }
+               $out->addModuleStyles( 'skins.vector' );
        }
 
        /**
@@ -103,15 +90,14 @@ class SkinVector extends SkinTemplate {
                        } else {
                                $talkId = "{$subjectId}_talk";
                        }
-                       $currentId = $isTalk ? $talkId : $subjectId;
 
                        // Adds namespace links
                        $links['namespaces'][$subjectId] = $this->tabAction(
-                               $subjectPage, 'vector-namespace-' . $subjectId, !$isTalk, '', true
+                               $subjectPage, 'nstab-' . $subjectId, !$isTalk, '', true
                        );
                        $links['namespaces'][$subjectId]['context'] = 'subject';
                        $links['namespaces'][$talkId] = $this->tabAction(
-                               $talkPage, 'vector-namespace-talk', $isTalk, '', true
+                               $talkPage, 'talk', $isTalk, '', true
                        );
                        $links['namespaces'][$talkId]['context'] = 'talk';
 
@@ -154,7 +140,7 @@ class SkinVector extends SkinTemplate {
                                );
                                // Checks if this is a current rev of talk page and we should show a new
                                // section link
-                               if ( ( $isTalk && $wgArticle->isCurrent() ) || ( $wgOut->showNewSectionLink() ) ) {
+                               if ( ( $isTalk && $wgArticle && $wgArticle->isCurrent() ) || ( $wgOut->showNewSectionLink() ) ) {
                                        // Checks if we should ever show a new section link
                                        if ( !$wgOut->forceHideNewSectionLink() ) {
                                                // Adds new section link
@@ -240,7 +226,8 @@ class SkinVector extends SkinTemplate {
                                        $wgUser->isAllowed( 'deletedhistory' ) &&
                                        $wgUser->isAllowed( 'undelete' )
                                ) {
-                                       if( $n = $this->mTitle->isDeleted() ) {
+                                       $n = $this->mTitle->isDeleted();
+                                       if( $n ) {
                                                $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
                                                $links['actions']['undelete'] = array(
                                                        'class' => false,
@@ -293,7 +280,7 @@ class SkinVector extends SkinTemplate {
                        // Checks if the user is logged in
                        if ( $this->loggedin ) {
                                if ( $wgVectorUseIconWatch ) {
-                                       $class = 'icon ';
+                                       $class = 'icon';
                                        $place = 'views';
                                } else {
                                        $class = '';
@@ -313,7 +300,7 @@ class SkinVector extends SkinTemplate {
                } else {
                        $links['namespaces']['special'] = array(
                                'class' => 'selected',
-                               'text' => wfMsg( 'vector-namespace-special' ),
+                               'text' => wfMsg( 'nstab-special' ),
                                'href' => $wgRequest->getRequestURL()
                        );
                }
@@ -367,7 +354,7 @@ class VectorTemplate extends QuickTemplate {
         * Outputs the entire contents of the XHTML page
         */
        public function execute() {
-               global $wgRequest, $wgOut, $wgContLang;
+               global $wgRequest, $wgLang;
 
                $this->skin = $this->data['skin'];
                $action = $wgRequest->getText( 'action' );
@@ -459,7 +446,7 @@ class VectorTemplate extends QuickTemplate {
                        }
                }
                // Reverse horizontally rendered navigation elements
-               if ( $wgContLang->isRTL() ) {
+               if ( $wgLang->isRTL() ) {
                        $this->data['view_urls'] =
                                array_reverse( $this->data['view_urls'] );
                        $this->data['namespace_urls'] =
@@ -487,7 +474,7 @@ class VectorTemplate extends QuickTemplate {
                        <!-- bodyContent -->
                        <div id="bodyContent">
                                <!-- tagline -->
-                               <h3 id="siteSub"><?php $this->msg( 'tagline' ) ?></h3>
+                               <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
                                <!-- /tagline -->
                                <!-- subtitle -->
                                <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html( 'subtitle' ) ?></div>
@@ -563,10 +550,10 @@ class VectorTemplate extends QuickTemplate {
                        <div style="clear:both"></div>
                </div>
                <!-- /footer -->
+               <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
                <!-- fixalpha -->
                <script type="<?php $this->text('jsmimetype') ?>"> if ( window.isMSIE55 ) fixalpha(); </script>
                <!-- /fixalpha -->
-               <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
                <?php $this->html( 'reporttime' ) ?>
                <?php if ( $this->data['debug'] ): ?>
                <!-- Debug output: <?php $this->text( 'debug' ); ?> -->
@@ -639,7 +626,7 @@ class VectorTemplate extends QuickTemplate {
        <div class="body">
                <ul>
                <?php foreach ( $this->data['language_urls'] as $langlink ): ?>
-                       <li class="<?php echo htmlspecialchars(  $langlink['class'] ) ?>"><a href="<?php echo htmlspecialchars( $langlink['href'] ) ?>"><?php echo $langlink['text'] ?></a></li>
+                       <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>
                <?php endforeach; ?>
                </ul>
        </div>
@@ -654,7 +641,7 @@ class VectorTemplate extends QuickTemplate {
        <div class="body">
                <?php if ( is_array( $content ) ): ?>
                <ul>
-               <?php foreach( $content as $key => $val ): ?>
+               <?php foreach( $content as $val ): ?>
                        <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>
                <?php endforeach; ?>
                </ul>
@@ -675,14 +662,14 @@ class VectorTemplate extends QuickTemplate {
         * when UI is in RTL mode
         */
        private function renderNavigation( $elements ) {
-               global $wgContLang, $wgVectorUseSimpleSearch, $wgVectorShowVariantName;
+               global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
 
                // If only one element was given, wrap it in an array, allowing more
                // flexible arguments
                if ( !is_array( $elements ) ) {
                        $elements = array( $elements );
                // If there's a series of elements, reverse them when in RTL mode
-               } else if ( $wgContLang->isRTL() ) {
+               } else if ( wfUILang()->isRTL() ) {
                        $elements = array_reverse( $elements );
                }
                // Render elements
@@ -694,8 +681,8 @@ class VectorTemplate extends QuickTemplate {
 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
        <h5><?php $this->msg('namespaces') ?></h5>
        <ul<?php $this->html('userlangattributes') ?>>
-               <?php foreach ($this->data['namespace_urls'] as $key => $link ): ?>
-                       <li <?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><span><?php echo htmlspecialchars( $link['text'] ) ?></span></a></li>
+               <?php foreach ($this->data['namespace_urls'] as $link ): ?>
+                       <li <?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></span></li>
                <?php endforeach; ?>
        </ul>
 </div>
@@ -706,7 +693,7 @@ class VectorTemplate extends QuickTemplate {
 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
        <?php if ( $wgVectorShowVariantName ): ?>
                <h4>
-               <?php foreach ( $this->data['variant_urls'] as $key => $link ): ?>
+               <?php foreach ( $this->data['variant_urls'] as $link ): ?>
                        <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
                                <?php echo htmlspecialchars( $link['text'] ) ?>
                        <?php endif; ?>
@@ -716,7 +703,7 @@ class VectorTemplate extends QuickTemplate {
        <h5><span><?php $this->msg('variants') ?></span><a href="#"></a></h5>
        <div class="menu">
                <ul<?php $this->html('userlangattributes') ?>>
-                       <?php foreach ( $this->data['variant_urls'] as $key => $link ): ?>
+                       <?php foreach ( $this->data['variant_urls'] as $link ): ?>
                                <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                        <?php endforeach; ?>
                </ul>
@@ -729,8 +716,8 @@ class VectorTemplate extends QuickTemplate {
 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
        <h5><?php $this->msg('views') ?></h5>
        <ul<?php $this->html('userlangattributes') ?>>
-               <?php foreach ( $this->data['view_urls'] as $key => $link ): ?>
-                       <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo (array_key_exists('img',$link) ?  '<img src="'.$link['img'].'" alt="'.$link['text'].'" />' : '<span>'.htmlspecialchars( $link['text'] ).'</span>') ?></a></li>
+               <?php foreach ( $this->data['view_urls'] as $link ): ?>
+                       <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo (array_key_exists('img',$link) ?  '<img src="'.$link['img'].'" alt="'.$link['text'].'" />' : htmlspecialchars( $link['text'] ) ) ?></a></span></li>
                <?php endforeach; ?>
        </ul>
 </div>
@@ -742,7 +729,7 @@ class VectorTemplate extends QuickTemplate {
        <h5><span><?php $this->msg('actions') ?></span><a href="#"></a></h5>
        <div class="menu">
                <ul<?php $this->html('userlangattributes') ?>>
-                       <?php foreach ($this->data['action_urls'] as $key => $link ): ?>
+                       <?php foreach ($this->data['action_urls'] as $link ): ?>
                                <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
                        <?php endforeach; ?>
                </ul>
@@ -755,7 +742,7 @@ class VectorTemplate extends QuickTemplate {
 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
        <h5><?php $this->msg('personaltools') ?></h5>
        <ul<?php $this->html('userlangattributes') ?>>
-               <?php foreach($this->data['personal_urls'] as $key => $item): ?>
+               <?php foreach($this->data['personal_urls'] as $item): ?>
                        <li <?php echo $item['attributes'] ?>><a href="<?php echo htmlspecialchars($item['href']) ?>"<?php echo $item['key'] ?><?php if(!empty($item['class'])): ?> class="<?php echo htmlspecialchars($item['class']) ?>"<?php endif; ?>><?php echo htmlspecialchars($item['text']) ?></a></li>
                <?php endforeach; ?>
        </ul>
@@ -768,10 +755,10 @@ class VectorTemplate extends QuickTemplate {
        <h5<?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
        <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
                <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
-               <?php if ( $wgVectorUseSimpleSearch ): ?>
+               <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
                <div id="simpleSearch">
                        <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; ?> />
-                       <button id="searchButton" type='submit' name='button' <?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?>>&#160;</button>
+                       <button id="searchButton" type='submit' name='button' <?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?>><img src="<?php echo $GLOBALS['wgStylePath'] . "/{$this->skin->stylename}/images/search-" . ( $GLOBALS['wgContLang']->isRTL() ? 'rtl' : 'ltr' ) . '.png?' . $GLOBALS['wgStyleVersion'] ?>" alt="<?php $this->msg( 'searchbutton' ) ?>" /></button>
                </div>
                <?php else: ?>
                <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; ?> />