本文整理汇总了PHP中HTMLForm::setSubmitCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLForm::setSubmitCallback方法的具体用法?PHP HTMLForm::setSubmitCallback怎么用?PHP HTMLForm::setSubmitCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLForm
的用法示例。
在下文中一共展示了HTMLForm::setSubmitCallback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getForm
/**
* Get the HTMLForm to control behavior
* @return HTMLForm|null
*/
protected function getForm()
{
$this->fields = $this->getFormFields();
$form = new HTMLForm($this->fields, $this->getContext(), $this->getMessagePrefix());
$form->setSubmitCallback(array($this, 'onSubmit'));
// If the form is a compact vertical form, then don't output this ugly
// fieldset surrounding it.
// XXX Special pages can setDisplayFormat to 'vform' in alterForm(), but that
// is called after this.
if (!$form->isVForm()) {
$form->setWrapperLegendMsg($this->getMessagePrefix() . '-legend');
}
$headerMsg = $this->msg($this->getMessagePrefix() . '-text');
if (!$headerMsg->isDisabled()) {
$form->addHeaderText($headerMsg->parseAsBlock());
}
// Retain query parameters (uselang etc)
$params = array_diff_key($this->getRequest()->getQueryValues(), array('title' => null));
$form->addHiddenField('redirectparams', wfArrayToCgi($params));
$form->addPreText($this->preText());
$form->addPostText($this->postText());
$this->alterForm($form);
// Give hooks a chance to alter the form, adding extra fields or text etc
wfRunHooks('SpecialPageBeforeFormDisplay', array($this->getName(), &$form));
return $form;
}
示例2: execute
public function execute($par)
{
$this->checkPermissions();
$this->checkReadOnly();
list($this->target, $this->type) = SpecialBlock::getTargetAndType($par, $this->getRequest());
$this->block = Block::newFromTarget($this->target);
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->setPageTitle($this->msg('unblockip'));
$out->addModules('mediawiki.special');
$form = new HTMLForm($this->getFields(), $this->getContext());
$form->setWrapperLegend(wfMsg('unblockip'));
$form->setSubmitCallback(array(__CLASS__, 'processUIUnblock'));
$form->setSubmitText(wfMsg('ipusubmit'));
$form->addPreText(wfMsgExt('unblockiptext', 'parse'));
if ($form->show()) {
switch ($this->type) {
case Block::TYPE_USER:
case Block::TYPE_IP:
$out->addWikiMsg('unblocked', $this->target);
break;
case Block::TYPE_RANGE:
$out->addWikiMsg('unblocked-range', $this->target);
break;
case Block::TYPE_ID:
case Block::TYPE_AUTO:
$out->addWikiMsg('unblocked-id', $this->target);
break;
}
}
}
示例3: execute
function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$this->getOutput()->addModuleStyles('mediawiki.special.pagesWithProp');
$request = $this->getRequest();
$propname = $request->getVal('propname', $par);
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('page_props', 'pp_propname', '', __METHOD__, array('DISTINCT', 'ORDER BY' => 'pp_propname'));
$propnames = array();
foreach ($res as $row) {
$propnames[$row->pp_propname] = $row->pp_propname;
}
$form = new HTMLForm(array('propname' => array('type' => 'selectorother', 'name' => 'propname', 'options' => $propnames, 'default' => $propname, 'label-message' => 'pageswithprop-prop', 'required' => true)), $this->getContext());
$form->setMethod('get');
$form->setSubmitCallback(array($this, 'onSubmit'));
$form->setWrapperLegendMsg('pageswithprop-legend');
$form->addHeaderText($this->msg('pageswithprop-text')->parseAsBlock());
$form->setSubmitTextMsg('pageswithprop-submit');
$form->prepareForm();
$form->displayForm(false);
if ($propname !== '' && $propname !== null) {
$form->trySubmit();
}
}
示例4: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
* @return bool|null
*/
public function execute($par)
{
global $wgExtensionAssetsPath;
$out = $this->getOutput();
// Add CSS
if (defined('MW_SUPPORTS_RESOURCE_MODULES')) {
$out->addModuleStyles('ext.video');
} else {
$out->addExtensionStyle($wgExtensionAssetsPath . '/Video/Video.css');
}
// If the user doesn't have the required 'addvideo' permission, display an error
if (!$this->userCanExecute($this->getUser())) {
$this->displayRestrictionError();
return;
}
// Show a message if the database is in read-only mode
if (wfReadOnly()) {
throw new ReadOnlyError();
}
// If user is blocked, s/he doesn't need to access this page
if ($this->getUser()->isBlocked()) {
throw new UserBlockedError($this->getUser()->mBlock);
}
$this->setHeaders();
$form = new HTMLForm($this->getFormFields(), $this->getContext());
$form->setIntro(wfMsgExt('video-addvideo-instructions', 'parse'));
$form->setWrapperLegend(wfMsg('video-addvideo-title'));
$form->setSubmitText(wfMsg('video-addvideo-button'));
$form->setSubmitCallback(array($this, 'submit'));
if ($this->getRequest()->getCheck('forReUpload')) {
$form->addHiddenField('forReUpload', true);
}
$form->show();
}
示例5: listDomains
/**
* @return void
*/
function listDomains()
{
$this->setHeaders();
$this->getOutput()->setPagetitle($this->msg('openstackmanager-domainlist'));
$this->getOutput()->addModuleStyles('ext.openstack');
$domainInfo = array();
$domainInfo['domainname'] = array('type' => 'text', 'label-message' => 'openstackmanager-domainname', 'default' => '', 'section' => 'domain', 'name' => 'domainname');
$domainInfo['fqdn'] = array('type' => 'text', 'label-message' => 'openstackmanager-fqdn', 'default' => '', 'section' => 'domain', 'name' => 'fqdn');
$domainInfo['location'] = array('type' => 'text', 'label-message' => 'openstackmanager-location', 'default' => '', 'section' => 'domain', 'help-message' => 'openstackmanager-location-help', 'name' => 'location');
$domainInfo['action'] = array('type' => 'hidden', 'default' => 'create', 'name' => 'action');
$domainForm = new HTMLForm($domainInfo, $this->getContext(), 'openstackmanager-novadomain');
$domainForm->setSubmitID('novadomain-form-createdomainsubmit');
$domainForm->setSubmitCallback(array($this, 'tryCreateSubmit'));
$domainForm->show();
$headers = array('openstackmanager-domainname', 'openstackmanager-fqdn', 'openstackmanager-location', 'openstackmanager-actions');
$domains = OpenStackNovaDomain::getAllDomains();
$domainRows = array();
foreach ($domains as $domain) {
$domainRow = array();
$domainName = $domain->getDomainName();
$this->pushResourceColumn($domainRow, $domainName);
$this->pushResourceColumn($domainRow, $domain->getFullyQualifiedDomainName());
$this->pushResourceColumn($domainRow, $domain->getLocation());
$this->pushRawResourceColumn($domainRow, $this->createActionLink('openstackmanager-delete', array('action' => 'delete', 'domainname' => $domainName)));
$domainRows[] = $domainRow;
}
if ($domainRows) {
$out = $this->createResourceTable($headers, $domainRows);
} else {
$out = '';
}
$this->getOutput()->addHTML($out);
}
示例6: buildForm
function buildForm()
{
$form = new HTMLForm($this->getFormFields(), $this->getContext(), 'lqt-' . $this->getPageName());
$par = $this->mThread->title()->getPrefixedText();
$form->setSubmitText($this->getSubmitText());
$form->setSubmitCallback(array($this, 'trySubmit'));
return $form;
}
示例7: show
public function show($par)
{
$formFields = array('account' => array('type' => 'text', 'validation-callback' => array(__CLASS__, 'validateUser'), 'label-message' => 'disableaccount-user'), 'confirm' => array('type' => 'toggle', 'validation-callback' => array(__CLASS__, 'checkConfirmation'), 'label-message' => 'disableaccount-confirm'));
$htmlForm = new HTMLForm($formFields, 'disableaccount');
$htmlForm->setSubmitCallback(array(__CLASS__, 'submit'));
$htmlForm->setTitle($this->getTitle());
$htmlForm->show();
}
示例8: execute
function execute($par)
{
global $wgOut, $wgUser, $wgEmailAuthentication;
$this->setHeaders();
if (!$this->userCanExecute($wgUser)) {
$this->displayRestrictionError();
return;
}
$error = SpecialEmailUser::getPermissionsError($wgUser, $wgUser->editToken());
if ($error) {
switch ($error) {
case 'blockedemailuser':
$wgOut->blockedPage();
return;
case 'actionthrottledtext':
$wgOut->rateLimited();
return;
case 'mailnologin':
$wgOut->showErrorPage('mailnologin', 'mailnologintext');
return;
default:
list($title, $msg, $params) = $error;
$wgOut->showErrorPage($title, $msg, $params);
return;
}
}
$dbr = wfGetDB(DB_SLAVE);
# $conds can be not that strict but cannot be too strict.
$conds = array("user_email <> ''");
if ($wgEmailAuthentication) {
$conds[] = 'user_email_authenticated IS NOT NULL';
}
$res = $dbr->select('user', '*', $conds);
$users = UserArray::newFromResult($res);
$usernames = array();
foreach ($users as $user) {
if ($user->canReceiveEmail() && $user->getId() != $wgUser->getId()) {
$usernames[$user->getName()] = $user->getId();
}
}
$this->userIds = array_values($usernames);
if (empty($usernames)) {
# No one to send mail to
$wgOut->addWikiMsg('emailusers-norecipient');
$wgOut->returnToMain();
return;
}
$form = array('target' => array('type' => 'multiselect', 'label-message' => 'emailto', 'options' => $usernames, 'validation-callback' => array($this, 'validateTarget')), 'target-reverse' => array('type' => 'check', 'default' => true, 'label-message' => 'emailusers-target-reverse'), 'subject' => array('type' => 'text', 'default' => wfMsg('defemailsubject'), 'label-message' => 'emailsubject'), 'text' => array('type' => 'textarea', 'label-message' => 'emailmessage'), 'ccme' => array('type' => 'check', 'default' => $wgUser->getOption('ccmeonemails'), 'label-message' => 'emailccme'));
$htmlForm = new HTMLForm($form);
$htmlForm->setTitle($this->getTitle($par));
$htmlForm->setSubmitCallback(array($this, 'submit'));
$this->outputHeader();
if ($htmlForm->show()) {
$wgOut->addWikiMsg('emailsenttext');
$htmlForm->displayForm(false);
}
}
示例9: execute
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->addModuleStyles('mediawiki.special');
$this->mTarget = is_null($par) ? $this->getRequest()->getVal('wpTarget', $this->getRequest()->getVal('target', '')) : $par;
// error out if sending user cannot do this
$error = self::getPermissionsError($this->getUser(), $this->getRequest()->getVal('wpEditToken'));
switch ($error) {
case null:
# Wahey!
break;
case 'badaccess':
throw new PermissionsError('sendemail');
case 'blockedemailuser':
throw new UserBlockedError($this->getUser()->mBlock);
case 'actionthrottledtext':
throw new ThrottledError();
case 'mailnologin':
case 'usermaildisabled':
throw new ErrorPageError($error, "{$error}text");
default:
# It's a hook error
list($title, $msg, $params) = $error;
throw new ErrorPageError($title, $msg, $params);
}
// Got a valid target user name? Else ask for one.
$ret = self::getTarget($this->mTarget);
if (!$ret instanceof User) {
if ($this->mTarget != '') {
$ret = $ret == 'notarget' ? 'emailnotarget' : $ret . 'text';
$out->wrapWikiMsg("<p class='error'>\$1</p>", $ret);
}
$out->addHTML($this->userForm($this->mTarget));
return false;
}
$this->mTargetObj = $ret;
$form = new HTMLForm($this->getFormFields(), $this->getContext());
$form->addPreText(wfMsgExt('emailpagetext', 'parseinline'));
$form->setSubmitText(wfMsg('emailsend'));
$form->setTitle($this->getTitle());
$form->setSubmitCallback(array(__CLASS__, 'submit'));
$form->setWrapperLegend(wfMsgExt('email-legend', 'parsemag'));
$form->loadData();
if (!wfRunHooks('EmailUserForm', array(&$form))) {
return false;
}
$out->setPageTitle($this->msg('emailpage'));
$result = $form->show();
if ($result === true || $result instanceof Status && $result->isGood()) {
$out->setPageTitle($this->msg('emailsent'));
$out->addWikiMsg('emailsenttext');
$out->returnToMain(false, $this->mTargetObj->getUserPage());
}
}
示例10: showResetForm
private function showResetForm()
{
$this->getOutput()->addWikiMsg('prefs-reset-intro');
$htmlForm = new HTMLForm(array(), $this->getContext(), 'prefs-restore');
$htmlForm->setSubmitText(wfMsg('restoreprefs'));
$htmlForm->setTitle($this->getTitle('reset'));
$htmlForm->setSubmitCallback(array($this, 'submitReset'));
$htmlForm->suppressReset();
$htmlForm->show();
}
示例11: execute
public function execute($par)
{
$this->checkPermissions();
$this->setHeaders();
$form = new HTMLForm(array('dbname' => array('default' => $par, 'filter-callback' => array('SpecialCreateWiki', 'filter'), 'label-message' => 'createwiki-label-dbname', 'maxlength' => 30, 'required' => true, 'size' => 30, 'type' => 'text', 'validation-callback' => array('SpecialCreateWiki', 'validateDBname')), 'founder' => array('filter-callback' => array('SpecialCreateWiki', 'filter'), 'label-message' => 'createwiki-label-founder', 'required' => true, 'size' => 30, 'type' => 'text', 'validation-callback' => array('SpecialCreateWiki', 'validateFounder')), 'comment' => array('label-message' => 'createwiki-label-comment', 'maxlength' => 79, 'size' => 79, 'type' => 'text')));
$form->setSubmitTextMsg('createwiki-label-create');
$form->setTitle($this->getPageTitle());
$form->setSubmitCallback(array('SpecialCreateWiki', 'processInput'));
$form->show();
}
示例12: execute
function execute($par)
{
global $wgRequest;
$this->setHeaders();
$form = new HTMLForm(array('TitleText' => array('type' => 'text', 'label-message' => 'luafoo-convert-title')));
$form->setSubmitText(wfMsg('luafoo-convert-submit'));
$form->setSubmitCallback(array($this, 'showTranslation'));
$form->setTitle($this->getTitle());
$form->show();
}
示例13: execute
public function execute($par)
{
global $wgRequest, $wgOut, $wgUser;
$this->setHeaders();
$this->outputHeader();
$this->mTarget = is_null($par) ? $wgRequest->getVal('wpTarget', $wgRequest->getVal('target', '')) : $par;
$ret = self::getTarget($this->mTarget);
if ($ret instanceof User) {
$this->mTargetObj = $ret;
} else {
$wgOut->showErrorPage("{$ret}title", "{$ret}text");
return false;
}
$error = self::getPermissionsError($wgUser, $wgRequest->getVal('wpEditToken'));
switch ($error) {
case null:
# Wahey!
break;
case 'badaccess':
$wgOut->permissionRequired('sendemail');
return;
case 'blockedemailuser':
$wgOut->blockedPage();
return;
case 'actionthrottledtext':
$wgOut->rateLimited();
return;
case 'mailnologin':
case 'usermaildisabled':
$wgOut->showErrorPage($error, "{$error}text");
return;
default:
# It's a hook error
list($title, $msg, $params) = $error;
$wgOut->showErrorPage($title, $msg, $params);
return;
}
$form = new HTMLForm($this->getFormFields());
$form->addPreText(wfMsgExt('emailpagetext', 'parseinline'));
$form->setSubmitText(wfMsg('emailsend'));
$form->setTitle($this->getTitle());
$form->setSubmitCallback(array(__CLASS__, 'submit'));
$form->setWrapperLegend(wfMsgExt('email-legend', 'parsemag'));
$form->loadData();
if (!wfRunHooks('EmailUserForm', array(&$form))) {
return false;
}
$wgOut->setPagetitle(wfMsg('emailpage'));
$result = $form->show();
if ($result === true || $result instanceof Status && $result->isGood()) {
$wgOut->setPagetitle(wfMsg('emailsent'));
$wgOut->addWikiMsg('emailsenttext');
$wgOut->returnToMain(false, $this->mTargetObj->getUserPage());
}
}
示例14: showResetForm
function showResetForm()
{
$this->getOutput()->addWikiMsg('prefs-reset-intro');
$htmlForm = new HTMLForm(array(), $this->getContext(), 'prefs-restore');
$htmlForm->setSubmitText(wfMsg('restoreprefs'));
$htmlForm->addHiddenField('username', $this->target);
$htmlForm->addHiddenField('reset', '1');
$htmlForm->setSubmitCallback(array($this, 'submitReset'));
$htmlForm->suppressReset();
$htmlForm->show();
}
示例15: execute
function execute($par)
{
global $wgOut;
$wgOut->setPageTitle(wfMsg('communityhiring-header'));
$formDescriptor = array('about-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-about-intro', 'parse'), 'raw' => 1, 'section' => 'aboutyou'), 'given-name' => array('type' => 'text', 'label-message' => 'communityhiring-given', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'family-name' => array('type' => 'text', 'label-message' => 'communityhiring-family', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-line1' => array('type' => 'textarea', 'label-message' => 'communityhiring-address', 'section' => 'aboutyou', 'rows' => '3', 'cols' => '20'), 'address-city' => array('type' => 'text', 'label-message' => 'communityhiring-address-city', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'address-postal' => array('type' => 'text', 'label-message' => 'communityhiring-address-postal', 'section' => 'aboutyou'), 'address-country' => array('type' => 'text', 'label-message' => 'communityhiring-address-country', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'phone' => array('type' => 'text', 'label-message' => 'communityhiring-phone', 'section' => 'aboutyou'), 'email' => array('type' => 'text', 'label-message' => 'communityhiring-email', 'section' => 'aboutyou', 'validation-callback' => array($this, 'validateRequired')), 'paragraph-intro' => array('type' => 'info', 'default' => wfMsgExt('communityhiring-paragraphs-intro', 'parse'), 'raw' => 1, 'section' => 'paragraphs', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'significance' => array('type' => 'textarea', 'label-message' => 'communityhiring-significance', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'excitement' => array('type' => 'textarea', 'label-message' => 'communityhiring-excitement', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'experiences' => array('type' => 'textarea', 'label-message' => 'communityhiring-experiences', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'other' => array('type' => 'textarea', 'label-message' => 'communityhiring-other', 'section' => 'paragraphs', 'rows' => 10, 'vertical-label' => 1), 'languages' => array('type' => 'textarea', 'options' => array_flip(Language::getLanguageNames()), 'section' => 'demonstrative/languages', 'rows' => '3', 'label-message' => 'communityhiring-languages-label', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'contributor' => array('type' => 'radio', 'label-message' => 'communityhiring-contributor', 'section' => 'demonstrative/involvement', 'options' => array('Yes' => 'yes', 'No' => 'no')), 'usernames' => array('type' => 'textarea', 'rows' => '3', 'cols' => '20', 'label-message' => 'communityhiring-usernames', 'section' => 'demonstrative/involvement', 'vertical-label' => 1), 'wikimedia-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links', 'section' => 'demonstrative/involvement', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'other-links' => array('type' => 'textarea', 'label-message' => 'communityhiring-links-other', 'section' => 'demonstrative', 'rows' => '3', 'cols' => '20', 'vertical-label' => 1), 'availability-time' => array('type' => 'text', 'label-message' => 'communityhiring-availability-intro', 'section' => 'availability', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')), 'availability-info' => array('type' => 'textarea', 'label-message' => 'communityhiring-availability-info', 'section' => 'availability', 'rows' => '5', 'cols' => '20', 'vertical-label' => 1), 'relocation' => array('type' => 'radio', 'label-message' => 'communityhiring-relocation-ok', 'section' => 'availability', 'vertical-label' => 1, 'options' => array('Yes' => 'yes', 'No' => 'no', 'It would be hard, but maybe I would' => 'maybe')), 'research' => array('type' => 'textarea', 'rows' => '5', 'label-message' => 'communityhiring-research', 'vertical-label' => 1, 'validation-callback' => array($this, 'validateRequired')));
$form = new HTMLForm($formDescriptor, 'communityhiring');
$form->setIntro(wfMsgExt('communityhiring-intro', 'parse'));
$form->setSubmitCallback(array($this, 'submit'));
$form->setTitle($this->getTitle());
$form->show();
}