function getInputHTML($value)
 {
     $datalist = new XmlSelect(false, $this->mName . '-datalist');
     $datalist->setTagName('datalist');
     $datalist->addOptions($this->getOptions());
     return parent::getInputHTML($value) . $datalist->getHTML();
 }
 function execute($params)
 {
     global $wgOut, $wgUser, $wgRequest;
     $wgOut->setPageTitle('WikiFactory Reporter');
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     if (!$wgUser->isAllowed('wikifactory')) {
         $this->displayRestrictionError();
         return;
     }
     $this->varid = $wgRequest->getInt('varid');
     $this->disable_limit = $wgRequest->getBool('nolimit');
     /***********************************************/
     $vars = WikiFactory::getVariables("cv_name", 0, 0);
     $select = new XmlSelect('varid', false, $this->varid);
     if (!empty($this->varid)) {
         //the cast is because the Xml select uses === to detect the default
         $select->setDefault((string) $this->varid);
         //change the name, using the var name
         $variable = WikiFactory::getVarById($this->varid, 0);
         $wgOut->setPageTitle('WikiFactory Reporter: ' . $variable->cv_name);
     }
     foreach ($vars as $variable) {
         $select->addOption("{$variable->cv_name} ({$variable->cv_id})", $variable->cv_id);
     }
     $action = self::getTitle()->getLocalURL();
     $wgOut->addHTML("<form action='{$action}' method='get'>\n");
     $wgOut->addHTML($select->getHTML());
     $wgOut->addHTML("<input type='submit'>\n");
     $wgOut->addHTML("</form>\n");
     /***********************************************/
     if (!empty($this->varid)) {
         $wgOut->addHTML($this->getCustomSettings());
     }
 }
 public static function typeSelector($name = 'type', $value = '', $id = false)
 {
     $s = new XmlSelect($name, $id, $value);
     $s->addOption(wfMsg('userrestrictiontype-none'), '');
     $s->addOption(wfMsg('userrestrictiontype-page'), UserRestriction::PAGE);
     $s->addOption(wfMsg('userrestrictiontype-namespace'), UserRestriction::NAMESPACE);
     return $s->getHTML();
 }
Example #4
0
 /**
  * Helper function get module selector.
  *
  * @param $selectedId \string Which value should be selected by default
  * @return \string HTML5-compatible select-element.
  */
 protected function moduleSelector($selectedId)
 {
     $selector = new XmlSelect('module', 'module', $selectedId);
     foreach ($this->aModules as $code) {
         $selector->addOption(wfMsg('translate-magic-' . $code), $code);
     }
     return $selector->getHTML();
 }
Example #5
0
 /**
  * Adding default later on should set the correct selection or
  * raise an exception.
  * To handle this, we need to render the options in getHtml()
  * @covers XmlSelect::setDefault
  */
 public function testSetDefaultAfterAddingOptions()
 {
     $this->select->addOption('foo1');
     $this->select->addOption('bar1');
     $this->select->addOption('foo2');
     $this->select->setDefault('bar1');
     # setting default after adding options
     $this->assertEquals('<select><option value="foo1">foo1</option>' . "\n" . '<option value="bar1" selected="">bar1</option>' . "\n" . '<option value="foo2">foo2</option></select>', $this->select->getHTML());
 }
 /**
  * Helper function get module selector.
  *
  * @param string $selectedId Which value should be selected by default
  * @return string HTML5-compatible select-element.
  */
 protected function moduleSelector($selectedId)
 {
     // Give grep a chance to find the usages:
     // translate-magic-words, translate-magic-special, translate-magic-namespace
     $selector = new XmlSelect('module', 'module', $selectedId);
     foreach ($this->aModules as $code) {
         $selector->addOption($this->msg('translate-magic-' . $code)->text(), $code);
     }
     return $selector->getHTML();
 }
 protected function buildSelect($list, $name, $default = '')
 {
     sort($list);
     $select = new XmlSelect($name);
     $select->setDefault($default);
     foreach ($list as $wiki) {
         $select->addOption($wiki);
     }
     return $select->getHTML();
 }
 /**
  * Output a form to allow searching for a user
  */
 function switchForm()
 {
     global $wgScript;
     $knownwiki = $this->getRequest()->getVal('wpKnownWiki');
     $knownwiki = $knownwiki ? $knownwiki : wfWikiId();
     // Generate wiki selector
     $selector = new XmlSelect('wpKnownWiki', 'wpKnownWiki', $knownwiki);
     foreach (CentralAuthUser::getWikiList() as $wiki) {
         $selector->addOption($wiki);
     }
     $this->getOutput()->addModuleStyles('mediawiki.special');
     $this->getOutput()->addHTML(Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1')) . Html::hidden('title', $this->getTitle()) . Xml::openElement('fieldset') . Xml::element('legend', array(), wfMsg('userrights-lookup-user')) . Xml::inputLabel(wfMsg('userrights-user-editname'), 'user', 'username', 30, $this->mTarget) . ' <br />' . Xml::label(wfMsg('centralauth-globalgrouppermissions-knownwiki'), 'wpKnownWiki') . ' ' . $selector->getHTML() . '<br />' . Xml::submitButton(wfMsg('editusergroup')) . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n");
 }
 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();
 }
