function getLemnatizedXMLbyID($docID) { $output = false; $docObj = new Document(); $doc = $docObj->getByID($docID); if (is_array($doc)) { if (!$this->docID) { $this->docID = $docID; } if (!$this->batchID) { $this->batchID = $docObj->batchID; } $parserID = $docObj->parserID; $batchObj = new Batch(); $batch = $batchObj->getByID($docObj->batchID); $edinaObj = new Geoparser_EdinaText(); $edinaObj->prepSettings(); $edinaObj->batchName = $batchObj->parserID; //Parser ID of the batch $edinaObj->resourceID = $docObj->parserID; //Parser ID of the resource for parsing $edinaObj->resultFormat = "xml"; $requestFile = $docObj->parserID . ".lem.xml"; //this is the file type to get $requestLink = false; foreach ($docObj->pLinks as $pLink) { if (strstr($pLink["edina-href"], $requestFile)) { $requestLink = $pLink["edina-href"]; //yeah! we found the same format, and lemnatization status, so use this link break; } } $edinaObj->resourceURI = $requestLink; $respBody = $edinaObj->cacheGetResult(); //get the result or use the cache to get it if ($edinaObj->HTTPstatusOK) { $output = $respBody; //these are the XML we're looking for } } return $output; }
function docReviewAction() { $this->_helper->viewRenderer->setNoRender(); Zend_Loader::loadClass('Batch'); Zend_Loader::loadClass('Document'); $docObj = new Document(); if (isset($_GET["docID"])) { $docID = $_GET["docID"]; $doc = $docObj->getByID($docID); $parserID = $docObj->parserID; } elseif (isset($_GET["parserID"])) { $parserID = $_GET["parserID"]; $doc = $docObj->getByParserID($parserID); $docID = $doc->id; } if (isset($_GET["type"])) { $type = $_GET["type"]; if (substr($type, 0, 1) != ".") { $type = "." . $type; } } else { $type = ""; } $format = "json"; //default to JSON format result $outputHeader = 'Content-Type: application/json; charset=utf8'; if (isset($_GET["format"])) { $format = $_GET["format"]; if ($format == "xml" || $format == "kml") { $outputHeader = 'Content-Type: application/xml; charset=utf8'; } } if (!$doc) { //$this->view->requestURI = $this->_request->getRequestUri(); //return $this->render('404error'); throw new Zend_Controller_Action_Exception('Cannnot find this page: ' . $this->_request->getRequestUri(), 404); } else { $doc["result"] = false; //default to no result found $output = Zend_Json::encode($doc); $batchObj = new Batch(); $batch = $batchObj->getByID($docObj->batchID); Zend_Loader::loadClass('Geoparser_Edina'); Zend_Loader::loadClass('Geoparser_EdinaText'); $edinaObj = new Geoparser_EdinaText(); $edinaObj->prepSettings(); $edinaObj->batchName = $batchObj->parserID; //Parser ID of the batch $edinaObj->resourceID = $docObj->parserID; //Parser ID of the resource for parsing $edinaObj->resultFormat = $format; if (is_array($docObj->pLinks)) { $requestFile = $docObj->parserID . $type . "." . $format; //this is the file type to get $requestLink = false; foreach ($docObj->pLinks as $pLink) { if (strstr($pLink["edina-href"], $requestFile)) { $requestLink = $pLink["edina-href"]; //yeah! we found the same format, and lemnatization status, so use this link break; } } $edinaObj->resourceURI = $requestLink; $respBody = $edinaObj->cacheGetResult(); //get the result or use the cache to get it if ($edinaObj->HTTPstatusOK) { if ($format == "json") { $doc["result"] = Zend_Json::decode($respBody); $output = Zend_Json::encode($doc); } else { $output = $respBody; } } else { throw new Zend_Controller_Action_Exception('Cannot complete request' . $respBody, 500); } } header($outputHeader); echo $output; } //end case with document in database }