Example #1
0
 /**
  * Returns true if the given collection role has at least one associated document
  * in server_state published.
  *
  * @param Opus_CollectionRole $collectionRole
  * @return bool
  */
 private function hasPublishedDocs($collectionRole)
 {
     $rootCollection = $collectionRole->getRootCollection();
     if (is_null($rootCollection)) {
         return false;
     }
     $publishedDocIDs = $rootCollection->getPublishedDocumentIds();
     return is_array($publishedDocIDs) && !empty($publishedDocIDs);
 }
 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;
 }
Example #3
0
 public function showAction()
 {
     $roleId = $this->getRequest()->getParam('role');
     $id = null;
     if (!is_null($roleId)) {
         $collectionRole = new Opus_CollectionRole($roleId);
         $rootCollection = $collectionRole->getRootCollection();
         if (is_null($rootCollection)) {
             // collection role without root collection: create a new root collection
             $rootCollection = $collectionRole->addRootCollection();
             $collectionRole->store();
         }
         $id = $rootCollection->getId();
     } else {
         $id = $this->getRequest()->getParam('id', '');
     }
     $collectionModel = null;
     try {
         $collectionModel = new Admin_Model_Collection($id);
     } catch (Application_Exception $e) {
         $this->_redirectToAndExit('index', array('failure' => $e->getMessage()), 'collectionroles');
         return;
     }
     $collection = $collectionModel->getObject();
     $this->view->breadcrumb = array_reverse($collection->getParents());
     $this->view->collections = $collection->getChildren();
     $this->view->collection_id = $collection->getId();
     $role = $collection->getRole();
     $this->view->role_id = $role->getId();
     $this->view->role_name = $role->getDisplayName();
     $this->setCollectionBreadcrumb($role);
 }
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
//
$oldOpusId = $doc->addIdentifierOpus3();
$oldOpusId->setValue(randString($counter++));
// empty URN will be automaticaly replace by new URN.