Example #10
0
	/**
	 * Hooks SpecialRecentChangesPanel. See the hook documentation for
	 * documentation of the function parameters.
	 *
	 * Adds a HTMl selector into $items
	 * @param $items
	 * @param $opts
	 * @return bool true
	 */
	public static function translationFilterForm( &$items, $opts ) {
		$opts->consumeValue( 'translations' );
		$default = $opts->getValue( 'translations' );

		$label = Xml::label( wfMsg( 'translate-rc-translation-filter' ), 'mw-translation-filter' );
		$select = new XmlSelect( 'translations', 'mw-translation-filter', $default );
		$select->addOption( wfMsg( 'translate-rc-translation-filter-no' ), 'noaction' );
		$select->addOption( wfMsg( 'translate-rc-translation-filter-only' ), 'only' );
		$select->addOption( wfMsg( 'translate-rc-translation-filter-filter' ), 'filter' );
		$select->addOption( wfMsg( 'translate-rc-translation-filter-site' ), 'site' );

		$items['translations'] = array( $label, $select->getHTML() );

		return true;
	}
 /**
  * Executes the special page
  *
  * @param $param string the parameter passed in the url
  */
 public function execute($param)
 {
     $out = $this->getOutput();
     $title = Title::newFromText($param);
     if ($title) {
         $pageId = $title->getArticleID();
     } else {
         $out->addWikiMsg('articlefeedbackv5-invalid-page-id');
         return;
     }
     $ratings = $this->fetchOverallRating($pageId);
     $found = isset($ratings['found']) ? $ratings['found'] : null;
     $rating = isset($ratings['rating']) ? $ratings['rating'] : null;
     $out->setPagetitle($this->msg('articlefeedbackv5-special-pagetitle', $title)->escaped());
     if (!$pageId) {
         $out->addWikiMsg('articlefeedbackv5-invalid-page-id');
     } else {
         # TODO: Fix links.
         $out->addHTML(Html::openElement('div', array('id' => 'articleFeedbackv5-header-links')) . Linker::link(Title::newFromText($param), $this->msg('articlefeedbackv5-go-to-article')->escaped()) . ' | ' . Linker::link(Title::newFromText($param), $this->msg('articlefeedbackv5-discussion-page')->escaped()) . ' | ' . Linker::link(Title::newFromText($param), $this->msg('articlefeedbackv5-whats-this')->escaped()) . Html::closeElement('div'));
     }
     $out->addHTML(Html::openElement('div', array('id' => 'articleFeedbackv5-showing-count-wrap')) . $this->msg('articlefeedbackv5-special-showing', Html::element('span', array('id' => 'articleFeedbackv5-feedback-count-total'), '0')) . Html::closeElement('div'));
     if ($found) {
         $out->addHtml(Html::openElement('div', array('id' => 'articleFeedbackv5-percent-found-wrap')) . $this->msg('articlefeedbackv5-percent-found', $found)->escaped() . Html::closeElement('div'));
     }
     #		if ( $rating ) {
     #			$out->addWikiMsg( 'articlefeedbackv5-overall-rating', $rating );
     #		}
     $out->addWikiMsg('articlefeedbackv5-special-title');
     $out->addJsConfigVars('afPageId', $pageId);
     $out->addModules('jquery.articleFeedbackv5.special');
     $sortLabels = array();
     $sortOpts = array('newest', 'oldest');
     foreach ($sortOpts as $sort) {
         $sortLabels[] = Html::element('a', array('href' => '#', 'id' => 'articleFeedbackv5-special-sort-' . $sort, 'class' => 'articleFeedbackv5-sort-link'), $this->msg('articlefeedbackv5-special-sort-' . $sort)->text());
     }
     $opts = array();
     $counts = $this->getFilterCounts($pageId);
     foreach ($this->filters as $filter) {
         $count = isset($counts[$filter]) ? $counts[$filter] : 0;
         $key = $this->msg('articlefeedbackv5-special-filter-' . $filter, $count)->escaped();
         $opts[(string) $key] = $filter;
     }
     $filterSelect = new XmlSelect(false, 'articleFeedbackv5-filter');
     $filterSelect->addOptions($opts);
     $out->addHTML(Html::openElement('div', array('id' => 'articleFeedbackv5-sort-filter-controls')) . $this->msg('articlefeedbackv5-special-sort-label-before')->escaped() . implode($this->msg('pipe-separator')->escaped(), $sortLabels) . $this->msg('articlefeedbackv5-special-sort-label-after')->escaped() . $this->msg('articlefeedbackv5-special-filter-label-before')->escaped() . $filterSelect->getHTML() . $this->msg('articlefeedbackv5-special-filter-label-after')->escaped() . Html::element('a', array('href' => '#', 'id' => 'articleFeedbackv5-special-add-feedback'), $this->msg('articlefeedbackv5-special-add-feedback')->text()) . Html::closeElement('div'));
     $out->addHTML(Html::element('div', array('id' => 'articleFeedbackv5-show-feedback')) . Html::element('a', array('href' => '#', 'id' => 'articleFeedbackv5-show-more'), $this->msg('articlefeedbackv5-special-more')->text()));
 }
