protected function addField($name)
 {
     switch ($name) {
         case 'type':
             $this->form->setValidator('type', new sfValidatorString(array('required' => true)));
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACTOR_RELATION_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         default:
             return parent::addField($name);
     }
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     $this->resource = $this->getRoute()->resource;
     // Check that object exists and that it is not the root
     if (!isset($this->resource) || !isset($this->resource->parent)) {
         $this->forward404();
     }
     // Check user authorization
     if (!QubitAcl::check($this->resource, 'update')) {
         QubitAcl::forwardUnauthorized();
     }
     // Add javascript libraries
     $this->response->addJavaScript('/vendor/yui/logger/logger', 'last');
     $this->response->addJavaScript('/vendor/yui/uploader/uploader-min', 'last');
     $this->response->addJavaScript('multiFileUpload', 'last');
     // Get max upload size limits
     $this->maxUploadSize = QubitDigitalObject::getMaxUploadSize();
     // Paths for uploader javascript
     $this->uploadSwfPath = "{$this->request->getRelativeUrlRoot()}/vendor/yui/uploader/assets/uploader.swf";
     $this->uploadResponsePath = "{$this->context->routing->generate(null, array('module' => 'digitalobject', 'action' => 'upload'))}?" . http_build_query(array(session_name() => session_id()));
     $this->uploadTmpDir = "{$this->request->getRelativeUrlRoot()}/uploads/tmp";
     // Build form
     $this->form->setValidator('files', new QubitValidatorCountable(array('required' => true)));
     $this->form->setValidator('title', new sfValidatorString());
     $this->form->setWidget('title', new sfWidgetFormInput());
     $this->form->setDefault('title', 'image %dd%');
     $this->form->setValidator('levelOfDescription', new sfValidatorString());
     $choices = array();
     $choices[null] = null;
     foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID) as $item) {
         $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
     }
     $this->form->setWidget('levelOfDescription', new sfWidgetFormSelect(array('choices' => $choices)));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters(), $request->getFiles());
         if ($this->form->isValid()) {
             $this->processForm();
         }
     }
 }
 /**
  * Add fields to form
  *
  * @param $name string
  * @return void
  */
 protected function addField($name)
 {
     switch ($name) {
         case 'type':
             $this->form->setDefault('type', $this->context->routing->generate(null, array($this->resource->type, 'module' => 'term')));
             $this->form->setValidator('type', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::FUNCTION_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'maintenanceNotes':
             $this->form->setDefault('maintenanceNotes', $this->isdf->maintenanceNotes);
             $this->form->setValidator('maintenanceNotes', new sfValidatorString());
             $this->form->setWidget('maintenanceNotes', new sfWidgetFormTextarea());
             break;
         case 'authorizedFormOfName':
         case 'classification':
         case 'dates':
         case 'descriptionIdentifier':
         case 'institutionIdentifier':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'history':
         case 'description':
         case 'legislation':
         case 'rules':
         case 'revisionHistory':
         case 'sources':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         default:
             return parent::addField($name);
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'date':
             $this->form->setValidator('date', new sfValidatorString());
             $this->form->setWidget('date', new sfWidgetFormInput());
             $this->form->getWidgetSchema()->date->setHelp($this->context->i18n->__('Enter free-text information, including qualifiers or typographical symbols to express uncertainty, to change the way the date displays. If this field is not used, the default will be the start and end years only.'));
             break;
         case 'endDate':
             $this->form->setValidator('endDate', new sfValidatorString());
             $this->form->setWidget('endDate', new sfWidgetFormInput());
             $this->form->getWidgetSchema()->endDate->setHelp($this->context->i18n->__('Enter the end year. Do not use any qualifiers or typographical symbols to express uncertainty. If the start and end years are the same, enter data only in the "Date" field and leave the "End date" blank.'));
             $this->form->getWidgetSchema()->endDate->setLabel($this->context->i18n->__('End'));
             break;
         case 'startDate':
             $this->form->setValidator('startDate', new sfValidatorString());
             $this->form->setWidget('startDate', new sfWidgetFormInput());
             $this->form->getWidgetSchema()->startDate->setHelp($this->context->i18n->__('Enter the start year. Do not use any qualifiers or typographical symbols to express uncertainty.'));
             $this->form->getWidgetSchema()->startDate->setLabel($this->context->i18n->__('Start'));
             break;
         case 'type':
             // Event types, Dublin Core is restricted
             $eventTypes = QubitTaxonomy::getTermsById(QubitTaxonomy::EVENT_TYPE_ID);
             if ('sfDcPlugin' == $this->request->module) {
                 $eventTypes = sfDcPlugin::eventTypes();
             }
             $choices = array();
             foreach ($eventTypes as $item) {
                 // Default event type is creation
                 if (QubitTerm::CREATION_ID == $item->id) {
                     $this->form->setDefault('type', $this->context->routing->generate(null, array($item, 'module' => 'term')));
                 }
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item->__toString();
             }
             $this->form->setValidator('type', new sfValidatorString());
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'type':
             $criteria = new Criteria();
             $this->resource->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
             QubitObjectTermRelation::addJoinTermCriteria($criteria);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MODS_RESOURCE_TYPE_ID);
             $value = array();
             foreach ($this->relations = QubitObjectTermRelation::get($criteria) as $item) {
                 $value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'));
             }
             $this->form->setDefault('type', $value);
             $this->form->setValidator('type', new sfValidatorPass());
             $choices = array();
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::MODS_RESOURCE_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         default:
             return parent::addField($name);
     }
 }
 /**
  * Return a list of all Relation Type terms
  *
  * @param array $options  option array to pass to Qubit Query object
  * @return QubitQuery object
  */
 public static function getRelationTypes($options = array())
 {
     return QubitTaxonomy::getTermsById(QubitTaxonomy::RELATION_TYPE_ID, $options);
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'type':
             $criteria = new Criteria();
             $criteria = $this->resource->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
             $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::REPOSITORY_TYPE_ID);
             $value = array();
             foreach ($this->relations = QubitObjectTermRelation::get($criteria) as $item) {
                 $value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'));
             }
             $this->form->setDefault('type', $value);
             $this->form->setValidator('type', new sfValidatorPass());
             $choices = array();
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::REPOSITORY_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item->__toString();
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         case 'descDetail':
         case 'descStatus':
             $this->form->setDefault($name, $this->context->routing->generate(null, array($this->resource[$name], 'module' => 'term')));
             $this->form->setValidator($name, new sfValidatorString());
             switch ($name) {
                 case 'descDetail':
                     $id = QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID;
                     break;
                 case 'descStatus':
                     $id = QubitTaxonomy::DESCRIPTION_STATUS_ID;
                     break;
             }
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById($id) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'identifier':
         case 'authorizedFormOfName':
         case 'descIdentifier':
         case 'descInstitutionIdentifier':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'history':
         case 'geoculturalContext':
         case 'mandates':
         case 'internalStructures':
         case 'collectingPolicies':
         case 'buildings':
         case 'holdings':
         case 'findingAids':
         case 'openingTimes':
         case 'accessConditions':
         case 'disabledAccess':
         case 'researchServices':
         case 'reproductionServices':
         case 'publicFacilities':
         case 'descRules':
         case 'descRevisionHistory':
         case 'descSources':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         default:
             return parent::addField($name);
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'alternateTitle':
         case 'edition':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'editionStatementOfResponsibility':
         case 'issuingJurisdictionAndDenomination':
         case 'noteOnPublishersSeries':
         case 'numberingWithinPublishersSeries':
         case 'otherTitleInformation':
         case 'otherTitleInformationOfPublishersSeries':
         case 'parallelTitleOfPublishersSeries':
         case 'standardNumber':
         case 'statementOfCoordinates':
         case 'statementOfProjection':
         case 'statementOfResponsibilityRelatingToPublishersSeries':
         case 'statementOfScaleArchitectural':
         case 'statementOfScaleCartographic':
         case 'titleStatementOfResponsibility':
         case 'titleProperOfPublishersSeries':
             $this->form->setDefault($name, $this->rad[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'type':
             $criteria = new Criteria();
             $this->resource->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
             QubitObjectTermRelation::addJoinTermCriteria($criteria);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MATERIAL_TYPE_ID);
             $value = array();
             foreach ($this->relations = QubitObjectTermRelation::get($criteria) as $item) {
                 $value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'));
             }
             $this->form->setDefault('type', $value);
             $this->form->setValidator('type', new sfValidatorPass());
             $choices = array();
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::MATERIAL_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         default:
             return parent::addField($name);
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'descriptionDetail':
             $this->form->setDefault('descriptionDetail', $this->context->routing->generate(null, array($this->resource->descriptionDetail, 'module' => 'term')));
             $this->form->setValidator('descriptionDetail', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('descriptionDetail', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'descriptionStatus':
             $this->form->setDefault('descriptionStatus', $this->context->routing->generate(null, array($this->resource->descriptionStatus, 'module' => 'term')));
             $this->form->setValidator('descriptionStatus', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_STATUS_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('descriptionStatus', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'language':
         case 'languageOfDescription':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorI18nChoiceLanguage(array('multiple' => true)));
             $this->form->setWidget($name, new sfWidgetFormI18nChoiceLanguage(array('culture' => $this->context->user->getCulture(), 'multiple' => true)));
             break;
         case 'otherName':
         case 'parallelName':
         case 'standardizedName':
             $criteria = new Criteria();
             $criteria = $this->resource->addOtherNamesCriteria($criteria);
             switch ($name) {
                 case 'otherName':
                     $criteria->add(QubitOtherName::TYPE_ID, QubitTerm::OTHER_FORM_OF_NAME_ID);
                     break;
                 case 'parallelName':
                     $criteria->add(QubitOtherName::TYPE_ID, QubitTerm::PARALLEL_FORM_OF_NAME_ID);
                     break;
                 case 'standardizedName':
                     $criteria->add(QubitOtherName::TYPE_ID, QubitTerm::STANDARDIZED_FORM_OF_NAME_ID);
                     break;
             }
             $value = $defaults = array();
             foreach ($this[$name] = QubitOtherName::get($criteria) as $item) {
                 $defaults[$value[] = $item->id] = $item;
             }
             $this->form->setDefault($name, $value);
             $this->form->setValidator($name, new sfValidatorPass());
             $this->form->setWidget($name, new QubitWidgetFormInputMany(array('defaults' => $defaults)));
             break;
         case 'script':
         case 'scriptOfDescription':
             $this->form->setDefault($name, $this->resource[$name]);
             $c = sfCultureInfo::getInstance($this->context->user->getCulture());
             $this->form->setValidator($name, new sfValidatorChoice(array('choices' => array_keys($c->getScripts()), 'multiple' => true)));
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $c->getScripts(), 'multiple' => true)));
             break;
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'levelOfDescription':
             $this->form->setDefault('levelOfDescription', $this->context->routing->generate(null, array($this->resource->levelOfDescription, 'module' => 'term')));
             $this->form->setValidator('levelOfDescription', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTaxonomyTerms(QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('levelOfDescription', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'publicationStatus':
             $publicationStatus = $this->resource->getStatus(array('typeId' => QubitTerm::STATUS_TYPE_PUBLICATION_ID));
             if (isset($publicationStatus)) {
                 $this->form->setDefault('publicationStatus', $publicationStatus->statusId);
             } else {
                 $this->form->setDefault('publicationStatus', sfConfig::get('app_defaultPubStatus'));
             }
             $this->form->setValidator('publicationStatus', new sfValidatorString());
             if (isset($this->resource) && QubitAcl::check($this->resource, 'publish') || !isset($this->resurce) && QubitAcl::check($this->parent, 'publish')) {
                 $choices = array();
                 foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::PUBLICATION_STATUS_ID) as $item) {
                     $choices[$item->id] = $item;
                 }
                 $this->form->setWidget('publicationStatus', new sfWidgetFormSelect(array('choices' => $choices)));
             } else {
                 $choices = array();
                 if (isset($publicationStatus)) {
                     $choices = array($publicationStatus->id => $publicationStatus->status->__toString());
                 } else {
                     $status = QubitTerm::getById(sfConfig::get('app_defaultPubStatus'));
                     $choices = array($status->id => $status->__toString());
                 }
                 // Disable widget if user doesn't have "publish" permission
                 $this->form->setWidget('publicationStatus', new sfWidgetFormSelect(array('choices' => $choices), array('disabled' => true)));
             }
             break;
         case 'repository':
             $this->form->setDefault('repository', $this->context->routing->generate(null, array($this->resource->repository, 'module' => 'repository')));
             $this->form->setValidator('repository', new sfValidatorString());
             $choices = array();
             if (isset($this->resource->repository)) {
                 $choices[$this->context->routing->generate(null, array($this->resource->repository, 'module' => 'repository'))] = $this->resource->repository;
             }
             $this->form->setWidget('repository', new sfWidgetFormSelect(array('choices' => $choices)));
             if (isset($this->getRoute()->resource)) {
                 $this->repoAcParams = array('module' => 'repository', 'action' => 'autocomplete', 'aclAction' => 'update');
             } else {
                 $this->repoAcParams = array('module' => 'repository', 'action' => 'autocomplete', 'aclAction' => 'create');
             }
             break;
         case 'accessConditions':
         case 'accruals':
         case 'acquisition':
         case 'archivalHistory':
         case 'arrangement':
         case 'extentAndMedium':
         case 'findingAids':
         case 'locationOfCopies':
         case 'locationOfOriginals':
         case 'physicalCharacteristics':
         case 'relatedUnitsOfDescription':
         case 'reproductionConditions':
         case 'revisionHistory':
         case 'rules':
         case 'scopeAndContent':
         case 'sources':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         case 'descriptionIdentifier':
         case 'identifier':
         case 'institutionResponsibleIdentifier':
         case 'title':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'subjectAccessPoints':
         case 'placeAccessPoints':
             $criteria = new Criteria();
             $criteria->add(QubitObjectTermRelation::OBJECT_ID, $this->resource->id);
             $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
             switch ($name) {
                 case 'subjectAccessPoints':
                     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
                     break;
                 case 'placeAccessPoints':
                     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
                     break;
             }
             $value = $choices = array();
             foreach ($this[$name] = QubitObjectTermRelation::get($criteria) as $item) {
                 $choices[$value[] = $this->context->routing->generate(null, array($item->term, 'module' => 'term'))] = $item->term;
             }
             $this->form->setDefault($name, $value);
             $this->form->setValidator($name, new sfValidatorPass());
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         case 'nameAccessPoints':
             $criteria = new Criteria();
             $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
             $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);
             $value = $choices = array();
             foreach ($this->nameAccessPoints = QubitRelation::get($criteria) as $item) {
                 $choices[$value[] = $this->context->routing->generate(null, array($item->object, 'module' => 'actor'))] = $item->object;
             }
             $this->form->setDefault($name, $value);
             $this->form->setValidator($name, new sfValidatorPass());
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         default:
             return parent::addField($name);
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'endDate':
             $this->form->setValidator('endDate', new sfValidatorString());
             $this->form->setWidget('endDate', new sfWidgetFormInput());
             $this->form->getWidgetSchema()->endDate->setLabel($this->context->i18n->__('End'));
             break;
         case 'startDate':
             $dt = new DateTime();
             $this->form->setDefault('startDate', $dt->format('Y-m-d'));
             $this->form->setValidator('startDate', new sfValidatorString());
             $this->form->setWidget('startDate', new sfWidgetFormInput());
             $this->form->getWidgetSchema()->startDate->setLabel($this->context->i18n->__('Start'));
             break;
         case 'restriction':
             $choices[1] = $this->context->i18n->__('Allow');
             $choices[0] = $this->context->i18n->__('Disallow');
             $this->form->setValidator('restriction', new sfValidatorBoolean());
             $this->form->setWidget('restriction', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'statuteDeterminationDate':
         case 'copyrightStatusDate':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'act':
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::RIGHT_ACT_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item->__toString();
             }
             $this->form->setValidator('act', new sfValidatorString());
             $this->form->setWidget('act', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'basis':
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::RIGHT_BASIS_ID) as $item) {
                 if (QubitTerm::RIGHT_BASIS_POLICY_ID == $item->id) {
                     $this->form->setDefault('basis', $this->context->routing->generate(null, array($item, 'module' => 'term')));
                 }
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item->__toString();
             }
             $this->form->setValidator('basis', new sfValidatorString());
             $this->form->setWidget('basis', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'copyrightStatus':
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::COPYRIGHT_STATUS_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item->__toString();
             }
             $this->form->setValidator('copyrightStatus', new sfValidatorString());
             $this->form->setWidget('copyrightStatus', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'rightsHolder':
             $this->form->setValidator('rightsHolder', new sfValidatorString());
             $this->form->setWidget('rightsHolder', new sfWidgetFormSelect(array('choices' => array())));
             break;
         case 'copyrightJurisdiction':
             $this->form->setValidator('copyrightJurisdiction', new sfValidatorI18nChoiceCountry());
             $this->form->setWidget('copyrightJurisdiction', new sfWidgetFormI18nChoiceCountry(array('add_empty' => true, 'culture' => $this->context->user->getCulture())));
             break;
         case 'copyrightNote':
         case 'licenseNote':
         case 'statuteJurisdiction':
         case 'statuteCitation':
         case 'statuteNote':
         case 'rightsNote':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         case 'licenseIdentifier':
         case 'licenseTerms':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
     }
 }
 protected function processDmdSec($xml, $informationObject = null)
 {
     if (!isset($informationObject)) {
         $informationObject = new QubitInformationObject();
     }
     foreach ($xml->xpath('.//mdWrap/xmlData/dublincore/*') as $item) {
         $value = $item->__toString();
         if (0 == strlen(trim($value))) {
             continue;
         }
         switch (str_replace('dcterms:', '', $item->getName())) {
             case 'title':
                 $informationObject->title = $value;
                 break;
             case 'creator':
                 $informationObject->setActorByName($value, array('event_type_id' => QubitTerm::CREATION_ID));
                 break;
             case 'coverage':
                 $informationObject->setAccessPointByName($value, array('type_id' => QubitTaxonomy::PLACE_ID));
                 break;
             case 'subject':
                 $informationObject->setAccessPointByName($value, array('type_id' => QubitTaxonomy::SUBJECT_ID));
                 break;
             case 'description':
                 $informationObject->scopeAndContent = $value;
                 break;
             case 'publisher':
                 $informationObject->setActorByName($value, array('event_type_id' => QubitTerm::PUBLICATION_ID));
                 break;
             case 'contributor':
                 $informationObject->setActorByName($value, array('event_type_id' => QubitTerm::CONTRIBUTION_ID));
                 break;
             case 'date':
                 $informationObject->setDates($value);
                 break;
             case 'type':
                 foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::DC_TYPE_ID) as $item) {
                     if (strtolower($value) == strtolower($item->__toString())) {
                         $relation = new QubitObjectTermRelation();
                         $relation->term = $item;
                         $informationObject->objectTermRelationsRelatedByobjectId[] = $relation;
                         break;
                     }
                 }
                 break;
             case 'format':
                 $informationObject->extentAndMedium = $value;
                 break;
             case 'identifier':
                 $informationObject->identifier = $value;
                 break;
             case 'source':
                 $informationObject->locationOfOriginals = $value;
                 break;
             case 'language':
                 $informationObject->language = array($value);
                 break;
             case 'isPartOf':
                 // TODO: ?
                 break;
             case 'rights':
                 $informationObject->accessConditions = $value;
                 break;
         }
     }
     return $informationObject;
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'acquisitionType':
             $this->form->setDefault('acquisitionType', $this->context->routing->generate(null, array($this->resource->acquisitionType, 'module' => 'term')));
             $this->form->setValidator('acquisitionType', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_ACQUISITION_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('acquisitionType', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'processingPriority':
             $this->form->setDefault('processingPriority', $this->context->routing->generate(null, array($this->resource->processingPriority, 'module' => 'term')));
             $this->form->setValidator('processingPriority', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_PROCESSING_PRIORITY_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('processingPriority', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'processingStatus':
             $this->form->setDefault('processingStatus', $this->context->routing->generate(null, array($this->resource->processingStatus, 'module' => 'term')));
             $this->form->setValidator('processingStatus', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_PROCESSING_STATUS_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('processingStatus', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'resourceType':
             $this->form->setDefault('resourceType', $this->context->routing->generate(null, array($this->resource->resourceType, 'module' => 'term')));
             $this->form->setValidator('resourceType', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_RESOURCE_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('resourceType', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'creators':
             $value = $choices = array();
             foreach ($this->creators = QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::CREATION_ID)) as $item) {
                 $choices[$value[] = $this->context->routing->generate(null, array($item->subject, 'module' => 'actor'))] = $item->subject;
             }
             $this->form->setDefault('creators', $value);
             $this->form->setValidator('creators', new sfValidatorPass());
             $this->form->setWidget('creators', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         case 'date':
             $this->form->setDefault('date', Qubit::renderDate($this->resource['date']));
             if (!isset($this->resource->id)) {
                 $dt = new DateTime();
                 $this->form->setDefault('date', $dt->format('Y-m-d'));
             }
             $this->form->setValidator('date', new sfValidatorString());
             $this->form->setWidget('date', new sfWidgetFormInput());
             break;
         case 'identifier':
             $this->form->setDefault('identifier', $this->resource['identifier']);
             if (!isset($this->resource->id)) {
                 $dt = new DateTime();
                 $this->form->setDefault('identifier', QubitAccession::generateAccessionIdentifier());
             }
             $this->form->setValidator('identifier', new sfValidatorString());
             $this->form->setWidget('identifier', new sfWidgetFormInput(array(), array('disabled' => 'disabled')));
             break;
         case 'receivedExtentUnits':
         case 'title':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'appraisal':
         case 'archivalHistory':
         case 'locationInformation':
         case 'physicalCharacteristics':
         case 'processingNotes':
         case 'scopeAndContent':
         case 'sourceOfAcquisition':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         default:
             return parent::addField($name);
     }
 }