Ejemplo n.º 1
0
 /**
  * Loads an old Opus ID
  *
  * @param Opus_Document $object Opus-Document for that the files should be registered
  * @return void
  */
 public function loadSignatureFiles($id)
 {
     $object = new Opus_Document($id);
     $this->_tmpPath = null;
     $opusId = $object->getIdentifierOpus3()->getValue();
     // Search the ID-directory in signaturefiles tree
     $this->searchDir($this->_path, $opusId);
     foreach ($object->getFile() as $file) {
         $sigfiles = $this->getFiles($this->_tmpPath, $file->getPathName());
         if (count($sigfiles) > 0) {
             $key = 0;
             foreach ($sigfiles as $signatureFile) {
                 $registered = false;
                 $signature = implode("", file($signatureFile));
                 // check if this signature has been registered
                 $hashes = $file->getHashValue();
                 foreach ($hashes as $hash) {
                     if (substr($hash->getType(), 0, 4) === 'gpg-') {
                         $key++;
                         if ($signature === $hash->getValue()) {
                             $registered = true;
                         }
                     }
                 }
                 // if not, add the signature
                 if ($registered === false) {
                     $hash = new Opus_HashValues();
                     $hash->setType('gpg-' . $key);
                     $hash->setValue($signature);
                     $file->addHashValue($hash);
                 }
                 unset($signatureFile);
             }
         }
         unset($file);
     }
     // Store signature(s) directly
     $object->store();
 }
    $doc = new Opus_Document($docId);
    $numOfTitles = 0;
    foreach ($doc->getTitleMain() as $title) {
        if ($title->getLanguage() === $doc->getLanguage()) {
            $numOfTitles++;
        }
    }
    $numOfAbstracts = 0;
    foreach ($doc->getTitleAbstract() as $abstract) {
        if ($abstract->getLanguage() === $doc->getLanguage()) {
            $numOfAbstracts++;
        }
    }
    if ($numOfTitles > 1 || $numOfAbstracts > 1) {
        $msg = "document #{$docId} (";
        $opusThreeId = $doc->getIdentifierOpus3();
        if (count($opusThreeId) > 0) {
            $msg .= 'opus3id #' . $opusThreeId[0]->getValue() . ' ';
        }
        $msg .= 'server_state: ' . $doc->getServerState() . ') needs to be updated manually: has';
        if ($numOfTitles > 1) {
            $msg .= " {$numOfTitles} titles";
        }
        if ($numOfAbstracts > 1) {
            $msg .= " {$numOfAbstracts} abstracts";
        }
        echo $msg . "\n";
        $updateRequired++;
    }
}
if ($updateRequired == 0) {
    $doc = new Opus_Document($docId);
    $numOfTitles = 0;
    foreach ($doc->getTitleMain() as $title) {
        if ($title->getLanguage() === $doc->getLanguage()) {
            $numOfTitles++;
        }
    }
    $numOfAbstracts = 0;
    foreach ($doc->getTitleAbstract() as $abstract) {
        if ($abstract->getLanguage() === $doc->getLanguage()) {
            $numOfAbstracts++;
        }
    }
    if ($numOfTitles > 1 || $numOfAbstracts > 1) {
        $msg = "document #{$docId} (";
        $opus3Id = $doc->getIdentifierOpus3();
        if (count($opus3Id) > 0) {
            $msg .= 'opus3id #' . $opus3Id[0]->getValue() . ' ';
        }
        $msg .= 'server_state: ' . $doc->getServerState() . ') needs to be updated manually: has';
        if ($numOfTitles > 1) {
            $msg .= " {$numOfTitles} titles";
        }
        if ($numOfAbstracts > 1) {
            $msg .= " {$numOfAbstracts} abstracts";
        }
        echo $msg . "\n";
        $updateRequired++;
    }
}
if ($updateRequired == 0) {