Example #12
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();
 }
	static function onRcForm( &$items, $opts ) {
		global $wmincProjects, $wmincProjectSite, $wmincLangCodeLength;
		
		list( $projectvalue, $codevalue ) = self::getValues();
		$opts->consumeValue( 'rc-testwiki-project' );
		$opts->consumeValue( 'rc-testwiki-code' );
		$label = Xml::label( wfMsg( 'wminc-testwiki' ), 'rc-testwiki' );
		$select = new XmlSelect( 'rc-testwiki-project', 'rc-testwiki-project', $projectvalue );
		$select->addOption( wfMsg( 'wminc-testwiki-none' ), 'none' );
		foreach( $wmincProjects as $prefix => $name ) {
			$select->addOption( $name, $prefix );
		}
		$select->addOption( $wmincProjectSite['name'], $wmincProjectSite['short'] );
		$langcode = Xml::input( 'rc-testwiki-code', (int)$wmincLangCodeLength, $codevalue,
			array( 'id' => 'rc-testwiki-code', 'maxlength' => (int)$wmincLangCodeLength ) );
		$items['testwiki'] = array( $label, $select->getHTML() . ' ' . $langcode );
		return true;
	}
 private function displayNavigation()
 {
     global $wgOut;
     $groupSelector = new XmlSelect('group', 'group-select');
     // pull groups
     $groups = MessageGroups::singleton()->getGroups();
     foreach ($groups as $group) {
         if (!$group->isMeta()) {
             continue;
         }
         $groupSelector->addOption($group->getLabel(), $group->getId());
     }
     $fields = array();
     $fields['transstats-choose-group'] = $groupSelector->getHTML();
     $fields['transstats-breakdown'] = Xml::check('breakdown', false);
     $out = Xml::openElement('form');
     $out .= Xml::buildForm($fields);
     $out .= Xml::submitButton(wfMsg('transstats-submit'));
     $out .= Xml::closeElement('form');
     $wgOut->addHTML($out);
 }
 /**
  * Message input fieldset
  *
  * @param $title Title (default: null)
  * @return \string HTML for fieldset.
  */
 function namespaceMessageForm(Title $title = null)
 {
     global $wgScript;
     $namespaces = new XmlSelect('namespace', 'namespace');
     $namespaces->setDefault($title->getNamespace());
     foreach ($this->getSortedNamespaces() as $text => $index) {
         $namespaces->addOption($text, $index);
     }
     $out = Xml::openElement('div', array('class' => 'namespaceoptions'));
     $out .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
     $out .= Html::hidden('title', $this->getTitle()->getPrefixedText());
     $out .= Xml::openElement('fieldset');
     $out .= Xml::element('legend', null, wfMsg('translate-translations-fieldset-title'));
     $out .= Xml::openElement('table', array('id' => 'nsselect', 'class' => 'allpages'));
     $out .= "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('translate-translations-messagename'), 'message') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('message', 30, $title->getText(), array('id' => 'message')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('translate-translations-project'), 'namespace') . "</td>\n\t\t\t\t<td class='mw-input'>" . $namespaces->getHTML() . ' ' . Xml::submitButton(wfMsg('allpagessubmit')) . "</td>\n\t\t\t\t</tr>";
     $out .= Xml::closeElement('table');
     $out .= Xml::closeElement('fieldset');
     $out .= Xml::closeElement('form');
     $out .= Xml::closeElement('div');
     return $out;
 }
