public function execute($par) { global $wgOut, $wgRequest; $this->setHeaders(); $code = $wgRequest->getVal('verify'); if ($code !== null) { $dbw = wfGetDB(DB_MASTER); $row = $dbw->selectRow('email_capture', array('ec_verified'), array('ec_code' => $code), __METHOD__); if ($row && !$row->ec_verified) { $dbw->update('email_capture', array('ec_verified' => 1), array('ec_code' => $code), __METHOD__); if ($dbw->affectedRows()) { $wgOut->addWikiMsg('emailcapture-success'); } else { $wgOut->addWikiMsg('emailcapture-failure'); } } elseif ($row && $row->ec_verified) { $wgOut->addWikiMsg('emailcapture-already-confirmed'); } else { $wgOut->addWikiMsg('emailcapture-invalid-code'); } } else { // Show simple form for submitting verification code $o = Html::openElement('form', array('action' => $this->getTitle()->getFullUrl(), 'method' => 'post')); $o .= Html::element('p', array(), wfMsg('emailcapture-instructions')); $o .= Html::openElement('blockquote'); $o .= Html::element('label', array('for' => 'emailcapture-verify'), wfMsg('emailcapture-verify')) . ' '; $o .= Html::input('verify', '', 'text', array('id' => 'emailcapture-verify', 'size' => 32)) . ' '; $o .= Html::input('submit', wfMsg('emailcapture-submit'), 'submit'); $o .= Html::closeElement('blockquote'); $o .= Html::closeElement('form'); $wgOut->addHtml($o); } }
function execute($category) { global $wgUser, $wgRequest, $wgOut, $wgPageSchemasHandlerClasses; if (!$wgUser->isAllowed('generatepages')) { $wgOut->permissionRequired('generatepages'); return; } $this->setHeaders(); $param = $wgRequest->getText('param'); if (!empty($param) && !empty($category)) { // Generate the pages! $this->generatePages($param, $wgRequest->getArray('page')); $text = Html::element('p', null, wfMessage('ps-generatepages-success')->parse()); $wgOut->addHTML($text); return true; } if ($category == "") { // No category listed. // TODO - show an error message. return true; } // Standard "generate pages" form, with category name set. // Check for a valid category, with a page schema defined. $pageSchemaObj = new PSSchema($category); if (!$pageSchemaObj->isPSDefined()) { $text = Html::element('p', null, wfMessage('ps-generatepages-noschema')->parse()); $wgOut->addHTML($text); return true; } $text = Html::element('p', null, wfMessage('ps-generatepages-desc')->parse()) . "\n"; $text .= '<form method="post">'; $text .= Html::input('param', $category, 'hidden') . "\n"; $text .= '<div id="ps_check_all_check_none"> <input type="button" id="ps_check_all" value="' . wfMessage('powersearch-toggleall')->parse() . '" /> <input type="button" id="ps_check_none" value="' . wfMessage('powersearch-togglenone')->parse() . '" /> </div><br/>'; $wgOut->addModules('ext.pageschemas.generatepages'); // This hook will set an array of strings, with each value // as a title of a page to be created. $pageList = array(); foreach ($wgPageSchemasHandlerClasses as $psHandlerClass) { $pagesFromHandler = call_user_func(array($psHandlerClass, "getPagesToGenerate"), $pageSchemaObj); foreach ($pagesFromHandler as $page) { $pageList[] = $page; } } foreach ($pageList as $page) { if (!$page instanceof Title) { continue; } $pageName = PageSchemas::titleString($page); $text .= Html::input('page[]', $pageName, 'checkbox', array('checked' => true)); $text .= "\n" . Linker::link($page) . "<br />\n"; } $text .= "<br />\n"; $text .= Html::input(null, wfMessage('generatepages')->parse(), 'submit'); $text .= "\n</form>"; $wgOut->addHTML($text); return true; }
function getInputHTML($value) { $attribs = array('id' => $this->mID, 'name' => $this->mName, 'size' => $this->getSize(), 'value' => $value) + $this->getTooltipAndAccessKey(); if ($this->mClass !== '') { $attribs['class'] = $this->mClass; } # @todo Enforce pattern, step, required, readonly on the server side as # well $allowedParams = array('min', 'max', 'pattern', 'title', 'step', 'placeholder', 'list', 'maxlength', 'tabindex', 'disabled', 'required', 'autofocus', 'multiple', 'readonly'); $attribs += $this->getAttributes($allowedParams); # Implement tiny differences between some field variants # here, rather than creating a new class for each one which # is essentially just a clone of this one. $type = 'text'; if (isset($this->mParams['type'])) { switch ($this->mParams['type']) { case 'int': $type = 'number'; break; case 'float': $type = 'number'; $attribs['step'] = 'any'; break; # Pass through # Pass through case 'email': case 'password': case 'file': case 'url': $type = $this->mParams['type']; break; } } return Html::input($this->mName, $value, $type, $attribs); }
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect; $checkbox_class = $is_mandatory ? 'mandatoryField' : 'createboxInput'; $span_class = 'checkboxSpan'; if (array_key_exists('class', $other_args)) { $span_class .= ' ' . $other_args['class']; } $input_id = "input_{$sfgFieldNum}"; // get list delimiter - default is comma if (array_key_exists('delimiter', $other_args)) { $delimiter = $other_args['delimiter']; } else { $delimiter = ','; } $cur_values = SFUtils::getValuesArray($cur_value, $delimiter); if (($possible_values = $other_args['possible_values']) == null) { $possible_values = array(); } $text = ''; foreach ($possible_values as $key => $possible_value) { $cur_input_name = $input_name . '[' . $key . ']'; if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels'])) { $label = $other_args['value_labels'][$possible_value]; } else { $label = $possible_value; } $checkbox_attrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex, 'class' => $checkbox_class); if (in_array($possible_value, $cur_values)) { $checkbox_attrs['checked'] = 'checked'; } if ($is_disabled) { $checkbox_attrs['disabled'] = 'disabled'; } $checkbox_input = Html::input($cur_input_name, $possible_value, 'checkbox', $checkbox_attrs); // Make a span around each checkbox, for CSS purposes. $text .= "\t" . Html::rawElement('span', array('class' => $span_class), $checkbox_input . ' ' . $label) . "\n"; $sfgTabIndex++; $sfgFieldNum++; } $outerSpanID = "span_{$sfgFieldNum}"; $outerSpanClass = 'checkboxesSpan'; if ($is_mandatory) { $outerSpanClass .= ' mandatoryFieldSpan'; } if (array_key_exists('show on select', $other_args)) { $outerSpanClass .= ' sfShowIfChecked'; foreach ($other_args['show on select'] as $div_id => $options) { if (array_key_exists($outerSpanID, $sfgShowOnSelect)) { $sfgShowOnSelect[$outerSpanID][] = array($options, $div_id); } else { $sfgShowOnSelect[$outerSpanID] = array(array($options, $div_id)); } } } $text .= Html::hidden($input_name . '[is_list]', 1); $outerSpanAttrs = array('id' => $outerSpanID, 'class' => $outerSpanClass); $text = "\t" . Html::rawElement('span', $outerSpanAttrs, $text) . "\n"; return $text; }
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 makeSearchForm() { global $wgScript; $fields = array(); $fields['edituser-username'] = Html::input('username', $this->target); $thisTitle = $this->getTitle(); $form = Html::rawElement('form', array('method' => 'get', 'action' => $wgScript), Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . Xml::buildForm($fields, 'edituser-dosearch')); return $form; }
/** * Produce a nice little form * @param OutputPage $out */ function getForm(OutputPage $out) { list($sum, $answer) = $this->pickSum(); $index = $this->storeCaptcha(array('answer' => $answer)); $form = '<table><tr><td>' . $this->fetchMath($sum) . '</td>'; $form .= '<td>' . Html::input('wpCaptchaWord', false, false, array('tabindex' => '1', 'autocomplete' => 'off', 'required')) . '</td></tr></table>'; $form .= Html::hidden('wpCaptchaId', $index); return $form; }
private function showForm($err = '') { global $wgOut, $wgUser; $wgOut->addWikiMsg('lockdbtext'); if ($err != '') { $wgOut->setSubtitle(wfMsg('formerror')); $wgOut->addHTML('<p class="error">' . htmlspecialchars($err) . "</p>\n"); } $wgOut->addHTML(Html::openElement('form', array('id' => 'lockdb', 'method' => 'POST', 'action' => $this->getTitle()->getLocalURL('action=submit'))) . "\n" . wfMsgHtml('enterlockreason') . ":\n" . Html::textarea('wpLockReason', $this->reason, array('rows' => 4)) . "\n<table>\n\t<tr>\n\t\t" . Html::openElement('td', array('style' => 'text-align:right')) . "\n\t\t\t" . Html::input('wpLockConfirm', null, 'checkbox') . "\n\t\t</td>\n\t\t" . Html::openElement('td', array('style' => 'text-align:left')) . wfMsgHtml('lockconfirm') . "</td>\n\t</tr>\n\t<tr>\n\t\t<td> </td>\n\t\t" . Html::openElement('td', array('style' => 'text-align:left')) . "\n\t\t\t" . Html::input('wpLock', wfMsg('lockbtn'), 'submit') . "\n\t\t</td>\n\t</tr>\n</table>\n" . Html::hidden('wpEditToken', $wgUser->editToken()) . "\n" . Html::closeElement('form')); }
/** * Executed when the user opens the DSMW administration special page * Calculates the PushFeed list and the pullfeed list (and everything that * is displayed on the psecial page * * @global <Object> $wgOut Output page instance * @global <String> $wgServerName * @global <String> $wgScriptPath * @return <bool> */ public function execute() { global $wgOut, $wgRequest, $wgServerName, $wgScriptPath, $wgDSMWIP, $wgServerName, $wgScriptPath, $wgUser; if (!$this->userCanExecute($wgUser)) { // If the user is not authorized, show an error. $this->displayRestrictionError(); return; } /**** Get status of refresh job, if any ****/ $dbr =& wfGetDB(DB_SLAVE); $row = $dbr->selectRow('job', '*', array('job_cmd' => 'DSMWUpdateJob'), __METHOD__); if ($row !== false) { // similar to Job::pop_type, but without deleting the job $title = Title::makeTitleSafe($row->job_namespace, $row->job_title); $updatejob = Job::factory($row->job_cmd, $title, Job::extractBlob($row->job_params), $row->job_id); } else { $updatejob = NULL; } $row1 = $dbr->selectRow('job', '*', array('job_cmd' => 'DSMWPropertyTypeJob'), __METHOD__); if ($row1 !== false) { // similar to Job::pop_type, but without deleting the job $title = Title::makeTitleSafe($row1->job_namespace, $row1->job_title); $propertiesjob = Job::factory($row1->job_cmd, $title, Job::extractBlob($row1->job_params), $row1->job_id); } else { $propertiesjob = NULL; } /**** Execute actions if any ****/ $action = $wgRequest->getText('action'); if ($action == 'logootize') { if ($updatejob === NULL) { // careful, there might be race conditions here $title = Title::makeTitle(NS_SPECIAL, 'DSMWAdmin'); $newjob = new DSMWUpdateJob($title); $newjob->insert(); $wgOut->addHTML('<p><font color="red"><b>' . wfMsg('dsmw-special-admin-articleupstarted') . '</b></font></p>'); } else { $wgOut->addHTML('<p><font color="red"><b>' . wfMsg('dsmw-special-admin-articleuprunning') . '</b></font></p>'); } } elseif ($action == 'addProperties') { if ($propertiesjob === NULL) { $title1 = Title::makeTitle(NS_SPECIAL, 'DSMWAdmin'); $newjob1 = new DSMWPropertyTypeJob($title1); $newjob1->insert(); $wgOut->addHTML('<p><font color="red"><b>' . wfMsg('dsmw-special-admin-typeupstarted') . '</b></font></p>'); } else { $wgOut->addHTML('<p><font color="red"><b>' . wfMsg('dsmw-special-admin-typeuprunning') . '</b></font></p>'); } } $wgOut->setPagetitle('DSMW Settings'); $wgOut->addHTML(Html::element('p', array(), wfMsg('dsmw-special-admin-intro'))); $wgOut->addHTML(Html::rawElement('form', array('name' => 'properties', 'action' => '', 'method' => 'POST'), Html::hidden('action', 'addProperties') . '<br />' . Html::element('h2', array(), wfMsg('dsmw-special-admin-propheader')) . Html::element('p', array(), wfMsg('dsmw-special-admin-proptext')) . Html::input('updateProperties', wfMsg('dsmw-special-admin-propheader'), 'submit'))); $wgOut->addHTML(Html::rawElement('form', array('name' => 'logoot', 'action' => '', 'method' => 'POST'), Html::hidden('action', 'logootize') . '<br />' . Html::element('h2', array(), wfMsg('dsmw-special-admin-upheader')) . Html::element('p', array(), wfMsg('dsmw-special-admin-uptext')) . Html::input('updateArticles', wfMsg('dsmw-special-admin-upbutton'), 'submit'))); return false; }
function getInputHTML($value) { $select = parent::getInputHTML($value[1]); $textAttribs = ['id' => $this->mID . '-other', 'size' => $this->getSize(), 'class' => ['mw-htmlform-select-and-other-field'], 'data-id-select' => $this->mID]; if ($this->mClass !== '') { $textAttribs['class'][] = $this->mClass; } $allowedParams = ['required', 'autofocus', 'multiple', 'disabled', 'tabindex', 'maxlength']; $textAttribs += $this->getAttributes($allowedParams); $textbox = Html::input($this->mName . '-other', $value[2], 'text', $textAttribs); return "{$select}<br />\n{$textbox}"; }
public function testRetornaClasseAnyComConfiguracaoPadrao() { Html::config(['input' => ['class' => 'form-input'], 'form' => ['class' => "form-horizontal"]]); $username = Html::input(['attributes' => ['type' => 'text', 'name' => 'username']]); $password = Html::input(['attributes' => ['type' => 'password', 'name' => 'password']]); $form = Html::form(['attributes' => ['action' => 'save.php'], 'content' => $username . PHP_EOL . $password]); $expected = '<form action="save.php" class="form-horizontal">'; $expected .= '<input type="text" name="username" class="form-input"/>' . PHP_EOL; $expected .= '<input type="password" name="password" class="form-input"/>'; $expected .= '</form>'; $this->assertEquals($expected, (string) $form); }
function _before_edit() { $html = new Html(); $advertising_list = $this->get_advertising(); $input_data = join(',', $advertising_list); $selected = $this->_mod->where(array('id' => $this->_get('id')))->getField('advertising'); $advertising = $html->input('select', 'advertising', $input_data, 'advertising', '', $selected); $this->assign('advertising', $advertising); //广告位 $this->assign('iframe_tools', true); //iFrame弹窗 }
function getInputHTML($value) { $select = parent::getInputHTML($value[1]); $textAttribs = array('id' => $this->mID . '-other', 'size' => $this->getSize()); if ($this->mClass !== '') { $textAttribs['class'] = $this->mClass; } $allowedParams = array('required', 'autofocus', 'multiple', 'disabled', 'tabindex'); $textAttribs += $this->getAttributes($allowedParams); $textbox = Html::input($this->mName . '-other', $value[2], 'text', $textAttribs); return "{$select}<br />\n{$textbox}"; }
/** * Displays a small form to add a new campaign. * * @since 0.1 */ protected function displayAddNewControl() { $out = $this->getOutput(); $out->addHTML(Html::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalURL()))); $out->addHTML('<fieldset>'); $out->addHTML('<legend>' . htmlspecialchars(wfMsg('surveys-special-addnew')) . '</legend>'); $out->addHTML(Html::element('p', array(), wfMsg('surveys-special-namedoc'))); $out->addHTML(Html::element('label', array('for' => 'newcampaign'), wfMsg('surveys-special-newname'))); $out->addHTML(' ' . Html::input('newsurvey') . ' '); $out->addHTML(Html::input('addnewsurvey', wfMsg('surveys-special-add'), 'submit')); global $wgUser; $out->addHTML(Html::hidden('wpEditToken', $wgUser->editToken())); $out->addHTML('</fieldset></form>'); }
function getInputHTML($value) { $attribs = array('id' => $this->mID, 'name' => $this->mName, 'size' => $this->getSize(), 'value' => $value, 'dir' => $this->mDir, 'spellcheck' => $this->getSpellCheck()) + $this->getTooltipAndAccessKey(); if ($this->mClass !== '') { $attribs['class'] = $this->mClass; } # @todo Enforce pattern, step, required, readonly on the server side as # well $allowedParams = array('type', 'min', 'max', 'pattern', 'title', 'step', 'placeholder', 'list', 'maxlength', 'tabindex', 'disabled', 'required', 'autofocus', 'multiple', 'readonly'); $attribs += $this->getAttributes($allowedParams); # Extract 'type' $type = $this->getType($attribs); return Html::input($this->mName, $value, $type, $attribs); }
/** * Returns the HTML for a storysubmission form. * * @param Parser $parser * @param array $args * * @return HTML */ private static function getFrom(Parser $parser, array $args) { global $wgUser, $wgStyleVersion, $wgScriptPath, $wgStylePath; global $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen; $maxLen = array_key_exists('maxlength', $args) && is_int($args['maxlength']) ? $args['maxlength'] : $egStoryboardMaxStoryLen; $minLen = array_key_exists('minlength', $args) && is_int($args['minlength']) ? $args['minlength'] : $egStoryboardMinStoryLen; efStoryboardAddJSLocalisation($parser); // Loading a seperate JS file would be overkill for just these 3 lines, and be bad for performance. $parser->getOutput()->addHeadItem(Html::linkedStyle("{$egStoryboardScriptPath}/storyboard.css?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/storyboard.js?{$wgStyleVersion}") . Html::linkedScript("{$wgStylePath}/common/jquery.min.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/jquery/jquery.validate.js?{$wgStyleVersion}") . Html::inlineScript(<<<EOT \$(function() { \tdocument.getElementById( 'storysubmission-button' ).disabled = true; \tstbValidateStory( document.getElementById('storytext'), {$minLen}, {$maxLen}, 'storysubmission-charlimitinfo', 'storysubmission-button' ) \t\$("#storyform").validate({ \t\tmessages: { \t\t\tstorytitle: { \t\t\t\tremote: jQuery.validator.format( stbMsg( 'storyboard-alreadyexistschange' ) ) \t\t\t} \t\t} \t});\t\t });\t\t\t EOT )); $fieldSize = 50; $width = StoryboardUtils::getDimension($args, 'width', $egStorysubmissionWidth); $formBody = "<table width='{$width}'>"; $defaultName = ''; $defaultEmail = ''; if ($wgUser->isLoggedIn()) { $defaultName = $wgUser->getRealName() !== '' ? $wgUser->getRealName() : $wgUser->getName(); $defaultEmail = $wgUser->getEmail(); } $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-yourname')) . '<td>' . Html::input('name', $defaultName, 'text', array('size' => $fieldSize, 'class' => 'required', 'maxlength' => 255, 'minlength' => 2)) . '</td></tr>'; $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-location')) . '<td>' . Html::input('location', '', 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 2)) . '</td></tr>'; $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-occupation')) . '<td>' . Html::input('occupation', '', 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 4)) . '</td></tr>'; $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-email')) . '<td>' . Html::input('email', $defaultEmail, 'text', array('size' => $fieldSize, 'class' => 'required email', 'size' => $fieldSize, 'maxlength' => 255)) . '</td></tr>'; $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-storytitle')) . '<td>' . Html::input('storytitle', '', 'text', array('size' => $fieldSize, 'class' => 'required storytitle', 'maxlength' => 255, 'minlength' => 2, 'remote' => "{$wgScriptPath}/api.php?format=json&action=storyexists")) . '</td></tr>'; $formBody .= '<tr><td colspan="2">' . wfMsg('storyboard-story') . Html::element('div', array('class' => 'storysubmission-charcount', 'id' => 'storysubmission-charlimitinfo'), wfMsgExt('storyboard-charsneeded', 'parsemag', $minLen)) . '<br />' . Html::element('textarea', array('id' => 'storytext', 'name' => 'storytext', 'rows' => 7, 'class' => 'required', 'onkeyup' => "stbValidateStory( this, {$minLen}, {$maxLen}, 'storysubmission-charlimitinfo', 'storysubmission-button' )"), null) . '</td></tr>'; // TODO: add upload functionality $formBody .= '<tr><td colspan="2"><input type="checkbox" id="storyboard-agreement" /> ' . $parser->recursiveTagParse(htmlspecialchars(wfMsg('storyboard-agreement'))) . '</td></tr>'; $formBody .= '<tr><td colspan="2">' . Html::input('storysubmission-button', wfMsg('htmlform-submit'), 'submit', array('id' => 'storysubmission-button')) . '</td></tr>'; $formBody .= '</table>'; $formBody .= Html::hidden('wpStoryEditToken', $wgUser->editToken()); if (!array_key_exists('language', $args) || !array_key_exists($args['language'], Language::getLanguageNames())) { global $wgContLanguageCode; $args['language'] = $wgContLanguageCode; } $formBody .= Html::hidden('lang', $args['language']); return Html::rawElement('form', array('id' => 'storyform', 'name' => 'storyform', 'method' => 'post', 'action' => SpecialPage::getTitleFor('StorySubmission')->getFullURL(), 'onsubmit' => 'return stbValidateSubmission( "storyboard-agreement" );'), $formBody); }
/** * Returns the HTML necessary for getting information about the * semantic property within the Page Schemas 'editschema' page. */ public static function getTemplateEditingHTML($psTemplate) { $prop_array = array(); $hasExistingValues = false; if (!is_null($psTemplate)) { $prop_array = $psTemplate->getObject('semanticinternalobjects_MainProperty'); if (!is_null($prop_array)) { $hasExistingValues = true; } } $text = '<p>' . 'Name of property to connect this template\'s fields to the rest of the page (should only be used if this template can have multiple instances):' . ' '; $propName = PageSchemas::getValueFromObject($prop_array, 'name'); $text .= Html::input('sio_property_name_num', $propName, array('size' => 15)) . "\n"; return array($text, $hasExistingValues); }
/** * Returns the HTML necessary for getting information about the * semantic property within the Page Schemas 'editschema' page. */ public static function getTemplateEditingHTML($psTemplate) { $prop_array = array(); $hasExistingValues = false; if (!is_null($psTemplate)) { $prop_array = $psTemplate->getObject('semanticinternalobjects_MainProperty'); if (!is_null($prop_array)) { $hasExistingValues = true; } } $text = '<p>' . wfMsgHtml('semanticinternalobjects-mainpropertyname') . ' ' . wfMsgHtml('semanticinternalobjects-propnamewarning') . ' '; $propName = PageSchemas::getValueFromObject($prop_array, 'name'); $text .= Html::input('sio_property_name_num', $propName, array('size' => 15)) . "\n"; return array($text, $hasExistingValues); }
public function getInputHTML($value) { $flags = ''; $prefix = 'mw-htmlform-'; if ($this->mParent instanceof VFormHTMLForm || $this->mParent->getConfig()->get('UseMediaWikiUIEverywhere')) { $prefix = 'mw-ui-'; // add mw-ui-button separately, so the descriptor doesn't need to set it $flags .= $prefix . 'button'; } foreach ($this->mFlags as $flag) { $flags .= ' ' . $prefix . $flag; } $attr = array('class' => 'mw-htmlform-submit ' . $this->mClass . $flags, 'id' => $this->mID) + $this->getAttributes(array('disabled', 'tabindex')); return Html::input($this->mName, $value, $this->buttonType, $attr); }
/** * Build the login page * @todo Refactor this into parent template */ public function execute() { $action = $this->data['action']; $token = $this->data['token']; $watchArticle = $this->getArticleTitleToWatch(); $stickHTTPS = $this->doStickHTTPS() ? Html::input('wpStickHTTPS', 'true', 'hidden') : ''; $username = strlen($this->data['name']) ? $this->data['name'] : null; // @TODO make sure this also includes returnto and returntoquery from the request $query = array('type' => 'signup'); // Security: $action is already filtered by SpecialUserLogin $actionQuery = wfCgiToArray($action); if (isset($actionQuery['returnto'])) { $query['returnto'] = $actionQuery['returnto']; } if (isset($actionQuery['returntoquery'])) { $query['returntoquery'] = $actionQuery['returntoquery']; // Allow us to distinguish sign ups from the left nav to logins. // This allows us to show them an edit tutorial when they return to the page. if ($query['returntoquery'] === 'welcome=yes') { $query['returntoquery'] = 'campaign=leftNavSignup'; } } // For Extension:Campaigns $campaign = $this->getSkin()->getRequest()->getText('campaign'); if ($campaign) { $query['campaign'] = $campaign; } // Check for permission to create new account first $user = $this->getRequestContext()->getUser(); if ($user->isAllowed('createaccount')) { $signupLink = Linker::link(SpecialPage::getTitleFor('Userlogin'), wfMessage('mobile-frontend-main-menu-account-create')->text(), array('class' => 'mw-mf-create-account mw-ui-block'), $query); } else { $signupLink = ''; } // Check for permission to reset password first if ($this->data['canreset'] && $this->data['useemail'] && $this->data['resetlink'] === true) { $passwordReset = Html::element('a', array('class' => 'mw-userlogin-help mw-ui-block', 'href' => SpecialPage::getTitleFor('PasswordReset')->getLocalUrl()), wfMessage('passwordreset')->text()); } else { $passwordReset = ''; } $login = Html::openElement('div', array('id' => 'mw-mf-login', 'class' => 'content')); $form = Html::openElement('div', array()) . Html::openElement('form', array('name' => 'userlogin', 'class' => 'user-login', 'method' => 'post', 'action' => $action)) . Html::openElement('div', array('class' => 'inputs-box')) . Html::input('wpName', $username, 'text', array('class' => 'loginText', 'placeholder' => wfMessage('mobile-frontend-username-placeholder')->text(), 'id' => 'wpName1', 'tabindex' => '1', 'size' => '20', 'required')) . Html::input('wpPassword', null, 'password', array('class' => 'loginPassword', 'placeholder' => wfMessage('mobile-frontend-password-placeholder')->text(), 'id' => 'wpPassword1', 'tabindex' => '2', 'size' => '20')) . Html::closeElement('div') . Html::input('wpRemember', '1', 'hidden') . Html::input('wpLoginAttempt', wfMessage('mobile-frontend-login')->text(), 'submit', array('id' => 'wpLoginAttempt', 'class' => $baseClass = MobileUI::buttonClass('constructive'), 'tabindex' => '3')) . Html::input('wpLoginToken', $token, 'hidden') . Html::input('watch', $watchArticle, 'hidden') . $stickHTTPS . Html::closeElement('form') . $passwordReset . $signupLink . Html::closeElement('div'); echo $login; $this->renderGuiderMessage(); $this->renderMessageHtml(); echo $form; echo Html::closeElement('div'); }
function searchForm() { $output = Html::element('legend', null, $this->msg('majorchanges-log-filter')->text()); $fields = array(); // Search conditions $fields['majorchanges-log-user-filter'] = Html::input('wpUserFilter', $this->mUserFilter); $fields['majorchanges-log-title-filter'] = Html::input('wpTitleFilter', $this->mTitleFilter); /* $fields['majorchanges-log-tag-filter'] = Html::input( 'wpRevTagFilter', $this->mRevTagFilter ); */ $fields['majorchanges-log-mode-filter'] = $this->getModeFilter(); $output .= Xml::tags('form', array('method' => 'get', 'action' => $this->getPageTitle()->getLocalURL()), Xml::buildForm($fields, 'htmlform-submit') . Html::hidden('title', $this->getPageTitle()->getPrefixedDBkey())); $output = Xml::tags('fieldset', null, $output); $this->getOutput()->addHTML($output); }
public function index() { $this->assign('curr_name', 'index'); $data = M('sysinfo')->where(array('lang' => $this->lang))->select(); $html = new Html(); $info = array(); foreach ($data as $key => $val) { $info[$val['tabtype']][$key] = $val; if ($val['vartype'] == 'bool') { $val['vartype'] = 'radio'; $input_data = 'Y,N'; } else { $input_data = $val['value']; } $info[$val['tabtype']][$key]['html'] = $html->input($val['vartype'], 'data[' . $val['id'] . ']', $input_data, $val['varname'], '', $val['value']); } $this->assign('info', $info); $this->display(); }
/** * @param array $aggregategroup * @param array $pages * @return string */ protected function showAggregateGroup($group, array $pages) { $out = ''; $id = $group->getId(); $label = $group->getLabel(); $desc = $group->getDescription($this->getContext()); $div = Html::openElement('div', array('class' => 'mw-tpa-group', 'data-groupid' => $id, 'data-id' => $this->htmlIdForGroup($group))); $out .= $div; $edit = ''; $remove = ''; $editGroup = ''; $select = ''; $addButton = ''; // Add divs for editing Aggregate Groups if ($this->hasPermission) { // Group edit and remove buttons $edit = Html::element('span', array('class' => 'tp-aggregate-edit-ag-button')); $remove = Html::element('span', array('class' => 'tp-aggregate-remove-ag-button')); // Edit group div $editGroupNameLabel = $this->msg('tpt-aggregategroup-edit-name')->escaped(); $editGroupName = Html::input('tp-agg-name', $label, 'text', array('class' => 'tp-aggregategroup-edit-name', 'maxlength' => '200')); $editGroupDescriptionLabel = $this->msg('tpt-aggregategroup-edit-description')->escaped(); $editGroupDescription = Html::input('tp-agg-desc', $desc, 'text', array('class' => 'tp-aggregategroup-edit-description')); $saveButton = Xml::submitButton($this->msg('tpt-aggregategroup-update')->text(), array('class' => 'tp-aggregategroup-update')); $cancelButton = Xml::submitButton($this->msg('tpt-aggregategroup-update-cancel')->text(), array('class' => 'tp-aggregategroup-update-cancel')); $editGroup = Html::rawElement('div', array('class' => 'tp-edit-group hidden'), $editGroupNameLabel . $editGroupName . '<br />' . $editGroupDescriptionLabel . $editGroupDescription . $saveButton . $cancelButton); // Subgroups selector $select = Html::input('tp-subgroups-input', '', 'text', array('class' => 'tp-group-input')); $addButton = Html::element('input', array('type' => 'button', 'value' => $this->msg('tpt-aggregategroup-add')->text(), 'class' => 'tp-aggregate-add-button')); } // Aggregate Group info div $groupName = Html::rawElement('h2', array('class' => 'tp-name'), htmlspecialchars($label) . $edit . $remove); $groupDesc = Html::element('p', array('class' => 'tp-desc'), $desc); $groupInfo = Html::rawElement('div', array('class' => 'tp-display-group'), $groupName . $groupDesc); $out .= $groupInfo; $out .= $editGroup; $out .= $this->listSubgroups($group); $out .= $select . $addButton; $out .= "</div>"; return $out; }
function fields_input($fields, $is_edit = 0, $mtype = 1) { if (is_array($fields)) { $html = new Html(); $fields_input = array(); foreach ($fields as $key => $val) { $attribute = ''; $selected = ''; $value = $val['defvalue']; /* if(!empty($val['verification'])) { $attribute .= ' pattern="'.$val['verification'].'" '; } */ if ($val['required'] == 1) { $attribute .= ' required="required" '; } //编辑时处理值 value if ($is_edit > 0) { $value = M('mflist')->where(array('aid' => $is_edit, 'fieldsid' => $val['id'], 'mtype' => $mtype, 'lang' => $this->lang))->getField('info'); //图片集 if ($val['formtype'] == 'images' && $value) { $img_arr = explode('|||', trim($value, '|||')); $value = array_chunk($img_arr, 2); $imglist['images_' . $val['id']] = $value; $fields_input['imglist'] = $imglist; } } if ($val['formtype'] == 'select' || $val['formtype'] == 'radio' || $val['formtype'] == 'checkbox') { $selected = $value; $value = $val['defvalue']; } $val['input'] = $html->input($val['formtype'], 'addfields[' . $val['id'] . ']', $value, $val['field'], $attribute, $selected); $fields_input[$val['id']] = $val; } // end foreach } //end if return $fields_input; }
/** * Hijack captcha output * * Captcha output appears in $tpl->data['header'] but there's a lot * of cruft that comes with it. We just want to get the captcha image * a display an input field for the user to enter captcha info, without * the additinal cruft. * * @todo move this into ConfirmEdit extension when MW is context aware * @param string $header * @return string */ protected function handleCaptcha($header) { // first look for <div class="captcha">, otherwise early return if (!$header || !stristr($header, 'captcha')) { return ''; } // find the captcha ID $lines = explode("\n", $header); $pattern = '/wpCaptchaId=([^"]+)"/'; $matches = array(); foreach ($lines as $line) { preg_match($pattern, $line, $matches); // if we have a match, stop processing if ($matches) { break; } } // make sure we've gotten the captchaId if (!isset($matches[1])) { return $header; } $captchaId = $matches[1]; // generate src for captcha img $captchaSrc = SpecialPage::getTitleFor('Captcha', 'image')->getLocalUrl(array('wpCaptchaId' => $captchaId)); // add reload if fancyCaptcha and has reload if (stristr($header, 'fancycaptcha-reload')) { $output = $this->getSkin()->getOutput(); $output->addModuleStyles('ext.confirmEdit.fancyCaptcha.styles'); $output->addModules('ext.confirmEdit.fancyCaptchaMobile'); $captchaReload = Html::element('br') . Html::openElement('div', array('id' => 'mf-captcha-reload-container')) . Html::element('span', array('class' => 'confirmedit-captcha-reload fancycaptcha-reload'), wfMessage('fancycaptcha-reload-text')->text()) . Html::closeElement('div'); #mf-captcha-reload-container } else { $captchaReload = ''; } // captcha output html $captchaHtml = Html::openElement('div', array('class' => 'inputs-box')) . Html::element('img', array('class' => 'fancycaptcha-image', 'src' => $captchaSrc)) . $captchaReload . Html::input('wpCaptchaWord', null, 'text', array('placeholder' => wfMessage('mobile-frontend-account-create-captcha-placeholder')->text(), 'id' => 'wpCaptchaWord', 'tabindex' => '5', 'size' => '20', 'autocorrect' => 'off', 'autocapitalize' => 'off')) . Html::input('wpCaptchaId', $captchaId, 'hidden', array('id' => 'wpCaptchaId')) . Html::closeElement('div'); return $captchaHtml; }
echo $this->escape($t['type_title']); ?> </span> </a> </td> </tr> <?php } ?> </tbody> </table> <input type="hidden" name="option" value="<?php echo $this->option; ?> " /> <input type="hidden" name="controller" value="<?php echo $this->controller; ?> " /> <input type="hidden" name="task" value="<?php echo $this->task; ?> " autocomplete="off" /> <input type="hidden" name="boxchecked" value="0" /> <?php echo Html::input('token'); ?> </form>
/** * @param $fields array * @return string */ protected function pretty($fields) { $out = ''; foreach ($fields as $list) { list($name, $label, $type, $value) = $list; if ($type == 'text') { $field = htmlspecialchars($value); } else { $attribs = array('id' => $name); if ($name == 'wpPassword') { $attribs[] = 'autofocus'; } $field = Html::input($name, $value, $type, $attribs); } $out .= "<tr>\n"; $out .= "\t<td class='mw-label'>"; if ($type != 'text') { $out .= Xml::label($this->msg($label)->text(), $name); } else { $out .= $this->msg($label)->escaped(); } $out .= "</td>\n"; $out .= "\t<td class='mw-input'>"; $out .= $field; $out .= "</td>\n"; $out .= "</tr>"; } return $out; }
/** * @param int $year * @param int $month * @return string Formatted HTML */ public static function dateMenu($year, $month) { # Offset overrides year/month selection if ($month && $month !== -1) { $encMonth = intval($month); } else { $encMonth = ''; } if ($year) { $encYear = intval($year); } elseif ($encMonth) { $timestamp = MWTimestamp::getInstance(); $thisMonth = intval($timestamp->format('n')); $thisYear = intval($timestamp->format('Y')); if (intval($encMonth) > $thisMonth) { $thisYear--; } $encYear = $thisYear; } else { $encYear = ''; } $inputAttribs = array('id' => 'year', 'maxlength' => 4, 'size' => 7); return self::label(wfMessage('year')->text(), 'year') . ' ' . Html::input('year', $encYear, 'number', $inputAttribs) . ' ' . self::label(wfMessage('month')->text(), 'month') . ' ' . self::monthSelector($encMonth, -1); }
function searchBox() { global $wgUseTwoButtonsSearchForm; ?> <div id="p-search" class="portlet"> <div id="searchBody" class="pBody"> <form action="<?php $this->text('wgScript'); ?> " id="searchform"> <input type='hidden' name="title" value="<?php $this->text('searchtitle'); ?> "/> <div class="searchWrapper"> <?php echo Html::input('search', isset($this->data['search']) ? $this->data['search'] : '', 'search', array('id' => 'searchInput', 'title' => $this->skin->titleAttrib('search'), 'accesskey' => $this->skin->accesskey('search'))); ?> <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php /* $this->msg('searcharticle') */ ?> " <?php echo $this->tooltipAndAccesskey('search-go'); ?> /> </div> <?php /* if ($wgUseTwoButtonsSearchForm) { ?> <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?> <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } */ ?> </form> </div> </div> <?php }
function creationHTML($template_num) { $field_form_text = $template_num . "_" . $this->mNum; $template_field = $this->template_field; $text = '<h3>' . wfMessage('sf_createform_field')->escaped() . " '" . $template_field->getFieldName() . "'</h3>\n"; $prop_link_text = SFUtils::linkText(SMW_NS_PROPERTY, $template_field->getSemanticProperty()); // TODO - remove this probably-unnecessary check? if ($template_field->getSemanticProperty() == "") { // Print nothing if there's no semantic property. } elseif ($template_field->getPropertyType() == "") { $text .= '<p>' . wfMessage('sf_createform_fieldpropunknowntype', $prop_link_text)->parseAsBlock() . "</p>\n"; } else { if ($template_field->isList()) { $propDisplayMsg = 'sf_createform_fieldproplist'; } else { $propDisplayMsg = 'sf_createform_fieldprop'; } // Get the display label for this property type. global $smwgContLang; $propertyTypeStr = ''; if ($smwgContLang != null) { $datatypeLabels = $smwgContLang->getDatatypeLabels(); $datatypeLabels['enumeration'] = 'enumeration'; $propTypeID = $template_field->getPropertyType(); // Special handling for SMW 1.9 if ($propTypeID == '_str' && !array_key_exists('_str', $datatypeLabels)) { $propTypeID = '_txt'; } $propertyTypeStr = $datatypeLabels[$propTypeID]; } $text .= Html::rawElement('p', null, wfMessage($propDisplayMsg, $prop_link_text, $propertyTypeStr)->parse()) . "\n"; } // If it's not a semantic field - don't add any text. $form_label_text = wfMessage('sf_createform_formlabel')->text(); $form_label_input = Html::input('label_' . $field_form_text, $template_field->getLabel(), 'text', array('size' => 20)); $input_type_text = wfMessage('sf_createform_inputtype')->escaped(); $text .= <<<END \t<div class="formField"> \t<p>{$form_label_text} {$form_label_input} \t  {$input_type_text} END; global $sfgFormPrinter; if (is_null($template_field->getPropertyType())) { $default_input_type = null; $possible_input_types = $sfgFormPrinter->getAllInputTypes(); } else { $default_input_type = $sfgFormPrinter->getDefaultInputType($template_field->isList(), $template_field->getPropertyType()); $possible_input_types = $sfgFormPrinter->getPossibleInputTypes($template_field->isList(), $template_field->getPropertyType()); } $text .= $this->inputTypeDropdownHTML($field_form_text, $default_input_type, $possible_input_types, $template_field->getInputType()); if (!is_null($template_field->getInputType())) { $cur_input_type = $template_field->getInputType(); } elseif (!is_null($default_input_type)) { $cur_input_type = $default_input_type; } else { $cur_input_type = $possible_input_types[0]; } global $wgRequest; $paramValues = array(); foreach ($wgRequest->getValues() as $key => $value) { if (($pos = strpos($key, '_' . $field_form_text)) != false) { $paramName = substr($key, 0, $pos); // Spaces got replaced by underlines in the // query. $paramName = str_replace('_', ' ', $paramName); $paramValues[$paramName] = $value; } } $other_param_text = wfMessage('sf_createform_otherparameters')->escaped(); $text .= "<fieldset class=\"sfCollapsibleFieldset\"><legend>{$other_param_text}</legend>\n"; $text .= Html::rawElement('div', array('class' => 'otherInputParams'), SFCreateForm::showInputTypeOptions($cur_input_type, $field_form_text, $paramValues)) . "\n"; $text .= "</fieldset>\n"; $text .= <<<END \t</p> \t</div> \t<hr> END; return $text; }