/** See update */
 function update_internal($resource_name, $resource)
 {
     $empty_array = array();
     $db = createBibDBBuilder();
     $db->build($resource_name, $resource);
     $this->stringdb = array_merge($this->stringdb, $db->stringdb);
     $result = $db->builtdb;
     foreach ($result as $b) {
         // new entries:
         if (!isset($this->bibdb[$b->getKey()])) {
             //echo 'adding...<br/>';
             $this->addEntry($b);
         } else {
             if (isset($this->bibdb[$b->getKey()]) && $b->getText() !== $this->bibdb[$b->getKey()]->getText()) {
                 //echo 'replacing...<br/>';
                 $this->bibdb[$b->getKey()] = $b;
             }
         }
     }
     // some entries have been removed
     foreach ($this->bibdb as $e) {
         if (!isset($result[$e->getKey()]) && $e->filename == $resource_name) {
             //echo 'deleting...<br/>';
             unset($this->bibdb[$e->getKey()]);
         }
     }
     // some @string have been removed
     foreach ($this->stringdb as $k => $e) {
         if (!isset($db->stringdb[$k]) && $e->filename == $resource_name) {
             //echo 'deleting...<br/>';
             unset($this->stringdb[$e->name]);
         }
     }
 }
Exemplo n.º 2
0
 /** Updates a database (replaces the new bibtex entries by the most recent ones) */
 function update($filename)
 {
     $empty_array = array();
     $db = createBibDBBuilder();
     $db->setData($empty_array, $this->stringdb);
     $db->build($filename);
     $this->stringdb = $db->stringdb;
     $result = $db->builtdb;
     foreach ($result as $b) {
         // new entries:
         if (!isset($this->bibdb[$b->getKey()])) {
             //echo 'adding...<br/>';
             $this->bibdb[$b->getKey()] = $b;
         } else {
             if (isset($this->bibdb[$b->getKey()]) && $b->getText() !== $this->bibdb[$b->getKey()]->getText()) {
                 //echo 'replacing...<br/>';
                 $this->bibdb[$b->getKey()] = $b;
             }
         }
     }
     // some entries have been removed
     foreach ($this->bibdb as $e) {
         if (!isset($result[$e->getKey()])) {
             //echo 'deleting...<br/>';
             unset($this->bibdb[$e->getKey()]);
         }
     }
 }