本文整理汇总了PHP中WikiError类的典型用法代码示例。如果您正苦于以下问题:PHP WikiError类的具体用法?PHP WikiError怎么用?PHP WikiError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WikiError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showRequestForm
/**
* Show a nice form for the user to request a confirmation mail
*/
function showRequestForm()
{
global $wgOut, $wgUser, $wgLang, $wgRequest;
if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
$ok = $wgUser->sendConfirmationMail();
if (WikiError::isError($ok)) {
$wgOut->addWikiMsg('confirmemail_sendfailed', $ok->toString());
} else {
$wgOut->addWikiMsg('confirmemail_sent');
}
} else {
if ($wgUser->isEmailConfirmed()) {
// date and time are separate parameters to facilitate localisation.
// $time is kept for backward compat reasons.
// 'emailauthenticated' is also used in SpecialPreferences.php
$time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
$d = $wgLang->date($wgUser->mEmailAuthenticated, true);
$t = $wgLang->time($wgUser->mEmailAuthenticated, true);
$wgOut->addWikiMsg('emailauthenticated', $time, $d, $t);
}
if ($wgUser->isEmailConfirmationPending()) {
$wgOut->wrapWikiMsg("<div class=\"error mw-confirmemail-pending\">\n\$1</div>", 'confirmemail_pending');
}
$wgOut->addWikiMsg('confirmemail_text');
$form = Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl()));
$form .= Xml::hidden('token', $wgUser->editToken());
$form .= Xml::submitButton(wfMsg('confirmemail_send'));
$form .= Xml::closeElement('form');
$wgOut->addHTML($form);
}
}
示例2: showRequestForm
/**
* Show a nice form for the user to request a confirmation mail
*/
function showRequestForm()
{
global $wgOut, $wgUser, $wgLang, $wgRequest;
if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
$ok = $wgUser->sendConfirmationMail();
if (WikiError::isError($ok)) {
$wgOut->addWikiMsg('confirmemail_sendfailed', $ok->toString());
} else {
$wgOut->addWikiMsg('confirmemail_sent');
}
} else {
if ($wgUser->isEmailConfirmed()) {
$time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
$wgOut->addWikiMsg('emailauthenticated', $time);
}
if ($wgUser->isEmailConfirmationPending()) {
$wgOut->addWikiMsg('confirmemail_pending');
}
$wgOut->addWikiMsg('confirmemail_text');
$self = SpecialPage::getTitleFor('Confirmemail');
$form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
$form .= wfHidden('token', $wgUser->editToken());
$form .= wfSubmitButton(wfMsgHtml('confirmemail_send'));
$form .= wfCloseElement('form');
$wgOut->addHtml($form);
}
}
示例3: processUpload
function processUpload()
{
global $wgUser, $wgOut, $wgFileExtensions;
$details = null;
$value = null;
$value = $this->internalProcessUpload($details);
switch ($value) {
case self::SUCCESS:
// don't... do... REDIRECT
return;
case self::BEFORE_PROCESSING:
return false;
case self::LARGE_FILE_SERVER:
return wfMsg('largefileserver');
case self::EMPTY_FILE:
return wfMsg('emptyfile');
case self::MIN_LENGTH_PARTNAME:
return wfMsg('minlength1');
return;
case self::ILLEGAL_FILENAME:
$filtered = $details['filtered'];
return wfMsg('illegalfilename', $filtered);
case self::PROTECTED_PAGE:
return wfMsg('protectedpage');
case self::OVERWRITE_EXISTING_FILE:
$errorText = $details['overwrite'];
$overwrite = new WikiError($wgOut->parse($errorText));
return $overwrite->toString();
case self::FILETYPE_MISSING:
return wfMsg('filetype-missing');
case self::FILETYPE_BADTYPE:
$finalExt = $details['finalExt'];
return wfMsg('filetype-badtype');
case self::VERIFICATION_ERROR:
$veri = $details['veri'];
return $veri->toString();
case self::UPLOAD_VERIFICATION_ERROR:
$error = $details['error'];
return $error;
case self::UPLOAD_WARNING:
$warning = $details['warning'];
return $warning;
}
throw new MWException(__METHOD__ . ": Unknown value `{$value}`");
}
示例4: wfSpecialImport
/**
* Constructor
*/
function wfSpecialImport($page = '')
{
global $wgUser, $wgOut, $wgLang, $wgRequest, $wgTitle;
global $wgImportSources;
###
# $wgOut->addWikiText( "Special:Import is not ready for this beta release, sorry." );
# return;
###
if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
switch ($wgRequest->getVal("source")) {
case "upload":
if ($wgUser->isAllowed('importupload')) {
$source = ImportStreamSource::newFromUpload("xmlimport");
} else {
return $wgOut->permissionRequired('importupload');
}
break;
case "interwiki":
$source = ImportStreamSource::newFromInterwiki($wgRequest->getVal("interwiki"), $wgRequest->getText("frompage"));
break;
default:
$source = new WikiError("Unknown import source type");
}
if (WikiError::isError($source)) {
$wgOut->addWikiText(wfEscapeWikiText($source->getMessage()));
} else {
$importer = new WikiImporter($source);
$result = $importer->doImport();
if (WikiError::isError($result)) {
$wgOut->addWikiText(wfMsg("importfailed", wfEscapeWikiText($result->getMessage())));
} else {
# Success!
$wgOut->addWikiText(wfMsg("importsuccess"));
}
}
}
$action = $wgTitle->escapeLocalUrl('action=submit');
if ($wgUser->isAllowed('importupload')) {
$wgOut->addWikiText(wfMsg("importtext"));
$wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('upload') . "</legend>\n\t<form enctype='multipart/form-data' method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='upload' />\n\t\t<input type='hidden' name='MAX_FILE_SIZE' value='2000000' />\n\t\t<input type='file' name='xmlimport' value='' size='30' />\n\t\t<input type='submit' value='" . wfMsgHtml("uploadbtn") . "'/>\n\t</form>\n</fieldset>\n");
} else {
if (empty($wgImportSources)) {
$wgOut->addWikiText(wfMsg('importnosources'));
}
}
if (!empty($wgImportSources)) {
$wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('importinterwiki') . "</legend>\n\t<form method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='interwiki' />\n\t\t<select name='interwiki'>\n");
foreach ($wgImportSources as $interwiki) {
$iw = htmlspecialchars($interwiki);
$wgOut->addHTML("<option value=\"{$iw}\">{$iw}</option>\n");
}
$wgOut->addHTML("\n\t\t</select>\n\t\t<input name='frompage' />\n\t\t<input type='submit' />\n\t</form>\n</fieldset>\n");
}
}
示例5: execute
public function execute()
{
global $wgUser;
if (!$wgUser->isAllowed('import')) {
$this->dieUsageMsg(array('cantimport'));
}
$params = $this->extractRequestParams();
if (!isset($params['token'])) {
$this->dieUsageMsg(array('missingparam', 'token'));
}
if (!$wgUser->matchEditToken($params['token'])) {
$this->dieUsageMsg(array('sessionfailure'));
}
$source = null;
$isUpload = false;
if (isset($params['interwikisource'])) {
if (!isset($params['interwikipage'])) {
$this->dieUsageMsg(array('missingparam', 'interwikipage'));
}
$source = ImportStreamSource::newFromInterwiki($params['interwikisource'], $params['interwikipage'], $params['fullhistory'], $params['templates']);
} else {
$isUpload = true;
if (!$wgUser->isAllowed('importupload')) {
$this->dieUsageMsg(array('cantimport-upload'));
}
$source = ImportStreamSource::newFromUpload('xml');
}
if ($source instanceof WikiErrorMsg) {
$this->dieUsageMsg(array_merge(array($source->getMessageKey()), $source->getMessageArgs()));
} else {
if (WikiError::isError($source)) {
// This shouldn't happen
$this->dieUsageMsg(array('import-unknownerror', $source->getMessage()));
}
}
$importer = new WikiImporter($source);
if (isset($params['namespace'])) {
$importer->setTargetNamespace($params['namespace']);
}
$reporter = new ApiImportReporter($importer, $isUpload, $params['interwikisource'], $params['summary']);
$result = $importer->doImport();
if ($result instanceof WikiXmlError) {
$this->dieUsageMsg(array('import-xml-error', $result->mLine, $result->mColumn, $result->mByte . $result->mContext, xml_error_string($result->mXmlError)));
} else {
if (WikiError::isError($result)) {
// This shouldn't happen
$this->dieUsageMsg(array('import-unknownerror', $result->getMessage()));
}
}
$resultData = $reporter->getData();
$this->getResult()->setIndexedTagName($resultData, 'page');
$this->getResult()->addValue(null, $this->getModuleName(), $resultData);
}
示例6: checkAndSend
/** */
function checkAndSend()
{
global $wgUser, $wgRequest;
if ($wgRequest->wasPosted() && $wgUser->isLoggedIn() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
$result = $wgUser->sendConfirmationMail();
if (WikiError::isError($result)) {
return 'confirmemail_sendfailed';
} else {
return 'confirmemail_sent';
}
} else {
# boo
return '';
}
}
示例7: dump
function dump()
{
# This shouldn't happen if on console... ;)
header('Content-type: text/html; charset=UTF-8');
# Notice messages will foul up your XML output even if they're
# relatively harmless.
// ini_set( 'display_errors', false );
$this->initProgress($this->history);
$this->db =& $this->backupDb();
$this->egress = new ExportProgressFilter($this->sink, $this);
$input = fopen($this->input, "rt");
$result = $this->readDump($input);
if (WikiError::isError($result)) {
wfDie($result->getMessage());
}
$this->report(true);
}
示例8: UW_GenericEditPage_emailSuggestion
function UW_GenericEditPage_emailSuggestion ( $category ) {
global $wgSuggestCategoryRecipient, $wgEmergencyContact, $wgSitename, $wgUser;
$from = new MailAddress ( $wgEmergencyContact );
$to = new MailAddress ( $wgSuggestCategoryRecipient );
$subj = wfMsg ( "gep-emailsubject", $wgSitename, $category );
$body = wfMsg ( "gep-emailbody", $wgUser->getName(), $category, $wgSitename );
// attempt to send the notification
$result = UserMailer::send( $to, $from, $subj, $body );
/* send a message back to the client, to let them
* know if the suggestion was successfully sent (or not) */
return WikiError::isError ( $result )
? wfMsg ( 'gep-emailfailure' )
: wfMsg ( 'gep-emailsuccess', $category );
}
示例9: showRequestForm
/**
* Show a nice form for the user to request a confirmation mail
*/
function showRequestForm()
{
global $wgOut, $wgUser, $wgLang, $wgRequest;
if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
$ok = $wgUser->sendConfirmationMail();
$message = WikiError::isError($ok) ? 'confirmemail_sendfailed' : 'confirmemail_sent';
$wgOut->addWikiText(wfMsg($message));
} else {
if ($wgUser->isEmailConfirmed()) {
$time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
$wgOut->addWikiText(wfMsg('emailauthenticated', $time));
}
$wgOut->addWikiText(wfMsg('confirmemail_text'));
$self = Title::makeTitle(NS_SPECIAL, 'Confirmemail');
$form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
$form .= wfHidden('token', $wgUser->editToken());
$form .= wfSubmitButton(wfMsgHtml('confirmemail_send'));
$form .= wfCloseElement('form');
$wgOut->addHtml($form);
}
}
示例10: run
function run($par)
{
global $wgRequest, $wgEmailMeAddress, $wgOut;
if ($wgRequest->wasPosted()) {
$from = $wgRequest->getText('from');
$subject = $wgRequest->getText('subject');
$message = $wgRequest->getText('message');
if (!($from && $subject && $message)) {
return $this->print_form($this->getTitle(), $subject, $from, $message, wfMsg('emailme-incomplete'));
}
if (!User::isValidEmailAddr($from)) {
return $this->print_form($this->getTitle(), $subject, $from, $message, wfMsg('emailme-invalid-email'));
}
$mailResult = UserMailer::send(new MailAddress($wgEmailMeAddress), new MailAddress($from), $subject, $message);
if (WikiError::isError($mailResult)) {
return $this->print_form($this->getTitle(), $subject, $from, $message, 'Sorry: ' . $mailResult->toString());
dvLog("ERROR: EmailMe::run(" . $mailResult->toString() . ") {$from}|{$subject}");
} else {
dvLog("EMAIL: {$from} -> {$wgEmailMeAddress} ( {$subject} ) ");
return $this->print_success();
}
}
return $this->print_form($this->getTitle(), str_replace('_', ' ', $par));
}
示例11: doSubmit
function doSubmit()
{
global $wgOut, $wgUser;
$to = new MailAddress($this->target);
$from = new MailAddress($wgUser);
$subject = $this->subject;
if (wfRunHooks('EmailUser', array(&$to, &$from, &$subject, &$this->text))) {
$mailResult = userMailer($to, $from, $subject, $this->text);
if (WikiError::isError($mailResult)) {
$wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
} else {
$titleObj = Title::makeTitle(NS_SPECIAL, "Emailuser");
$encTarget = wfUrlencode($this->target->getName());
$wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
wfRunHooks('EmailUserComplete', array($to, $from, $subject, $this->text));
}
}
}
示例12: saveSettings_basic
function saveSettings_basic()
{
global $wgUser, $wgRequest, $wgEmailAuthentication;
$wgUser->setRealName($wgRequest->getVal('real_name'));
$wgUser->setEmail($wgRequest->getVal('email'));
if ($wgUser->getEmail() != $wgRequest->getVal('email')) {
$wgUser->mEmailAuthenticated = null;
# but flag as "dirty" = unauthenticated
}
if ($wgEmailAuthentication && !$wgUser->isEmailConfirmed()) {
# Mail a temporary password to the dirty address.
# User can come back through the confirmation URL to re-enable email.
$result = $wgUser->sendConfirmationMail();
if (WikiError::isError($result)) {
$error = wfMsg('mailerror', htmlspecialchars($result->getMessage()));
} else {
$error = wfMsg('eauthentsent', $wgUser->getName());
}
}
$wgUser->saveSettings();
}
示例13: savePreferences
/**
* @access private
*/
function savePreferences()
{
global $wgUser, $wgOut, $wgParser;
global $wgEnableUserEmail, $wgEnableEmail;
global $wgEmailAuthentication, $wgRCMaxAge;
global $wgAuth, $wgEmailConfirmToEdit;
$wgUser->setRealName($this->mRealName);
$oldOptions = $wgUser->mOptions;
if ($wgUser->getOption('language') !== $this->mUserLanguage) {
$needRedirect = true;
} else {
$needRedirect = false;
}
# Validate the signature and clean it up as needed
global $wgMaxSigChars;
if (mb_strlen($this->mNick) > $wgMaxSigChars) {
global $wgLang;
$this->mainPrefsForm('error', wfMsgExt('badsiglength', 'parsemag', $wgLang->formatNum($wgMaxSigChars)));
return;
} elseif ($this->mToggles['fancysig']) {
if ($wgParser->validateSig($this->mNick) !== false) {
$this->mNick = $wgParser->cleanSig($this->mNick);
} else {
$this->mainPrefsForm('error', wfMsg('badsig'));
return;
}
} else {
// When no fancy sig used, make sure ~{3,5} get removed.
$this->mNick = $wgParser->cleanSigInSig($this->mNick);
}
$wgUser->setOption('language', $this->mUserLanguage);
$wgUser->setOption('variant', $this->mUserVariant);
$wgUser->setOption('nickname', $this->mNick);
$wgUser->setOption('quickbar', $this->mQuickbar);
global $wgAllowUserSkin;
if ($wgAllowUserSkin) {
$wgUser->setOption('skin', $this->mSkin);
}
global $wgUseTeX;
if ($wgUseTeX) {
$wgUser->setOption('math', $this->mMath);
}
$wgUser->setOption('date', $this->validateDate($this->mDate));
$wgUser->setOption('searchlimit', $this->validateIntOrNull($this->mSearch));
$wgUser->setOption('contextlines', $this->validateIntOrNull($this->mSearchLines));
$wgUser->setOption('contextchars', $this->validateIntOrNull($this->mSearchChars));
$wgUser->setOption('rclimit', $this->validateIntOrNull($this->mRecent));
$wgUser->setOption('rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600 * 24))));
$wgUser->setOption('wllimit', $this->validateIntOrNull($this->mWatchlistEdits, 0, 1000));
$wgUser->setOption('rows', $this->validateInt($this->mRows, 4, 1000));
$wgUser->setOption('cols', $this->validateInt($this->mCols, 4, 1000));
$wgUser->setOption('stubthreshold', $this->validateIntOrNull($this->mStubs));
$wgUser->setOption('timecorrection', $this->validateTimeZone($this->mTimeZone, $this->mHourDiff));
$wgUser->setOption('imagesize', $this->mImageSize);
$wgUser->setOption('thumbsize', $this->mThumbSize);
$wgUser->setOption('underline', $this->validateInt($this->mUnderline, 0, 2));
$wgUser->setOption('watchlistdays', $this->validateFloat($this->mWatchlistDays, 0, 7));
$wgUser->setOption('disablesuggest', $this->mDisableMWSuggest);
# Set search namespace options
foreach ($this->mSearchNs as $i => $value) {
$wgUser->setOption("searchNs{$i}", $value);
}
if ($wgEnableEmail && $wgEnableUserEmail) {
$wgUser->setOption('disablemail', $this->mEmailFlag);
}
# Set user toggles
foreach ($this->mToggles as $tname => $tvalue) {
$wgUser->setOption($tname, $tvalue);
}
$error = false;
if ($wgEnableEmail) {
$newadr = $this->mUserEmail;
$oldadr = $wgUser->getEmail();
if ($newadr != '' && $newadr != $oldadr) {
# the user has supplied a new email address on the login page
if ($wgUser->isValidEmailAddr($newadr)) {
# new behaviour: set this new emailaddr from login-page into user database record
$wgUser->setEmail($newadr);
# but flag as "dirty" = unauthenticated
$wgUser->invalidateEmail();
if ($wgEmailAuthentication) {
# Mail a temporary password to the dirty address.
# User can come back through the confirmation URL to re-enable email.
$result = $wgUser->sendConfirmationMail();
if (WikiError::isError($result)) {
$error = wfMsg('mailerror', htmlspecialchars($result->getMessage()));
} else {
$error = wfMsg('eauthentsent', $wgUser->getName());
}
}
} else {
$error = wfMsg('invalidemailaddress');
}
} else {
if ($wgEmailConfirmToEdit && empty($newadr)) {
$this->mainPrefsForm('error', wfMsg('noemailtitle'));
return;
//.........这里部分代码省略.........
示例14: mailPassword
/**
* @private
*/
function mailPassword()
{
global $wgUser, $wgOut, $wgAuth;
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return false;
}
if (!$wgAuth->allowPasswordChange()) {
$this->mainLoginForm(wfMsg('resetpass_forbidden'));
return;
}
# Check against blocked IPs so blocked users can't flood admins
# with password resets
if ($wgUser->isBlocked()) {
$this->mainLoginForm(wfMsg('blocked-mailpassword'));
return;
}
# Check for hooks
$error = null;
if (!wfRunHooks('UserLoginMailPassword', array($this->mName, &$error))) {
$this->mainLoginForm($error);
return;
}
# If the user doesn't have a login token yet, set one.
if (!self::getLoginToken()) {
self::setLoginToken();
$this->mainLoginForm(wfMsg('sessionfailure'));
return;
}
# If the user didn't pass a login token, tell them we need one
if (!$this->mToken) {
$this->mainLoginForm(wfMsg('sessionfailure'));
return;
}
# Check against the rate limiter
if ($wgUser->pingLimiter('mailpassword')) {
$wgOut->rateLimited();
return;
}
if ($this->mName == '') {
$this->mainLoginForm(wfMsg('noname'));
return;
}
$u = User::newFromName($this->mName);
if (!$u instanceof User) {
$this->mainLoginForm(wfMsg('noname'));
return;
}
if (0 == $u->getID()) {
$this->mainLoginForm(wfMsgWikiHtml('nosuchuser', htmlspecialchars($u->getName())));
return;
}
# Validate the login token
if ($this->mToken !== self::getLoginToken()) {
$this->mainLoginForm(wfMsg('sessionfailure'));
return;
}
# Check against password throttle
if ($u->isPasswordReminderThrottled()) {
global $wgPasswordReminderResendTime;
# Round the time in hours to 3 d.p., in case someone is specifying
# minutes or seconds.
$this->mainLoginForm(wfMsgExt('throttled-mailpassword', array('parsemag'), round($wgPasswordReminderResendTime, 3)));
return;
}
$result = $this->mailPasswordInternal($u, true, 'passwordremindertitle', 'passwordremindertext');
if (WikiError::isError($result)) {
$this->mainLoginForm(wfMsg('mailerror', $result->getMessage()));
} else {
$this->mainLoginForm(wfMsg('passwordsent', $u->getName()), 'success');
self::clearLoginToken();
}
}
示例15: mailPassword
/**
* @private
*/
function mailPassword()
{
global $wgUser, $wgOut;
# Check against the rate limiter
if ($wgUser->pingLimiter('mailpassword')) {
$wgOut->rateLimited();
return;
}
if ('' == $this->mName) {
$this->mainLoginForm(wfMsg('noname'));
return;
}
$u = User::newFromName($this->mName);
if (is_null($u)) {
$this->mainLoginForm(wfMsg('noname'));
return;
}
if (0 == $u->getID()) {
$this->mainLoginForm(wfMsg('nosuchuser', $u->getName()));
return;
}
$u->loadFromDatabase();
$result = $this->mailPasswordInternal($u);
if (WikiError::isError($result)) {
$this->mainLoginForm(wfMsg('mailerror', $result->getMessage()));
} else {
$this->mainLoginForm(wfMsg('passwordsent', $u->getName()), 'success');
}
}