Example #16
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 #17
0
 function getInputHTML($value)
 {
     $select = new XmlSelect($this->mName, $this->mID, strval($value));
     # If one of the options' 'name' is int(0), it is automatically selected.
     # because PHP sucks and thinks int(0) == 'some string'.
     # Working around this by forcing all of them to strings.
     foreach ($this->mParams['options'] as &$opt) {
         if (is_int($opt)) {
             $opt = strval($opt);
         }
     }
     unset($opt);
     # PHP keeps $opt around as a reference, which is a bit scary
     if (!empty($this->mParams['disabled'])) {
         $select->setAttribute('disabled', 'disabled');
     }
     if ($this->mClass !== '') {
         $select->setAttribute('class', $this->mClass);
     }
     $select->addOptions($this->mParams['options']);
     return $select->getHTML();
 }
Example #18
0
 /**
  * @param $name
  * @param $value
  * @return string
  */
 function buildTypeSelector($name, $value)
 {
     $select = new XmlSelect($name, 'set-type', $value);
     foreach (array(WikiSet::OPTIN, WikiSet::OPTOUT) as $type) {
         $select->addOption(wfMsg("centralauth-editset-{$type}"), $type);
     }
     return $select->getHTML();
 }
Example #19
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();
	}
 protected function _executeDelete($wgFarmer)
 {
     global $wgOut, $wgUser, $wgRequest;
     if (!$wgFarmer->getActiveWiki()->isDefaultWiki()) {
         $wgOut->wrapWikiMsg("== \$1 ==\n\$2", 'farmer-notaccessible', 'farmer-notaccessible-test');
         return;
     }
     if (!MediaWikiFarmer::userIsFarmerAdmin($wgUser)) {
         $wgOut->wrapWikiMsg("== \$1 ==\n\$2", 'farmer-permissiondenied', 'farmer-permissiondenied-text');
         return;
     }
     if ($wgRequest->wasPosted() && ($wiki = $wgRequest->getVal('wpWiki')) && $wiki != '-1') {
         if ($wgRequest->getCheck('wpConfirm')) {
             $wgOut->wrapWikiMsg('<div class="successbox">$1</div>', array('farmer-deleting', $wiki));
             $log = new LogPage('farmer');
             $log->addEntry('delete', $this->getTitle(), $wgRequest->getVal('wpReason'), array($wiki));
             $deleteWiki = MediaWikiFarmer_Wiki::factory($wiki);
             $deleteWiki->deleteWiki();
         } else {
             $wgOut->addWikiMsg('farmer-delete-confirm-wiki', $wiki);
             $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'name' => 'deleteWiki')) . "\n" . Xml::buildForm(array('farmer-delete-reason' => Xml::input('wpReason', false, $wgRequest->getVal('wpReason')), 'farmer-delete-confirm' => Xml::check('wpConfirm')), 'farmer-delete-form-submit') . "\n" . Html::Hidden('wpWiki', $wiki) . "\n" . Xml::closeElement('form'));
         }
         return;
     }
     $list = $wgFarmer->getFarmList();
     $wgOut->wrapWikiMsg("== \$1 ==\n\$2", 'farmer-delete-title', 'farmer-delete-text');
     $select = new XmlSelect('wpWiki', false, $wgRequest->getVal('wpWiki'));
     $select->addOption(wfMsg('farmer-delete-form'), '-1');
     foreach ($list as $wiki) {
         if ($wiki['name'] != $wgFarmer->getDefaultWiki()) {
             $name = $wiki['name'];
             $title = $wiki['title'];
             $select->addOption("{$name} - {$title}", $name);
         }
     }
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'name' => 'deleteWiki')) . "\n" . $select->getHTML() . "\n" . Xml::submitButton(wfMsg('farmer-delete-form-submit')) . "\n" . Xml::closeElement('form'));
 }
