当前位置: 首页>>代码示例>>PHP>>正文


PHP Opus_Document::getFile方法代码示例

本文整理汇总了PHP中Opus_Document::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Opus_Document::getFile方法的具体用法?PHP Opus_Document::getFile怎么用?PHP Opus_Document::getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opus_Document的用法示例。


在下文中一共展示了Opus_Document::getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clear

 /**
  * Publishes documents and adds the given Person as referee.
  *
  * @param array $docIds
  * @param mixed $userId
  * @param Opus_Person $person
  *
  * FIXME capture success or failure for display afterwards
  */
 public function clear(array $docIds = null, $userId = null, $person = null)
 {
     $logger = Zend_Registry::get('Zend_Log');
     foreach ($docIds as $docId) {
         $logger->debug('Change state to "published" for document: ' . $docId);
         $document = new Opus_Document($docId);
         $document->setServerState('published');
         $date = new Opus_Date();
         $date->setNow();
         $document->setServerDatePublished($date);
         $document->setPublishedDate($date);
         $guest_role = Opus_UserRole::fetchByName('guest');
         foreach ($document->getFile() as $file) {
             $guest_role->appendAccessFile($file->getId());
         }
         if (isset($person)) {
             $document->addPersonReferee($person);
         }
         $enrichment = $document->addEnrichment();
         $enrichment->setKeyName('review.accepted_by')->setValue($userId);
         // TODO: Put into same transaction...
         $document->store();
         $guest_role->store();
     }
     return;
 }
开发者ID:alexukua,项目名称:opus4,代码行数:35,代码来源:ClearDocumentsHelper.php

示例2: prepareRenderingAsView

 /**
  * Bereitet Formular fuer Anzeige als View vor.
  *
  * Fuegt Unterformular fuer Dateien hinzu. Dateien sind nicht Teil des Metadaten-Formulars, werden aber in der
  * Metadaten-Übersicht mit aufgelistet.
  */
 public function prepareRenderingAsView()
 {
     parent::prepareRenderingAsView();
     if (!is_null($this->document)) {
         if (count($this->document->getFile()) > 0) {
             $subform = new Admin_Form_Document_Files();
             $subform->populateFromModel($this->document);
             $this->addSubForm($subform, 'Files');
         }
     }
 }
开发者ID:alexukua,项目名称:opus4,代码行数:17,代码来源:Document.php

示例3: getAccessibleFiles

 /**
  * Returns all associated Opus_File objects that are visible in OAI and accessible by user
  * @return array Accessible Opus_File objects
  *
  * TODO check embargo date
  * TODO merge access checks with code for deliver controller
  */
 public function getAccessibleFiles()
 {
     $realm = Opus_Security_Realm::getInstance();
     // admins sollen immer durchgelassen werden, nutzer nur wenn das doc im publizierten Zustand ist
     if (!$realm->skipSecurityChecks()) {
         // kein administrator
         // PUBLISHED Dokumente sind immer verfügbar (Zugriff auf Modul kann eingeschränkt sein)
         if ($this->_doc->getServerState() !== 'published') {
             // Dokument nicht published
             if (!$realm->checkDocument($this->_docId)) {
                 // Dokument ist nicht verfügbar für aktuellen Nutzer
                 $this->logErrorMessage('document id =' . $this->_docId . ' is not published and access is not allowed for current user');
                 throw new Oai_Model_Exception('access to requested document is forbidden');
             }
         }
         if ($this->_doc->hasEmbargoPassed() === false) {
             if (!$realm->checkDocument($this->_docId)) {
                 // Dokument ist nicht verfügbar für aktuellen Nutzer
                 $this->logErrorMessage('document id =' . $this->_docId . ' is not embargoed and access is not allowed for current user');
                 throw new Oai_Model_Exception('access to requested document files is embargoed');
             }
         }
     }
     $files = array();
     $filesToCheck = $this->_doc->getFile();
     /* @var $file Opus_File */
     foreach ($filesToCheck as $file) {
         $filename = $this->_appConfig->getFilesPath() . $this->_docId . DIRECTORY_SEPARATOR . $file->getPathName();
         if (is_readable($filename)) {
             array_push($files, $file);
         } else {
             $this->logErrorMessage("skip non-readable file {$filename}");
         }
     }
     if (empty($files)) {
         $this->logErrorMessage('document with id ' . $this->_docId . ' does not have any associated files');
         throw new Oai_Model_Exception('requested document does not have any associated readable files');
     }
     $containerFiles = array();
     /* @var $file Opus_File */
     foreach ($files as $file) {
         if ($file->getVisibleInOai() && $realm->checkFile($file->getId())) {
             array_push($containerFiles, $file);
         }
     }
     if (empty($containerFiles)) {
         $this->logErrorMessage('document with id ' . $this->_docId . ' does not have associated files that are accessible');
         throw new Oai_Model_Exception('access denied on all files that are associated to the requested document');
     }
     return $containerFiles;
 }
