Пример #1
0
 public function fulltext()
 {
     $this->allowMethods(array('GET'));
     if (!isset($this->queryParams['since'])) {
         $this->e400("'since' not provided");
     }
     $newer = Zotero_FullText::getNewerInLibrary($this->objectLibraryID, $this->queryParams['since']);
     $this->libraryVersion = Zotero_Libraries::getVersion($this->objectLibraryID);
     echo Zotero_Utilities::formatJSON($newer);
     $this->end();
 }
Пример #2
0
 public function fulltext()
 {
     $this->allowMethods(array('GET'));
     // Default empty library
     if ($this->objectLibraryID === 0) {
         return new stdClass();
     }
     $newer = Zotero_FullText::getNewerInLibrary($this->objectLibraryID, !empty($this->queryParams['since']) ? $this->queryParams['since'] : 0);
     $this->libraryVersion = Zotero_Libraries::getVersion($this->objectLibraryID);
     echo Zotero_Utilities::formatJSON($newer);
     $this->end();
 }
Пример #3
0
 /**
  * For multi-object requests for some actions, return 304 Not Modified
  * if the library hasn't been updated since If-Modified-Since-Version
  */
 protected function checkLibraryIfModifiedSinceVersion($action)
 {
     if (!$this->singleObject && in_array($action, ["items", "collections", "searches", "settings", "tags"]) && isset($_SERVER['HTTP_IF_MODIFIED_SINCE_VERSION']) && !$this->isWriteMethod() && $this->permissions->canAccess($this->objectLibraryID) && Zotero_Libraries::getVersion($this->objectLibraryID) <= $_SERVER['HTTP_IF_MODIFIED_SINCE_VERSION']) {
         $this->e304();
     }
 }
Пример #4
0
 private static function cachePrimaryDataByLibrary($libraryID)
 {
     $type = static::field('object');
     $types = static::field('objects');
     Z_Core::debug("Caching primary {$type} data for library {$libraryID}");
     if (!isset(self::$primaryDataByKey[$type][$libraryID])) {
         self::$primaryDataByKey[$type][$libraryID] = array();
     }
     if (!isset(self::$primaryDataByID[$type][$libraryID])) {
         self::$primaryDataByID[$type][$libraryID] = array();
     }
     self::$primaryDataByKey[$type][$libraryID] = array();
     self::$primaryDataByID[$type][$libraryID] = array();
     $cacheKey = $type . "Data_" . $libraryID . "_" . str_replace(" ", "_", Zotero_Libraries::getVersion($libraryID, true)) . "_" . self::$cacheVersion;
     $rows = Z_Core::$MC->get($cacheKey);
     if ($rows === false) {
         $className = "Zotero_" . ucwords($types);
         $sql = self::getPrimaryDataSQL() . "libraryID=?";
         $shardID = Zotero_Shards::getByLibraryID($libraryID);
         $rows = Zotero_DB::query($sql, $libraryID, $shardID);
         Z_Core::debug("Caching {$cacheKey}");
         Z_Core::$MC->set($cacheKey, $rows ? $rows : array());
     } else {
         Z_Core::debug("Retrieved " . $cacheKey);
     }
     if (!$rows) {
         return;
     }
     foreach ($rows as $row) {
         self::$primaryDataByKey[$type][$libraryID][$row['key']] = $row;
         self::$primaryDataByID[$type][$libraryID][$row['id']] =& self::$primaryDataByKey[$type][$libraryID][$row['key']];
     }
 }