Exemple #1
0
    /**
     * Render Login-ext
     */
    function renderLoginExt($skin, $context)
    {
        global $wgUser, $wgRequest, $wgScript, $wgTweekiReturnto;
        if (session_id() == '') {
            wfSetupSession();
        }
        //build path for form action
        $returnto = $skin->getSkin()->getTitle()->getFullText();
        if ($returnto == SpecialPage::getTitleFor('UserLogin') || $returnto == SpecialPage::getTitleFor('UserLogout')) {
            $returnto = Title::newMainPage()->getFullText();
        }
        $returnto = $wgRequest->getVal('returnto', $returnto);
        if (isset($wgTweekiReturnto) && $returnto == Title::newMainPage()->getFullText()) {
            $returnto = $wgTweekiReturnto;
        }
        $action = $wgScript . '?title=special:userlogin&action=submitlogin&type=login&returnto=' . $returnto;
        //create login token if it doesn't exist
        if (!$wgRequest->getSessionData('wsLoginToken')) {
            $wgRequest->setSessionData('wsLoginToken', MWCryptRand::generateHex(32));
        }
        $wgUser->setCookies();
        $dropdown['class'] = ' dropdown-toggle';
        $dropdown['data-toggle'] = 'dropdown';
        $dropdown['text'] = $this->getMsg('userlogin')->text();
        $dropdown['html'] = $dropdown['text'] . ' <b class="caret"></b>';
        $dropdown['href'] = '#';
        $dropdown['type'] = 'button';
        $dropdown['id'] = 'n-login-ext';
        $renderedDropdown = TweekiHooks::makeLink($dropdown);
        echo '<li class="nav">
		' . $renderedDropdown . '
		<ul class="dropdown-menu" role="menu" aria-labelledby="' . $this->getMsg('userlogin')->text() . '" id="loginext">
			<form action="' . $action . '" method="post" name="userloginext" class="clearfix">
				<div class="form-group">
					<label for="wpName2" class="hidden-xs">
						' . $this->getMsg('userlogin-yourname')->text() . '
					</label>';
        echo Html::input('wpName', null, 'text', array('class' => 'form-control', 'id' => 'wpName2', 'tabindex' => '101', 'placeholder' => $this->getMsg('userlogin-yourname-ph')->text()));
        echo '</div>
				<div class="form-group">
					<label for="wpPassword2" class="hidden-xs">
						' . $this->getMsg('userlogin-yourpassword')->text() . '
					</label>';
        echo Html::input('wpPassword', null, 'password', array('class' => 'form-control', 'id' => 'wpPassword2', 'tabindex' => '102', 'placeholder' => $this->getMsg('userlogin-yourpassword-ph')->text()));
        echo '</div>
				<div class="form-group">
					<button type="submit" name="wpLoginAttempt" tabindex="103" id="wpLoginAttempt2" class="pull-right btn btn-default btn-block">
						' . $this->getMsg('pt-login-button')->text() . '
					</button>
				</div>
				<input type="hidden" value="' . $wgRequest->getSessionData('wsLoginToken') . '" name="wpLoginToken">
			</form>';
        if ($wgUser->isAllowed('createaccount')) {
            echo '<div>
				<a href="' . $wgScript . '?title=special:userlogin&amp;type=signup" class="btn btn-link center-block">
					' . $this->getMsg('createaccount')->text() . '
				</a>
			</div>';
        }
        echo '
		</ul>
		</li>';
        echo '<script>
			$( document ).ready( function() {
				$( "#n-login" ).click( function() {
					if( ! $( this ).parent().hasClass( "open" ) ) {
						setTimeout( \'$( "#wpName2" ).focus();\', 500 );
						}
				});
			});
			</script>';
    }
Exemple #2
0
 /**
  * Produce HTML for a list item
  * 
  * This is a slightly adapted copy of the makeListItem function in SkinTemplate.php
  * -> some of the changed parts are marked by comments //
  *
  * @param $item array
  * @param $options array
  */
 static function makeListItem($item, $options = array())
 {
     if (isset($item['links'])) {
         $html = '';
         foreach ($item['links'] as $linkKey => $link) {
             $html .= TweekiHooks::makeLink($link, $options);
         }
     } else {
         $link = $item;
         // These keys are used by makeListItem and shouldn't be passed on to the link
         foreach (array('id', 'class', 'active', 'tag') as $k) {
             unset($link[$k]);
         }
         if (isset($item['id']) && !isset($item['single-id'])) {
             // The id goes on the <li> not on the <a> for single links
             // but makeSidebarLink still needs to know what id to use when
             // generating tooltips and accesskeys.
             $link['single-id'] = $item['id'];
         }
         $html = TweekiHooks::makeLink($link, $options);
     }
     $attrs = array();
     foreach (array('id', 'class') as $attr) {
         if (isset($item[$attr])) {
             $attrs[$attr] = $item[$attr];
         }
     }
     if (isset($item['active']) && $item['active']) {
         if (!isset($attrs['class'])) {
             $attrs['class'] = '';
         }
         $attrs['class'] .= ' active';
         $attrs['class'] = trim($attrs['class']);
     }
     return Html::rawElement(isset($options['tag']) ? $options['tag'] : 'li', $attrs, $html);
 }