开发者ID:KOBV,项目名称:opus4-matheon,代码行数:58,代码来源:Container.php

示例4: loadSignatureFiles

 /**
  * 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();
 }
开发者ID:alexukua,项目名称:opus4,代码行数:45,代码来源:Opus3SignatureImport.php

示例5: renderPublishMailBody

 /**
  * Render body of notification mail.
  *
  * @param string $baseUrlServer
  * @param string $baseUrlFiles
  * @return string
  */
 public function renderPublishMailBody($baseUrlServer, $baseUrlFiles)
 {
     $baseUrlServer = preg_replace('/[\\/]+$/', '', $baseUrlServer);
     $baseUrlFiles = preg_replace('/[\\/]+$/', '', $baseUrlFiles);
     $loggedUserModel = new Publish_Model_LoggedUser();
     $person = $loggedUserModel->createPerson();
     $submitterString = '';
     if (!is_null($person) and $person->isValid()) {
         $submitterString = trim($person->getFirstName() . " " . $person->getLastName());
     }
     $titleModels = $this->_document->getTitleMain();
     $titleString = '';
     if (count($titleModels) > 0) {
         $titleString = trim($titleModels[0]->getValue());
     }
     $abstractModels = $this->_document->getTitleAbstract();
     $abstractString = '';
     if (count($abstractModels) > 0) {
         $abstractString = trim($abstractModels[0]->getValue());
     }
     $template = new Matheon_Model_Template();
     $template->template = APPLICATION_PATH . '/modules/matheon/models/confirmation-mail.template';
     return $template->render(array('baseUrlServer' => $baseUrlServer, 'baseUrlFiles' => $baseUrlFiles, 'docId' => $this->getId(), 'submitterString' => $submitterString, 'titleString' => $titleString, 'abstractString' => $abstractString, 'files' => $this->_document->getFile()));
 }
开发者ID:KOBV,项目名称:opus4-matheon,代码行数:31,代码来源:Document.php

示例6: foreach

 * @copyright   Copyright (c) 2008-2012, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id: find_urns_for_docs_without_visible_files.php 11775 2013-06-25 14:28:41Z tklein $
 */
/**
 * Dieses Script sucht Dokumente ohne sichtbare Dateien, fuer die bereits
 * eine URN vergeben wurde.
 */
$updateRequired = 0;
$docfinder = new Opus_DocumentFinder();
$docfinder->setIdentifierTypeExists('urn');
echo "checking documents...\n";
foreach ($docfinder->ids() as $docId) {
    $doc = new Opus_Document($docId);
    $numVisibleFiles = 0;
    foreach ($doc->getFile() as $file) {
        if ($file->getVisibleInOai() == 1) {
            $numVisibleFiles++;
        }
    }
    if ($numVisibleFiles > 0) {
        continue;
    }
    echo "-- document {$docId} has an URN " . $doc->getIdentifierUrn(0)->getValue() . ", but no visible files\n";
}
if ($updateRequired == 0) {
    echo "all docs were checked -- nothing to do!\n";
} else {
    echo "{$updateRequired} docs need to be updated manually!\n";
}
exit;
开发者ID:alexukua,项目名称:opus4,代码行数:31,代码来源:find_urns_for_docs_without_visible_files.php

