本文整理汇总了PHP中HTMLForm::loadData方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLForm::loadData方法的具体用法?PHP HTMLForm::loadData怎么用?PHP HTMLForm::loadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLForm
的用法示例。
在下文中一共展示了HTMLForm::loadData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: spellCheckingForm
/**
* Display form for testing spell checking feature
*/
function spellCheckingForm($languages)
{
$fields = array('text' => array('class' => 'HTMLTextField', 'label-message' => 'spellchecker-info-spellcheck-text'), 'lang' => array('class' => 'HTMLSelectField', 'label-message' => 'spellchecker-info-spellcheck-languages', 'options' => array_combine($languages, $languages)));
$form = new HTMLForm($fields);
$form->setTitle($this->title);
$form->setSubmitText($this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-submit'));
$form->loadData();
$form->displayForm('');
// page was POSTed, perform spell cheking
if ($this->request->wasPosted()) {
$text = $this->request->getText('wptext');
$langCode = $this->request->getText('wplang');
// create spell checking service
$service = new SpellCheckerService($langCode);
$info = $service->getInfo();
// check the spelling (returns true or array of spelling suggestions)
$data = $service->checkWord($text);
// print out results
if ($data === true) {
$result = $this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-is-correct', $text);
} else {
$result = $this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-suggestions', $text, implode(', ', $data));
}
$this->out->addHtml("<p>{$result}</p>");
$this->out->addHtml("<p><small>{$info['desc']} / {$info['lang']}</small></p>");
}
}
示例2: 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());
}
}
示例3: 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());
}
}
示例4: execute
/**
* Show a form for filtering namespace and username
*
* @param $par String
* @return String
*/
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$form = new HTMLForm(array('Page1' => array('type' => 'text', 'name' => 'page1', 'label-message' => 'compare-page1', 'size' => '40', 'section' => 'page1', 'validation-callback' => array($this, 'checkExistingTitle')), 'Revision1' => array('type' => 'int', 'name' => 'rev1', 'label-message' => 'compare-rev1', 'size' => '8', 'section' => 'page1', 'validation-callback' => array($this, 'checkExistingRevision')), 'Page2' => array('type' => 'text', 'name' => 'page2', 'label-message' => 'compare-page2', 'size' => '40', 'section' => 'page2', 'validation-callback' => array($this, 'checkExistingTitle')), 'Revision2' => array('type' => 'int', 'name' => 'rev2', 'label-message' => 'compare-rev2', 'size' => '8', 'section' => 'page2', 'validation-callback' => array($this, 'checkExistingRevision')), 'Action' => array('type' => 'hidden', 'name' => 'action'), 'Diffonly' => array('type' => 'hidden', 'name' => 'diffonly'), 'Unhide' => array('type' => 'hidden', 'name' => 'unhide')), $this->getContext(), 'compare');
$form->setSubmitTextMsg('compare-submit');
$form->suppressReset();
$form->setMethod('get');
$form->setSubmitCallback(array(__CLASS__, 'showDiff'));
$form->loadData();
$form->displayForm('');
$form->trySubmit();
}
示例5: execute
/**
* Show a form for filtering namespace and username
*
* @param $par String
* @return String
*/
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$form = new HTMLForm(array('Page1' => array('type' => 'text', 'name' => 'page1', 'label-message' => 'compare-page1', 'size' => '40', 'section' => 'page1'), 'Revision1' => array('type' => 'int', 'name' => 'rev1', 'label-message' => 'compare-rev1', 'size' => '8', 'section' => 'page1'), 'Page2' => array('type' => 'text', 'name' => 'page2', 'label-message' => 'compare-page2', 'size' => '40', 'section' => 'page2'), 'Revision2' => array('type' => 'int', 'name' => 'rev2', 'label-message' => 'compare-rev2', 'size' => '8', 'section' => 'page2'), 'Action' => array('type' => 'hidden', 'name' => 'action'), 'Diffonly' => array('type' => 'hidden', 'name' => 'diffonly')), 'compare');
$form->setSubmitText(wfMsg('compare-submit'));
$form->suppressReset();
$form->setMethod('get');
$form->setTitle($this->getTitle());
$form->loadData();
$form->displayForm('');
self::showDiff($form->mFieldData);
}
示例6: execute
public function execute($par)
{
$out = $this->getOutput();
$out->addModuleStyles('mediawiki.special');
$this->mTarget = is_null($par) ? $this->getRequest()->getVal('wpTarget', $this->getRequest()->getVal('target', '')) : $par;
// This needs to be below assignment of $this->mTarget because
// getDescription() needs it to determine the correct page title.
$this->setHeaders();
$this->outputHeader();
// error out if sending user cannot do this
$error = self::getPermissionsError($this->getUser(), $this->getRequest()->getVal('wpEditToken'), $this->getConfig());
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 != '') {
// Messages used here: notargettext, noemailtext, nowikiemailtext
$ret = $ret == 'notarget' ? 'emailnotarget' : $ret . 'text';
$out->wrapWikiMsg("<p class='error'>\$1</p>", $ret);
}
$out->addHTML($this->userForm($this->mTarget));
return;
}
$this->mTargetObj = $ret;
$context = new DerivativeContext($this->getContext());
$context->setTitle($this->getPageTitle());
// Remove subpage
$form = new HTMLForm($this->getFormFields(), $context);
// By now we are supposed to be sure that $this->mTarget is a user name
$form->addPreText($this->msg('emailpagetext', $this->mTarget)->parse());
$form->setSubmitTextMsg('emailsend');
$form->setSubmitCallback(array(__CLASS__, 'uiSubmit'));
$form->setWrapperLegendMsg('email-legend');
$form->loadData();
if (!Hooks::run('EmailUserForm', array(&$form))) {
return;
}
$result = $form->show();
if ($result === true || $result instanceof Status && $result->isGood()) {
$out->setPageTitle($this->msg('emailsent'));
$out->addWikiMsg('emailsenttext', $this->mTarget);
$out->returnToMain(false, $this->mTargetObj->getUserPage());
}
}
示例7: loadData
/**
* Override the function in HTMLForm to only load the data when this form
* was actually clicked.
*
* We do nothing if the form wasn't clicked.
*/
function loadData()
{
if ($this->wasClicked()) {
parent::loadData();
}
}