/**
  * Get the values submitted in the wizard and update the Record with them.
  * 
  * @param object $record
  * @param object $wizard
  * @return void
  * @access public
  * @since 10/19/04
  */
 function updateFromWizard(Record $record, Wizard $wizard)
 {
     $recordStructure = $record->getRecordStructure();
     $recordStructureId = $recordStructure->getId();
     $properties = $wizard->getAllValues();
     $values = $properties["record"];
     // Delete the old parts
     $parts = $record->getParts();
     while ($parts->hasNext()) {
         $part = $parts->next();
         $partId = $part->getId();
         $record->deletePart($partId);
     }
     $parts = $record->getParts();
     if ($parts->hasNext()) {
         print "have a part!!!";
     }
     // debug
     // Go through each of the partStructures and save any values as parts.
     $partStructures = $recordStructure->getPartStructures();
     while ($partStructures->hasNext()) {
         $partStructure = $partStructures->next();
         $partStructureId = $partStructure->getId();
         $partStructureType = $partStructure->getType();
         $valueObjClass = $partStructureType->getKeyword();
         $id = str_replace(".", "_", $partStructureId->getIdString());
         if ($partStructure->isRepeatable()) {
             // Add a part for each property
             foreach (array_keys($values[$id]) as $valueIndex) {
                 $value = $values[$id][$valueIndex]["value"];
                 $newPart = $record->createPart($partStructureId, $value);
             }
         } else {
             // Add a part for the property
             $value = $values[$id];
             $newPart = $record->createPart($partStructureId, $value);
         }
     }
 }
 /**
  * Get the values submitted in the wizard and update the Record with them.
  * 
  * @param object $record
  * @param object $wizard
  * @return void
  * @access public
  * @since 10/19/04
  */
 function updateFromWizard(Record $record, Wizard $wizard)
 {
     $properties = $wizard->getAllValues();
     $values = $properties["record"];
     printpre($properties);
     // Get all the parts
     $partIterator = $record->getParts();
     $parts = array();
     while ($partIterator->hasNext()) {
         $part = $partIterator->next();
         $partStructure = $part->getPartStructure();
         $partStructureId = $partStructure->getId();
         $parts[$partStructureId->getIdString()] = $part;
     }
     // if a new File was uploaded, store it.
     if ($values['file_upload']['tmp_name'] && $values['file_upload']['name']) {
         $name = $values['file_upload']['name'];
         $tmpName = $values['file_upload']['tmp_name'];
         $mimeType = $values['file_upload']['type'];
         // If we weren't passed a mime type or were passed the generic
         // application/octet-stream type, see if we can figure out the
         // type.
         if (!$mimeType || $mimeType == 'application/octet-stream') {
             $mime = Services::getService("MIME");
             $mimeType = $mime->getMimeTypeForFileName($name);
         }
         $parts['FILE_DATA']->updateValue(file_get_contents($tmpName));
         $parts['FILE_NAME']->updateValue($name);
         $parts['MIME_TYPE']->updateValue($mimeType);
     }
     // If we've uploaded a thumbnail, safe it.
     if ($values['thumbnail_upload']['tmp_name'] && $values['thumbnail_upload']['name']) {
         $name = $values['thumbnail_upload']['name'];
         $tmpName = $values['thumbnail_upload']['tmp_name'];
         $mimeType = $values['thumbnail_upload']['type'];
         // If we weren't passed a mime type or were passed the generic
         // application/octet-stream type, see if we can figure out the
         // type.
         if (!$mimeType || $mimeType == 'application/octet-stream') {
             $mime = Services::getService("MIME");
             $mimeType = $mime->getMimeTypeForFileName($name);
         }
         $parts['THUMBNAIL_DATA']->updateValue(file_get_contents($tmpName));
         $parts['THUMBNAIL_MIME_TYPE']->updateValue($mimeType);
     } else {
         if ($values['file_upload']['tmp_name'] && $values['file_upload']['name']) {
             $imageProcessor = Services::getService("ImageProcessor");
             // If our image format is supported by the image processor,
             // generate a thumbnail.
             if ($imageProcessor->isFormatSupported($mimeType)) {
                 $parts['THUMBNAIL_DATA']->updateValue($imageProcessor->generateThumbnailData($mimeType, file_get_contents($tmpName)));
                 $parts['THUMBNAIL_MIME_TYPE']->updateValue($imageProcessor->getThumbnailFormat());
             } else {
                 $parts['THUMBNAIL_DATA']->updateValue("");
                 $parts['THUMBNAIL_MIME_TYPE']->updateValue("NULL");
             }
         }
     }
     // if the "use custom" box was checked store the name.
     if ($values['use_custom_filename']) {
         $parts['FILE_NAME']->updateValue($values['file_name']);
     }
     // if the "use custom" box was checked store the mime type.
     if ($values['use_custom_type']) {
         $parts['MIME_TYPE']->updateValue($values['mime_type']);
     }
     // if the "use custom" box was checked store the height.
     if ($values['use_custom_height'] && preg_match("/^([0-9]+)px\$/", $values['height'], $matches)) {
         $dimArray = $parts['DIMENSIONS']->getValue();
         $dimArray[1] = $matches[1];
         print "Setting DIMENSIONS to:";
         printpre($dimArray);
         $parts['DIMENSIONS']->updateValue($dimArray);
     }
     unset($dimArray, $matches);
     // if the "use custom" box was checked store the width.
     if ($values['use_custom_width'] && preg_match("/^([0-9]+)px\$/", $values['width'], $matches)) {
         $dimArray = $parts['DIMENSIONS']->getValue();
         $dimArray[0] = $matches[1];
         print "Setting DIMENSIONS to:";
         printpre($dimArray);
         $parts['DIMENSIONS']->updateValue($dimArray);
     }
     unset($dimArray, $matches);
     // if the "use custom" box was checked store the height.
     if ($values['use_custom_thumbnail_height'] && preg_match("/^([0-9]+)px\$/", $values['thumbnail_height'], $matches)) {
         $dimArray = $parts['THUMBNAIL_DIMENSIONS']->getValue();
         $dimArray[1] = $matches[1];
         print "Setting THUMBNAIL_DIMENSIONS to:";
         printpre($dimArray);
         $parts['THUMBNAIL_DIMENSIONS']->updateValue($dimArray);
     }
     unset($dimArray, $matches);
     // if the "use custom" box was checked store the width.
     if ($values['use_custom_thumbnail_width'] && preg_match("/^([0-9]+)px\$/", $values['thumbnail_width'], $matches)) {
         $dimArray = $parts['THUMBNAIL_DIMENSIONS']->getValue();
         $dimArray[0] = $matches[1];
         print "Setting THUMBNAIL_DIMENSIONS to:";
         printpre($dimArray);
         $parts['THUMBNAIL_DIMENSIONS']->updateValue($dimArray);
     }
     unset($dimArray, $matches);
 }