Example #21
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 
    }
 /**
  * @param $group
  * @return string
  */
 function buildWikiSetSelector($group)
 {
     $sets = WikiSet::getAllWikiSets();
     $default = WikiSet::getWikiSetForGroup($group);
     if (!$this->userCanEdit($this->getUser())) {
         $set = WikiSet::newFromID($default);
         if ($set) {
             return Linker::link(SpecialPage::getTitleFor('WikiSets', $set->getId()), htmlspecialchars($set->getName()));
         } else {
             return $this->msg('centralauth-editgroup-nowikiset');
         }
     }
     $select = new XmlSelect('set', 'wikiset', $default);
     $select->addOption($this->msg('centralauth-editgroup-noset')->text(), '0');
     /**
      * @var $set WikiSet
      */
     foreach ($sets as $set) {
         $select->addOption($set->getName(), $set->getID());
     }
     $editlink = $this->msg('centralauth-editgroup-editsets')->parse();
     return $select->getHTML() . "&#160;{$editlink}";
 }
 /**
  * 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 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;
 }
Example #25
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 #26
0
 function getExistingSelector($warnMsg)
 {
     $existingSelector = new XmlSelect('wpFilterWarnMessage', 'mw-abusefilter-warn-message-existing', $warnMsg == 'abusefilter-warning' ? 'abusefilter-warning' : 'other');
     // Find other messages.
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('page', array('page_title'), array('page_namespace' => 8, 'page_title LIKE ' . $dbr->addQuotes('Abusefilter-warning%')), __METHOD__);
     $existingSelector->addOption('abusefilter-warning');
     $lang = $this->getLanguage();
     foreach ($res as $row) {
         if ($lang->lcfirst($row->page_title) == $lang->lcfirst($warnMsg)) {
             $existingSelector->setDefault($lang->lcfirst($warnMsg));
         }
         if ($row->page_title != 'Abusefilter-warning') {
             $existingSelector->addOption($lang->lcfirst($row->page_title));
         }
     }
     $existingSelector->addOption(wfMsg('abusefilter-edit-warn-other'), 'other');
     return $existingSelector->getHTML();
 }
Example #27
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 #28
0
 /**
  * Gets the HTML for a filter control.
  *
  * @since 0.1
  *
  * @param boolean $hideWhenNoResults When true, there are no results, and no filters are applied, an empty string is returned.
  *
  * @return string
  */
 public function getFilterControl($hideWhenNoResults = true)
 {
     $filterOptions = $this->getFilterOptions();
     foreach ($this->conds as $name => $value) {
         if (array_key_exists($name, $filterOptions)) {
             unset($filterOptions[$name]);
         }
     }
     if (count($filterOptions) < 1) {
         return '';
     }
     $this->addFilterValues($filterOptions);
     if ($hideWhenNoResults && $this->getNumRows() < 1) {
         $noFiltersSet = array_reduce($filterOptions, function ($current, array $data) {
             return $current && ($data['value'] === '' || is_null($data['value']));
         }, true);
         if ($noFiltersSet) {
             return '';
         }
     }
     $controls = array();
     foreach ($filterOptions as $optionName => $optionData) {
         switch ($optionData['type']) {
             case 'select':
                 $select = new XmlSelect($optionName, $optionName, $optionData['value']);
                 $select->addOptions($optionData['options']);
                 $control = $select->getHTML();
                 break;
         }
         $control = '&#160;' . $this->getMsg('filter-' . $optionName) . '&#160;' . $control;
         $controls[] = $control;
     }
     $title = $this->getTitle()->getFullText();
     return '<fieldset>' . '<legend>' . wfMsgHtml('ep-pager-showonly') . '</legend>' . '<form method="post" action="' . htmlspecialchars(wfAppendQuery($GLOBALS['wgScript'], array('title' => $title))) . '">' . Html::hidden('title', $title) . implode('', $controls) . '&#160;<input type="submit" class="ep-pager-go" value="' . wfMsgHtml('ep-pager-go') . '">' . '&#160;<button class="ep-pager-clear">' . wfMsgHtml('ep-pager-clear') . '</button>' . '</form>' . '</fieldset>';
 }
