Пример #1
0
 function getTokenIssues($tokenID)
 {
     $paraID = false;
     $context = false;
     $place = false;
     $db = $this->startDB();
     $sql = "SELECT * FROM gap_issues WHERE tokenID = {$tokenID}  AND active = 1 ORDER BY updated DESC;";
     $result = $db->fetchAll($sql, 2);
     $sql = "SELECT * FROM gap_issues WHERE tokenID = {$tokenID}  AND active = 0 ORDER BY updated DESC;";
     $resultOld = $db->fetchAll($sql, 2);
     $tokensObj = new Tokens();
     $tokenData = $tokensObj->getTokenByID($tokenID);
     $tokensObj->highlightToken = $tokenID;
     if (is_array($tokenData)) {
         $token = $tokenData["token"];
         $paraID = $tokenData["paraID"];
         $pageID = $tokenData["pageID"];
         $docID = $tokenData["docID"];
         $context = $tokensObj->getGapVisDocPage($docID, $pageID, $paraID, $tokenID);
         $place = $tokensObj->getPlaceByTokensID($tokenID);
         $related = false;
         $relatedPlaceTokens = false;
         if (is_array($place)) {
             $related = $tokensObj->getTokenIDsBySharedPlaceURIid($tokenID, $place["uriID"], $token);
             $relatedPlaceTokens = $tokensObj->getUniqueTokensFromPlaceURI($place["uri"]);
         }
         $docObj = new Document();
         $document = $docObj->getByID($docID);
     }
     $output = array("tokenID" => $tokenID, "token" => $token, "docID" => $docID, "document" => $document, "pageID" => $pageID, "context" => $context, "place" => $place, "related" => $related, "relatedPlaceTokens" => $relatedPlaceTokens, "issues" => $result, "oldIssues" => $resultOld, "oldPlaces" => $tokensObj->getTokenDeactivatedPlaceRefs($tokenID));
     return $output;
 }
Пример #2
0
 public function bookpagejsonAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $requestParams = $this->_request->getParams();
     $data = false;
     if (isset($requestParams['docID']) && isset($requestParams['pageID'])) {
         $docID = $requestParams['docID'];
         $pageID = $requestParams['pageID'];
         Zend_Loader::loadClass("Document");
         Zend_Loader::loadClass("Tokens");
         Zend_Loader::loadClass("Issues");
         $docObj = new Document();
         $translated = $docObj->getTranslatedVersions($docID);
         $tokObj = new Tokens();
         if ($docID == 2) {
             //$tokObj->tokenStructure($docID);
         }
         $text = $tokObj->getGapVisDocPage($docID, $pageID);
         $textAdded = false;
         if ($text != false) {
             foreach ($translated as $row) {
                 $lang = $row["lang"];
                 $transDocID = $row["documentID"];
                 if ($transDocID == $docID) {
                     $data["text@" . $lang] = $text;
                     $textAdded = true;
                 } else {
                     $data["text@" . $lang] = $tokObj->getGapVisDocPage($transDocID, $pageID);
                 }
             }
             if (!$textAdded) {
                 $data["text"] = $text;
             }
             $data["section"] = $tokObj->sectionID;
             $data["image"] = false;
         }
     }
     if (!$data) {
         $this->view->requestURI = $this->_request->getRequestUri();
         return $this->render('404error');
     } else {
         $output = Zend_Json::encode($data);
         $output = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U\$1')))", json_encode($data));
         //$output = json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
     }
     //$output["memory"] = memory_get_usage(true);
     header('Content-Type: application/json; charset=utf8');
     header("Access-Control-Allow-Origin: *");
     echo $output;
 }