예제 #1
0
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
0
 /**
  * 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
0
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
0
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
0
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;
}