Example #29
0
 function cutoffselector($options)
 {
     // Cast everything to strings immediately, so that we know all of the values have the same
     // precision, and can be compared with '==='. 2/24 has a few more decimal places than its
     // default string representation, for example, and would confuse comparisons.
     // Misleadingly, the 'days' option supports hours too.
     $days = array_map('strval', array(1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7));
     $userWatchlistOption = (string) $this->getUser()->getOption('watchlistdays');
     // add the user preference, if it isn't available already
     if (!in_array($userWatchlistOption, $days) && $userWatchlistOption !== '0') {
         $days[] = $userWatchlistOption;
     }
     $maxDays = (string) ($this->getConfig()->get('RCMaxAge') / (3600 * 24));
     // add the maximum possible value, if it isn't available already
     if (!in_array($maxDays, $days)) {
         $days[] = $maxDays;
     }
     $selected = (string) $options['days'];
     if ($selected <= 0) {
         $selected = $maxDays;
     }
     // add the currently selected value, if it isn't available already
     if (!in_array($selected, $days)) {
         $days[] = $selected;
     }
     $select = new XmlSelect('days', 'days', $selected);
     asort($days);
     foreach ($days as $value) {
         if ($value < 1) {
             $name = $this->msg('hours')->numParams($value * 24)->text();
         } else {
             $name = $this->msg('days')->numParams($value)->text();
         }
         $select->addOption($name, $value);
     }
     return $select->getHTML() . "\n<br />\n";
 }
 /**
  * Show a drop-down box of special pages
  * @return string
  */
 function specialPagesList()
 {
     global $wgScript;
     $select = new XmlSelect('title');
     $pages = SpecialPageFactory::getUsablePages();
     array_unshift($pages, SpecialPageFactory::getPage('SpecialPages'));
     foreach ($pages as $obj) {
         $select->addOption($obj->getDescription(), $obj->getTitle()->getPrefixedDBkey());
     }
     return Html::rawElement('form', array('id' => 'specialpages', 'method' => 'get', 'action' => $wgScript), $select->getHTML() . Xml::submitButton(wfMessage('go')->text()));
 }