/** * If the part is repeatable, then we will build a list of all parts, * keeping track of which ones are had by all, and which ones are had * just by some. * * @param object PartStructure $partStruct * @return object WizardComponent * @access public * @since 10/26/05 */ function getRepeatablePartStructComponent($partStruct) { // Make a component for each of values $repeatableProperty = new WRepeatableComponentCollection(); $repeatableProperty->setStartingNumber(0); $repeatableProperty->setAddLabel(_("Add New ") . $partStruct->getDisplayName()); $repeatableProperty->setRemoveLabel(_("Remove ") . $partStruct->getDisplayName()); $property = $repeatableProperty->addComponent('partvalue', $this->getComponentForPartStruct($partStruct)); ob_start(); print "\n\t\t\t<div>"; print "[[partvalue]]"; print "\n\t\t\t</div>"; $repeatableProperty->setElementLayout(ob_get_contents()); ob_end_clean(); return $repeatableProperty; }
/** * 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; } } } } */ }