function getInputHTML($value)
 {
     $valInSelect = false;
     if ($value !== false) {
         $value = strval($value);
         $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true);
     }
     $selected = $valInSelect ? $value : 'other';
     $select = new XmlSelect($this->mName, $this->mID, $selected);
     $select->addOptions($this->getOptions());
     $select->setAttribute('class', 'mw-htmlform-select-or-other');
     $tbAttribs = array('id' => $this->mID . '-other', 'size' => $this->getSize());
     if (!empty($this->mParams['disabled'])) {
         $select->setAttribute('disabled', 'disabled');
         $tbAttribs['disabled'] = 'disabled';
     }
     if (isset($this->mParams['tabindex'])) {
         $select->setAttribute('tabindex', $this->mParams['tabindex']);
         $tbAttribs['tabindex'] = $this->mParams['tabindex'];
     }
     $select = $select->getHTML();
     if (isset($this->mParams['maxlength'])) {
         $tbAttribs['maxlength'] = $this->mParams['maxlength'];
     }
     if ($this->mClass !== '') {
         $tbAttribs['class'] = $this->mClass;
     }
     $textbox = Html::input($this->mName . '-other', $valInSelect ? '' : $value, 'text', $tbAttribs);
     return "{$select}<br />\n{$textbox}";
 }
 function getInputHTML($value)
 {
     $select = new XmlSelect($this->mName, $this->mID, strval($value));
     if (!empty($this->mParams['disabled'])) {
         $select->setAttribute('disabled', 'disabled');
     }
     if (isset($this->mParams['tabindex'])) {
         $select->setAttribute('tabindex', $this->mParams['tabindex']);
     }
     if ($this->mClass !== '') {
         $select->setAttribute('class', $this->mClass);
     }
     $select->addOptions($this->getOptions());
     return $select->getHTML();
 }
	protected function showToolbar() {
		$langSelector = Xml::languageSelector( $this->lang );

		$fontSelector = new XmlSelect();
		$fontSelector->setAttribute( 'id', 'webfonts-font-chooser' );

		$sizeSelector = new XmlSelect();
		$sizeSelector->setAttribute( 'id', 'webfonts-size-chooser' );
		for ( $size = 8; $size <= 28; $size += 2 ) {
			$sizeSelector->addOption( $size , $size );
		}
		$sizeSelector->setDefault( 16 );

		$bold = Html::Element( 'button', array( 'id' => 'webfonts-preview-bold' )  , 'B' );

		$italic = Html::Element( 'button', array( 'id' => 'webfonts-preview-italic' ) , 'I' );

		$underline = Html::Element( 'button', array( 'id' => 'webfonts-preview-underline' ) ,  'U' );

		$download  = Html::Element( 'a', array( 'id' => 'webfonts-preview-download', 'href' => '#' ) ,
			wfMsg( 'webfonts-preview-download' ) );

		return Html::openElement( 'div', array( 'id' => 'webfonts-preview-toolbar' ) )
			. $langSelector[1]
			. $fontSelector->getHtml()
			. $sizeSelector->getHtml()
			. $bold
			. $italic
			. $underline
			. $download
			. Html::closeElement( 'div' );
	}
Example #4
0
 function getInputHTML($value)
 {
     $select = new XmlSelect($this->mName, $this->mID, strval($value));
     if (!empty($this->mParams['disabled'])) {
         $select->setAttribute('disabled', 'disabled');
     }
     $allowedParams = ['tabindex', 'size'];
     $customParams = $this->getAttributes($allowedParams);
     foreach ($customParams as $name => $value) {
         $select->setAttribute($name, $value);
     }
     if ($this->mClass !== '') {
         $select->setAttribute('class', $this->mClass);
     }
     $select->addOptions($this->getOptions());
     return $select->getHTML();
 }
Example #5
0
 /**
  * @covers XmlSelect::setAttribute
  * @covers XmlSelect::getAttribute
  */
 public function testGetAttributes()
 {
     # create some attributes
     $this->select->setAttribute('dummy', 0x777);
     $this->select->setAttribute('string', 'euro €');
     $this->select->setAttribute(1911, 'razor');
     # verify we can retrieve them
     $this->assertEquals($this->select->getAttribute('dummy'), 0x777);
     $this->assertEquals($this->select->getAttribute('string'), 'euro €');
     $this->assertEquals($this->select->getAttribute(1911), 'razor');
     # inexistant keys should give us 'null'
     $this->assertEquals($this->select->getAttribute('I DO NOT EXIT'), null);
     # verify string / integer
     $this->assertEquals($this->select->getAttribute('1911'), 'razor');
     $this->assertEquals($this->select->getAttribute('dummy'), 0x777);
 }
Example #6
0
 /**
  * Build protection level selector
  *
  * @param string $action Action to protect
  * @param string $selected Current protection level
  * @return string HTML fragment
  */
 function buildSelector($action, $selected)
 {
     // If the form is disabled, display all relevant levels. Otherwise,
     // just show the ones this user can use.
     $levels = MWNamespace::getRestrictionLevels($this->mTitle->getNamespace(), $this->disabled ? null : $this->mContext->getUser());
     $id = 'mwProtect-level-' . $action;
     $select = new XmlSelect($id, $id, $selected);
     $select->setAttribute('size', count($levels));
     if ($this->disabled) {
         $select->setAttribute('disabled', 'disabled');
     }
     foreach ($levels as $key) {
         $select->addOption($this->getOptionLabel($key), $key);
     }
     return $select->getHTML();
 }
