/**
  * Get the link to users talk page
  * @return string
  */
 protected function getTalkLink()
 {
     // replace secondary icon
     $attrs = array('class' => MobileUI::iconClass('talk', 'before', MobileUI::buttonClass()), 'href' => $this->targetUser->getTalkPage()->getLocalUrl());
     // FIXME: What if this is the user's own profile? Should we change the message?
     return Html::element('a', $attrs, $this->msg('mobile-frontend-profile-usertalk', $this->targetUser->getName()));
 }
 /**
  * Build the login page
  * @todo Refactor this into parent template
  */
 public function execute()
 {
     $action = $this->data['action'];
     $token = $this->data['token'];
     $watchArticle = $this->getArticleTitleToWatch();
     $stickHTTPS = $this->doStickHTTPS() ? Html::input('wpStickHTTPS', 'true', 'hidden') : '';
     $username = strlen($this->data['name']) ? $this->data['name'] : null;
     // @TODO make sure this also includes returnto and returntoquery from the request
     $query = array('type' => 'signup');
     // Security: $action is already filtered by SpecialUserLogin
     $actionQuery = wfCgiToArray($action);
     if (isset($actionQuery['returnto'])) {
         $query['returnto'] = $actionQuery['returnto'];
     }
     if (isset($actionQuery['returntoquery'])) {
         $query['returntoquery'] = $actionQuery['returntoquery'];
         // Allow us to distinguish sign ups from the left nav to logins.
         // This allows us to show them an edit tutorial when they return to the page.
         if ($query['returntoquery'] === 'welcome=yes') {
             $query['returntoquery'] = 'campaign=leftNavSignup';
         }
     }
     // For Extension:Campaigns
     $campaign = $this->getSkin()->getRequest()->getText('campaign');
     if ($campaign) {
         $query['campaign'] = $campaign;
     }
     // Check for permission to create new account first
     $user = $this->getRequestContext()->getUser();
     if ($user->isAllowed('createaccount')) {
         $signupLink = Linker::link(SpecialPage::getTitleFor('Userlogin'), wfMessage('mobile-frontend-main-menu-account-create')->text(), array('class' => 'mw-mf-create-account mw-ui-block'), $query);
     } else {
         $signupLink = '';
     }
     // Check for permission to reset password first
     if ($this->data['canreset'] && $this->data['useemail'] && $this->data['resetlink'] === true) {
         $passwordReset = Html::element('a', array('class' => 'mw-userlogin-help mw-ui-block', 'href' => SpecialPage::getTitleFor('PasswordReset')->getLocalUrl()), wfMessage('passwordreset')->text());
     } else {
         $passwordReset = '';
     }
     $login = Html::openElement('div', array('id' => 'mw-mf-login', 'class' => 'content'));
     $form = Html::openElement('div', array()) . Html::openElement('form', array('name' => 'userlogin', 'class' => 'user-login', 'method' => 'post', 'action' => $action)) . Html::openElement('div', array('class' => 'inputs-box')) . Html::input('wpName', $username, 'text', array('class' => 'loginText', 'placeholder' => wfMessage('mobile-frontend-username-placeholder')->text(), 'id' => 'wpName1', 'tabindex' => '1', 'size' => '20', 'required')) . Html::input('wpPassword', null, 'password', array('class' => 'loginPassword', 'placeholder' => wfMessage('mobile-frontend-password-placeholder')->text(), 'id' => 'wpPassword1', 'tabindex' => '2', 'size' => '20')) . Html::closeElement('div') . Html::input('wpRemember', '1', 'hidden') . Html::input('wpLoginAttempt', wfMessage('mobile-frontend-login')->text(), 'submit', array('id' => 'wpLoginAttempt', 'class' => $baseClass = MobileUI::buttonClass('constructive'), 'tabindex' => '3')) . Html::input('wpLoginToken', $token, 'hidden') . Html::input('watch', $watchArticle, 'hidden') . $stickHTTPS . Html::closeElement('form') . $passwordReset . $signupLink . Html::closeElement('div');
     echo $login;
     $this->renderGuiderMessage();
     $this->renderMessageHtml();
     echo $form;
     echo Html::closeElement('div');
 }
 /**
  * Render Login/Create specific template
  * @todo refactor this into parent template
  */
 public function execute()
 {
     $action = $this->data['action'];
     $token = $this->data['token'];
     $watchArticle = $this->getArticleTitleToWatch();
     $stickHTTPS = $this->doStickHTTPS() ? Html::input('wpStickHTTPS', 'true', 'hidden') : '';
     $username = strlen($this->data['name']) ? $this->data['name'] : null;
     // handle captcha
     $captchaHtml = '';
     if (isset($this->data['header'])) {
         $captchaHtml .= $this->data['header'];
     }
     if (isset($this->data['extrafields'])) {
         $captchaHtml .= $this->data['extrafields'];
     }
     $captcha = $this->handleCaptcha($captchaHtml);
     $form = Html::openElement('form', array('name' => 'userlogin2', 'method' => 'post', 'class' => 'user-login', 'action' => $action, 'id' => 'userlogin2')) . Html::openElement('div', array('class' => 'inputs-box')) . Html::input('wpName', $username, 'text', array('class' => 'loginText', 'placeholder' => wfMessage('mobile-frontend-username-placeholder')->text(), 'id' => 'wpName1', 'tabindex' => '1', 'size' => '20', 'required')) . Html::input('wpPassword', null, 'password', array('class' => 'loginPassword', 'placeholder' => wfMessage('mobile-frontend-password-placeholder')->text(), 'id' => 'wpPassword2', 'tabindex' => '2', 'size' => '20')) . Html::input('wpRetype', null, 'password', array('class' => 'loginPassword', 'placeholder' => wfMessage('mobile-frontend-password-confirm-placeholder')->text(), 'id' => 'wpRetype', 'tabindex' => '3', 'size' => '20')) . Html::input('wpEmail', null, 'email', array('class' => 'loginText', 'placeholder' => wfMessage('mobile-frontend-account-create-email-placeholder')->text(), 'id' => 'wpEmail', 'tabindex' => '4', 'size' => '20')) . Html::closeElement('div') . $captcha . Html::input('wpCreateaccount', wfMessage('mobile-frontend-account-create-submit')->text(), 'submit', array('id' => 'wpCreateaccount', 'class' => MobileUI::buttonClass('constructive'), 'tabindex' => '6')) . Html::input('wpRemember', '1', 'hidden') . Html::input('wpCreateaccountToken', $token, 'hidden') . Html::input('watch', $watchArticle, 'hidden') . $stickHTTPS . Html::closeElement('form');
     echo Html::openElement('div', array('id' => 'mw-mf-accountcreate', 'class' => 'content'));
     $this->renderMessageHtml('signup', true);
     echo $form;
     echo Html::closeElement('div');
 }
 public function execute($par = '')
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->disallowUserJs();
     # Prevent hijacked user scripts from sniffing passwords etc.
     $this->requireLogin('prefsnologintext2');
     $this->checkReadOnly();
     if ($this->getRequest()->getCheck('success')) {
         $out->wrapWikiMsg("<div class=\"alert successbox\">\$1</div>", 'savedprefs');
     }
     if ($par && in_array($par, $this->validTabs)) {
         $htmlForm = $this->getPreferencesForm($par);
         $htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
         $htmlForm->show();
     } else {
         foreach ($this->validTabs as $tabName) {
             $attrs = array('class' => $baseClass = MobileUI::buttonClass('block'), 'href' => SpecialPage::getTitleFor($this->getName(), $tabName)->getLocalUrl());
             $button = Html::element('a', $attrs, $this->msg("prefs-{$tabName}"));
             $out->addHtml($button);
         }
     }
 }
    /**
     * Render the settings form (with actual set settings) to display to user
     */
    private function getSettingsForm()
    {
        $out = $this->getOutput();
        $context = MobileContext::singleton();
        $user = $this->getUser();
        $out->setPageTitle($this->msg('mobile-frontend-main-menu-settings-heading'));
        if ($this->getRequest()->getCheck('success')) {
            $out->wrapWikiMsg("<div class=\"successbox\"><strong>\n\$1\n</strong></div><div id=\"mw-pref-clear\"></div>", 'savedprefs');
        }
        $betaEnabled = $context->isBetaGroupMember();
        $imagesChecked = $context->imagesDisabled() ? '' : 'checked';
        // images are off when disabled
        $imagesBeta = $betaEnabled ? 'checked' : '';
        $imagesDescriptionMsg = $this->msg('mobile-frontend-settings-images-explain')->parse();
        $disableMsg = $this->msg('mobile-frontend-images-status')->parse();
        $betaEnableMsg = $this->msg('mobile-frontend-settings-beta')->parse();
        $betaDescriptionMsg = $this->msg('mobile-frontend-opt-in-explain')->parse();
        $saveSettings = $this->msg('mobile-frontend-save-settings')->escaped();
        $action = $this->getPageTitle()->getLocalURL();
        $html = Html::openElement('form', array('class' => 'mw-mf-settings', 'method' => 'POST', 'action' => $action));
        $token = $user->isLoggedIn() ? Html::hidden('token', $user->getEditToken()) : '';
        $returnto = Html::hidden('returnto', $this->returnToTitle->getFullText());
        // array to save the data of options, which should be displayed here
        $options = array();
        // image settings
        $options['images'] = array('checked' => $imagesChecked, 'label' => $disableMsg, 'description' => $imagesDescriptionMsg, 'name' => 'enableImages', 'id' => 'enable-images-toggle');
        // beta settings
        if ($this->getMFConfig()->get('MFEnableBeta')) {
            $options['beta'] = array('checked' => $imagesBeta, 'label' => $betaEnableMsg, 'description' => $betaDescriptionMsg, 'name' => 'enableBeta', 'id' => 'enable-beta-toggle');
        }
        $templateParser = new TemplateParser(__DIR__ . '/../../resources/mobile.special.mobileoptions.scripts');
        // @codingStandardsIgnoreStart Long line
        foreach ($options as $key => $data) {
            if (isset($data['type']) && $data['type'] === 'hidden') {
                $html .= Html::element('input', array('type' => 'hidden', 'name' => $data['name'], 'value' => $data['checked']));
            } else {
                $html .= $templateParser->processTemplate('checkbox', $data);
            }
        }
        $className = MobileUI::buttonClass('constructive');
        $html .= <<<HTML
\t\t<input type="submit" class="{$className}" id="mw-mf-settings-save" value="{$saveSettings}">
\t\t{$token}
\t\t{$returnto}
\t</form>
HTML;
        // @codingStandardsIgnoreEnd
        $out->addHTML($html);
    }
 /**
  * Get the header for the watchlist page
  * @param User user
  * @return string Parsed HTML
  */
 public static function getWatchlistHeader(User $user)
 {
     $sp = SpecialPage::getTitleFor('Watchlist');
     $attrsList = $attrsFeed = array();
     $view = $user->getOption(SpecialMobileWatchlist::VIEW_OPTION_NAME, 'a-z');
     $filter = $user->getOption(SpecialMobileWatchlist::FILTER_OPTION_NAME, 'all');
     if ($view === 'feed') {
         $attrsList['class'] = MobileUI::buttonClass();
         // FIXME [MediaWiki UI] This probably be described as a different type of mediawiki ui element
         $attrsFeed['class'] = MobileUI::buttonClass('progressive', 'active');
     } else {
         $attrsFeed['class'] = MobileUI::buttonClass();
         // FIXME [MediaWiki UI] This probably be described as a different type of mediawiki ui element
         $attrsList['class'] = MobileUI::buttonClass('progressive', 'active');
     }
     $html = Html::openElement('ul', array('class' => 'button-bar mw-ui-button-group')) . Html::openElement('li', $attrsList) . Linker::link($sp, wfMessage('mobile-frontend-watchlist-a-z')->text(), array('class' => 'button'), array('watchlistview' => 'a-z')) . Html::closeElement('li') . Html::openElement('li', $attrsFeed) . Linker::link($sp, wfMessage('mobile-frontend-watchlist-feed')->text(), array('class' => 'button'), array('watchlistview' => 'feed', 'filter' => $filter)) . Html::closeElement('li') . Html::closeElement('ul');
     return '<div class="content-header">' . $html . '</div>';
 }
 /**
  * Get HTML representing secondary page actions like language selector
  * @return string
  */
 protected function getSecondaryActionsHtml()
 {
     $baseClass = MobileUI::buttonClass('', 'button');
     $html = Html::openElement('div', array('id' => 'page-secondary-actions'));
     foreach ($this->getSecondaryActions() as $el) {
         if (isset($el['attributes']['class'])) {
             $el['attributes']['class'] .= ' ' . $baseClass;
         } else {
             $el['attributes']['class'] = $baseClass;
         }
         $html .= Html::element('a', $el['attributes'], $el['label']);
     }
     return $html . Html::closeElement('div');
 }