/** * Initialisiert das Formular mit einer Collection. * @param Opus_Collection $collection */ public function populateFromModel($collection) { $this->getElement(self::ELEMENT_ID)->setValue($collection->getId()); $displayName = $this->getDisplayNameForCollection($collection); $this->getElement(self::ELEMENT_EDIT)->setLabel($displayName); $this->setLegend($displayName); }
public function appendChild($number, $title) { $collections = Opus_Collection::fetchCollectionsByRoleNumber($this->_role->getId(), $number); if (count($collections) > 0) { throw new Remotecontrol_Model_Exception("Model_Collection: Collection with number '{$number}' already exists."); } $newChild = $this->_collection->addLastChild(); $newChild->setNumber($number)->setName($title)->setVisible(1)->store(); return $newChild; }
public function testCollectionMsc() { $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '51H10'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '90B06'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '90B90'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '05D99'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); }
public function testCollectionPacs() { $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '82.56.-b'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '84.60.-h'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '78.20.-e'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '42.70.-a'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); }
public function testCollectionJel() { $this->markTestIncomplete(); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'P31'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'H20'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'I2'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'F21'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); }
public function testCollectionCcs() { $this->markTestIncomplete(); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'K.6.0'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'UP 7500'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'D.2.12'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'I.2.10'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'E.1'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); }
public function __construct($collectionId) { if (is_null($collectionId)) { throw new Solrsearch_Model_Exception('Could not browse collection due to missing id parameter.'); } $collection = null; try { $collection = new Opus_Collection((int) $collectionId); } catch (Opus_Model_NotFoundException $e) { throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' does not exist."); } // check if an unvisible collection exists along the path to the root collection foreach ($collection->getParents() as $parent) { if (!$parent->isRoot() && $parent->getVisible() !== '1') { throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' is not visible."); } } $collectionRole = null; try { $collectionRole = new Opus_CollectionRole($collection->getRoleId()); } catch (Opus_Model_NotFoundException $e) { throw new Solrsearch_Model_Exception("Collection role with id '" . $collection->getRoleId() . "' does not exist."); } if (!($collectionRole->getVisible() === '1' && $collectionRole->getVisibleBrowsingStart() === '1')) { throw new Solrsearch_Model_Exception("Collection role with id '" . $collectionRole->getId() . "' is not visible."); } // additional root collection check $rootCollection = $collectionRole->getRootCollection(); if (!is_null($rootCollection)) { // check if at least one visible child exists or current collection has at least one associated document if (!$rootCollection->hasVisibleChildren() && count($rootCollection->getPublishedDocumentIds()) == 0) { throw new Solrsearch_Model_Exception("Collection role with id '" . $collectionRole->getId() . "' is not clickable and therefore not displayed."); } } $this->_collectionRole = $collectionRole; $this->_collection = $collection; }
public function testPopulateFromModel() { $form = new Admin_Form_Collection(); $model = new Opus_Collection(); $model->setName('TestName'); $model->setNumber('50'); $model->setVisible(1); $model->setVisiblePublish(1); $model->setOaiSubset('TestSubset'); $model->setTheme('plain'); $form->populateFromModel($model); $this->assertEquals('TestName', $form->getElement('Name')->getValue()); $this->assertEquals(50, $form->getElement('Number')->getValue()); $this->assertEquals(1, $form->getElement('Visible')->getValue()); $this->assertEquals(1, $form->getElement('VisiblePublish')->getValue()); $this->assertEquals('TestSubset', $form->getElement('OaiSubset')->getValue()); $this->assertEquals('plain', $form->getElement('Theme')->getValue()); }
/** * Für jede Collection der Collection Role series wird eine neue Schriftenreihe * Opus_Series angelegt, wobei der Name, die Sichtbarkeit und die Sorierreihenfolge * übernommen wird. * * Die Wurzel-Collection der Collection Role series wird nicht betrachtet. * * * @return int number of collections that were migrated */ private function migrateCollectionToSeries() { $numOfCollectionsMigrated = 0; foreach (Opus_Collection::fetchCollectionsByRoleId($this->seriesRole->getId()) as $collection) { // ignore root collection (does not have valid data and associated documents) if ($collection->isRoot()) { continue; } $series = new Opus_Series(Opus_Series::createRowWithCustomId($collection->getId())); $series->setTitle($collection->getName()); $series->setVisible($collection->getVisible()); $series->setSortOrder($collection->getSortOrder()); $series->store(); $this->logger->info('created series with id #' . $collection->getId()); $numOfCollectionsMigrated++; } return $numOfCollectionsMigrated; }
/** * Wenn eine übergeordnete Collection (z.B. die Root-Collection) für das Attribut visiblePublish = false gesetzt ist, * sollen die Kinder auch unsichtbar sein im Publish-Modul. */ public function testRootCollectionFieldVisiblePublish() { $collectionRole = new Opus_CollectionRole(); $collectionRole->setName("test"); $collectionRole->setOaiName("test"); $collectionRole->setDisplayBrowsing("Name"); $collectionRole->setDisplayFrontdoor("Name"); $collectionRole->setDisplayOai("Name"); $collectionRole->setPosition(101); $collectionRole->setVisible(true); $collectionRole->store(); $rootCollection = $collectionRole->addRootCollection(); $rootCollection->setName("rootInvisible"); $rootCollection->setVisible(true); $rootCollection->setVisiblePublish(false); $rootCollection->store(); $visibleCollection = new Opus_Collection(); $visibleCollection->setName("visible collection"); $visibleCollection->setNumber("123"); $visibleCollection->setVisible(true); $visibleCollection->setVisiblePublish(true); $rootCollection->addFirstChild($visibleCollection); $visibleCollection->store(); $invisibleCollection = new Opus_Collection(); $invisibleCollection->setName("collection to invisible root collection"); $invisibleCollection->setNumber("123"); $invisibleCollection->setVisible(true); $invisibleCollection->setVisiblePublish(false); $rootCollection->addFirstChild($invisibleCollection); $invisibleCollection->store(); $childCollection = new Opus_Collection(); $childCollection->setName("collection child"); $childCollection->setNumber("123"); $childCollection->setVisible(true); $childCollection->setVisiblePublish(true); $invisibleCollection->addFirstChild($childCollection); $childCollection->store(); $val = new Publish_Model_Validation('Collection', $this->session, 'test'); $children = $val->selectOptions('Collection'); // clean-up $collectionRole->delete(); $this->assertEquals(0, count($children), "root collection should be invisible in publish"); }
/** * Imports Institutes from Opus3 to Opus4 directly (without XML) * * @param DOMDocument $data XML-Document to be imported * @return array List of documents that have been imported */ protected function importInstitutes($data, $pColls) { $mf = $this->_config->migration->mapping->institutes; $fp = null; try { $fp = @fopen($mf, 'w'); if (!$fp) { throw new Exception("ERROR Opus3InstituteImport: Could not create '" . $mf . "' for Institutes.\n"); } } catch (Exception $e) { $this->_logger->log($e->getMessage(), Zend_Log::ERR); return; } $classification = $this->transferOpusClassification($data); foreach ($classification as $class) { if (array_key_exists('fakultaet', $class) === false || array_key_exists('name', $class) === false || array_key_exists('nr', $class) === false) { $invalidInstitute = ''; foreach ($class as $key => $val) { $invalidInstitute .= "[{$key}:'{$val}'] "; } $this->_logger->log("Invalid entry for Institute will be ignored: '" . $invalidInstitute, Zend_Log::ERR); continue; } if (array_key_exists($class['fakultaet'], $pColls) === false) { $this->_logger->log("No Faculty with ID '" . $class['fakultaet'] . "' for Institute with ID '" . $class['nr'] . "'", Zend_Log::ERR); continue; } /* Create a Collection for Institute */ $root = new Opus_Collection($pColls[$class['fakultaet']]); $coll = $root->addLastChild(); $coll->setName($class['name']); $coll->setVisible(1); $root->store(); $this->_logger->log("Institute imported: " . $class['name'], Zend_Log::DEBUG); fputs($fp, $class['nr'] . ' ' . $coll->getId() . "\n"); } fclose($fp); }
/** * Store root collection: Initialize Node. * * @param Opus_Collection $collection Collection to store as Root. * * @see Opus_Model_AbstractDb */ public function _storeRootCollection($collection) { if (!isset($collection)) { return; } if ($collection->isNewRecord()) { $collection->setPositionKey('Root'); $collection->setRoleId($this->getId()); } $collection->store(); }
public function _validateCollectionLeafSelection() { $collectionLeafSelection = true; $elements = $this->form->getElements(); foreach ($elements as $element) { /* @var $element Zend_Form_Element */ if ($element->getAttrib('collectionLeaf') !== true) { continue; } $elementName = $element->getName(); if (isset($this->session->additionalFields['step' . $elementName])) { $step = $this->session->additionalFields['step' . $elementName]; if ($step >= 2) { $element = $this->form->getElement('collId' . $step . $elementName); } } $matches = array(); if (preg_match('/^(\\d+)$/', $element->getValue(), $matches) == 0) { continue; } $collId = $matches[1]; if (isset($collId)) { $coll = null; try { $coll = new Opus_Collection($collId); } catch (Opus_Model_Exception $e) { $this->log->err("could not instantiate Opus_Collection with id {$collId}", $e); $collectionLeafSelection = false; } if ($coll != null && $coll->hasChildren()) { if (isset($element)) { $element->clearErrorMessages(); $element->addError($this->translate('publish_error_collection_leaf_required')); $collectionLeafSelection = false; } } } } return $collectionLeafSelection; }
public function testCollectionHoldsDocument() { $bottom1 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'bottom1'); $this->assertEquals(1, count($bottom1[0]->getDocumentIds())); }
private function mapClassifications() { $old_bkl = array('name' => 'OldBkl', 'role' => 'bkl'); $old_ccs = array('name' => 'OldCcs', 'role' => 'ccs'); $old_ddc = array('name' => 'OldDdc', 'role' => 'ddc'); $old_jel = array('name' => 'OldJel', 'role' => 'jel'); $old_msc = array('name' => 'OldMsc', 'role' => 'msc'); $old_pacs = array('name' => 'OldPacs', 'role' => 'pacs'); $old_array = array($old_bkl, $old_ccs, $old_ddc, $old_jel, $old_msc, $old_pacs); foreach ($old_array as $oa) { $elements = $this->document->getElementsByTagName($oa['name']); while ($elements->length > 0) { $e = $elements->Item(0); $value = $e->getAttribute('Value'); $role = Opus_CollectionRole::fetchByName($oa['role']); $colls = Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $value); if (count($colls) > 0) { foreach ($colls as $c) { /* TODO: DDC-Hack */ if ($oa['role'] === 'ddc' and $c->hasChildren()) { continue; } array_push($this->collections, $c->getId()); } } else { $this->logger->log("Old ID '" . $this->oldId . "' : Document not added to '" . $oa['role'] . "' '" . $value . "'", Zend_Log::ERR); } $this->document->removeChild($e); } } }
protected function _addCollection($colId) { $collection = new Opus_Collection($colId); $collectionRole = $collection->getRole(); $roleName = $collectionRole->getName(); $roleForm = $this->_getRoleForm($roleName); $collectionForm = new Admin_Form_Document_Collection(); $collectionForm->populateFromModel($collection); $position = count($roleForm->getSubForms()); $roleForm->addSubForm($collectionForm, 'collection' . $position); }
function migrateSubjectToCollection($doc, $subjectType, $roleId, $eKeyName) { global $logger; $logPrefix = sprintf("[docId % 5d] ", $doc->getId()); $keepSubjects = array(); $removeSubjects = array(); foreach ($doc->getSubject() as $subject) { $keepSubjects[$subject->getId()] = $subject; $type = $subject->getType(); $value = $subject->getValue(); if ($type !== $subjectType) { // $logger->debug("$logPrefix Skipping subject (type '$type', value '$value')"); continue; } // From now on, every subject will be migrated $keepSubjects[$subject->getId()] = false; $removeSubjects[] = $subject; // check if (unique) collection for subject value exists $collections = Opus_Collection::fetchCollectionsByRoleNumber($roleId, $value); if (!is_array($collections) or count($collections) < 1) { $logger->warn("{$logPrefix} No collection found for value '{$value}' -- migrating to enrichment {$eKeyName}."); // migrate subject to enrichments $doc->addEnrichment()->setKeyName($eKeyName)->setValue($value); continue; } if (count($collections) > 1) { $logger->warn("{$logPrefix} Ambiguous collections for value '{$value}' -- migrating to enrichment {$eKeyName}."); // migrate subject to enrichments $doc->addEnrichment()->setKeyName($eKeyName)->setValue($value); continue; } $collection = $collections[0]; if ($collection->isRoot()) { $logger->warn("{$logPrefix} No non-root collection found for value '{$value}' -- migrating to enrichment {$eKeyName}."); // migrate subject to enrichments $doc->addEnrichment()->setKeyName($eKeyName)->setValue($value); continue; } $collectionId = $collection->getId(); // check if document already belongs to this collection if (checkDocumentHasCollectionId($doc, $collectionId)) { // nothing to do $logger->info("{$logPrefix} Migrating subject (type '{$type}', value '{$value}') -- collection already assigned to collection {$collectionId}."); continue; } // migrate subject to collections $logger->info("{$logPrefix} Migrating subject (type '{$type}', value '{$value}') to collection {$collectionId}."); $doc->addCollection($collection); } if (count($removeSubjects) > 0) { // debug: removees foreach ($removeSubjects as $r) { $logger->debug("{$logPrefix} Removing subject (type '" . $r->getType() . "', value '" . $r->getValue() . "')"); } $newSubjects = array_filter(array_values($keepSubjects)); foreach ($newSubjects as $k) { $logger->debug("{$logPrefix} Keeping subject (type '" . $k->getType() . "', value '" . $k->getValue() . "')"); } $doc->setSubject($newSubjects); } return $removeSubjects; }
public function testInstituteHoldsDocument() { $institute = Opus_Collection::fetchCollectionsByRoleName('1', 'Institut 2'); $this->assertTrue($institute[0]->holdsDocumentById($this->doc->getId())); }
private function prepareAssignSubPage($documentId, $collectionId) { $collection = new Opus_Collection($collectionId); $children = $collection->getChildren(); if (count($children) === 0) { // zurück zur Ausgangsansicht $this->_redirectToAndExit('assign', array('failure' => 'specified collection does not have any subcollections'), 'collection', 'admin', array('document' => $documentId)); return; } $this->view->collections = array(); foreach ($children as $child) { array_push($this->view->collections, array('id' => $child->getId(), 'name' => $child->getNumberAndName(), 'hasChildren' => $child->hasChildren(), 'visible' => $child->getVisible())); } $this->view->documentId = $documentId; $this->view->breadcrumb = array_reverse($collection->getParents()); $this->view->role_name = $collection->getRole()->getDisplayName(); }
public function testPopulateFromPost() { $form = new Admin_Form_Document_Collection(); $post = array('Id' => '499'); $form->populateFromPost($post); $collection = new Opus_Collection(499); $this->assertEquals($collection->getDisplayName(), $form->getLegend()); $this->assertEquals($collection->getId(), $form->getElement('Id')->getValue()); }
/** * wird nur für Collection Roles aufgerufen * @param int $id ID einer Collection * @param int $step aktuelle Stufe innerhalb der Gruppe (>= 1) * @param int $fieldset aktuelle Gruppe (>= 1) */ private function collectionEntries($id, $step, $fieldset) { try { $collection = new Opus_Collection($id); } catch (Exception $e) { // TODO: improve exception handling! return null; } $children = array(); if ($collection->hasChildren()) { $selectField = $this->form->createElement('select', 'collId' . $step . $this->elementName . '_' . $fieldset); $selectField->setDisableTranslator(true); $selectField->setLabel('choose_collection_subcollection'); $role = $collection->getRole(); $collsVisiblePublish = $collection->getVisiblePublishChildren(); $collsVisible = $collection->getVisibleChildren(); $colls = array_intersect($collsVisible, $collsVisiblePublish); foreach ($colls as $coll) { $children[] = array('key' => strval($coll->getId()), 'value' => $coll->getDisplayNameForBrowsingContext($role)); } $selectField->setMultiOptions($children); } //show no field? if (empty($children)) { $selectField = $this->form->createElement('text', 'collId' . $step . $this->elementName . '_' . $fieldset); $selectField->setDisableTranslator(true); $selectField->setLabel('endOfCollectionTree'); $selectField->setAttrib('disabled', true); $selectField->setAttrib('isLeaf', true); } return $selectField; }
protected function _fetchDisplayFrontdoor() { $displayName = $this->getDisplayName('frontdoor'); $parentId = $this->getParentNodeId(); if (!empty($parentId)) { $parent = new Opus_Collection($parentId); $parentDisplayName = $parent->getDisplayFrontdoor(); // implicitly calls $parent->_fetchDisplayFrontdoor() if (!empty($parentDisplayName)) { $displayName = $parentDisplayName . ' / ' . $displayName; } } return $displayName; }
/** * Store all Opus_Collection objects for this document. * * @return void */ protected function _storeCollection($collections) { if (true === is_null($this->getId())) { return; } Opus_Collection::unlinkCollectionsByDocumentId($this->getId()); foreach ($collections as $collection) { if ($collection->isNewRecord()) { $collection->store(); } if ($collection->holdsDocumentById($this->getId())) { continue; } $collection->linkDocumentById($this->getId()); } }
$doc->addPersonContributor($contributor); // // Titles // foreach (array('addTitleMain', 'addTitleAbstract', 'addTitleParent', 'addTitleSub', 'addTitleAdditional') as $titleMethod) { $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage(randString($counter++)); $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage('deu'); $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage('eng'); } // // Collections // $institutesRole = new Opus_CollectionRole(); $institutesRole->setName('institutes' . randString($counter++) . rand())->setOaiName('institutes' . randString($counter++) . rand())->setPosition(1)->setVisible(1)->setVisibleBrowsingStart(1)->setDisplayBrowsing('Name')->setVisibleFrontdoor(1)->setDisplayFrontdoor('Name')->setVisibleOai('Name')->setDisplayOai('Name')->store(); $instituteName = 'Institut für empirische Forschung ' . randString($counter++); $instituteCollections = Opus_Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName); if (count($instituteCollections) >= 1) { $instituteCollection = $instituteCollections[0]; } else { $rootCollection = $institutesRole->getRootCollection(); if (is_null($rootCollection) === true) { $rootCollection = $institutesRole->addRootCollection(); $rootCollection->setVisible(1)->store(); $institutesRole->store(); } $instituteCollection = $rootCollection->addLastChild(); $instituteCollection->setVisible(1)->setName(randString($counter++))->store(); } $doc->addCollection($instituteCollection); // // Identifiers
/** * Maps query for publist action. */ public function mapQuery($roleParam, $numberParam) { if (is_null(Opus_CollectionRole::fetchByName($roleParam))) { throw new Application_Exception('specified role does not exist'); } $role = Opus_CollectionRole::fetchByName($roleParam); if ($role->getVisible() != '1') { throw new Application_Exception('specified role is invisible'); } if (count(Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam)) == 0) { throw new Application_Exception('specified number does not exist for specified role'); } $collection = null; foreach (Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam) as $coll) { if ($coll->getVisible() == '1' && is_null($collection)) { $collection = $coll; } } if (is_null($collection)) { throw new Application_Exception('specified collection is invisible'); } return $collection; }
echo "Error: collection with id {$parent_collection_id} does not exist\n"; exit; } if (!is_null($root_collection)) { $line_count = 0; $lines_imported = 0; foreach (file($input_file) as $line) { $line_count++; if (trim($line) === '') { continue; } $parts = explode('|', $line); if (count($parts) > 2) { echo "Warning: ignore line number {$line_count} (more than one | character exists): {$line}\n"; continue; } if (count($parts) < 2) { echo "Warning: ignore line number {$line_count} (| character does not exist): {$line}\n"; continue; } $collection = new Opus_Collection(); $collection->setName(trim($parts[0])); $collection->setNumber(trim($parts[1])); $collection->setVisible($visible); $root_collection->addLastChild($collection); $root_collection->store(); $lines_imported++; } echo "{$lines_imported} collections were successfully imported\n"; } exit;
private function _collectionSelect() { $collectionRole = Opus_CollectionRole::fetchByName($this->collectionRole); if (is_null($collectionRole) || is_null($collectionRole->getRootCollection())) { return null; } if ($collectionRole->getVisible() == '1' && $collectionRole->getRootCollection()->getVisiblePublish() == '1' && $this->hasVisiblePublishChildren($collectionRole)) { $children = array(); $collectionId = $collectionRole->getRootCollection()->getId(); $collection = new Opus_Collection($collectionId); $colls = $collection->getVisiblePublishChildren(); foreach ($colls as $coll) { $children[$coll->getId()] = $coll->getDisplayNameForBrowsingContext($collectionRole); } return $children; } return null; }
/** * Display documents (all or filtered by state) * * @return void */ public function indexAction() { $this->view->title = 'admin_documents_index'; $this->prepareDocStateLinks(); $url_call_id = array('module' => 'admin', 'controller' => 'document', 'action' => 'index'); $this->view->url_call_id = $this->view->url($url_call_id, 'default', true); $this->prepareSortingLinks(); $data = $this->_request->getParams(); $filter = $this->_getParam("filter"); $this->view->filter = $filter; $data = $this->_request->getParams(); $page = 1; if (array_key_exists('page', $data)) { // set page if requested $page = $data['page']; } $collectionId = null; if (array_key_exists('collectionid', $data)) { $collectionId = $data['collectionid']; } $seriesId = null; if (array_key_exists('seriesid', $data)) { $seriesId = $data['seriesid']; } $sort_reverse = $this->getSortingDirection($data); $this->view->sort_reverse = $sort_reverse; $this->view->sortDirection = $sort_reverse ? 'descending' : 'ascending'; $state = $this->getStateOption($data); $this->view->state = $state; $sort_order = $this->getSortingOption($data); $this->view->sort_order = $sort_order; if (!empty($collectionId)) { $collection = new Opus_Collection($collectionId); $result = $collection->getDocumentIds(); $this->view->collection = $collection; if ($collection->isRoot()) { $collectionRoleName = 'default_collection_role_' . $collection->getRole()->getDisplayName(); $this->view->collectionName = $this->view->translate($collectionRoleName); if ($this->view->collectionName == $collectionRoleName) { $this->view->collectionName = $collection->getRole()->getDisplayName(); } } else { $this->view->collectionName = $collection->getNumberAndName(); } } else { if (!empty($seriesId)) { $series = new Opus_Series($seriesId); $this->view->series = $series; $result = $series->getDocumentIdsSortedBySortKey(); } else { $result = $this->_helper->documents($sort_order, $sort_reverse, $state); } } $paginator = Zend_Paginator::factory($result); $page = 1; if (array_key_exists('page', $data)) { // paginator $page = $data['page']; } $this->view->maxHitsPerPage = $this->getItemCountPerPage($data); $paginator->setItemCountPerPage($this->view->maxHitsPerPage); $paginator->setCurrentPageNumber($page); $this->view->paginator = $paginator; $this->prepareItemCountLinks(); }
public function testCollectionDdc() { $ddc_collections = Opus_Collection::fetchCollectionsByRoleNumber('2', '000'); $this->assertTrue($ddc_collections[0]->holdsDocumentById($this->doc->getId())); }