Ejemplo n.º 1
0
 public function __construct()
 {
     foreach (Opus_CollectionRole::fetchAll() as $collectionRole) {
         if ($this->isVisible($collectionRole) && ($this->HasVisibleChildren($collectionRole) || $this->hasPublishedDocs($collectionRole))) {
             array_push($this->collectionRoles, $collectionRole);
         }
     }
 }
Ejemplo n.º 2
0
 public function testOptions()
 {
     $element = $this->getElement();
     $options = $element->getMultiOptions();
     $collectionRoles = Opus_CollectionRole::fetchAll();
     // One additional option for last position
     $this->assertEquals(count($collectionRoles) + 1, count($options));
     $this->assertEquals('admin_collectionroles_last_position', array_pop($options));
 }
Ejemplo n.º 3
0
 public function init()
 {
     parent::init();
     $allCollectionRoles = Opus_CollectionRole::fetchAll();
     $translator = Zend_Registry::get('Zend_Translate');
     foreach ($allCollectionRoles as $collectionRole) {
         $position = $collectionRole->getPosition();
         $this->addMultiOption($position, $position . ' - ' . $translator->translate('default_collection_role_' . $collectionRole->getDisplayName()));
     }
     $this->addMultiOption(count($allCollectionRoles) + 1, 'admin_collectionroles_last_position');
 }
Ejemplo n.º 4
0
 /**
  * Returns array with information about collection roles.
  * @return array
  *
  * TODO using view in action helper is not best design
  */
 public function getCollectionRolesInfo()
 {
     $collections = array();
     $collectionRoles = Opus_CollectionRole::fetchAll();
     foreach ($collectionRoles as $collectionRole) {
         $rootCollection = $collectionRole->getRootCollection();
         if (!is_null($rootCollection)) {
             array_push($collections, array('id' => $rootCollection->getId(), 'name' => $this->view->translate('default_collection_role_' . $collectionRole->getDisplayName()), 'hasChildren' => $rootCollection->hasChildren(), 'visible' => $collectionRole->getVisible()));
         }
     }
     return $collections;
 }
Ejemplo n.º 5
0
 /**
  * Bereitet die Einstiegseite für das Zuweisen von einer Collection zu einem Dokument vor.
  * 
  * Auf der Einstiegsseite werden die CollectionRoles mit Root-Collections aufgelistet. Da ein Dokument nur einer
  * Collection zugewiesen werden kann wird die Sichtbarkeit der Root-Collection als Kriterium für die Markierung
  * als sichtbare oder unsichtbare Collection verwendet.
  * 
  * @param int $documentId
  */
 private function prepareAssignStartPage($documentId)
 {
     $collectionRoles = Opus_CollectionRole::fetchAll();
     $this->view->collections = array();
     foreach ($collectionRoles as $collectionRole) {
         $rootCollection = $collectionRole->getRootCollection();
         if (!is_null($rootCollection)) {
             array_push($this->view->collections, array('id' => $rootCollection->getId(), 'name' => $this->view->translate('default_collection_role_' . $collectionRole->getDisplayName()), 'hasChildren' => $rootCollection->hasChildren(), 'visible' => $rootCollection->getVisible()));
         }
     }
     $this->view->documentId = $documentId;
     $this->view->breadcrumb = array();
     $this->view->role_name = $collectionRole->getDisplayName();
 }
 /**
  * List all available collection role instances.
  */
 public function indexAction()
 {
     $this->view->collectionRoles = Opus_CollectionRole::fetchAll();
 }
 public function testMove()
 {
     $colRole = new Opus_CollectionRole();
     $colRole->setName('MoveTestColRole-Name');
     $colRole->setOaiName('MoveTestColRole-OaiName');
     $colRole->setDisplayFrontdoor('Number');
     $colRole->setDisplayBrowsing('Name');
     $colRole->setPosition(100);
     $this->moveTestColId = $colRole->store();
     $colRoles = Opus_CollectionRole::fetchAll();
     $colRolesCount = count($colRoles);
     $this->assertEquals($this->moveTestColId, $colRoles[$colRolesCount - 1]->getId());
     $this->assertEquals($this->collectionRoleId, $colRoles[$colRolesCount - 2]->getId());
     $model = new Admin_Model_CollectionRole($this->collectionRoleId);
     $model->move(100);
     $colRoles = Opus_CollectionRole::fetchAll();
     $colRolesCount = count($colRoles);
     // Reihenfolge ist jetzt vertauscht
     $this->assertEquals($this->collectionRoleId, $colRoles[$colRolesCount - 1]->getId());
     $this->assertEquals($this->moveTestColId, $colRoles[$colRolesCount - 2]->getId());
 }
 public function testCreateActionForEdit()
 {
     $this->useEnglish();
     $roles = Opus_CollectionRole::fetchAll();
     $role = new Opus_CollectionRole();
     $role->setName('EditTestName');
     $role->setOaiName('EditTestOaiName');
     $role->setDisplayBrowsing('Name');
     $role->setDisplayFrontdoor('Number');
     $role->setVisible(1);
     $role->setVisibleBrowsingStart(1);
     $role->setVisibleFrontdoor(0);
     $role->setVisibleOai(0);
     $role->setPosition(20);
     $roleId = $role->store();
     $post = array('oid' => $roleId, 'Name' => 'ModifiedName', 'OaiName' => 'ModifiedOaiName', 'DisplayBrowsing' => 'Number,Name', 'DisplayFrontdoor' => 'Name,Number', 'Visible' => '0', 'VisibleBrowsingStart' => '0', 'VisibleFrontdoor' => '1', 'VisibleOai' => '1', 'Position' => '19', 'Save' => 'Speichern');
     $this->getRequest()->setMethod('POST')->setPost($post);
     $this->dispatch('/admin/collectionroles/create');
     $this->assertEquals(count($roles) + 1, count(Opus_CollectionRole::fetchAll()));
     // keine neue Collection
     $role = new Opus_CollectionRole($roleId);
     $role->delete();
     $this->assertEquals('ModifiedName', $role->getName());
     $this->assertEquals('ModifiedOaiName', $role->getOaiName());
     $this->assertEquals('Number,Name', $role->getDisplayBrowsing());
     $this->assertEquals('Name,Number', $role->getDisplayFrontdoor());
     $this->assertEquals(0, $role->getVisible());
     $this->assertEquals(0, $role->getVisibleBrowsingStart());
     $this->assertEquals(1, $role->getVisibleFrontdoor());
     $this->assertEquals(1, $role->getVisibleOai());
     $this->assertEquals(19, $role->getPosition());
     $this->assertRedirectTo('/admin/collectionroles');
     $this->verifyFlashMessage('Collection role \'ModifiedName\' was edited successfully.', self::MESSAGE_LEVEL_NOTICE);
 }