/** * Create a new PrimitiveIO object that allows for selection from an authority * list * * @param <##> * @return <##> * @access public * @since 5/1/06 */ static function createComponentForPartStructure($partStruct) { ArgumentValidator::validate($partStruct, ExtendsValidatorRule::getRule("PartStructure")); $partStructType = $partStruct->getType(); // get the datamanager data type $dataType = $partStructType->getKeyword(); // printpre($dataType); $authoritativeValues = $partStruct->getAuthoritativeValues(); if ($authoritativeValues->hasNext()) { $authZManager = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $partStruct->getRepositoryId())) { $component = new PrimitiveIO_AuthoritativeContainer(); $component->setSelectComponent(PrimitiveIOManager::createAuthoritativeComponent($dataType)); $component->setNewComponent(PrimitiveIOManager::createComponent($dataType)); } else { $component = PrimitiveIOManager::createAuthoritativeComponent($dataType); } while ($authoritativeValues->hasNext()) { $component->addOptionFromSObject($authoritativeValues->next()); } } else { // get the simple component for this data type $component = PrimitiveIOManager::createComponent($dataType); } return $component; }
/** * Returns the a string for the passed part structure corresponding to a {@link WizardComponent} that is added automatically. * * @param object WizardStep $wizard The wizard step to add components. * @param object Record $record The Record to modify. * @param object PartStructure $partStructure The partStructure to add the step for. * @return string * @access public * @since 8/30/04 */ function _addComponentForPartStructure($wizardStep, $record, $partStructure) { $partStructureId = $partStructure->getId(); $partStructureType = $partStructure->getType(); $parts = $record->getPartsByPartStructure($partStructureId); // get the display name $name = $partStructure->getDisplayName(); // get the id $id = str_replace(".", "_", $partStructureId->getIdString()); // get the datamanager data type $dataType = $partStructureType->getKeyword(); // get the correct component for this data type $component = PrimitiveIOManager::createComponent($dataType); if (!$component) { return ''; } $m = ''; if ($partStructure->isRepeatable()) { // replace $component with a wrapper. $mult = new WRepeatableComponentCollection(); $mult->setElementLayout("[[value]]"); $mult->addComponent("value", $component); $mult->setStartingNumber(0); $mult->setAddLabel(dgettext("polyphony", "Add New ") . $partStructure->getDisplayName()); $mult->setRemoveLabel(dgettext("polyphony", "Remove ") . $partStructure->getDisplayName()); $component = $mult; $m = "<table border='0'><tr><td valign='top'><b>{$name}</b>:</td><td valign='top'>[[{$id}]]</td></tr></table>"; // set our values while ($parts->hasNext()) { $part = $parts->next(); $collection = array(); $collection['value'] = $part->getValue(); $component->addValueCollection($collection); unset($collection); } } else { $m = "<b>{$name}</b>: [[{$id}]]"; // set the default value. if ($parts->hasNext()) { $part = $parts->next(); $value = $part->getValue(); $component->setValue($value); } } // add the component $wizardStep->addComponent($id, $component); return $m; /* THIS CODE IS OLD // Switch for any special partStructure types switch (TRUE) { // default Works for most part types default: $property =$step->createProperty(strval($partStructureId->getIdString()), new AlwaysTrueValidatorRule, $partStructure->isMandatory()); ob_start(); print "\n<em>".$partStructure->getDescription()."</em>\n<hr />"; print "\n<br /><strong>".$partStructure->getDisplayName()."</strong>:"; print " <input type='text'"; print " name='".$partStructureId->getIdString()."'"; print " value='[[".$partStructureId->getIdString()."]]' /> "; print " [[".$partStructureId->getIdString()."|Error]]"; if ($partStructure->isRepeatable()) { print "\n<br />[Buttons] <em>"._("Click here to save the value above.")."</em>"; print "\n<br /><hr />"; print _("Already Added:"); print "\n<table>"; print "[List]\n<tr>"; print "\n<td valign='top'>[ListButtons]<br />[ListMoveButtons]</td>"; print "\n<td style='padding-bottom: 20px'>"; print "\n\t<strong>".$partStructure->getDisplayName().":</strong>" ." [[".$partStructureId->getIdString()."]]"; print "</td>\n</tr>[/List]\n</table>"; } $step->setText(ob_get_contents()); ob_end_clean(); // If we have parts, load their values as the defaults. while ($parts->hasNext()) { $part =$parts->next(); $currentPartStructure =$part->getPartStructure(); if ($partStructureId->isEqual($currentPartStructure->getId())) { $valueObj =$part->getValue(); $property->setValue($valueObj->asString()); if ($partStructure->isRepeatable()) { $step->saveCurrentPropertiesAsNewSet(); } else { break; } } } } */ }