当前位置: 首页>>代码示例>>PHP>>正文


PHP Status::warning方法代码示例

本文整理汇总了PHP中Status::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::warning方法的具体用法?PHP Status::warning怎么用?PHP Status::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Status的用法示例。


在下文中一共展示了Status::warning方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: subscribeToMediaWikiAnnounce

 /**
  * @param $s Status
  */
 private function subscribeToMediaWikiAnnounce(Status $s)
 {
     $params = array('email' => $this->getVar('_AdminEmail'), 'language' => 'en', 'digest' => 0);
     // Mailman doesn't support as many languages as we do, so check to make
     // sure their selected language is available
     $myLang = $this->getVar('_UserLang');
     if (in_array($myLang, $this->mediaWikiAnnounceLanguages)) {
         $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang;
         // rewrite to Mailman's pt_BR
         $params['language'] = $myLang;
     }
     if (MWHttpRequest::canMakeRequests()) {
         $res = MWHttpRequest::factory($this->mediaWikiAnnounceUrl, array('method' => 'POST', 'postData' => $params))->execute();
         if (!$res->isOK()) {
             $s->warning('config-install-subscribe-fail', $res->getMessage());
         }
     } else {
         $s->warning('config-install-subscribe-notpossible');
     }
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:23,代码来源:Installer.php

示例2: testGetStatusArrayWithNonObjectMessages

 /**
  * @dataProvider provideNonObjectMessages
  * @covers Status::getStatusArray
  */
 public function testGetStatusArrayWithNonObjectMessages($nonObjMsg)
 {
     $status = new Status();
     if (!array_key_exists(1, $nonObjMsg)) {
         $status->warning($nonObjMsg[0]);
     } else {
         $status->warning($nonObjMsg[0], $nonObjMsg[1]);
     }
     $array = $status->getWarningsArray();
     // We use getWarningsArray to access getStatusArray
     $this->assertEquals(1, count($array));
     $this->assertEquals($nonObjMsg, $array[0]);
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:17,代码来源:StatusTest.php

示例3: setupSearchIndex

 /**
  * @param Status $status
  * @return Status
  */
 public function setupSearchIndex(&$status)
 {
     global $IP;
     $module = DatabaseSqlite::getFulltextSearchModule();
     $fts3tTable = $this->db->checkForEnabledSearch();
     if ($fts3tTable && !$module) {
         $status->warning('config-sqlite-fts3-downgrade');
         $this->db->sourceFile("{$IP}/maintenance/sqlite/archives/searchindex-no-fts.sql");
     } elseif (!$fts3tTable && $module == 'FTS3') {
         $this->db->sourceFile("{$IP}/maintenance/sqlite/archives/searchindex-fts3.sql");
     }
     return $status;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:17,代码来源:SqliteInstaller.php

示例4: highlight

 /**
  * Highlight a code-block using a particular lexer.
  *
  * @param string $code Code to highlight.
  * @param string|null $lang Language name, or null to use plain markup.
  * @param array $args Associative array of additional arguments.
  *  If it contains a 'line' key, the output will include line numbers.
  *  If it includes a 'highlight' key, the value will be parsed as a
  *  comma-separated list of lines and line-ranges to highlight.
  *  If it contains a 'start' key, the value will be used as the line at which to
  *  start highlighting.
  *  If it contains a 'inline' key, the output will not be wrapped in `<div><pre/></div>`.
  * @return Status Status object, with HTML representing the highlighted
  *  code as its value.
  */
 protected static function highlight($code, $lang = null, $args = array())
 {
     global $wgPygmentizePath;
     $status = new Status();
     $lexer = self::getLexer($lang);
     if ($lexer === null && $lang !== null) {
         $status->warning('syntaxhighlight-error-unknown-language', $lang);
     }
     $length = strlen($code);
     if (strlen($code) > self::HIGHLIGHT_MAX_BYTES) {
         $status->warning('syntaxhighlight-error-exceeds-size-limit', $length, self::HIGHLIGHT_MAX_BYTES);
         $lexer = null;
     }
     if (wfShellExecDisabled() !== false) {
         $status->warning('syntaxhighlight-error-pygments-invocation-failure');
         wfWarn('MediaWiki determined that it cannot invoke Pygments. ' . 'As a result, SyntaxHighlight_GeSHi will not perform any syntax highlighting. ' . 'See the debug log for details: ' . 'https://www.mediawiki.org/wiki/Manual:$wgDebugLogFile');
         $lexer = null;
     }
     $inline = isset($args['inline']);
     if ($lexer === null) {
         if ($inline) {
             $status->value = htmlspecialchars(trim($code), ENT_NOQUOTES);
         } else {
             $pre = Html::element('pre', array(), $code);
             $status->value = Html::rawElement('div', array('class' => self::HIGHLIGHT_CSS_CLASS), $pre);
         }
         return $status;
     }
     $options = array('cssclass' => self::HIGHLIGHT_CSS_CLASS, 'encoding' => 'utf-8');
     // Line numbers
     if (isset($args['line'])) {
         $options['linenos'] = 'inline';
     }
     if ($lexer === 'php' && strpos($code, '<?php') === false) {
         $options['startinline'] = 1;
     }
     // Highlight specific lines
     if (isset($args['highlight'])) {
         $lines = self::parseHighlightLines($args['highlight']);
         if (count($lines)) {
             $options['hl_lines'] = implode(' ', $lines);
         }
     }
     // Starting line number
     if (isset($args['start'])) {
         $options['linenostart'] = $args['start'];
     }
     if ($inline) {
         $options['nowrap'] = 1;
     }
     $cache = wfGetMainCache();
     $cacheKey = self::makeCacheKey($code, $lexer, $options);
     $output = $cache->get($cacheKey);
     if ($output === false) {
         $optionPairs = array();
         foreach ($options as $k => $v) {
             $optionPairs[] = "{$k}={$v}";
         }
         $builder = new ProcessBuilder();
         $builder->setPrefix($wgPygmentizePath);
         $process = $builder->add('-l')->add($lexer)->add('-f')->add('html')->add('-O')->add(implode(',', $optionPairs))->getProcess();
         $process->setInput($code);
         $process->run();
         if (!$process->isSuccessful()) {
             $status->warning('syntaxhighlight-error-pygments-invocation-failure');
             wfWarn('Failed to invoke Pygments: ' . $process->getErrorOutput());
             $status->value = self::highlight($code, null, $args)->getValue();
             return $status;
         }
         $output = $process->getOutput();
         $cache->set($cacheKey, $output);
     }
     if ($inline) {
         $output = trim($output);
     }
     $status->value = $output;
     return $status;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:93,代码来源:SyntaxHighlight_GeSHi.class.php

示例5: merge

 /**
  * Actually attempt the history move
  *
  * @todo if all versions of page A are moved to B and then a user
  * tries to do a reverse-merge via the "unmerge" log link, then page
  * A will still be a redirect (as it was after the original merge),
  * though it will have the old revisions back from before (as expected).
  * The user may have to "undo" the redirect manually to finish the "unmerge".
  * Maybe this should delete redirects at the source page of merges?
  *
  * @param User $user
  * @param string $reason
  * @return Status status of the history merge
  */
 public function merge(User $user, $reason = '')
 {
     $status = new Status();
     // Check validity and permissions required for merge
     $validCheck = $this->isValidMerge();
     // Check this first to check for null pages
     if (!$validCheck->isOK()) {
         return $validCheck;
     }
     $permCheck = $this->checkPermissions($user, $reason);
     if (!$permCheck->isOK()) {
         return $permCheck;
     }
     $this->dbw->update('revision', array('rev_page' => $this->dest->getArticleID()), array('rev_page' => $this->source->getArticleID(), $this->timeWhere), __METHOD__);
     // Check if this did anything
     $this->revisionsMerged = $this->dbw->affectedRows();
     if ($this->revisionsMerged < 1) {
         $status->fatal('mergehistory-fail-no-change');
         return $status;
     }
     // Make the source page a redirect if no revisions are left
     $haveRevisions = $this->dbw->selectField('revision', 'rev_timestamp', array('rev_page' => $this->source->getArticleID()), __METHOD__, array('FOR UPDATE'));
     if (!$haveRevisions) {
         if ($reason) {
             $reason = wfMessage('mergehistory-comment', $this->source->getPrefixedText(), $this->dest->getPrefixedText(), $reason)->inContentLanguage()->text();
         } else {
             $reason = wfMessage('mergehistory-autocomment', $this->source->getPrefixedText(), $this->dest->getPrefixedText())->inContentLanguage()->text();
         }
         $contentHandler = ContentHandler::getForTitle($this->source);
         $redirectContent = $contentHandler->makeRedirectContent($this->dest, wfMessage('mergehistory-redirect-text')->inContentLanguage()->plain());
         if ($redirectContent) {
             $redirectPage = WikiPage::factory($this->source);
             $redirectRevision = new Revision(array('title' => $this->source, 'page' => $this->source->getArticleID(), 'comment' => $reason, 'content' => $redirectContent));
             $redirectRevision->insertOn($this->dbw);
             $redirectPage->updateRevisionOn($this->dbw, $redirectRevision);
             // Now, we record the link from the redirect to the new title.
             // It should have no other outgoing links...
             $this->dbw->delete('pagelinks', array('pl_from' => $this->dest->getArticleID()), __METHOD__);
             $this->dbw->insert('pagelinks', array('pl_from' => $this->dest->getArticleID(), 'pl_from_namespace' => $this->dest->getNamespace(), 'pl_namespace' => $this->dest->getNamespace(), 'pl_title' => $this->dest->getDBkey()), __METHOD__);
         } else {
             // Warning if we couldn't create the redirect
             $status->warning('mergehistory-warning-redirect-not-created');
         }
     } else {
         $this->source->invalidateCache();
         // update histories
     }
     $this->dest->invalidateCache();
     // update histories
     // Update our logs
     $logEntry = new ManualLogEntry('merge', 'merge');
     $logEntry->setPerformer($user);
     $logEntry->setComment($reason);
     $logEntry->setTarget($this->source);
     $logEntry->setParameters(array('4::dest' => $this->dest->getPrefixedText(), '5::mergepoint' => $this->timestampLimit->getTimestamp(TS_MW)));
     $logId = $logEntry->insert();
     $logEntry->publish($logId);
     Hooks::run('ArticleMergeComplete', array($this->source, $this->dest));
     return $status;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:74,代码来源:MergeHistory.php

示例6: testGetErrorsByType

 /**
  * @covers Status::getErrorsByType
  */
 public function testGetErrorsByType()
 {
     $status = new Status();
     $warning = new Message('warning111');
     $error = new Message('error111');
     $status->warning($warning);
     $status->error($error);
     $warnings = $status->getErrorsByType('warning');
     $errors = $status->getErrorsByType('error');
     $this->assertCount(1, $warnings);
     $this->assertCount(1, $errors);
     $this->assertEquals($warning, $warnings[0]['message']);
     $this->assertEquals($error, $errors[0]['message']);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:17,代码来源:StatusTest.php


注:本文中的Status::warning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。