示例#1
0
 private function loadPrimaryData($allowFail = false)
 {
     Z_Core::debug("Loading primary data for item {$this->libraryID}/{$this->key}");
     if ($this->loaded['primaryData']) {
         throw new Exception("Primary data already loaded for item {$this->libraryID}/{$this->key}");
     }
     $libraryID = $this->libraryID;
     $id = $this->id;
     $key = $this->key;
     if (!$libraryID) {
         throw new Exception("Library ID not set");
     }
     if (!$id && !$key) {
         throw new Exception("ID or key not set");
     }
     if ($id) {
         Z_Core::debug("Loading data for item {$libraryID}/{$id}");
         $row = Zotero_Items::getPrimaryDataByID($libraryID, $id);
     } else {
         Z_Core::debug("Loading data for item {$libraryID}/{$key}");
         $row = Zotero_Items::getPrimaryDataByKey($libraryID, $key);
     }
     $this->reload = false;
     $this->loaded['primaryData'] = true;
     if (!$row) {
         if ($allowFail) {
             return false;
         }
         throw new Exception("Item " . ($id ? $id : "{$libraryID}/{$key}") . " not found");
     }
     if ($row['libraryID'] != $libraryID) {
         throw new Exception("libraryID {$row['libraryID']} != {$this->libraryID}");
     }
     $this->loadFromRow($row);
     return true;
 }