Exemplo n.º 1
0
function create_roi($image_pid, $options, $workflow_id)
{
    global $user;
    if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canAnalyzeSpecimen")) {
        global $base_url;
        list($true_y1, $true_x1, $true_height, $true_width, $roi_type) = explode(":", $options);
        if ($roi_type == "Annotation") {
            $roi_type = "Annotation/Other";
        }
        $roiMetadata_base_url = $base_url;
        $imageMetadata_record = AP_Image::getimageMetadata_record($image_pid);
        $parent_image_height = $imageMetadata_record["h"];
        //To Be Removed
        $parent_image_width = $imageMetadata_record["w"];
        //To Be Removed
        $sourceURL = $imageMetadata_record['URL'];
        //To Be Removed//The ROI sourceURL is the ap-image URL
        $parent_image_display_width = 650;
        //To Be Removed
        $parent_image_display_height = $parent_image_height * $parent_image_display_width / $parent_image_width;
        //To Be Removed
        $rft_id = $imageMetadata_record['rft_id'];
        $roiURL = getDjatokaURL($rft_id, 'getRegion', '100', $true_y1, $true_x1, $true_height, $true_width, '', '');
        $new_roi = new AP_ROI();
        $new_roi->roiMetadata_base_url = $roiMetadata_base_url;
        $status = $new_roi->createROIObject($image_pid, $sourceURL, $roiURL, $roi_type, $true_x1, $true_y1, $true_width, $true_height, $parent_image_width, $parent_image_height, $parent_image_display_width, $parent_image_display_height, "");
        $roi_pid = $new_roi->pid;
        $roiMetadata_record = AP_ROI::getroiMetadata_record($roi_pid);
        $changedHeight = thumbHeightReset($roiMetadata_record['h'], $roiMetadata_record['w']);
        if (!$changedHeight) {
            $roi_thumb_url = getDjatokaURL($roiMetadata_record['sourceURL'], 'getRegion', '100', $roiMetadata_record['y'], $roiMetadata_record['x'], $roiMetadata_record['h'], $roiMetadata_record['w'], '78', '0');
        } else {
            $roi_thumb_url = getDjatokaURL($roiMetadata_record['sourceURL'], 'getRegion', '100', $roiMetadata_record['y'], $roiMetadata_record['x'], $changedHeight, $roiMetadata_record['w'], '78', '0');
        }
        $status_dom = AP_ROI::getROIStatusDom($roi_pid);
        $transcribed_status = $status_dom->getElementsByTagName("transcribedStatus")->item(0)->nodeValue;
        $parsed_status = $status_dom->getElementsByTagName("parsedL1Status")->item(0)->nodeValue;
        if ($transcribed_status == "") {
            $transcribed_status = "Undefined";
        }
        if ($parsed_status == "") {
            $parsed_status = "Undefined";
        }
        $html = generate_roi_html($roi_pid, $roi_thumb_url, $roiMetadata_record, $transcribed_status, $parsed_status, $workflow_id);
        $returnHTML['html'] = $html;
        $returnHTML['pid'] = $roi_pid;
        $returnHTML['roi_queue_html'] = add_roi_to_queue($image_pid, $roi_pid, $workflow_id);
        if ($status == true) {
            //Echo JQuery function to add HTML for new ROI
        }
    } else {
        header('HTTP/1.1 401 Unauthorized');
        $returnHTML .= "Sorry! You do not have permission for this operation";
    }
    echo json_encode($returnHTML);
}
Exemplo n.º 2
0
function get_transcribe_content($roi_pid, $size, $workflow_id)
{
    global $user;
    list($height, $width) = explode(":", $size);
    $returnJSON = "";
    if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canTranscribe")) {
        $roiMetadata_record = AP_ROI::getroiMetadata_record($roi_pid);
        $roiURL = $roiMetadata_record['roiURL'];
        if ($height > $roiMetadata_record['h'] / $roiMetadata_record['w'] * $width) {
            $roi_image_url = scaleDjatokaURL($roiURL, $width, '0');
            //$roi_image_url = getDjatokaURL($roiMetadata_record['sourceURL'], 'getRegion', '100', $roiMetadata_record['y'], $roiMetadata_record['x'], $roiMetadata_record['h'], $roiMetadata_record['w'], $width, '0');
            $returnJSON['image_html'] = "<img class='transcribe_roi_image' src='{$roi_image_url}' />";
        } else {
            $roi_image_url = scaleDjatokaURL($roiURL, '0', $height);
            //$roi_image_url = getDjatokaURL($roiMetadata_record['sourceURL'], 'getRegion', '100', $roiMetadata_record['y'], $roiMetadata_record['x'], $roiMetadata_record['h'], $roiMetadata_record['w'], '0', $height);
            $returnJSON['image_html'] = "<img class='transcribe_roi_image' src='{$roi_image_url}' />";
        }
        $roi_obj = new roiHandler($roi_pid);
        $returnJSON['gocr'] = "";
        $returnJSON['ocrad'] = "";
        $returnJSON['ocropus'] = "";
        $returnJSON['text'] = "";
        if ($roi_obj->ifExist("GOCR")) {
            $returnJSON['gocr'] = $roi_obj->getDatastream("GOCR");
        }
        if ($roi_obj->ifExist("ocrad")) {
            $returnJSON['ocrad'] = $roi_obj->getDatastream("ocrad");
        }
        if ($roi_obj->ifExist("OCRopus")) {
            $returnJSON['ocropus'] = $roi_obj->getDatastream("OCRopus");
        }
        if ($roi_obj->ifExist("Text")) {
            $returnJSON['text'] = $roi_obj->getDatastream("Text");
        }
    } else {
        echo "Sorry! You do not have permission for this operation";
    }
    echo json_encode($returnJSON);
}
Exemplo n.º 3
0
function specimenMetadata_details_content($roi_pid = null)
{
    global $base_url;
    $fedora_base_url = variable_get("fedora_base_url", "http://localhost:8080/fedora");
    $html = '';
    $html .= '<div id="specimenMetadata_details_content">' . "\n";
    if ($roi_pid != null && $roi_pid != "0") {
        $roi = new AP_ROI();
        $image_pid = $roi->get_image_pid($roi_pid);
        $sp_pid = AP_Image::get_specimen_pid($image_pid);
        $roiMetadata_record = $roi->getroiMetadata_record($roi_pid);
        $roiURL = $roiMetadata_record['roiURL'];
        $djatoka_url = scaleDjatokaURL($roiURL, '300', '0');
        $html .= "<h3>Details: {$roi_pid}</h3>";
        $html .= "<table><tr><td valign='top' width='300'>";
        $html .= "<img src='{$djatoka_url}'/></td>";
        $html .= "<td>Specimen: {$sp_pid}<br/>Image: {$image_pid}<br/>ROI: {$roi_pid}<br/>Datastream: specimenMetadata<br/><br/>";
        $text = shell_exec("curl -H - XGET {$fedora_base_url}/get/{$roi_pid}/specimenMetadata");
        $check = strpos($text, "404 Not Found");
        if ($check === FALSE) {
            $specimenMetadata_xml_url = $server_base . '/drupal/modules/apiary_project/workflow/include/specimenMetadata_xml.php?pid=' . $roi_pid;
            $html .= '<textarea style="width:500px; height:200px">' . $text . '</textarea></td>';
            $html .= "</tr></table>";
        } else {
            $html .= "No specimenMetadata found";
        }
    } else {
    }
    $html .= '</div><!-- specimenMetadata_details_content -->' . "\n";
    echo $html;
}
Exemplo n.º 4
0
function get_parsing_content($roi_pid, $size, $parse_level, $workflow_id)
{
    global $user;
    list($height, $width) = explode(":", $size);
    if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, $parse_level)) {
        $roiMetadata_record = AP_ROI::getroiMetadata_record($roi_pid);
        $roiURL = $roiMetadata_record['roiURL'];
        if ($height > $roiMetadata_record['h'] / $roiMetadata_record['w'] * $width) {
            $roi_image_url = scaleDjatokaURL($roiURL, $width, '0');
            $image_html = "<img class='transcribe_roi_image' src='{$roi_image_url}' />";
        } else {
            $roi_image_url = scaleDjatokaURL($roiURL, '0', $height);
            $image_html = "<img class='transcribe_roi_image' src='{$roi_image_url}' />";
        }
        $roi_obj = new roiHandler($roi_pid);
        $returnJSON['text'] = "";
        if ($roi_obj->ifExist("Text")) {
            $text = nl2br($roi_obj->getDatastream("Text"));
        }
    } else {
        return false;
    }
    return array($image_html, $text);
}
Exemplo n.º 5
0
function get_right_click_list($pid)
{
    $ap_roi = new AP_ROI();
    $roiMetadata_record = $ap_roi->getroiMetadata_record($pid);
    $roi_type_temp = $roiMetadata_record['roiType'];
    $roi_list = getROItypeList();
    $roi_type = '';
    switch ($roi_type_temp) {
        case $roi_list[0]:
            $roi_type = "primary";
            break;
        case $roi_list[1]:
            $roi_type = "determination";
            break;
        case $roi_list[2]:
            $roi_type = "barcode";
            break;
        case $roi_list[3]:
            $roi_type = "type";
            break;
        case $roi_list[4]:
            $roi_type = "annotation";
            break;
    }
    //Context Menu List
    print '<ul id="apiary_context_menu" class="jeegoocontext cm_blue">';
    //Who & When
    print '<li>Who & When<ul>';
    $whoObj = db_query("select * from {apiary_project} where parse_level=1 AND (ui_categories='who' OR ui_categories='when')");
    while ($res = db_fetch_object($whoObj)) {
        if (stristr($res->roi_association, $roi_type) !== false) {
            print '<li><a id="menu_' . $res->term . '" href=javascript:getSelText("' . $res->term . '")>' . $res->display_label . '</a>';
        }
    }
    print "</ul></li>";
    //What
    print '<li>What<ul>';
    $whatObj = db_query("select * from {apiary_project} where parse_level=1 AND ui_categories='what'");
    while ($res = db_fetch_object($whatObj)) {
        if (stristr($res->roi_association, $roi_type) !== false) {
            print '<li><a id="menu_' . $res->term . '" href=javascript:getSelText("' . $res->term . '")>' . $res->display_label . '</a>';
        }
    }
    print "</ul></li>";
    //Where
    print '<li>Where</a><ul>';
    $whereObj = db_query("select * from {apiary_project} where parse_level=1 AND ui_categories='where'");
    while ($res = db_fetch_object($whereObj)) {
        if (stristr($res->roi_association, $roi_type) !== false) {
            print '<li><a id="menu_' . $res->term . '" href=javascript:getSelText("' . $res->term . '")>' . $res->display_label . '</a>';
        }
    }
    print "</ul></li>";
    print '</ul>';
}