Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 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;
 }