本文整理汇总了PHP中Opus_Document::store方法的典型用法代码示例。如果您正苦于以下问题:PHP Opus_Document::store方法的具体用法?PHP Opus_Document::store怎么用?PHP Opus_Document::store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opus_Document
的用法示例。
在下文中一共展示了Opus_Document::store方法的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;
}
示例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());
}
示例3: rand
* @copyright Copyright (c) 2008-2011, OPUS 4 development team
* @license http://www.gnu.org/licenses/gpl.html General Public License
* @version $Id$
*/
/**
* script to create 10000 documents, e.g., for performance testing
*/
for ($i = 1; $i < 10000; $i++) {
$d = new Opus_Document();
$d->setServerState('published');
$d->setType('preprint');
$d->setLanguage('deu');
$title = $d->addTitleMain();
$title->setLanguage('deu');
$title->setValue('title-' . rand());
$date = new Opus_Date();
$date->setNow();
$date->setYear(1990 + $i % 23);
$d->setPublishedDate($date);
$p = new Opus_Person();
$p->setFirstName("foo-" . $i % 7);
$p->setLastName("bar-" . $i % 5);
$p = $d->addPersonAuthor($p);
$c = new Opus_Collection(15990 + $i % 103);
$d->addCollection($c);
$s = $d->addSubject()->setType('ddc');
$s->setValue($i % 97);
$docId = $d->store();
echo "docId: {$docId}\n";
}
exit;
示例4: deleteFile
/**
* Deletes a single file from a document.
* @param type $docId
* @param type $fileId
* @return type
*/
public function deleteFile($docId, $fileId)
{
$doc = new Opus_Document($docId);
$keepFiles = array();
$files = $doc->getFile();
foreach ($files as $index => $file) {
if ($file->getId() !== $fileId) {
$keepFiles[] = $file;
}
}
$doc->setFile($keepFiles);
$doc->store();
}
示例5: addDocument
public function addDocument($documentId)
{
if (is_null($documentId)) {
throw new Admin_ModelException('missing document id');
}
$document = null;
try {
$document = new Opus_Document($documentId);
} catch (Opus_Model_Exception $e) {
throw new Admin_Model_Exception('invalid document id');
}
$document->addCollection($this->_collection);
$document->store();
}
示例6: testGuestAccessToFileRegression3281
public function testGuestAccessToFileRegression3281()
{
$this->enableSecurity();
// test document access as user without access rights
$doc = $this->createTestDocument();
$doc->setServerState('published');
$docId = $doc->store();
$this->tryAccessForDocument($docId, true);
$doc = new Opus_Document($docId);
$doc->setServerState('unpublished');
$docId = $doc->store();
$this->tryAccessForDocument($docId, false);
}
示例7: changeState
/**
* Performs state change on document.
* @param Opus_Document $document
* @param string $targetState
*
* TODO enforcing permissions and throwing exceptions (OPUSVIER-1959)
*/
public function changeState($document, $targetState)
{
switch ($targetState) {
case 'deleted':
$document->delete();
break;
case 'removed':
$document->deletePermanent();
break;
default:
$document->setServerState($targetState);
$document->store();
break;
}
}
示例8: testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates
/**
* Regression test for OPUSVIER-2165
*
* if database contains more than one title in the document's language,
* the first title is used as page title
*/
public function testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates()
{
$d = new Opus_Document(146);
$lang = $d->getLanguage();
$d->setLanguage('deu');
$titles = $d->getTitleMain();
$d->addTitleMain()->setValue('VBOK')->setLanguage('deu');
$d->store();
$this->dispatch('/frontdoor/index/index/docId/146');
// restore language
// restore titles
$d = new Opus_Document(146);
$d->setLanguage($lang);
$d->setTitleMain($titles);
$d->store();
$this->assertNotContains('<title>OPUS 4 | COLN</title>', $this->getResponse()->getBody());
$this->assertNotContains('<title>OPUS 4 | VBOK</title>', $this->getResponse()->getBody());
$this->assertContains('<title>OPUS 4 | KOBV</title>', $this->getResponse()->getBody());
}
示例9: 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');
}
示例10: setDocumentType
private function setDocumentType($documenttype)
{
$doc = new Opus_Document($this->documentId);
$doc->setType($documenttype);
$doc->store();
}
示例11: store
/**
* Store current document.
*
* @return integer
*/
public function store()
{
return $this->_document->store();
}
示例12: debugAction
public function debugAction()
{
$this->requirePrivilege('admin');
$docId = $this->_getParam('docId');
$document = new Opus_Document($docId);
$document->setServerState('unpublished');
$loggedUserModel = new Publish_Model_LoggedUser();
$loggedUserId = $loggedUserModel->getUserId();
$document->addEnrichment()->setKeyName('submitter.user_id')->setValue($loggedUserId);
$document->store();
$session = new Zend_Session_Namespace('Publish');
$session->depositConfirmDocumentId = $docId;
}
示例13: testConfirmationDisabled
public function testConfirmationDisabled()
{
$config = Zend_Registry::get('Zend_Config');
$config->merge(new Zend_Config(array('confirmation' => array('document' => array('statechange' => array('enabled' => '0'))))));
$this->dispatch('/admin/workflow/changestate/docId/102/targetState/deleted');
$this->assertRedirectTo('/admin/document/index/id/102');
// Änderung wird sofort durchgefuehrt
$doc = new Opus_Document(102);
$this->assertEquals('deleted', $doc->getServerState());
$doc->setServerState('unpublished');
$doc->store();
}
示例14: foreach
echo "sorting documents in series #" . $series->getId() . " numerically\n";
if (!asort($seriesNumbers, SORT_NUMERIC)) {
echo "Error while sorting docs -- skip series #" . $series->getId() . "\n";
break;
}
} else {
echo "sorting documents in series #" . $series->getId() . " lexicographically\n";
if (!asort($seriesNumbers, SORT_STRING)) {
echo "Error while sorting docs -- skip series #" . $series->getId() . "\n";
break;
}
}
$seriesCounter = 0;
foreach ($seriesNumbers as $docId => $seriesNumber) {
$doc = new Opus_Document($docId);
$allSeries = $doc->getSeries();
$doc->setSeries(array());
$doc->store();
foreach ($allSeries as $docSeries) {
$seriesInstance = $docSeries->getModel();
if ($seriesInstance->getId() === $series->getId()) {
echo "reassign doc_sort_order for doc #" . $doc->getId() . " (series number: " . $docSeries->getNumber() . ") -- old / new doc_sort_order: " . $docSeries->getDocSortOrder() . " / " . $seriesCounter . "\n";
$doc->addSeries($seriesInstance)->setNumber($docSeries->getNumber())->setDocSortOrder($seriesCounter++);
} else {
$doc->addSeries($seriesInstance)->setNumber($docSeries->getNumber())->setDocSortOrder($docSeries->getDocSortOrder());
}
}
$doc->store();
}
}
exit;
示例15: 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();
}