示例7: _addAccessRights

 private function _addAccessRights(DOMNode $domNode, Opus_Document $doc)
 {
     $visible = 0;
     $files = $doc->getFile();
     if (count($files) > 0) {
         foreach ($files as $file) {
             if ($file->getField('VisibleInOai')->getValue() && $file->getField('VisibleInFrontdoor')->getValue()) {
                 $visible = 1;
             }
         }
     } else {
         $visible = 1;
     }
     if (!$doc->hasEmbargoPassed()) {
         $visible = 2;
     }
     $fileElement = $domNode->ownerDocument->createElement('Rights');
     switch ($visible) {
         case 0:
             $fileElement->setAttribute('Value', 'info:eu-repo/semantics/closedAccess');
             break;
         case 1:
             $fileElement->setAttribute('Value', 'info:eu-repo/semantics/openAccess');
             break;
         case 2:
             $fileElement->setAttribute('Value', 'info:eu-repo/semantics/embargoedAccess');
             break;
         case 3:
             $fileElement->setAttribute('Value', 'info:eu-repo/semantics/restrictedAccess');
             break;
     }
     $domNode->appendChild($fileElement);
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:33,代码来源:IndexController.php

示例8: isFileBelongsToDocument

 /**
  * Checks if a file ID is linked to a document.
  * @param int $docId
  * @param int $fileId
  * @return boolean True - if the file is linked to the document
  */
 public function isFileBelongsToDocument($docId, $fileId)
 {
     if (empty($fileId) || !is_numeric($fileId)) {
         return false;
     }
     $doc = new Opus_Document($docId);
     $files = $doc->getFile();
     foreach ($files as $file) {
         if ($file->getId() == $fileId) {
             return true;
         }
     }
     return false;
 }
开发者ID:alexukua,项目名称:opus4,代码行数:20,代码来源:FileImport.php

示例9: testPublistActionDisplaysUrlencodedFiles

 /**
  * Regression Test for OPUSVIER-2998 and OPUSVIER-2999
  */
 public function testPublistActionDisplaysUrlencodedFiles()
 {
     Zend_Registry::get('Zend_Config')->merge(new Zend_Config(array('plugins' => array('export' => array('publist' => array('file' => array('allow' => array('mimetype' => array('application/xhtml+xml' => 'HTML')))))))));
     // explicitly re-initialize mime type config to apply changes in Zend_Config
     // This is necessary due to static variable in Export_Model_PublicationList
     // which is not reset between tests.
     $config = Zend_Registry::get('Zend_Config');
     $this->assertTrue(isset($config->plugins->export->publist->file->allow->mimetype), 'Failed setting configuration option');
     $this->assertEquals(array('application/xhtml+xml' => 'HTML'), $config->plugins->export->publist->file->allow->mimetype->toArray(), 'Failed setting configuration option');
     $doc = new Opus_Document(92);
     $file = $doc->getFile(1);
     $this->assertTrue($file instanceof Opus_File, 'Test setup has changed.');
     $this->assertEquals('datei mit unüblichem Namen.xhtml', $file->getPathName(), 'Test setup has changed.');
     $collection = $doc->getCollection(0);
     $this->assertEquals('coll_visible', $collection->getNumber(), 'Test setup has changed');
     $this->assertEquals(1, $collection->getVisible(), 'Test setup has changed');
     $this->dispatch('/export/index/publist/role/publists/number/coll_visible');
     $this->assertResponseCode(200, $this->getResponse()->getBody());
     $response = $this->getResponse();
     $this->assertContains(urlencode('datei mit unüblichem Namen.xhtml'), $response->getBody());
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:24,代码来源:IndexControllerTest.php

示例10: testGetRecordEpicurUrlEncoding

 /**
  * Test verb=GetRecord, prefix=epicur.
  */
 public function testGetRecordEpicurUrlEncoding()
 {
     $expectedFileNames = array("'many'  -  spaces  and  quotes.pdf", 'special-chars-%-"-#-&.pdf');
     $doc = new Opus_Document(147);
     $fileNames = array_map(function ($f) {
         return $f->getPathName();
     }, $doc->getFile());
     sort($fileNames);
     $this->assertEquals(2, count($fileNames), "testdata changed");
     $this->assertEquals($expectedFileNames, $fileNames, "testdata changed");
     $this->dispatch('/oai?verb=GetRecord&metadataPrefix=epicur&identifier=oai::147');
     $this->assertResponseCode(200);
     $response = $this->getResponse();
     $badStrings = array("Exception", "Error", "Stacktrace", "badVerb");
     $this->checkForCustomBadStringsInHtml($response->getBody(), $badStrings);
     $xpath = $this->prepareXpathFromResultString($response->getBody());
     // Regression test for OPUSVIER-2444 - url encoding of transfer files.
     $elements = $xpath->query('//epicur:resource/epicur:identifier[@target="transfer"]/text()');
     $this->assertEquals(2, $elements->length, "Unexpected identifier count");
     $fetchedNames = array();
     foreach ($elements as $element) {
         $fetchedNames[] = preg_replace("/^.*\\/147\\//", "", $element->nodeValue);
     }
     $this->assertContains("special-chars-%25-%22-%23-%26.pdf", $fetchedNames);
     $this->assertContains("%27many%27%20%20-%20%20spaces%20%20and%20%20quotes.pdf", $fetchedNames);
 }
开发者ID:esmo,项目名称:opus4-application,代码行数:29,代码来源:IndexControllerTest.php

示例11:

    exit;
}
if ($dryrun) {
    _log("TEST RUN: NO DATA WILL BE MODIFIED");
}
$docFinder = new Opus_DocumentFinder();
$docIds = $docFinder->setServerState('published');
if ($documentType != false) {
    $docFinder->setType($documentType);
}
$docIds = $docFinder->ids();
_log(count($docIds) . " documents " . ($documentType != false ? "of type '{$documentType}' " : '') . "found");
foreach ($docIds as $docId) {
    try {
        $doc = new Opus_Document($docId);
        if (count($doc->getFile()) == 0) {
            _log("Document <{$docId}> has no files, skipping..");
            continue;
        }
        if (!is_null($thesisPublisherId)) {
            $thesisPublisher = $doc->getThesisPublisher();
            if (empty($thesisPublisher)) {
                if (!$dryrun) {
                    $doc->setThesisPublisher($dnbInstitute);
                    $doc->store();
                }
                _log("Setting ThesisPublisher <{$thesisPublisherId}> on Document <{$docId}>");
            } else {
                $existingThesisPublisherId = $thesisPublisher[0]->getId();
                _log("ThesisPublisher <{$existingThesisPublisherId[1]}> already set for Document <{$docId}>");
            }
开发者ID:alexukua,项目名称:opus4,代码行数:31,代码来源:update-dnbinstitute.php

示例12: extract

 private function extract($startId, $endId)
 {
     $this->forceSyncMode();
     $docIds = $this->getDocumentIds($startId, $endId);
     $extractor = Opus_Search_Service::selectIndexingService('indexBuilder');
     echo date('Y-m-d H:i:s') . " Start indexing of " . count($docIds) . " documents.\n";
     $numOfDocs = 0;
     $runtime = microtime(true);
     // measure time for each document
     foreach ($docIds as $docId) {
         $timeStart = microtime(true);
         $doc = new Opus_Document($docId);
         foreach ($doc->getFile() as $file) {
             try {
                 $extractor->extractDocumentFile($file, $doc);
             } catch (Opus_Search_Exception $e) {
                 echo date('Y-m-d H:i:s') . " ERROR: Failed extracting document {$docId}.\n";
                 echo date('Y-m-d H:i:s') . "        {$e->getMessage()}\n";
             } catch (Opus_Storage_Exception $e) {
                 echo date('Y-m-d H:i:s') . " ERROR: Failed extracting unavailable file on document {$docId}.\n";
                 echo date('Y-m-d H:i:s') . "        {$e->getMessage()}\n";
             }
         }
         $timeDelta = microtime(true) - $timeStart;
         if ($timeDelta > 30) {
             echo date('Y-m-d H:i:s') . " WARNING: Extracting document {$docId} took {$timeDelta} seconds.\n";
         }
         $numOfDocs++;
         if ($numOfDocs % 10 == 0) {
             $this->outputProgress($runtime, $numOfDocs);
         }
     }
     $runtime = microtime(true) - $runtime;
     echo PHP_EOL . date('Y-m-d H:i:s') . ' Finished extracting.' . PHP_EOL;
     // new search API doesn't track number of indexed files, but issues are kept written to log file
     //echo "\n\nErrors appeared in " . $indexer->getErrorFileCount() . " of " . $indexer->getTotalFileCount()
     //    . " files. Details were written to opus-console.log";
     echo PHP_EOL . PHP_EOL . 'Details were written to opus-console.log';
     $this->resetMode();
     return $runtime;
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:41,代码来源:SolrFulltextCacheBuilder.php

示例13: getFileCount

 public function getFileCount()
 {
     return count($this->document->getFile());
 }
开发者ID:alexukua,项目名称:opus4,代码行数:4,代码来源:DocumentAdapter.php

示例14: testFileUploadDateAfterModification

 /**
  * Nach einer Änderung in der Datei soll das ursprüngliche Upload-Datum gesetzt bleiben.
  */
 public function testFileUploadDateAfterModification()
 {
     $this->useGerman();
     $doc = new Opus_Document(305);
     foreach ($doc->getFile() as $file) {
         $file->setComment(rand());
     }
     $docId = $doc->store();
     $this->dispatch('admin/filemanager/index/id/' . $docId);
     $this->assertQueryContentContains('//div', '10.12.2013');
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:14,代码来源:FilemanagerControllerTest.php

示例15: testGetFieldValues

 public function testGetFieldValues()
 {
     $form = new Admin_Form_Files();
     $document = new Opus_Document(155);
     $files = $document->getFile();
     $values = $form->getFieldValues($document);
     $this->assertEquals(count($files), count($values));
     foreach ($files as $index => $file) {
         $this->assertEquals($file->getId(), $values[$index]->getId(), 'Files are not in expected order.');
     }
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:11,代码来源:FilesTest.php


注:本文中的Opus_Document::getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。