Пример #1
0
 public function bookjsonAction()
 {
     Zend_Loader::loadClass("Document");
     Zend_Loader::loadClass("GazetteerRefs");
     $this->_helper->viewRenderer->setNoRender();
     $requestParams = $this->_request->getParams();
     $host = App_Config::getHost();
     $output = array("found" => $requestParams);
     $GazetteerRefsObj = new GazetteerRefs();
     $GazetteerRefsObj->updatePleiadesCoordsData();
     if (isset($requestParams['id'])) {
         $docID = $requestParams['id'];
         $docObj = new Document();
         $data = $docObj->getGapVisDataByID($docID);
         if (!$data) {
             $this->view->requestURI = $this->_request->getRequestUri();
             return $this->render('404error');
         }
         unset($docObj);
         $output = Zend_Json::encode($data);
         if (isset($requestParams["callback"])) {
             header('Content-Type: application/javascript; charset=utf8');
             $output = $requestParams["callback"] . "(" . $output . ");";
             echo $output;
         } else {
             header('Content-Type: application/json; charset=utf8');
             header("Access-Control-Allow-Origin: *");
             echo $output;
             //outputs JSON of a given book's word cloud
         }
     }
 }
Пример #2
0
 function getBatchDocuments($batch)
 {
     $db = $this->startDB();
     $sql = "SELECT * FROM gap_documents WHERE batchID = {$batch}";
     $result = $db->fetchAll($sql, 2);
     $output = false;
     if ($result) {
         $output = array();
         $allDone = true;
         foreach ($result as $row) {
             $actOut = $row;
             $actOut["doc-rev-href"] = App_Config::getHost() . self::docLinkSuffix . $row["id"];
             if (strlen($row["pLinks"]) > 4) {
                 $actOut["pLinks"] = Zend_Json::decode($row["pLinks"]);
             } else {
                 $allDone = false;
             }
             $output[] = $actOut;
         }
         if ($allDone) {
             $this->updateStatus("completed");
         }
     }
     $this->documents = $output;
     return $output;
 }
Пример #3
0
 private function setSetting()
 {
     ini_set('display_errors', $this->currentMode->phpSettings->display_errors);
     ini_set('log_errors ', 1);
     if ($this->currentMode->phpSettings->display_errors) {
         ini_set("error_reporting", E_ALL ^ E_NOTICE);
     }
     define("DB_USER", $this->currentMode->db->username);
     define("DB_HOST", $this->currentMode->db->host);
     define("DB_PASS", $this->currentMode->db->password);
     define("DB_SCHEMA", $this->currentMode->db->schema);
     define("DISPLAY_EXCEPTIONS", $this->currentMode->frontController->displayExceptions);
     define("DISPLAY_MYSQL_ERRORS", $this->currentMode->db->mysqlError);
     self::$fb_app_id = $this->currentMode->fb->app_id;
 }
Пример #4
0
 public function jsonAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $db_params = OpenContext_OCConfig::get_db_config();
     $db = new Zend_Db_Adapter_Pdo_Mysql($db_params);
     $db->getConnection();
     $requestParams = $this->_request->getParams();
     $host = App_Config::getHost();
     $reference = new Reference();
     $reference->initialize($requestParams);
     if ($reference->get_refs()) {
         header('Content-Type: application/json; charset=utf8');
         //echo Zend_Json::encode($reference->placeTokens);
         echo Zend_Json::encode($reference->tmPlaces);
     } else {
         $this->view->requestURI = $this->_request->getRequestUri();
         return $this->render('404error');
     }
 }
