本文整理汇总了PHP中AjaxResponse::printText方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::printText方法的具体用法?PHP AjaxResponse::printText怎么用?PHP AjaxResponse::printText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponse
的用法示例。
在下文中一共展示了AjaxResponse::printText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performAction
function performAction()
{
global $wgAjaxExportList, $wgOut;
if (empty($this->mode)) {
return;
}
wfProfileIn('AjaxDispatcher::performAction');
if (!in_array($this->func_name, $wgAjaxExportList)) {
header('Status: 400 Bad Request', true, 400);
print "unknown function " . htmlspecialchars((string) $this->func_name);
} else {
try {
$result = call_user_func_array($this->func_name, $this->args);
if ($result === false || $result === NULL) {
header('Status: 500 Internal Error', true, 500);
echo "{$this->func_name} returned no data";
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
$result->sendHeaders();
$result->printText();
}
} catch (Exception $e) {
if (!headers_sent()) {
header('Status: 500 Internal Error', true, 500);
print $e->getMessage();
} else {
print $e->getMessage();
}
}
}
wfProfileOut('AjaxDispatcher::performAction');
$wgOut = null;
}
示例2: performAction
function performAction()
{
global $wgAjaxExportList, $wgOut;
if (empty($this->mode)) {
return;
}
wfProfileIn(__METHOD__);
if (!in_array($this->func_name, $wgAjaxExportList)) {
wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
} else {
try {
$result = call_user_func_array($this->func_name, $this->args);
if ($result === false || $result === NULL) {
wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
$result->sendHeaders();
$result->printText();
}
} catch (Exception $e) {
if (!headers_sent()) {
wfHttpError(500, 'Internal Error', $e->getMessage());
} else {
print $e->getMessage();
}
}
}
wfProfileOut(__METHOD__);
$wgOut = null;
}
示例3: performAction
/** Pass the request to our internal function.
* BEWARE! Data are passed as they have been supplied by the user,
* they should be carefully handled in the function processing the
* request.
*/
function performAction()
{
global $wgAjaxExportList, $wgOut, $wgUser;
if (empty($this->mode)) {
return;
}
/*
* Wikia Change - begin
*/
Transaction::setEntryPoint(Transaction::ENTRY_POINT_AJAX);
Transaction::setAttribute(Transaction::PARAM_FUNCTION, $this->func_name);
if (function_exists('newrelic_disable_autorum')) {
newrelic_disable_autorum();
}
/*
* Wikia Change - end
*/
wfProfileIn(__METHOD__);
if (!in_array($this->func_name, $wgAjaxExportList)) {
wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
} elseif (!in_array('read', User::getGroupPermissions(array('*')), true) && !$wgUser->isAllowed('read')) {
wfHttpError(403, 'Forbidden', 'You must log in to view pages.');
} else {
wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
if (strpos($this->func_name, '::') !== false) {
$func = explode('::', $this->func_name, 2);
} else {
$func = $this->func_name;
}
try {
$result = call_user_func_array($func, $this->args);
if ($result === false || $result === null) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . "no data returned\n");
/* Wikia changes start */
//let's avoid falling back to Iowa (500, 503) in this case,
//probably someone is asking for a non-existing dynamic method name
wfHttpError(501, 'Not Implemented', "{$this->func_name} returned no data");
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
$result->sendHeaders();
$result->printText();
wfDebug(__METHOD__ . ' dispatch complete for ' . $this->func_name . "\n");
}
} catch (Exception $e) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . get_class($e) . ": " . $e->getMessage() . "\n");
if (!headers_sent()) {
wfHttpError(500, 'Internal Error', $e->getMessage());
} else {
print $e->getMessage();
}
}
}
$wgOut = null;
wfProfileOut(__METHOD__);
}
示例4: performAction
/** Pass the request to our internal function.
* BEWARE! Data are passed as they have been supplied by the user,
* they should be carefully handled in the function processing the
* request.
*/
function performAction()
{
global $wgAjaxExportList, $wgOut;
if (empty($this->mode)) {
return;
}
wfProfileIn(__METHOD__);
if (!in_array($this->func_name, $wgAjaxExportList)) {
wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
} else {
wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
if (strpos($this->func_name, '::') !== false) {
$func = explode('::', $this->func_name, 2);
} else {
$func = $this->func_name;
}
try {
$result = call_user_func_array($func, $this->args);
if ($result === false || $result === NULL) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . "no data returned\n");
wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
$result->sendHeaders();
$result->printText();
wfDebug(__METHOD__ . ' dispatch complete for ' . $this->func_name . "\n");
}
} catch (Exception $e) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . get_class($e) . ": " . $e->getMessage() . "\n");
if (!headers_sent()) {
wfHttpError(500, 'Internal Error', $e->getMessage());
} else {
print $e->getMessage();
}
}
}
wfProfileOut(__METHOD__);
$wgOut = null;
}
示例5: performAction
/** Pass the request to our internal function.
* BEWARE! Data are passed as they have been supplied by the user,
* they should be carefully handled in the function processing the
* request.
*/
function performAction()
{
global $wgAjaxExportList;
if (empty($this->mode)) {
return;
}
if (!in_array($this->func_name, $wgAjaxExportList)) {
header("HTTP/1.0 400 Bad Request");
header("Status: 400 Bad Request");
header('Content-type: text/html; charset=utf-8');
print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" . "<html><head><title>" . htmlspecialchars("Bad Request") . "</title></head><body><h1>" . htmlspecialchars("Bad Request") . "</h1><p>" . nl2br(htmlspecialchars("unknown function " . (string) $this->func_name)) . "</p></body></html>\n";
} else {
if (strpos($this->func_name, '::') !== false) {
$func = explode('::', $this->func_name, 2);
} else {
$func = $this->func_name;
}
try {
$result = call_user_func_array($func, $this->args);
if ($result === false || $result === NULL) {
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
if ($this->contentType) {
$result->setContentType($this->contentType);
}
$result->sendHeaders($this->expire, $this->contentType);
$result->printText();
}
} catch (Exception $e) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . get_class($e) . ": " . $e->getMessage() . "\n");
if (!headers_sent()) {
wfHttpError(500, 'Internal Error', $e->getMessage());
} else {
print $e->getMessage();
}
}
}
}
示例6: performAction
/**
* Pass the request to our internal function.
* BEWARE! Data are passed as they have been supplied by the user,
* they should be carefully handled in the function processing the
* request.
*
* @param User $user
*/
function performAction(User $user)
{
if (empty($this->mode)) {
return;
}
if (!in_array($this->func_name, $this->config->get('AjaxExportList'))) {
wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
wfHttpError(400, 'Bad Request', "unknown function " . $this->func_name);
} elseif (!User::isEveryoneAllowed('read') && !$user->isAllowed('read')) {
wfHttpError(403, 'Forbidden', 'You are not allowed to view pages.');
} else {
wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
try {
$result = call_user_func_array($this->func_name, $this->args);
if ($result === false || $result === null) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . "no data returned\n");
wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
// Make sure DB commit succeeds before sending a response
wfGetLBFactory()->commitMasterChanges(__METHOD__);
$result->sendHeaders();
$result->printText();
wfDebug(__METHOD__ . ' dispatch complete for ' . $this->func_name . "\n");
}
} catch (Exception $e) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . get_class($e) . ": " . $e->getMessage() . "\n");
if (!headers_sent()) {
wfHttpError(500, 'Internal Error', $e->getMessage());
} else {
print $e->getMessage();
}
}
}
}
示例7: performAction
/**
* Pass the request to our internal function.
* BEWARE! Data are passed as they have been supplied by the user,
* they should be carefully handled in the function processing the
* request.
*/
function performAction()
{
global $wgAjaxExportList, $wgUser;
if (empty($this->mode)) {
return;
}
wfProfileIn(__METHOD__);
if (!in_array($this->func_name, $wgAjaxExportList)) {
wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
} elseif (!in_array('read', User::getGroupPermissions(array('*')), true) && !$wgUser->isAllowed('read')) {
wfHttpError(403, 'Forbidden', 'You must log in to view pages.');
} else {
wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
try {
$result = call_user_func_array($this->func_name, $this->args);
if ($result === false || $result === null) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . "no data returned\n");
wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
} else {
if (is_string($result)) {
$result = new AjaxResponse($result);
}
$result->sendHeaders();
$result->printText();
wfDebug(__METHOD__ . ' dispatch complete for ' . $this->func_name . "\n");
}
} catch (Exception $e) {
wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . get_class($e) . ": " . $e->getMessage() . "\n");
if (!headers_sent()) {
wfHttpError(500, 'Internal Error', $e->getMessage());
} else {
print $e->getMessage();
}
}
}
wfProfileOut(__METHOD__);
}