本文整理汇总了PHP中AjaxResponse::setResponseCode方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::setResponseCode方法的具体用法?PHP AjaxResponse::setResponseCode怎么用?PHP AjaxResponse::setResponseCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponse
的用法示例。
在下文中一共展示了AjaxResponse::setResponseCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WMU
function WMU()
{
global $wgRequest, $wgGroupPermissions, $wgAllowCopyUploads;
// Overwrite configuration settings needed by image import functionality
$wgAllowCopyUploads = true;
$wgGroupPermissions['user']['upload_by_url'] = true;
$dir = dirname(__FILE__) . '/';
require_once $dir . 'WikiaMiniUpload_body.php';
$method = $wgRequest->getVal('method');
$wmu = new WikiaMiniUpload();
if (method_exists($wmu, $method)) {
$html = $wmu->{$method}();
$ar = new AjaxResponse($html);
$ar->setContentType('text/html; charset=utf-8');
} else {
$errorMessage = 'WMU::' . $method . ' does not exist';
\Wikia\Logger\WikiaLogger::instance()->error($errorMessage);
$payload = json_encode(['message' => $errorMessage]);
$ar = new AjaxResponse($payload);
$ar->setResponseCode('501 Not implemented');
$ar->setContentType('application/json; charset=utf-8');
}
return $ar;
}
示例2: returnMsg
/**
* Returns the JSON message
*/
protected static function returnMsg($code, $state)
{
$msgId = self::NAME . '-' . ($state ? 'unprotect' : 'protect');
$response = array('code' => $code, 'msg' => self::translateCode($code), 'state' => $state, 'text' => wfMsg($msgId));
$result = self::SimpleJsonEncode($response);
$ajaxResponse = new AjaxResponse($result);
$ajaxResponse->setContentType('application/json');
$ajaxResponse->setResponseCode(self::$codeHttpMap[$code]);
return $ajaxResponse;
}
示例3: smwf_tb_getTripleStoreStatus
function smwf_tb_getTripleStoreStatus()
{
global $smwgTripleStoreGraph;
$con = TSConnection::getConnector();
try {
$con->connect();
$statusInfo = $con->getStatus($smwgTripleStoreGraph);
$response = new AjaxResponse(json_encode($statusInfo));
$response->setContentType("application/json");
$response->setResponseCode(200);
$con->disconnect();
} catch (Exception $e) {
$response = new AjaxResponse($e->getMessage());
$response->setContentType("application/text");
$response->setResponseCode(500);
}
return $response;
}
示例4: playerAjaxHandler
function playerAjaxHandler($file, $options)
{
$response = new AjaxResponse();
try {
#TODO: caching!
$player = Player::newFromName($file, $options, 'thumbsize');
$html = $player->getPlayerHTML();
$response->addText($html);
} catch (PlayerException $ex) {
$response->setResponseCode($ex->getHTTPCode());
$response->addText($ex->getHTML());
}
return $response;
}
示例5: wfAjaxPostCollection
function wfAjaxPostCollection($collection = '', $redirect = '')
{
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
if (session_id() == '') {
wfSetupSession();
}
$collection = $json->decode($collection);
$collection['enabled'] = true;
$_SESSION['wsCollection'] = $collection;
$r = new AjaxResponse();
if ($redirect) {
$title = Title::newFromText($redirect);
$redirecturl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
$r->setResponseCode(302);
header('Location: ' . $redirecturl);
} else {
$title = SpecialPage::getTitleFor('Book');
$redirecturl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
$r->setContentType('application/json');
$r->addText($json->encode(array('redirect_url' => $redirecturl)));
}
return $r;
}