Пример #5
0
 public function allAction()
 {
     $requestParams = $this->_request->getParams();
     $host = App_Config::getHost();
     $frontendOptions = array('lifetime' => 72000, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => './bookdata/');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     $requestURI = $this->_request->getRequestUri();
     // for testing
     $requestURI = str_replace("/", "_", $requestURI);
     $requestURI = str_replace(".", "_", $requestURI);
     if (isset($requestParams["callback"])) {
         $requestURI = str_replace("?", "", $requestURI);
         $requestURI = str_replace("callback=" . $requestParams["callback"], "", $requestURI);
     }
     $cache_id = $requestURI;
     if (isset($requestParams['avar'])) {
         $aVar = $requestParams['avar'];
         if ($aVar == ".json") {
             $books = new Books();
             $books->get_all_books();
             $outputArray = $books->bookData;
             unset($books);
             $output = Zend_Json::encode($outputArray);
             $this->_helper->viewRenderer->setNoRender();
             if (isset($requestParams["callback"])) {
                 header('Content-Type: application/javascript; charset=utf8');
                 $output = $requestParams["callback"] . "(" . $output . ");";
                 echo $output;
             } else {
                 header('Content-Type: application/json; charset=utf8');
                 header("Access-Control-Allow-Origin: *");
                 echo $output;
                 //outputs JSON of a given book's word cloud
             }
         } elseif (is_numeric($aVar)) {
             $book = $aVar;
             if (isset($requestParams['bvar'])) {
                 if ($requestParams['bvar'] == "words.json") {
                     if (!($cache_result = $cache->load($cache_id))) {
                         $bookObj = new Book();
                         $bookObj->initialize($book);
                         $bookObj->book = $book;
                         $bookObj->get_book_meta();
                         $bookObj->getBookWordData();
                         $outputArray = $bookObj->wordSummary;
                         $output = Zend_Json::encode($outputArray);
                         $cache->save($output, $cache_id);
                     } else {
                         $output = $cache_result;
                     }
                     $this->_helper->viewRenderer->setNoRender();
                     if (isset($requestParams["callback"])) {
                         header('Content-Type: application/javascript; charset=utf8');
                         $output = $requestParams["callback"] . "(" . $output . ");";
                         echo $output;
                     } else {
                         header('Content-Type: application/json; charset=utf8');
                         header("Access-Control-Allow-Origin: *");
                         echo $output;
                         //outputs JSON of a given book's word cloud
                     }
                 } elseif ($requestParams['bvar'] == "page") {
                     $failPageRequest = true;
                     if (isset($requestParams['cvar'])) {
                         if (stristr($requestParams['cvar'], ".json")) {
                             $page = str_replace(".json", "", $requestParams['cvar']);
                             if (is_numeric($page)) {
                                 $failPageRequest = false;
                                 $bookObj = new Book();
                                 $bookObj->initialize($book);
                                 $bookObj->book = $book;
                                 $bookObj->page = $page;
                                 $bookObj->get_book_meta();
                                 $bookObj->getBookPageData();
                                 $outputArray = $bookObj->pageOutput;
                                 $output = Zend_Json::encode($outputArray);
                                 $this->_helper->viewRenderer->setNoRender();
                                 if (isset($requestParams["callback"])) {
                                     header('Content-Type: application/javascript; charset=utf8');
                                     $output = $requestParams["callback"] . "(" . $output . ");";
                                     echo $output;
                                 } else {
                                     header('Content-Type: application/json; charset=utf8');
                                     header("Access-Control-Allow-Origin: *");
                                     echo $output;
                                     //outputs JSON of a given book's word cloud
                                 }
                             }
                         }
                     }
                     if ($failPageRequest) {
                         $this->view->requestURI = $this->_request->getRequestUri();
                         return $this->render('404error');
                     }
                 }
             } else {
                 $bookObj = new Book();
                 $bookObj->initialize($book);
                 $bookObj->get_book_meta();
                 $bookObj->getAllPlaces();
                 if (!$bookObj->bookURI) {
                     $this->view->requestURI = $this->_request->getRequestUri();
                     return $this->render('404error');
                 } else {
                     $this->view->book = $bookObj;
                     return $this->render('summary');
                 }
             }
         } elseif (strlen($aVar) > 5 && stristr($aVar, ".json")) {
             $book = str_replace(".json", "", $requestParams['avar']);
             if (is_numeric($book)) {
                 if (!($cache_result = $cache->load($cache_id))) {
                     $bookObj = new Book();
                     $bookObj->initialize($book);
                     $bookObj->get_book_meta();
                     $bookObj->getAllPlacesJSON();
                     $outputArray = array("id" => $bookObj->book, "title" => $bookObj->bookTitle, "uri" => $bookObj->bookURI, "author" => $bookObj->bookAuthors, "printed" => $bookObj->bookDate, "pages" => $bookObj->JSONpageArray, "places" => $bookObj->JSONplacesArray);
                     $output = Zend_Json::encode($outputArray);
                     $cache->save($output, $cache_id);
                 } else {
                     $output = $cache_result;
                 }
                 $this->_helper->viewRenderer->setNoRender();
                 if (isset($requestParams["callback"])) {
                     header('Content-Type: application/javascript; charset=utf8');
                     $output = $requestParams["callback"] . "(" . $output . ");";
                     echo $output;
                 } else {
                     header('Content-Type: application/json; charset=utf8');
                     header("Access-Control-Allow-Origin: *");
                     echo $output;
                     //outputs JSON of a given book's word cloud
                 }
             } else {
                 $this->view->requestURI = $this->_request->getRequestUri();
                 return $this->render('404error');
             }
         } else {
             $this->view->requestURI = $this->_request->getRequestUri();
             return $this->render('404error');
         }
     } else {
         $this->_helper->viewRenderer->setNoRender();
         echo "Index of books";
     }
 }
Пример #6
-2
 public static function run()
 {
     self::initAutoLoad();
     App_Config::getInstance();
     try {
         $http = App_Http::getInstance();
         //           if($http->isXHR()){
         //             if(!App_CSRFUtil::getInstance()->isValid()){
         //                   throw new Exception('Invalid token');
         //             }
         //           }
         $className = 'App_Controller_' . $http->getModuleName() . '_' . $http->getControllerName();
         if ($http->isAdminModule()) {
             $auth = App_Auth::getInstance()->getInstance();
             if (!$auth->isAuthAction()) {
                 $http->setModuleName("Admin")->setControllerName("Auth")->setActionName("login");
                 $className = 'App_Controller_' . $http->getModuleName() . '_' . $http->getControllerName();
             }
         }
         $ctrl = new $className();
         $ctrl->dispatch($http->getActionName() . 'Action');
     } catch (App_Request_Params_Exceptions $e) {
         die($e->getMessage());
     } catch (App_Mysql_Exceptions $e) {
         die($e->getMessage());
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }