本文整理汇总了PHP中XmlSelect::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlSelect::setAttribute方法的具体用法?PHP XmlSelect::setAttribute怎么用?PHP XmlSelect::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlSelect
的用法示例。
在下文中一共展示了XmlSelect::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInputHTML
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}";
}
示例2: getInputHTML
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();
}
示例3: 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' );
}
示例4: getInputHTML
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();
}
示例5: testGetAttributes
/**
* @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);
}
示例6: buildSelector
/**
* 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();
}
示例7: execute
//.........这里部分代码省略.........
?>
</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"';
示例8: 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;
}
示例9: getLimitSelect
/**
* 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();
}
示例10: getTagSelect
/**
* 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;
}
示例11: 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;
}
示例12: execute
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);
//.........这里部分代码省略.........
示例13: execute
//.........这里部分代码省略.........
<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"';
示例14: showTalkpageViewOptions
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;
}
示例15: 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 ) . " " . $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;
}