当前位置: 首页>>代码示例>>PHP>>正文


PHP XmlSelect::setDefault方法代码示例

本文整理汇总了PHP中XmlSelect::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlSelect::setDefault方法的具体用法?PHP XmlSelect::setDefault怎么用?PHP XmlSelect::setDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlSelect的用法示例。


在下文中一共展示了XmlSelect::setDefault方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showToolbar

	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' );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:SpecialWebFonts.php

示例2: execute

 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());
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SpecialWikiFactoryReporter_body.php

示例3: testSetDefaultAfterAddingOptions

 /**
  * 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());
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:15,代码来源:XmlSelectTest.php

示例4: buildSelect

 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();
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:10,代码来源:CloseWikis.page.php

示例5: namespaceMessageForm

 /**
  * 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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:SpecialTranslations.php

示例6: getExistingSelector

 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();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:AbuseFilterViewEdit.php

示例7: getActionSelector

 /**
  * Drop down menu for selection of actions that can be used to filter the log
  * @param array $types
  * @param string $action
  * @return string
  * @since 1.27
  */
 private function getActionSelector($types, $action)
 {
     if ($this->allowedActions === null || !count($this->allowedActions)) {
         return '';
     }
     $html = '';
     $html .= Xml::label(wfMessage('log-action-filter-' . $types[0])->text(), 'action-filter-' . $types[0]) . "\n";
     $select = new XmlSelect('subtype');
     $select->addOption(wfMessage('log-action-filter-all')->text(), '');
     foreach ($this->allowedActions as $value) {
         $msgKey = 'log-action-filter-' . $types[0] . '-' . $value;
         $select->addOption(wfMessage($msgKey)->text(), $value);
     }
     $select->setDefault($action);
     $html .= $select->getHTML();
     return $html;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:24,代码来源:LogEventsList.php

示例8: limitSelector

 protected function limitSelector()
 {
     $items = array(100, 1000, 5000);
     $selector = new XmlSelect('limit', 'limit');
     $selector->setDefault($this->options['limit']);
     foreach ($items as $count) {
         $selector->addOption($this->msg('translate-page-limit-option')->numParams($count)->text(), $count);
     }
     return $selector->getHTML();
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:10,代码来源:SpecialTranslate.php

示例9: constructCreateForm

 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");
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:SpecialAccountManager.php

示例10: userSelect

 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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:DeleteBatch.body.php

示例11: languageSelector

	/**
	 * Returns a language selector.
	 * @param $language \string Language code of the language the names should
	 * be localised to.
	 * @param $selectedId \string The language code that is selected by default.
	 * @return string
	 */
	public static function languageSelector( $language, $selectedId ) {
		$languages = self::getLanguageNames( $language );
		ksort( $languages );

		$selector = new XmlSelect( 'language', 'language' );
		$selector->setDefault( $selectedId );
		foreach ( $languages as $code => $name ) {
			$selector->addOption( "$code - $name", $code );
		}

		return $selector->getHTML();
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:TranslateUtils.php

示例12: searchProfileForm

	/**
	 * Hook: SpecialSearchProfileForm
	 */
	public static function searchProfileForm( SpecialSearch $search, &$form, /*string*/ $profile, $term, array $opts ) {
		if ( $profile !== 'translation' ) {
			return true;
		}

		if ( !$search->getSearchEngine()->supports( 'title-suffix-filter' ) ) {
			return false;
		}

		$hidden = '';
		foreach ( $opts as $key => $value ) {
			$hidden .= Html::hidden( $key, $value );
		}

		$context = $search->getContext();
		$code = $context->getLanguage()->getCode();
		$selected = $context->getRequest()->getVal( 'languagefilter' );

		if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {
			$languages = LanguageNames::getNames( $code,
				LanguageNames::FALLBACK_NORMAL,
				LanguageNames::LIST_MW
			);
		} else {
			$languages = Language::getLanguageNames( false );
		}

		ksort( $languages );

		$selector = new XmlSelect( 'languagefilter', 'languagefilter' );
		$selector->setDefault( $selected );
		$selector->addOption( wfMessage( 'translate-search-nofilter' )->text(), '-' );
		foreach ( $languages as $code => $name ) {
			$selector->addOption( "$code - $name", $code );
		}

		$selector = $selector->getHTML();

		$label = Xml::label( wfMessage( 'translate-search-languagefilter' )->text(), 'languagefilter' ) . '&#160;';
		$params = array( 'id' => 'mw-searchoptions' );

		$form = Xml::fieldset( false, false, $params ) .
			$hidden . $label . $selector .
			Html::closeElement( 'fieldset' );
		return false;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:49,代码来源:TranslateHooks.php

示例13: showPermissions

	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;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:75,代码来源:SpecialFirstSteps.php

示例14: getWorkflowStatus

 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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:33,代码来源:SpecialTranslate.php


注:本文中的XmlSelect::setDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。