protected function addField($name) { switch ($name) { case 'authorizedFormOfName': $this->form->setDefault('authorizedFormOfName', $this->resource->authorizedFormOfName); $this->form->setValidator('authorizedFormOfName', new sfValidatorString()); $this->form->setWidget('authorizedFormOfName', new sfWidgetFormInput()); break; default: return parent::addField($name); } }
protected function addField($name) { switch ($name) { case 'location': case 'name': $this->form->setDefault($name, $this->resource[$name]); $this->form->setValidator($name, new sfValidatorString()); $this->form->setWidget($name, new sfWidgetFormInput()); break; case 'type': $this->form->setDefault('type', $this->context->routing->generate(null, array($this->resource->type, 'module' => 'term'))); $this->form->setValidator('type', new sfValidatorString()); $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => QubitTerm::getIndentedChildTree(QubitTerm::CONTAINER_ID, ' ', array('returnObjectInstances' => true))))); break; default: return parent::addField($name); } }
protected function addField($name) { switch ($name) { case 'containers': $this->form->setValidator('containers', new sfValidatorPass()); $this->form->setWidget('containers', new sfWidgetFormSelect(array('choices' => array(), 'multiple' => true))); break; case 'location': case 'name': $this->form->setValidator($name, new sfValidatorString()); $this->form->setWidget($name, new sfWidgetFormInput()); break; case 'type': $this->form->setValidator('type', new sfValidatorString()); $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => QubitTerm::getIndentedChildTree(QubitTerm::CONTAINER_ID, ' ', array('returnObjectInstances' => true))))); break; default: return parent::addField($name); } }
protected function addField($name) { switch ($name) { case 'content': $this->form->setDefault('content', $this->resource->content); $this->form->setValidator('content', new sfValidatorString()); $this->form->setWidget('content', new sfWidgetFormTextarea()); break; case 'slug': $this->form->setDefault('slug', $this->resource->slug); $this->form->setValidator('slug', new sfValidatorRegex(array('pattern' => '/^[^;]*$/'), array('invalid' => $this->context->i18n->__('Mustn\'t contain ";"')))); $this->form->setWidget('slug', new sfWidgetFormInput()); case 'title': $this->form->setDefault('title', $this->resource->title); $this->form->setValidator('title', new sfValidatorString()); $this->form->setWidget('title', new sfWidgetFormInput()); default: return parent::addField($name); } }
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 'entityType': $this->form->setDefault('entityType', $this->context->routing->generate(null, array($this->resource->entityType, 'module' => 'term'))); $this->form->setValidator('entityType', new sfValidatorString()); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTaxonomyTerms(QubitTaxonomy::ACTOR_ENTITY_TYPE_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('entityType', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'authorizedFormOfName': case 'corporateBodyIdentifiers': case 'datesOfExistence': case 'descriptionIdentifier': case 'institutionResponsibleIdentifier': $this->form->setDefault($name, $this->resource[$name]); $this->form->setValidator($name, new sfValidatorString()); $this->form->setWidget($name, new sfWidgetFormInput()); break; case 'functions': case 'generalContext': case 'history': case 'internalStructures': case 'legalStatus': case 'mandates': case 'places': case 'revisionHistory': case 'rules': 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 '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 '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); } }
protected function addField($name) { switch ($name) { case 'code': $this->form->setDefault('code', $this->resource->code); $this->form->setValidator('code', new sfValidatorString()); $this->form->setWidget('code', new sfWidgetFormInput()); break; case 'displayNote': case 'scopeNote': case 'sourceNote': $criteria = new Criteria(); $criteria->add(QubitNote::OBJECT_ID, $this->resource->id); switch ($name) { case 'scopeNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::SCOPE_NOTE_ID); break; case 'sourceNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::SOURCE_NOTE_ID); break; case 'displayNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::DISPLAY_NOTE_ID); break; } $value = $defaults = array(); foreach ($this[$name] = QubitNote::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, 'fieldname' => 'content'))); break; case 'name': $this->form->setDefault('name', $this->resource->name); $this->form->setValidator('name', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('This is a mandatory element.')))); $this->form->setWidget('name', new sfWidgetFormInput()); break; case 'narrowTerms': $this->form->setValidator('narrowTerms', new sfValidatorPass()); $this->form->setWidget('narrowTerms', new QubitWidgetFormInputMany(array('defaults' => array()))); break; case 'parent': $this->form->setDefault('parent', $this->context->routing->generate(null, array($this->resource->parent, 'module' => 'term'))); $this->form->setValidator('parent', new sfValidatorString()); $choices = array(); if (isset($this->resource->parent)) { $choices[$this->context->routing->generate(null, array($this->resource->parent, 'module' => 'term'))] = $this->resource->parent; } if (isset($this->request->parent)) { $this->form->setDefault('parent', $this->request->parent); $params = $this->context->routing->parse(Qubit::pathInfo($this->request->parent)); $choices[$this->request->parent] = $params['_sf_route']->resource; } $this->form->setWidget('parent', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'relatedTerms': $value = $choices = array(); foreach ($this->relations = QubitRelation::getBySubjectOrObjectId($this->resource->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)) as $item) { $choices[$value[] = $this->context->routing->generate(null, array($item->object, 'module' => 'term'))] = $item->object; } $this->form->setDefault('relatedTerms', $value); $this->form->setValidator('relatedTerms', new sfValidatorPass()); $this->form->setWidget('relatedTerms', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true))); break; case 'taxonomy': $this->form->setDefault('taxonomy', $this->context->routing->generate(null, array($this->resource->taxonomy, 'module' => 'taxonomy'))); $this->form->setValidator('taxonomy', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('This is a mandatory element.')))); $choices = array(); if (isset($this->resource->taxonomy)) { $choices[$this->context->routing->generate(null, array($this->resource->taxonomy, 'module' => 'taxonomy'))] = $this->resource->taxonomy; } if (isset($this->request->taxonomy)) { $this->form->setDefault('taxonomy', $this->request->taxonomy); $params = $this->context->routing->parse(Qubit::pathInfo($this->request->taxonomy)); $choices[$this->request->taxonomy] = $params['_sf_route']->resource; } $this->form->setWidget('taxonomy', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'useFor': $criteria = new Criteria(); $criteria->add(QubitOtherName::OBJECT_ID, $this->resource->id); $criteria->add(QubitOtherName::TYPE_ID, QubitTerm::ALTERNATIVE_LABEL_ID); $value = $defaults = array(); foreach ($this->useFor = QubitOtherName::get($criteria) as $item) { $defaults[$value[] = $item->id] = $item; } $this->form->setDefault('useFor', $value); $this->form->setValidator('useFor', new sfValidatorPass()); $this->form->setWidget('useFor', new QubitWidgetFormInputMany(array('defaults' => $defaults))); break; default: return parent::addField($name); } }