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


PHP ApiFormatBase::getIsHtml方法代码示例

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


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

示例1: executeActionWithErrorHandling

 /**
  * Execute an action, and in case of an error, erase whatever partial results
  * have been accumulated, and replace it with an error message and a help screen.
  */
 protected function executeActionWithErrorHandling()
 {
     // Verify the CORS header before executing the action
     if (!$this->handleCORS()) {
         // handleCORS() has sent a 403, abort
         return;
     }
     // Exit here if the request method was OPTIONS
     // (assume there will be a followup GET or POST)
     if ($this->getRequest()->getMethod() === 'OPTIONS') {
         return;
     }
     // In case an error occurs during data output,
     // clear the output buffer and print just the error information
     ob_start();
     $t = microtime(true);
     try {
         $this->executeAction();
     } catch (Exception $e) {
         $this->handleException($e);
     }
     // Log the request whether or not there was an error
     $this->logRequest(microtime(true) - $t);
     // Send cache headers after any code which might generate an error, to
     // avoid sending public cache headers for errors.
     $this->sendCacheHeaders();
     if ($this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled()) {
         echo wfReportTime();
     }
     ob_end_flush();
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:35,代码来源:ApiMain.php

示例2: executeActionWithErrorHandling

 /**
  * Execute an action, and in case of an error, erase whatever partial results
  * have been accumulated, and replace it with an error message and a help screen.
  */
 protected function executeActionWithErrorHandling()
 {
     // Verify the CORS header before executing the action
     if (!$this->handleCORS()) {
         // handleCORS() has sent a 403, abort
         return;
     }
     // Exit here if the request method was OPTIONS
     // (assume there will be a followup GET or POST)
     if ($this->getRequest()->getMethod() === 'OPTIONS') {
         return;
     }
     // In case an error occurs during data output,
     // clear the output buffer and print just the error information
     ob_start();
     $t = microtime(true);
     try {
         $this->executeAction();
     } catch (Exception $e) {
         // Allow extra cleanup and logging
         wfRunHooks('ApiMain::onException', array($this, $e));
         // Log it
         if ($e instanceof MWException && !$e instanceof UsageException) {
             global $wgLogExceptionBacktrace;
             if ($wgLogExceptionBacktrace) {
                 wfDebugLog('exception', $e->getLogMessage() . "\n" . $e->getTraceAsString() . "\n");
             } else {
                 wfDebugLog('exception', $e->getLogMessage());
             }
         }
         // Handle any kind of exception by outputting properly formatted error message.
         // If this fails, an unhandled exception should be thrown so that global error
         // handler will process and log it.
         $errCode = $this->substituteResultWithError($e);
         // Error results should not be cached
         $this->setCacheMode('private');
         $response = $this->getRequest()->response();
         $headerStr = 'MediaWiki-API-Error: ' . $errCode;
         if ($e->getCode() === 0) {
             $response->header($headerStr);
         } else {
             $response->header($headerStr, true, $e->getCode());
         }
         // Reset and print just the error message
         ob_clean();
         // If the error occurred during printing, do a printer->profileOut()
         $this->mPrinter->safeProfileOut();
         $this->printResult(true);
     }
     // Log the request whether or not there was an error
     $this->logRequest(microtime(true) - $t);
     // Send cache headers after any code which might generate an error, to
     // avoid sending public cache headers for errors.
     $this->sendCacheHeaders();
     if ($this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled()) {
         echo wfReportTime();
     }
     ob_end_flush();
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:63,代码来源:ApiMain.php

示例3: executeActionWithErrorHandling

 /**
  * Execute an action, and in case of an error, erase whatever partial results
  * have been accumulated, and replace it with an error message and a help screen.
  */
 protected function executeActionWithErrorHandling()
 {
     // In case an error occurs during data output,
     // clear the output buffer and print just the error information
     ob_start();
     try {
         $this->executeAction();
     } catch (Exception $e) {
         // Log it
         if ($e instanceof MWException) {
             wfDebugLog('exception', $e->getLogMessage());
         }
         // Handle any kind of exception by outputing properly formatted error message.
         // If this fails, an unhandled exception should be thrown so that global error
         // handler will process and log it.
         $errCode = $this->substituteResultWithError($e);
         // Error results should not be cached
         $this->setCacheMode('private');
         $response = $this->getRequest()->response();
         $headerStr = 'MediaWiki-API-Error: ' . $errCode;
         if ($e->getCode() === 0) {
             $response->header($headerStr);
         } else {
             $response->header($headerStr, true, $e->getCode());
         }
         // Reset and print just the error message
         ob_clean();
         // If the error occured during printing, do a printer->profileOut()
         $this->mPrinter->safeProfileOut();
         $this->printResult(true);
     }
     // Send cache headers after any code which might generate an error, to
     // avoid sending public cache headers for errors.
     $this->sendCacheHeaders();
     if ($this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled()) {
         echo wfReportTime();
     }
     ob_end_flush();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:43,代码来源:ApiMain.php


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