Пример #1
0
// set the Moodle root directory
$MOODLEROOT = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
// load dependencies
require_once "{$MOODLEROOT}/config.php";
require_once "{$MOODLEROOT}/repository/omero/lib.php";
require_once "{$MOODLEROOT}/repository/omero/locallib.php";
// check whether Moodle Env exists
defined('MOODLE_INTERNAL') || die;
// check whether the user is logged
if (!isloggedin()) {
    $moodle_url = "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/moodle";
    header('Location: ' . $moodle_url);
}
// omero server
$omero_server = new omero();
// get method
$method = required_param("m", PARAM_TEXT);
// get the Image ID
$image_id = required_param("id", PARAM_INT);
// set the response header
header('Content-Type: application/json');
if ($method == "img_details") {
    echo $omero_server->process_request(PathUtils::build_image_detail_url($image_id), false);
} else {
    if ($method == "dzi") {
        echo $omero_server->process_request(PathUtils::build_image_dzi_url($image_id), false);
    } else {
        echo json_encode(array("error" => "Not supported method!!!"));
    }
}
exit;