本文整理汇总了PHP中Status::isOK方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::isOK方法的具体用法?PHP Status::isOK怎么用?PHP Status::isOK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::isOK方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: endStage
/**
* @param string $step
* @param Status $status
*/
public function endStage($step, $status)
{
if ($step == 'extension-tables') {
$this->endLiveBox();
}
$msg = $status->isOK() ? 'config-install-step-done' : 'config-install-step-failed';
$html = wfMessage('word-separator')->escaped() . wfMessage($msg)->escaped();
if (!$status->isOK()) {
$html = "<span class=\"error\">{$html}</span>";
}
$this->addHTML($html . "</li>\n");
if (!$status->isGood()) {
$this->parent->showStatusBox($status);
}
}
示例2: efSharedHelpArticleCreation
/**
* @param WikiPage $article
* @param $user
* @param $text
* @param $summary
* @param $minoredit
* @param $watchthis
* @param $sectionanchor
* @param $flags
* @param $revision
* @param Status $status
* @param $baseRevId
* @return bool
*/
function efSharedHelpArticleCreation(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
{
global $wgCityId, $wgHelpWikiId;
// only run on help wikis
if ($wgCityId !== $wgHelpWikiId) {
return true;
}
// not likely if we got here, but... healthy paranoia ;)
if (wfReadOnly()) {
return true;
}
if ($article->mTitle->getNamespace() !== NS_HELP) {
return true;
}
if (!$status->isOK()) {
return true;
}
if (!($flags & EDIT_NEW)) {
return true;
}
$talkTitle = Title::newFromText($article->mTitle->getText(), NS_HELP_TALK);
if ($talkTitle->exists()) {
return true;
}
$talkArticle = new Article($talkTitle);
$redir = $article->getRedirectTarget();
if ($redir) {
$target = $redir->getTalkNsText() . ':' . $redir->getText();
$talkArticle->doEdit("#REDIRECT [[{$target}]]", wfMsgForContent('sharedhelp-autotalkcreate-summary'));
} else {
$talkArticle->doEdit('{{talkheader}}', wfMsgForContent('sharedhelp-autotalkcreate-summary'));
}
return true;
}
示例3:
/**
* Release the locks when this goes out of scope
*/
function __destruct() {
$wasOk = $this->status->isOK();
$this->status->merge( $this->manager->unlockByType( $this->pathsByType ) );
if ( $wasOk ) {
// Make sure status is OK, despite any unlockFiles() fatals
$this->status->setResult( true, $this->status->value );
}
}
示例4: undelete
/**
* Restore the given (or all) text and file revisions for the page.
* Once restored, the items will be removed from the archive tables.
* The deletion log will be updated with an undeletion notice.
*
* This also sets Status objects, $this->fileStatus and $this->revisionStatus
* (depending what operations are attempted).
*
* @param array $timestamps Pass an empty array to restore all revisions,
* otherwise list the ones to undelete.
* @param string $comment
* @param array $fileVersions
* @param bool $unsuppress
* @param User $user User performing the action, or null to use $wgUser
* @param string|string[] $tags Change tags to add to log entry
* ($user should be able to add the specified tags before this is called)
* @return array(number of file revisions restored, number of image revisions
* restored, log message) on success, false on failure.
*/
function undelete($timestamps, $comment = '', $fileVersions = [], $unsuppress = false, User $user = null, $tags = null)
{
// If both the set of text revisions and file revisions are empty,
// restore everything. Otherwise, just restore the requested items.
$restoreAll = empty($timestamps) && empty($fileVersions);
$restoreText = $restoreAll || !empty($timestamps);
$restoreFiles = $restoreAll || !empty($fileVersions);
if ($restoreFiles && $this->title->getNamespace() == NS_FILE) {
$img = wfLocalFile($this->title);
$img->load(File::READ_LATEST);
$this->fileStatus = $img->restore($fileVersions, $unsuppress);
if (!$this->fileStatus->isOK()) {
return false;
}
$filesRestored = $this->fileStatus->successCount;
} else {
$filesRestored = 0;
}
if ($restoreText) {
$this->revisionStatus = $this->undeleteRevisions($timestamps, $unsuppress, $comment);
if (!$this->revisionStatus->isOK()) {
return false;
}
$textRestored = $this->revisionStatus->getValue();
} else {
$textRestored = 0;
}
// Touch the log!
if ($textRestored && $filesRestored) {
$reason = wfMessage('undeletedrevisions-files')->numParams($textRestored, $filesRestored)->inContentLanguage()->text();
} elseif ($textRestored) {
$reason = wfMessage('undeletedrevisions')->numParams($textRestored)->inContentLanguage()->text();
} elseif ($filesRestored) {
$reason = wfMessage('undeletedfiles')->numParams($filesRestored)->inContentLanguage()->text();
} else {
wfDebug("Undelete: nothing undeleted...\n");
return false;
}
if (trim($comment) != '') {
$reason .= wfMessage('colon-separator')->inContentLanguage()->text() . $comment;
}
if ($user === null) {
global $wgUser;
$user = $wgUser;
}
$logEntry = new ManualLogEntry('delete', 'restore');
$logEntry->setPerformer($user);
$logEntry->setTarget($this->title);
$logEntry->setComment($reason);
$logEntry->setTags($tags);
Hooks::run('ArticleUndeleteLogEntry', [$this, &$logEntry, $user]);
$logid = $logEntry->insert();
$logEntry->publish($logid);
return [$textRestored, $filesRestored, $reason];
}
示例5: getStatusError
/**
* Get error message key and parameters from status
*
* @param \Status $status
* @return array of error message key, and message parameters as an array
* @throws Exception if called on an "OK" Status
*/
public function getStatusError(\Status $status)
{
if ($status->isOK()) {
throw new \Exception('Status contains no errors');
}
$errors = $status->getErrorsByType('error');
if (!empty($errors[0]['message'])) {
$message = $errors[0]['message'];
$params = $errors[0]['params'];
} else {
$message = 'fbconnect-error';
$params = [];
}
return [$message, $params];
}
示例6: onSubmit
/**
* Process the form. At this point we know that the user passes all the criteria in
* userCanExecute(), and if the data array contains 'Username', etc, then Username
* resets are allowed.
* @param array $data
* @throws MWException
* @throws ThrottledError|PermissionsError
* @return Status
*/
public function onSubmit(array $data)
{
if (isset($data['Capture']) && !$this->getUser()->isAllowed('passwordreset')) {
// The user knows they don't have the passwordreset permission,
// but they tried to spoof the form. That's naughty
throw new PermissionsError('passwordreset');
}
$username = isset($data['Username']) ? $data['Username'] : null;
$email = isset($data['Email']) ? $data['Email'] : null;
$capture = !empty($data['Capture']);
$this->method = $username ? 'username' : 'email';
$this->result = Status::wrap($this->passwordReset->execute($this->getUser(), $username, $email, $capture));
if ($capture && $this->result->isOK()) {
$this->passwords = $this->result->getValue();
}
if ($this->result->hasMessage('actionthrottledtext')) {
throw new ThrottledError();
}
return $this->result;
}
示例7: callback
/**
* Callback function
* Does some basic verification of data
* Decides whether to show the preview screen
* or the submitted message
*
* @param $data Array
* @return Status
*/
public function callback(array $data)
{
$this->verifyData($data);
// Die on errors.
if (!$this->status->isOK()) {
$this->state = 'form';
return $this->status;
}
// Add a global footer
$footer = $this->msg('massmessage-message-footer')->inContentLanguage()->parse();
if (trim($footer)) {
// Only add the footer if it is not just whitespace
$data['message'] .= "\n" . $footer;
}
//format this message the wikiHow way
$data['message'] = self::FormatMessage($data['message']);
if ($this->state == 'submit') {
return $this->submit($data);
} else {
// $this->state can only be 'preview' here
return $this->preview($data);
}
}
示例8: testFatalWithMessage
/**
* @dataProvider provideMockMessageDetails
* @covers Status::fatal
* @covers Status::getErrorsArray
* @covers Status::getStatusArray
*/
public function testFatalWithMessage($mockDetails)
{
$status = new Status();
$messages = $this->getMockMessages($mockDetails);
foreach ($messages as $message) {
$status->fatal($message);
}
$errors = $status->getErrorsArray();
$this->assertEquals(count($messages), count($errors));
foreach ($messages as $key => $message) {
$expectedArray = array_merge(array($message->getKey()), $message->getParams());
$this->assertEquals($errors[$key], $expectedArray);
}
$this->assertFalse($status->isOK());
}
示例9: getErrors
/**
* Format and display an error message stack.
*
* @param string|array|Status $errors
*
* @return string
*/
function getErrors($errors)
{
if ($errors instanceof Status) {
if ($errors->isOK()) {
$errorstr = '';
} else {
$errorstr = $this->getOutput()->parse($errors->getWikiText());
}
} elseif (is_array($errors)) {
$errorstr = $this->formatErrors($errors);
} else {
$errorstr = $errors;
}
return $errorstr ? Html::rawElement('div', array('class' => 'error'), $errorstr) : '';
}
示例10: runPostMergeFilters
/**
* Run hooks that can filter edits just before they get saved.
*
* @param Content $content The Content to filter.
* @param Status $status For reporting the outcome to the caller
* @param User $user The user performing the edit
*
* @return bool
*/
protected function runPostMergeFilters(Content $content, Status $status, User $user)
{
// Run old style post-section-merge edit filter
if (!ContentHandler::runLegacyHooks('EditFilterMerged', array($this, $content, &$this->hookError, $this->summary))) {
# Error messages etc. could be handled within the hook...
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR;
return false;
} elseif ($this->hookError != '') {
# ...or the hook could be expecting us to produce an error
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR_EXPECTED;
return false;
}
// Run new style post-section-merge edit filter
if (!wfRunHooks('EditFilterMergedContent', array($this->mArticle->getContext(), $content, $status, $this->summary, $user, $this->minoredit))) {
# Error messages etc. could be handled within the hook...
// XXX: $status->value may already be something informative...
$this->hookError = $status->getWikiText();
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR;
return false;
} elseif (!$status->isOK()) {
# ...or the hook could be expecting us to produce an error
// FIXME this sucks, we should just use the Status object throughout
$this->hookError = $status->getWikiText();
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR_EXPECTED;
return false;
}
return true;
}
示例11: runPostMergeFilters
/**
* Run hooks that can filter edits just before they get saved.
*
* @param Content $content The Content to filter.
* @param Status $status For reporting the outcome to the caller
* @param User $user The user performing the edit
*
* @return bool
*/
protected function runPostMergeFilters(Content $content, Status $status, User $user)
{
// Run old style post-section-merge edit filter
if (!ContentHandler::runLegacyHooks('EditFilterMerged', array($this, $content, &$this->hookError, $this->summary))) {
# Error messages etc. could be handled within the hook...
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR;
return false;
} elseif ($this->hookError != '') {
# ...or the hook could be expecting us to produce an error
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR_EXPECTED;
return false;
}
// Run new style post-section-merge edit filter
if (!Hooks::run('EditFilterMergedContent', array($this->mArticle->getContext(), $content, $status, $this->summary, $user, $this->minoredit))) {
# Error messages etc. could be handled within the hook...
if ($status->isGood()) {
$status->fatal('hookaborted');
// Not setting $this->hookError here is a hack to allow the hook
// to cause a return to the edit page without $this->hookError
// being set. This is used by ConfirmEdit to display a captcha
// without any error message cruft.
} else {
$this->hookError = $status->getWikiText();
}
// Use the existing $status->value if the hook set it
if (!$status->value) {
$status->value = self::AS_HOOK_ERROR;
}
return false;
} elseif (!$status->isOK()) {
# ...or the hook could be expecting us to produce an error
// FIXME this sucks, we should just use the Status object throughout
$this->hookError = $status->getWikiText();
$status->fatal('hookaborted');
$status->value = self::AS_HOOK_ERROR_EXPECTED;
return false;
}
return true;
}
示例12: editPageAttemptSaveAfter
/**
* This is attached to the MediaWiki 'EditPage::attemptSave:after' hook.
*
* @param EditPage $editPage
* @param Status $status
* @return boolean
*/
public static function editPageAttemptSaveAfter(EditPage $editPage, Status $status)
{
$article = $editPage->getArticle();
$request = $article->getContext()->getRequest();
if ($request->getVal('editingStatsId')) {
$data = array();
$data['editingSessionId'] = $request->getVal('editingStatsId');
if ($status->isOK()) {
$action = 'saveSuccess';
} else {
$action = 'saveFailure';
$errors = $status->getErrorsArray();
if (isset($errors[0][0])) {
$data['action.saveFailure.message'] = $errors[0][0];
}
if ($status->value === EditPage::AS_CONFLICT_DETECTED) {
$data['action.saveFailure.type'] = 'editConflict';
} elseif ($status->value === EditPage::AS_ARTICLE_WAS_DELETED) {
$data['action.saveFailure.type'] = 'editPageDeleted';
} elseif (isset($errors[0][0]) && $errors[0][0] === 'abusefilter-disallowed') {
$data['action.saveFailure.type'] = 'extensionAbuseFilter';
} elseif (isset($editPage->getArticle()->getPage()->ConfirmEdit_ActivateCaptcha)) {
// TODO: :(
$data['action.saveFailure.type'] = 'extensionCaptcha';
} elseif (isset($errors[0][0]) && $errors[0][0] === 'spamprotectiontext') {
$data['action.saveFailure.type'] = 'extensionSpamBlacklist';
} else {
// Catch everything else... We don't seem to get userBadToken or
// userNewUser through this hook.
$data['action.saveFailure.type'] = 'responseUnknown';
}
}
self::doEventLogging($action, $article, $data);
}
return true;
}
示例13: getErrors
/**
* @param string|array|Status $err
* @return string
*/
function getErrors($err)
{
if (!$err) {
$errors = array();
} elseif ($err instanceof Status) {
if ($err->isOK()) {
$errors = array();
} else {
$errors = $err->getErrorsByType('error');
foreach ($errors as &$error) {
// Input: array( 'message' => 'foo', 'errors' => array( 'a', 'b', 'c' ) )
// Output: array( 'foo', 'a', 'b', 'c' )
$error = array_merge(array($error['message']), $error['params']);
}
}
} else {
$errors = $err;
if (!is_array($errors)) {
$errors = array($errors);
}
}
foreach ($errors as &$error) {
if (is_array($error)) {
$msg = array_shift($error);
} else {
$msg = $error;
$error = array();
}
// if the error is already a message object, don't use it as a message key
if (!$msg instanceof Message) {
$error = $this->msg($msg, $error)->parse();
} else {
$error = $msg->parse();
}
$error = new OOUI\HtmlSnippet($error);
}
// Used in getBody()
$this->oouiErrors = $errors;
return '';
}
示例14: showStatusBox
/**
* Output an error or warning box using a Status object.
*
* @param Status $status
*/
public function showStatusBox($status)
{
if (!$status->isGood()) {
$text = $status->getWikiText();
if ($status->isOK()) {
$box = $this->getWarningBox($text);
} else {
$box = $this->getErrorBox($text);
}
$this->output->addHTML($box);
}
}
示例15: showStatusMessage
public function showStatusMessage(Status $status)
{
$warnings = array_merge($status->getWarningsArray(), $status->getErrorsArray());
if (count($warnings) !== 0) {
foreach ($warnings as $w) {
call_user_func_array([$this, 'showMessage'], $w);
}
}
if (!$status->isOK()) {
echo "\n";
exit(1);
}
}