Example #7
0
    function execute()
    {
        global $wgCookieExpiration;
        $expirationDays = ceil($wgCookieExpiration / (3600 * 24));
        ?>
<div class="mw-ui-container">
	<div id="userloginprompt"><?php 
        $this->msgWiki('loginprompt');
        ?>
</div>
	<?php 
        if ($this->haveData('languages')) {
            ?>
		<div id="languagelinks">
			<p><?php 
            $this->html('languages');
            ?>
</p>
		</div>
	<?php 
        }
        ?>
	<div id="userloginForm">
		<form name="userlogin" class="mw-ui-vform" method="post" action="<?php 
        $this->text('action');
        ?>
">
			<?php 
        if ($this->data['loggedin']) {
            ?>
				<div class="warningbox">
					<?php 
            echo $this->getMsg('userlogin-loggedin')->params($this->data['loggedinuser'])->parse();
            ?>
				</div>
			<?php 
        }
        ?>
			<section class="mw-form-header">
				<?php 
        $this->html('header');
        /* extensions such as ConfirmEdit add form HTML here */
        ?>
			</section>

			<?php 
        if ($this->data['message']) {
            ?>
				<div class="<?php 
            $this->text('messagetype');
            ?>
box">
					<?php 
            if ($this->data['messagetype'] == 'error') {
                ?>
						<strong><?php 
                $this->msg('loginerror');
                ?>
</strong>
						<br />
					<?php 
            }
            ?>
					<?php 
            $this->html('message');
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->data['formheader']) {
            ?>
				<div class="mw-form-formheader">
					<?php 
            $this->html('formheader');
            /* extensions such as MobileFrontend add HTML here */
            ?>
				</div>
			<?php 
        }
        ?>
			<div class="mw-ui-vform-field">
				<label for="wpName1">
					<?php 
        $this->msg('userlogin-yourname');
        if ($this->data['secureLoginUrl']) {
            echo Html::element('a', ['href' => $this->data['secureLoginUrl'], 'class' => 'mw-ui-flush-right mw-secure'], $this->getMsg('userlogin-signwithsecure')->text());
        }
        ?>
				</label>
				<?php 
        echo Html::input('wpName', $this->data['name'], 'text', ['class' => 'loginText mw-ui-input', 'id' => 'wpName1', 'tabindex' => '1', 'required' => true, 'autofocus' => !$this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourname-ph')->text()]);
        ?>
			</div>

			<div class="mw-ui-vform-field">
				<label for="wpPassword1">
					<?php 
        $this->msg('userlogin-yourpassword');
        ?>
				</label>
				<?php 
        echo Html::input('wpPassword', null, 'password', ['class' => 'loginPassword mw-ui-input', 'id' => 'wpPassword1', 'tabindex' => '2', 'autofocus' => (bool) $this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourpassword-ph')->text()]);
        ?>
			</div>

			<?php 
        if (isset($this->data['usedomain']) && $this->data['usedomain']) {
            $select = new XmlSelect('wpDomain', false, $this->data['domain']);
            $select->setAttribute('tabindex', 3);
            foreach ($this->data['domainnames'] as $dom) {
                $select->addOption($dom);
            }
            ?>
				<div class="mw-ui-vform-field" id="mw-user-domain-section">
					<label for="wpDomain"><?php 
            $this->msg('yourdomainname');
            ?>
</label>
					<?php 
            echo $select->getHTML();
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->haveData('extrafields')) {
            echo $this->data['extrafields'];
        }
        ?>

			<div class="mw-ui-vform-field">
				<?php 
        if ($this->data['canremember']) {
            ?>
					<div class="mw-ui-checkbox">
						<input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
							<?php 
            if ($this->data['remember']) {
                echo 'checked="checked"';
            }
            ?>
						><label for="wpRemember">
							<?php 
            echo $this->getMsg('userlogin-remembermypassword')->numParams($expirationDays)->escaped();
            ?>
</label>
					</div>
				<?php 
        }
        ?>
			</div>

			<div class="mw-ui-vform-field">
				<?php 
        $attrs = ['id' => 'wpLoginAttempt', 'name' => 'wpLoginAttempt', 'tabindex' => '6'];
        $modifiers = ['mw-ui-progressive'];
        echo Html::submitButton($this->getMsg('pt-login-button')->text(), $attrs, $modifiers);
        ?>
			</div>

			<div class="mw-ui-vform-field mw-form-related-link-container" id="mw-userlogin-help">
				<?php 
        echo Html::element('a', ['href' => Skin::makeInternalOrExternalUrl(wfMessage('helplogin-url')->inContentLanguage()->text())], $this->getMsg('userlogin-helplink2')->text());
        ?>
			</div>
			<?php 
        if ($this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true) {
            echo Html::rawElement('div', ['class' => 'mw-ui-vform-field mw-form-related-link-container'], Linker::link(SpecialPage::getTitleFor('PasswordReset'), $this->getMsg('userlogin-resetpassword-link')->escaped()));
        }
        if ($this->haveData('createOrLoginHref')) {
            if ($this->data['loggedin']) {
                ?>
					<div class="mw-form-related-link-container mw-ui-vform-field">
						<a href="<?php 
                $this->text('createOrLoginHref');
                ?>
" id="mw-createaccount-join" tabindex="7"><?php 
                $this->msg('userlogin-createanother');
                ?>
</a>
					</div>
				<?php 
            } else {
                ?>
					<div id="mw-createaccount-cta" class="mw-ui-vform-field">
						<?php 
                $this->msg('userlogin-noaccount');
                ?>
<a href="<?php 
                $this->text('createOrLoginHref');
                ?>
" id="mw-createaccount-join" tabindex="7" class="mw-ui-button"><?php 
                $this->msg('userlogin-joinproject');
                ?>
</a>
					</div>
				<?php 
            }
        }
        // Hidden fields
        $fields = '';
        if ($this->haveData('uselang')) {
            $fields .= Html::hidden('uselang', $this->data['uselang']);
        }
        if ($this->haveData('token')) {
            $fields .= Html::hidden('wpLoginToken', $this->data['token']);
        }
        if ($this->data['cansecurelogin']) {
            $fields .= Html::hidden('wpForceHttps', $this->data['stickhttps']);
        }
        if ($this->data['cansecurelogin'] && $this->haveData('fromhttp')) {
            $fields .= Html::hidden('wpFromhttp', $this->data['fromhttp']);
        }
        echo $fields;
        ?>
		</form>
	</div>
</div>
<?php 
    }
Example #8
0
 protected function getWorkflowStatus()
 {
     global $wgTranslateWorkflowStates, $wgUser;
     if (!$wgTranslateWorkflowStates) {
         return false;
     }
     if (MessageGroups::isDynamic($this->group)) {
         return false;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $current = $dbr->selectField('translate_groupreviews', 'tgr_state', array('tgr_group' => $this->options['group'], 'tgr_lang' => $this->options['language']), __METHOD__);
     if ($wgUser->isAllowed('translate-groupreview')) {
         $selector = new XmlSelect('workflow');
         $selector->setAttribute('class', 'mw-translate-workflowselector');
         $selector->setDefault($current);
         $selector->addOption(wfMessage('translate-workflow-state-')->text(), '');
         foreach (array_keys($wgTranslateWorkflowStates) as $state) {
             $stateMessage = wfMessage("translate-workflow-state-{$state}");
             $stateText = $stateMessage->isBlank() ? $state : $stateMessage->text();
             $selector->addOption($stateText, $state);
         }
         $state = $selector->getHTML();
         $attributes = array('type' => 'button', 'id' => 'mw-translate-workflowset', 'data-token' => ApiGroupReview::getToken(0, ''), 'data-group' => $this->options['group'], 'data-language' => $this->options['language'], 'style' => 'visibility: hidden;', 'value' => 'Set');
         $state .= Html::element('input', $attributes);
     } elseif (strval($current) !== '') {
         $state = $current;
     } else {
         $state = wfMessage('translate-workflow-state-')->escaped();
     }
     $message = wfMessage('translate-workflowstatus')->rawParams($state);
     $box = Html::rawElement('div', array('id' => 'mw-sp-translate-workflow'), $message->escaped());
     return $box;
 }
Example #9
0
	/**
	 * Get a "<select>" element which has options for each of the allowed limits
	 *
	 * @param $attribs String: Extra attributes to set
	 * @return String: HTML fragment
	 */
	public function getLimitSelect( $attribs = array() ) {
		$select = new XmlSelect( 'limit', false, $this->mLimit );
		$select->addOptions( $this->getLimitSelectList() );
		foreach ( $attribs as $name => $value ) {
			$select->setAttribute( $name, $value );
		}
		return $select->getHTML();
	}
Example #10
0
 /**
  * Returns a <select multiple> element with a list of change tags that can be
  * applied by users.
  *
  * @param array $selectedTags The tags that should be preselected in the
  * list. Any tags in this list, but not in the list returned by
  * ChangeTags::listExplicitlyDefinedTags, will be appended to the <select>
  * element.
  * @param string $label The text of a <label> to precede the <select>
  * @return array HTML <label> element at index 0, HTML <select> element at
  * index 1
  */
 protected function getTagSelect($selectedTags, $label)
 {
     $result = [];
     $result[0] = Xml::label($label, 'mw-edittags-tag-list');
     $select = new XmlSelect('wpTagList[]', 'mw-edittags-tag-list', $selectedTags);
     $select->setAttribute('multiple', 'multiple');
     $select->setAttribute('size', '8');
     $tags = ChangeTags::listExplicitlyDefinedTags();
     $tags = array_unique(array_merge($tags, $selectedTags));
     // Values of $tags are also used as <option> labels
     $select->addOptions(array_combine($tags, $tags));
     $result[1] = $select->getHTML();
     return $result;
 }
Example #11
0
 function userSelect($name, $tabindex)
 {
     $options = array(wfMsg('deletebatch-select-script') => 'script', wfMsg('deletebatch-select-yourself') => 'you');
     $select = new XmlSelect($name, $name);
     $select->setDefault($this->mMode);
     $select->setAttribute('tabindex', $tabindex);
     // 'addOptions' method was added in MW 1.15
     if (method_exists($select, 'addOptions')) {
         $select->addOptions($options);
     } else {
         foreach ($options as $option) {
             $select->addOption($option);
         }
     }
     return $select;
 }
Example #12
0
    function execute()
    {
        global $wgCookieExpiration;
        $expirationDays = ceil($wgCookieExpiration / (3600 * 24));
        ?>
<div class="mw-ui-container">
	<?php 
        if ($this->haveData('languages')) {
            ?>
		<div id="languagelinks">
			<p><?php 
            $this->html('languages');
            ?>
</p>
		</div>
	<?php 
        }
        ?>
	<div id="userloginForm">
		<form name="userlogin" class="mw-ui-vform" method="post" action="<?php 
        $this->text('action');
        ?>
">
			<?php 
        if ($this->data['loggedin']) {
            ?>
				<div class="warningbox">
					<?php 
            echo $this->getMsg('userlogin-loggedin')->params($this->data['loggedinuser'])->parse();
            ?>
				</div>
			<?php 
        }
        ?>
			<section class="mw-form-header">
				<?php 
        $this->html('header');
        /* extensions such as ConfirmEdit add form HTML here */
        ?>
			</section>

			<?php 
        if ($this->data['message']) {
            ?>
				<div class="<?php 
            $this->text('messagetype');
            ?>
box">
					<?php 
            if ($this->data['messagetype'] == 'error') {
                ?>
						<strong><?php 
                $this->msg('loginerror');
                ?>
</strong>
						<br />
					<?php 
            }
            ?>
					<?php 
            $this->html('message');
            ?>
				</div>
			<?php 
        }
        ?>

			<div>
				<label for='wpName1'>
					<?php 
        $this->msg('userlogin-yourname');
        if ($this->data['secureLoginUrl']) {
            echo Html::element('a', array('href' => $this->data['secureLoginUrl'], 'class' => 'mw-ui-flush-right mw-secure'), $this->getMsg('userlogin-signwithsecure')->text());
        }
        ?>
				</label>
				<?php 
        $extraAttrs = array();
        echo Html::input('wpName', $this->data['name'], 'text', array('class' => 'loginText', 'id' => 'wpName1', 'tabindex' => '1', 'size' => '20', 'required' => true, 'autofocus' => !$this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourname-ph')->text()));
        ?>
			</div>

			<div>
				<label for='wpPassword1'>
					<?php 
        $this->msg('userlogin-yourpassword');
        if ($this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true) {
            echo ' ' . Linker::link(SpecialPage::getTitleFor('PasswordReset'), $this->getMsg('userlogin-resetpassword-link')->parse(), array('class' => 'mw-ui-flush-right'));
        }
        ?>
				</label>
				<?php 
        echo Html::input('wpPassword', null, 'password', array('class' => 'loginPassword', 'id' => 'wpPassword1', 'tabindex' => '2', 'size' => '20', 'autofocus' => (bool) $this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourpassword-ph')->text()));
        ?>
			</div>

			<?php 
        if (isset($this->data['usedomain']) && $this->data['usedomain']) {
            $select = new XmlSelect('wpDomain', false, $this->data['domain']);
            $select->setAttribute('tabindex', 3);
            foreach ($this->data['domainnames'] as $dom) {
                $select->addOption($dom);
            }
            ?>
				<div id="mw-user-domain-section">
					<label for='wpDomain'><?php 
            $this->msg('yourdomainname');
            ?>
</label>
					<?php 
            echo $select->getHTML();
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->haveData('extrafields')) {
            echo $this->data['extrafields'];
        }
        ?>

			<div>
				<?php 
        if ($this->data['canremember']) {
            ?>
					<label class="mw-ui-checkbox-label">
						<input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
							<?php 
            if ($this->data['remember']) {
                echo 'checked="checked"';
            }
            ?>
						>
						<?php 
            echo $this->getMsg('userlogin-remembermypassword')->numParams($expirationDays)->escaped();
            ?>
					</label>
				<?php 
        }
        ?>
			</div>

			<div>
				<?php 
        echo Html::input('wpLoginAttempt', $this->getMsg('login')->text(), 'submit', array('id' => 'wpLoginAttempt', 'tabindex' => '6', 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive'));
        ?>
			</div>

			<div id="mw-userlogin-help">
				<?php 
        echo $this->getMsg('userlogin-helplink')->parse();
        ?>
			</div>
			<?php 
        if ($this->haveData('createOrLoginHref')) {
            ?>
				<?php 
            if ($this->data['loggedin']) {
                ?>
					<div id="mw-createaccount-another">
						<a href="<?php 
                $this->text('createOrLoginHref');
                ?>
" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button"><?php 
                $this->msg('userlogin-createanother');
                ?>
</a>
					</div>
				<?php 
            } else {
                ?>
					<div id="mw-createaccount-cta">
						<?php 
                $this->msg('userlogin-noaccount');
                ?>
<a href="<?php 
                $this->text('createOrLoginHref');
                ?>
" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-progressive"><?php 
                $this->msg('userlogin-joinproject');
                ?>
</a>
					</div>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
			<?php 
        if ($this->haveData('uselang')) {
            ?>
<input type="hidden" name="uselang" value="<?php 
            $this->text('uselang');
            ?>
" /><?php 
        }
        ?>
			<?php 
        if ($this->haveData('token')) {
            ?>
<input type="hidden" name="wpLoginToken" value="<?php 
            $this->text('token');
            ?>
" /><?php 
        }
        ?>
			<?php 
        if ($this->data['cansecurelogin']) {
            ?>
<input type="hidden" name="wpForceHttps" value="<?php 
            $this->text('stickhttps');
            ?>
" /><?php 
        }
        ?>
		</form>
	</div>
</div>
<?php 
    }
Example #13
0
    function execute()
    {
        global $wgCookieExpiration;
        $expirationDays = ceil($wgCookieExpiration / (3600 * 24));
        ?>
<div id="userlogin_alt_logins">
	<div class="headline">Log in via</div>
	<?php 
        echo UserLoginBox::getSocialLogin();
        ?>
</div>
	
<div class="mw-ui-container">
	<?php 
        if ($this->haveData('languages')) {
            ?>
		<div id="languagelinks">
			<p><?php 
            $this->html('languages');
            ?>
</p>
		</div>
	<?php 
        }
        ?>
	
	<div id="userloginForm" class="userloginform">
		<div id="userloginprompt"><?php 
        $this->msgWiki('loginprompt');
        ?>
</div>
		<form name="userlogin" class="mw-ui-vform" method="post" action="<?php 
        $this->text('action');
        ?>
">
			<?php 
        if ($this->data['loggedin']) {
            ?>
				<div class="warningbox">
					<?php 
            echo $this->getMsg('userlogin-loggedin')->params($this->data['loggedinuser'])->parse();
            ?>
				</div>
			<?php 
        }
        ?>
			<section class="mw-form-header">
				<?php 
        $this->html('header');
        /* extensions such as ConfirmEdit add form HTML here */
        ?>
			</section>

			<div>
				<label for='wpName1' class='userlogin_label'>
					<?php 
        $this->msg('usernameoremail');
        ?>
				</label>
				<?php 
        $extraAttrs = array();
        echo Html::input('wpName', $this->data['name'], 'text', array('class' => 'loginText input_med', 'id' => 'wpName1', 'tabindex' => '1', 'size' => '20', 'required' => true, 'autofocus' => !$this->data['name']));
        ?>
					
				<?php 
        if (in_array('username', $this->data['errorlist'])) {
            ?>
					<div class="mw-error-bottom mw-error" id="wpName1_error">
						<div class="mw-error-top">
							<?php 
            $this->html('message');
            ?>
						</div>
					</div>
				<?php 
        }
        ?>
			</div>

			<div>
				<label for='wpPassword1'>
					<?php 
        $this->msg('userlogin-yourpassword');
        ?>
				</label>
				<?php 
        echo Html::input('wpPassword', null, 'password', array('class' => 'loginPassword input_med', 'id' => 'wpPassword1', 'tabindex' => '2', 'size' => '20', 'autofocus' => (bool) $this->data['name']));
        ?>
				<?php 
        if (in_array('password', $this->data['errorlist'])) {
            ?>
					<div class="mw-error-bottom mw-error" id="wpPassword1_error">
						<div class="mw-error-top">
							<?php 
            $this->html('message');
            ?>
						</div>
					</div>
				<?php 
        }
        ?>
			</div>
			<div id="forgot_pwd">
				<?php 
        if ($this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true) {
            echo ' ' . Linker::link(SpecialPage::getTitleFor('PasswordReset'), $this->getMsg('forgot_pwd')->parse(), array('class' => 'mw-ui-flush-right'));
        }
        ?>
			</div>
			<br /><br />
			<?php 
        if (isset($this->data['usedomain']) && $this->data['usedomain']) {
            $select = new XmlSelect('wpDomain', false, $this->data['domain']);
            $select->setAttribute('tabindex', 3);
            foreach ($this->data['domainnames'] as $dom) {
                $select->addOption($dom);
            }
            ?>
				<div id="mw-user-domain-section">
					<label for='wpDomain'><?php 
            $this->msg('yourdomainname');
            ?>
</label>
					<?php 
            echo $select->getHTML();
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->haveData('extrafields')) {
            echo $this->data['extrafields'];
        }
        ?>

			<div class="remember_pwd">
				<?php 
        if ($this->data['canremember']) {
            ?>
					<label class="mw-ui-checkbox-label">
						<input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
							<?php 
            if ($this->data['remember']) {
                echo 'checked="checked"';
            }
            ?>
						>
						<?php 
            echo $this->getMsg('rememberme')->numParams($expirationDays)->escaped();
            ?>
					</label>
				<?php 
        }
        ?>
			</div>

			<div>
				<?php 
        echo Html::input('wpLoginAttempt', $this->getMsg('login')->text(), 'submit', array('id' => 'wpLoginAttempt', 'tabindex' => '6', 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive button primary submit_button'));
        ?>
			</div>

			<?php 
        if ($this->haveData('uselang')) {
            ?>
<input type="hidden" name="uselang" value="<?php 
            $this->text('uselang');
            ?>
" /><?php 
        }
        ?>
			<?php 
        if ($this->haveData('token')) {
            ?>
<input type="hidden" name="wpLoginToken" value="<?php 
            $this->text('token');
            ?>
" /><?php 
        }
        ?>
			<?php 
        if ($this->data['cansecurelogin']) {
            ?>
<input type="hidden" name="wpForceHttps" value="<?php 
            $this->text('stickhttps');
            ?>
" /><?php 
        }
        ?>
		</form>
	</div>
</div>
<?php 
    }
Example #14
0
 function showTalkpageViewOptions()
 {
     $form_action_url = $this->talkpageUrl($this->title, 'talkpage_sort_order');
     $html = '';
     $html .= Xml::label(wfMessage('lqt_sorting_order')->text(), 'lqt_sort_select') . ' ';
     $sortOrderSelect = new XmlSelect('lqt_order', 'lqt_sort_select', $this->getSortType());
     $sortOrderSelect->setAttribute('class', 'lqt_sort_select');
     $sortOrderSelect->addOption(wfMessage('lqt_sort_newest_changes')->text(), LQT_NEWEST_CHANGES);
     $sortOrderSelect->addOption(wfMessage('lqt_sort_newest_threads')->text(), LQT_NEWEST_THREADS);
     $sortOrderSelect->addOption(wfMessage('lqt_sort_oldest_threads')->text(), LQT_OLDEST_THREADS);
     $html .= $sortOrderSelect->getHTML();
     $html .= Xml::submitButton(wfMessage('lqt-changesortorder')->text(), array('class' => 'lqt_go_sort'));
     $html .= Html::hidden('title', $this->title->getPrefixedText());
     $html = Xml::tags('form', array('action' => $form_action_url, 'method' => 'get', 'name' => 'lqt_sort'), $html);
     $html = Xml::tags('div', array('class' => 'lqt_view_options'), $html);
     return $html;
 }
	protected function showPermissions( $step ) {
		global $wgLang, $wgRequest;
		$header = new HtmlTag( 'h2' );
		$step_message = 'translate-fs-permissions-title';
		$header->content( wfMsg( $step_message ) )->style( 'opacity', 0.4 );

		if ( $step ) {
			$this->out->addHtml( $header );
			return $step;
		}

		if ( $wgRequest->wasPosted() &&
			$this->user->matchEditToken( $wgRequest->getVal( 'token' ) ) &&
			$wgRequest->getText( 'step' ) === 'permissions' )
		{
			// This is ridiculous
			global $wgCaptchaTriggers;
			$captcha = $wgCaptchaTriggers;
			$wgCaptchaTriggers = null;

			$language = $wgRequest->getVal( 'primary-language' );
			$message = $wgRequest->getText( 'message', '...' );
			$params = array(
				'action' => 'threadaction',
				'threadaction' => 'newthread',
				'token' => $this->user->editToken(),
				'talkpage' => 'Project:Translator',
				'subject' => "{{LanguageHeader|$language}}",
				'reason' => 'Using Special:FirstSteps',
				'text' => $message,
			);
			$request = new FauxRequest( $params, true, $_SESSION );
			$api = new ApiMain( $request, true );
			$api->execute();
			$result = $api->getResultData();
			$wgCaptchaTriggers = $captcha;
			$page = $result['threadaction']['thread']['thread-title'];
			$this->user->setOption( 'translate-firststeps-request', $page );
			$this->user->saveSettings();
		}

		$page = $this->user->getOption( 'translate-firststeps-request' );
		if ( $this->user->isAllowed( 'translate' ) ) {
			$header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) );
			$this->out->addHtml( $header );
			return $step;
		} elseif ( $page ) {
			$header->content( $header->content . wfMsg( 'translate-fs-pagetitle-pending' ) );
			$this->out->addHtml( $header->style( 'opacity', false ) );
			$this->out->addWikiMsg( 'translate-fs-permissions-pending', $page );
			return $step_message;
		}

		$this->out->addHtml( $header->style( 'opacity', false ) );
		$this->out->addWikiMsg( 'translate-fs-permissions-help' );

		$output = Html::openElement( 'form', array( 'method' => 'post' ) );
		$output .= Html::hidden( 'step', 'permissions' );
		$output .= Html::hidden( 'token', $this->user->editToken() );
		$output .= Html::hidden( 'title', $this->getTitle() );
		$name = $id = 'primary-language';
		$selector = new XmlSelect();
		$selector->addOptions( $this->languages( $wgLang->getCode() ) );
		$selector->setAttribute( 'id', $id );
		$selector->setAttribute( 'name', $name );
		$selector->setDefault( $wgLang->getCode() );
		$text = wfMessage( 'translate-fs-permissions-planguage' )->text();
		$output .= Xml::label( $text, $id ) . "&#160;" . $selector->getHtml() . '<br />';
		$output .= Html::element( 'textarea', array( 'rows' => 5, 'name' => 'message' ), '' );
		$output .= Xml::submitButton( wfMsg( 'translate-fs-permissions-submit' ) );
		$output .= Html::closeElement( 'form' );

		$this->out->addHtml( $output );
		return $step_message;
	}
 function getInputHTML($value)
 {
     $oldClass = $this->mClass;
     $this->mClass = (array) $this->mClass;
     $valInSelect = false;
     $ret = '';
     if ($this->getOptions()) {
         if ($value !== false) {
             $value = strval($value);
             $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true);
         }
         $selected = $valInSelect ? $value : 'other';
         $select = new XmlSelect($this->mName . '-select', $this->mID . '-select', $selected);
         $select->addOptions($this->getOptions());
         $select->setAttribute('class', 'mw-htmlform-select-or-other');
         if (!empty($this->mParams['disabled'])) {
             $select->setAttribute('disabled', 'disabled');
         }
         if (isset($this->mParams['tabindex'])) {
             $select->setAttribute('tabindex', $this->mParams['tabindex']);
         }
         $ret = $select->getHTML() . "<br />\n";
         $this->mClass[] = 'mw-htmlform-hide-if';
     }
     if ($valInSelect) {
         $value = '';
     } else {
         $key = array_search(strval($value), $this->autocomplete, true);
         if ($key !== false) {
             $value = $key;
         }
     }
     $this->mClass[] = 'mw-htmlform-autocomplete';
     $ret .= parent::getInputHTML($valInSelect ? '' : $value);
     $this->mClass = $oldClass;
     return $ret;
 }
 /**
  * Get a "<select>" for selecting languages.
  *
  * @param string $name
  * @param string $label
  * @param string $selectedCode
  * @param string $helpHtml
  *
  * @return string
  */
 public function getLanguageSelector($name, $label, $selectedCode, $helpHtml = '')
 {
     global $wgDummyLanguageCodes;
     $output = $helpHtml;
     $select = new XmlSelect($name, $name, $selectedCode);
     $select->setAttribute('tabindex', $this->parent->nextTabIndex());
     $languages = Language::fetchLanguageNames();
     ksort($languages);
     foreach ($languages as $code => $lang) {
         if (isset($wgDummyLanguageCodes[$code])) {
             continue;
         }
         $select->addOption("{$code} - {$lang}", $code);
     }
     $output .= $select->getHTML();
     return $this->parent->label($label, $name, $output);
 }
 function constructCreateForm()
 {
     global $wgOut, $wgScript;
     global $wgUserProperties, $wgActivityModes;
     $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post')));
     $wgOut->addHTML(Xml::element('h2', null, wfMsg('nss-create-account-header')) . "\n");
     $wgOut->addHTML("<table border=\"1\" id=\"newuser\">\n");
     $props = array_merge(array('username', 'email'), $wgUserProperties);
     foreach ($props as $i) {
         $msg = 'am-' . $i;
         $wgOut->addHTML("\t<tr><th>" . (wfEmptyMsg($msg, wfMsg($msg)) ? $i : wfMsgHtml($msg)) . "</th><td>" . Xml::input("am-" . str_replace(' ', '_', $i), 40) . "</td></tr>\n");
     }
     global $wgActivityModes;
     $select = new XmlSelect("am-active");
     $select->setDefault('active');
     $select->setAttribute('width', '100%');
     foreach ($wgActivityModes as $key) {
         $select->addOption($key);
     }
     $wgOut->addHTML("\t<tr><th>" . wfMsgHtml('am-active') . "</th><td>" . $select->getHTML() . "</td></tr>\n");
     $wgOut->addHTML("</table>\n");
     $wgOut->addHTML("<div id=\"newaccount-submit\">\n" . Html::Hidden('action', 'create') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n");
     $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post')));
     $wgOut->addHTML("<div id=\"newaccount-raw\">\n" . Xml::textarea('nss-create-account-raw', '') . "\n" . Html::Hidden('action', 'create-raw') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n");
 }
Example #19
0
    function execute()
    {
        global $wgCookieExpiration;
        $expirationDays = ceil($wgCookieExpiration / (3600 * 24));
        ?>
<div class="mw-ui-container">
	<?php 
        if ($this->haveData('languages')) {
            ?>
		<div id="languagelinks">
			<p><?php 
            $this->html('languages');
            ?>
</p>
		</div>
	<?php 
        }
        if (!wfMessage('signupstart')->isDisabled()) {
            ?>
		<div id="signupstart"><?php 
            $this->msgWiki('signupstart');
            ?>
</div>
	<?php 
        }
        ?>
	<div id="userloginForm">
		<h2 class="createaccount-join">
			<?php 
        $this->msg($this->data['loggedin'] ? 'createacct-another-join' : 'createacct-join');
        ?>
		</h2>
		<form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php 
        $this->text('action');
        ?>
">
			<section class="mw-form-header">
				<?php 
        $this->html('header');
        /* extensions such as ConfirmEdit add form HTML here */
        ?>
			</section>
			<!-- This element is used by the mediawiki.special.userlogin.signup.js module. -->
			<div
				id="mw-createacct-status-area"
				<?php 
        if ($this->data['message']) {
            ?>
					class="<?php 
            echo $this->data['messagetype'];
            ?>
box"
				<?php 
        } else {
            ?>
					style="display: none;"
				<?php 
        }
        ?>
			>
			<?php 
        if ($this->data['message']) {
            ?>
					<?php 
            if ($this->data['messagetype'] == 'error') {
                ?>
						<strong><?php 
                $this->msg('createacct-error');
                ?>
</strong>
						<br />
					<?php 
            }
            ?>
					<?php 
            $this->html('message');
            ?>
			<?php 
        }
        ?>
			</div>

			<div>
				<label for='wpName2'>
					<?php 
        $this->msg('userlogin-yourname');
        ?>

					<span class="mw-ui-flush-right"><?php 
        echo $this->getMsg('createacct-helpusername')->parse();
        ?>
</span>
				</label>
				<?php 
        echo Html::input('wpName', $this->data['name'], 'text', array('class' => 'mw-input loginText', 'id' => 'wpName2', 'tabindex' => '1', 'size' => '20', 'required', 'placeholder' => $this->getMsg($this->data['loggedin'] ? 'createacct-another-username-ph' : 'userlogin-yourname-ph')->text()));
        ?>
			</div>

			<div>
				<?php 
        if ($this->data['createemail']) {
            ?>
					<label class="mw-ui-checkbox-label">
						<input name="wpCreateaccountMail" type="checkbox" value="1" id="wpCreateaccountMail" tabindex="2"
							<?php 
            if ($this->data['createemailset']) {
                echo 'checked="checked"';
            }
            ?>
						>
						<?php 
            $this->msg('createaccountmail');
            ?>
					</label>
				<?php 
        }
        ?>
			</div>

			<div class="mw-row-password">
				<label for='wpPassword2'><?php 
        $this->msg('userlogin-yourpassword');
        ?>
</label>
				<?php 
        echo Html::input('wpPassword', null, 'password', array('class' => 'mw-input loginPassword', 'id' => 'wpPassword2', 'tabindex' => '3', 'size' => '20', 'required', 'placeholder' => $this->getMsg('createacct-yourpassword-ph')->text()) + User::passwordChangeInputAttribs());
        ?>
			</div>

			<?php 
        if ($this->data['usedomain']) {
            $select = new XmlSelect('wpDomain', false, $this->data['domain']);
            $select->setAttribute('tabindex', 4);
            foreach ($this->data['domainnames'] as $dom) {
                $select->addOption($dom);
            }
            ?>
				<div id="mw-user-domain-section">
					<label for="wpDomain"><?php 
            $this->msg('yourdomainname');
            ?>
</label>
					<div class="mw-input">
						<?php 
            echo $select->getHTML();
            ?>
					</div>
				</div>
			<?php 
        }
        ?>

			<div class="mw-row-password">
				<label for='wpRetype'><?php 
        $this->msg('createacct-yourpasswordagain');
        ?>
</label>
				<?php 
        echo Html::input('wpRetype', null, 'password', array('class' => 'mw-input loginPassword', 'id' => 'wpRetype', 'tabindex' => '5', 'size' => '20', 'required', 'placeholder' => $this->getMsg('createacct-yourpasswordagain-ph')->text()) + User::passwordChangeInputAttribs());
        ?>
			</div>

			<div>
				<?php 
        if ($this->data['useemail']) {
            ?>
					<label for='wpEmail'>
						<?php 
            $this->msg($this->data['emailrequired'] ? 'createacct-emailrequired' : 'createacct-emailoptional');
            ?>
					</label>
					<?php 
            echo Html::input('wpEmail', $this->data['email'], 'email', array('class' => 'mw-input loginText', 'id' => 'wpEmail', 'tabindex' => '6', 'size' => '20', 'required' => $this->data['emailrequired'], 'placeholder' => $this->getMsg($this->data['loggedin'] ? 'createacct-another-email-ph' : 'createacct-email-ph')->text()));
            ?>
				<?php 
        }
        ?>
			</div>

			<?php 
        if ($this->data['userealname']) {
            ?>
				<div>
					<label for='wpRealName'><?php 
            $this->msg('createacct-realname');
            ?>
</label>
					<input type='text' class='mw-input loginText' name="wpRealName" id="wpRealName"
						tabindex="7"
						value="<?php 
            $this->text('realname');
            ?>
" size='20' />
					<div class="prefsectiontip">
						<?php 
            $this->msgWiki($this->data['loggedin'] ? 'createacct-another-realname-tip' : 'prefs-help-realname');
            ?>
					</div>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->data['usereason']) {
            ?>
				<div>
					<label for='wpReason'><?php 
            $this->msg('createacct-reason');
            ?>
</label>
					<?php 
            echo Html::input('wpReason', $this->data['reason'], 'text', array('class' => 'mw-input loginText', 'id' => 'wpReason', 'tabindex' => '8', 'size' => '20', 'placeholder' => $this->getMsg('createacct-reason-ph')->text()));
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        $tabIndex = 9;
        if (isset($this->data['extraInput']) && is_array($this->data['extraInput'])) {
            foreach ($this->data['extraInput'] as $inputItem) {
                ?>
					<div>
						<?php 
                // If it's a checkbox, output the whole thing (assume it has a msg).
                if ($inputItem['type'] == 'checkbox') {
                    ?>
							<label class="mw-ui-checkbox-label">
								<input
									name="<?php 
                    echo htmlspecialchars($inputItem['name']);
                    ?>
"
									id="<?php 
                    echo htmlspecialchars($inputItem['name']);
                    ?>
"
									type="checkbox" value="1"
									tabindex="<?php 
                    echo $tabIndex++;
                    ?>
"
									<?php 
                    if (!empty($inputItem['value'])) {
                        echo 'checked="checked"';
                    }
                    ?>
								>
								<?php 
                    $this->msgHtml($inputItem['msg']);
                    ?>
							</label>
						<?php 
                } else {
                    // Not a checkbox.
                    // TODO (bug 31909) support other input types, e.g. select boxes.
                    ?>
							<?php 
                    if (!empty($inputItem['msg'])) {
                        ?>
								<label for="<?php 
                        echo htmlspecialchars($inputItem['name']);
                        ?>
">
									<?php 
                        $this->msgWiki($inputItem['msg']);
                        ?>
								</label>
							<?php 
                    }
                    ?>
							<input
								type="<?php 
                    echo htmlspecialchars($inputItem['type']);
                    ?>
"
								class="mw-input"
								name="<?php 
                    echo htmlspecialchars($inputItem['name']);
                    ?>
"
								tabindex="<?php 
                    echo $tabIndex++;
                    ?>
"
								value="<?php 
                    echo htmlspecialchars($inputItem['value']);
                    ?>
"
								id="<?php 
                    echo htmlspecialchars($inputItem['name']);
                    ?>
"
							/>
						<?php 
                }
                ?>
						<?php 
                if ($inputItem['helptext'] !== false) {
                    ?>
							<div class="prefsectiontip">
								<?php 
                    $this->msgWiki($inputItem['helptext']);
                    ?>
							</div>
						<?php 
                }
                ?>
					</div>
				<?php 
            }
        }
        // JS attempts to move the image CAPTCHA below this part of the form,
        // so skip one index.
        $tabIndex++;
        ?>
			<div class="mw-submit">
				<?php 
        echo Html::input('wpCreateaccount', $this->getMsg($this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit'), 'submit', array('class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive", 'id' => 'wpCreateaccount', 'tabindex' => $tabIndex++));
        ?>
			</div>
			<?php 
        if ($this->haveData('uselang')) {
            ?>
<input type="hidden" name="uselang" value="<?php 
            $this->text('uselang');
            ?>
" /><?php 
        }
        ?>
			<?php 
        if ($this->haveData('token')) {
            ?>
<input type="hidden" name="wpCreateaccountToken" value="<?php 
            $this->text('token');
            ?>
" /><?php 
        }
        ?>
		</form>
		<?php 
        if (!wfMessage('signupend')->isDisabled()) {
            ?>
			<div id="signupend"><?php 
            $this->html('signupend');
            ?>
</div>
		<?php 
        }
        ?>
	</div>
	<div class="mw-createacct-benefits-container">
		<h2><?php 
        $this->msg('createacct-benefit-heading');
        ?>
</h2>
		<div class="mw-createacct-benefits-list">
			<?php 
        for ($benefitIdx = 1; $benefitIdx <= $this->data['benefitCount']; $benefitIdx++) {
            // Pass each benefit's head text (by default a number) as a parameter to the body's message for PLURAL handling.
            $headUnescaped = $this->getMsg("createacct-benefit-head{$benefitIdx}")->text();
            ?>
				<div class="mw-number-text <?php 
            $this->msg("createacct-benefit-icon{$benefitIdx}");
            ?>
">
					<h3><?php 
            $this->msg("createacct-benefit-head{$benefitIdx}");
            ?>
</h3>
					<p><?php 
            echo $this->getMsg("createacct-benefit-body{$benefitIdx}")->params($headUnescaped)->escaped();
            ?>
</p>
				</div>
			<?php 
        }
        ?>
		</div>
	</div>
</div>
<?php 
    }
Example #20
0
 /**
  * Returns log page selector.
  * @return XmlSelect
  * @since 1.19
  */
 public function getTypeSelector()
 {
     $typesByName = array();
     // Temporary array
     // First pass to load the log names
     foreach (LogPage::validTypes() as $type) {
         $page = new LogPage($type);
         $restriction = $page->getRestriction();
         if ($this->getUser()->isAllowed($restriction)) {
             $typesByName[$type] = $page->getName()->text();
         }
     }
     // Second pass to sort by name
     asort($typesByName);
     // Always put "All public logs" on top
     $public = $typesByName[''];
     unset($typesByName['']);
     $typesByName = array('' => $public) + $typesByName;
     $select = new XmlSelect('type');
     // Jordan, upgrade 1.21: added style attribute to select
     $select->setAttribute('style', 'margin:0 0 15px 10px;');
     foreach ($typesByName as $type => $name) {
         $select->addOption($name, $type);
     }
     return $select;
 }
Example #21
0
 /**
  * Create a date selector
  *
  * @param string $selected The month which should be selected, default ''.
  * @param string $allmonths Value of a special item denoting all month.
  *   Null to not include (default).
  * @param string $id Element identifier
  * @return string Html string containing the month selector
  */
 public static function monthSelector($selected = '', $allmonths = null, $id = 'month')
 {
     global $wgLang;
     $options = [];
     $data = new XmlSelect('month', $id, $selected);
     if (is_null($selected)) {
         $selected = '';
     }
     if (!is_null($allmonths)) {
         $options[wfMessage('monthsall')->text()] = $allmonths;
     }
     for ($i = 1; $i < 13; $i++) {
         $options[$wgLang->getMonthName($i)] = $i;
     }
     $data->addOptions($options);
     $data->setAttribute('class', 'mw-month-selector');
     return $data->getHTML();
 }
Example #22
0
 function getInputHTML($value)
 {
     $valInSelect = false;
     if ($value !== false) {
         $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->mParams['options']));
     }
     $selected = $valInSelect ? $value : 'other';
     $opts = self::forceToStringRecursive($this->mParams['options']);
     $select = new XmlSelect($this->mName, $this->mID, $selected);
     $select->addOptions($opts);
     $select->setAttribute('class', 'mw-htmlform-select-or-other');
     $tbAttribs = array('id' => $this->mID . '-other', 'size' => $this->getSize());
     if (!empty($this->mParams['disabled'])) {
         $select->setAttribute('disabled', 'disabled');
         $tbAttribs['disabled'] = 'disabled';
     }
     $select = $select->getHTML();
     if (isset($this->mParams['maxlength'])) {
         $tbAttribs['maxlength'] = $this->mParams['maxlength'];
     }
     $textbox = Html::input($this->mName . '-other', $valInSelect ? '' : $value, 'text', $tbAttribs);
     return Html::rawElement('span', array('class' => 'input_like'), "{$select}<br />\n{$textbox}");
 }