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


PHP Opus_Document::addFile方法代码示例

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


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

示例1: addFilesToDocument

 /**
  *
  * @param string $docId
  * @param array $files
  * @throws Application_Exception in case database contains no document with id $docID
  */
 public function addFilesToDocument($docId, $files)
 {
     if (empty($files)) {
         throw new Application_Exception('no files for import');
     }
     $document = null;
     try {
         $document = new Opus_Document($docId);
     } catch (Opus_Model_NotFoundException $e) {
         throw new Application_Exception('no document found for id ' . $docId, null, $e);
     }
     $log = $this->getLogger();
     $validFilenames = $this->getNamesOfIncomingFiles();
     foreach ($files as $file) {
         $log->debug('check filename ' . $file);
         if (in_array($file, $validFilenames)) {
             $pathname = $this->__importFolder . DIRECTORY_SEPARATOR . $file;
             $log->info('import file ' . $pathname);
             $docfile = $document->addFile();
             $docfile->setTempFile($pathname);
             $docfile->setPathName($file);
             $docfile->setLabel($file);
             try {
                 $document->store();
                 $log->info('import of file ' . $pathname . ' successful');
             } catch (Exception $e) {
                 $log->err('import of file ' . $pathname . ' failed: ' . $e->getMessage());
             }
             $log->info('try to delete file ' . $pathname);
             if (!unlink($pathname)) {
                 $log->err('could not delete file ' . $pathname);
             }
         }
     }
 }
开发者ID:alexukua,项目名称:opus4,代码行数:41,代码来源:FileImport.php

示例2: testClearDocumentWithFile

 public function testClearDocumentWithFile()
 {
     $this->markTestIncomplete('TODO: Re-enable, as soon as OPUSVIER-1220 is fixed.');
     $path = '/tmp/opus4-test/' . uniqid() . "/src";
     mkdir($path, 0777, true);
     $filepath = $path . DIRECTORY_SEPARATOR . "foobar.pdf";
     touch($filepath);
     $document = new Opus_Document($this->documentId);
     $document->addFile()->setTempFile($filepath)->setPathName('foobar.pdf')->setLabel('Volltextdokument (PDF)');
     $document->store();
     $helper = new Review_Model_ClearDocumentsHelper();
     $helper->clear(array($this->documentId), 23, $this->person);
     $document = new Opus_Document($this->documentId);
     $this->assertEquals('published', $document->getServerState());
     $this->assertEquals(1, count($document->getPersonReferee()));
     $enrichments = $document->getEnrichment();
     $this->assertEquals(1, count($enrichments));
     $this->assertEquals(23, $enrichments[0]->getValue());
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:19,代码来源:ClearDocumentsHelperTest.php


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