public function index_image($pid) { $dom = new DOMDocument('1.0', 'iso-8859-1'); $addElement = $dom->createElement('add', ''); $dom->appendChild($addElement); $docElement = $dom->createElement('doc', ''); $addElement->appendChild($docElement); $fieldElement = $dom->createElement('field', $pid); $fieldElement->setAttribute("name", "id"); $docElement->appendChild($fieldElement); $curr_pid = new roiHandler($pid); //we may need to create an imageHandler but should decide on moving ahead with the curl route or using islandora and stick with one route if ($curr_pid->ifExist("RELS-EXT")) { $xml = new DOMDocument('1.0', 'iso-8859-1'); $xml->loadXML($curr_pid->getDatastream("RELS-EXT")); $ip_string = $xml->getElementsByTagName("hasModel")->item(0)->getAttributeNode("rdf:resource")->value; $specimen_pid = str_replace("info:fedora/", "", $ip_string); $fieldElement = $dom->createElement('field', $specimen_pid); $fieldElement->setAttribute("name", "parent_id"); $docElement->appendChild($fieldElement); } if ($curr_pid->ifExist("status")) { $xml = new DOMDocument('1.0', 'iso-8859-1'); $xml->loadXML($curr_pid->getDatastream("status")); $StatusesElement = $xml->getElementsByTagName("statuses")->item(0); foreach ($StatusesElement->childNodes as $theTerm) { $searchValue = $theTerm->nodeValue; if ($theTerm->nodeName != "locked_time") { $searchField = "status_" . $theTerm->nodeName; } else { $searchField = "locked_time"; } $fieldElement = $dom->createElement('field', $searchValue); $fieldElement->setAttribute("name", $searchField); $docElement->appendChild($fieldElement); } } if ($curr_pid->ifExist("imageMetadata")) { $xml = new DOMDocument('1.0', 'iso-8859-1'); $xml->loadXML($curr_pid->getDatastream("imageMetadata")); $imageMetadataElement = $xml->getElementsByTagName("imageMetadata_record")->item(0); foreach ($imageMetadataElement->childNodes as $theTerm) { if ($theTerm->nodeName != '#text') { $searchValue = $theTerm->nodeValue; $searchField = "imageMetadata_" . str_replace("api:", "", $theTerm->nodeName); $fieldElement = $dom->createElement('field', $searchValue); $fieldElement->setAttribute("name", $searchField); $docElement->appendChild($fieldElement); } } } $this->result_doc = $dom; if (!$this->update_index()) { echo "Error Occurred while update index of Image: {$pid}"; } }
function reload_transcribe_text($roi_pid, $nothing, $workflow_id) { global $user; $returnHTML = ""; if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canTranscribe")) { $roi_obj = new roiHandler($roi_pid); if ($roi_obj->ifExist("Text")) { $returnHTML = nl2br($roi_obj->getDatastream("Text")); } } echo $returnHTML; }
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); }
function specimenGroundtruthXML($specimen_pid) { global $base_url; $roi_obj = new roiHandler($specimen_pid); if ($roi_obj->ifExist("groundtruth")) { $groundtruth_xml = $roi_obj->getDatastream("groundtruth"); } else { $groundtruth_xml = '<groundtruth>' . "\n"; $groundtruth_xml .= "\t" . '<apiary_instance_ID>' . $base_url . '</apiary_instance_ID>' . "\n"; $groundtruth_xml .= "\t" . '<specimenID>' . $specimen_pid . '</specimenID>' . "\n"; $groundtruth_xml .= "\t" . '<specimenMetadata>' . "\n"; $groundtruth_xml .= "\t" . '</specimenMetadata>' . "\n"; $groundtruth_xml .= "\t" . '<rois>' . "\n"; $groundtruth_xml .= "\t" . '</rois>' . "\n"; $groundtruth_xml .= '</groundtruth>' . "\n"; } //$groundtruth_dom = new DOMDocument; //$groundtruth_dom->loadXML($groundtruth); return $groundtruth_xml; }