Author: jablko
Date: Tue Aug 11 13:39:19 2009
New Revision: 3008
Log:
Move fields shared by multiple actions to base class
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Tue Aug 11 13:02:45 2009 (r3007)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Tue Aug 11 13:39:19 2009 (r3008)
@@ -158,8 +158,41 @@
}
}
+ protected function processField($field)
+ {
+ switch ($field->getName())
+ {
+ case 'language':
+ case 'languageOfDescription':
+ case 'script':
+ case 'scriptOfDescription':
+
+ if (!isset($this[$field->getName()]))
+ {
+ $this[$field->getName()] = new QubitProperty;
+ $this[$field->getName()]->name = $fiel->getName();
+ $this->informationObject->propertys[] = $this[$field->getName()];
+ }
+
+ $this[$field->getName()]->__set('value',
serialize($this->form->getValue($field->getName())), array('sourceCulture' =>
true));
+
+ break;
+
+ default:
+ $this->informationObject[$field->getName()] =
$this->form->getValue($field->getName());
+ }
+ }
+
protected function processForm()
{
+ foreach ($this->form as $field)
+ {
+ if (isset($this->request[$field->getName()]))
+ {
+ $this->processField($field);
+ }
+ }
+
// set the informationObject's attributes
$this->informationObject->setId($this->getRequestParameter('id'));
$this->updateInformationObjectAttributes();
Modified:
trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
Tue Aug 11 13:02:45 2009 (r3007)
+++ trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
Tue Aug 11 13:39:19 2009 (r3008)
@@ -100,77 +100,56 @@
$this->dcRelation =
$this->informationObject->getPropertyByName('information_object_relation',
array('scope'=>'dc'));
}
- protected function processForm()
+ protected function processField($field)
{
- foreach ($this->form as $field)
+ switch ($field->getName())
{
- if (isset($this->request[$field->getName()]))
- {
- switch ($field->getName())
+ case 'relation':
+
+ if (!isset($this->relation))
{
- case 'language':
+ $this->relation = new QubitProperty;
+ $this->relation->name = 'relation';
+ $this->relation->scope = 'dc';
+ $this->informationObject->propertys[] = $this->relation;
+ }
+
+ $this->relation->value = serialize($this->form->getValue('relation'));
- if (!isset($this->language))
- {
- $this->language = new QubitProperty;
- $this->language->name = 'language';
- $this->informationObject->propertys[] = $this->language;
- }
-
- $this->language->__set('value',
serialize($this->form->getValue('language')), array('sourceCulture' => true));
-
- break;
-
- case 'relation':
-
- if (!isset($this->relation))
- {
- $this->relation = new QubitProperty;
- $this->relation->name = 'relation';
- $this->relation->scope = 'dc';
- $this->informationObject->propertys[] = $this->relation;
- }
-
- $this->relation->value =
serialize($this->form->getValue('relation'));
-
- break;
-
- case 'typeIds':
- $filtered = $flipped =
array_flip($this->form->getValue('typeIds'));
-
- $criteria = new Criteria;
-
$this->informationObject->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
- QubitTermRelation::addJoinTermCriteria($criteria);
- $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::DC_TYPE_ID);
-
- foreach (QubitObjectTermRelation::get($criteria) as $relation)
- {
- if (isset($flipped[$relation->term->id]))
- {
- unset($filtered[$relation->term->id]);
- }
- else
- {
- $relation->delete();
- }
- }
-
- foreach ($filtered as $id => $key)
- {
- $relation = new QubitObjectTermRelation;
- $relation->termId = $id;
+ break;
- $this->informationObject->objectTermRelationsRelatedByObjectId[]
= $relation;
- }
+ case 'typeIds':
+ $filtered = $flipped = array_flip($this->form->getValue('typeIds'));
- break;
+ $criteria = new Criteria;
+
$this->informationObject->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
+ QubitTermRelation::addJoinTermCriteria($criteria);
+ $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::DC_TYPE_ID);
- default:
- $this->informationObject[$field->getName()] =
$this->form->getValue($field->getName());
+ foreach (QubitObjectTermRelation::get($criteria) as $relation)
+ {
+ if (isset($flipped[$relation->term->id]))
+ {
+ unset($filtered[$relation->term->id]);
+ }
+ else
+ {
+ $relation->delete();
+ }
}
- }
- }
- parent::processForm();
+ foreach ($filtered as $id => $key)
+ {
+ $relation = new QubitObjectTermRelation;
+ $relation->termId = $id;
+
+ $this->informationObject->objectTermRelationsRelatedByObjectId[] =
$relation;
+ }
+
+ break;
+
+ default:
+ parent::processField($field);
+ }
}
}
Modified:
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Tue Aug 11 13:02:45 2009 (r3007)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Tue Aug 11 13:39:19 2009 (r3008)
@@ -106,16 +106,16 @@
$criteria = new Criteria;
$this->informationObject->addPropertysCriteria($criteria);
- $criteria->add(QubitProperty::NAME, 'languageOfMaterial');
+ $criteria->add(QubitProperty::NAME, 'language');
if (1 == count($query = QubitProperty::get($criteria)))
{
- $this->languageOfMaterial = $query[0];
- $this->form->setDefault('languageOfMaterial',
unserialize($this->languageOfMaterial->__get('value', array('sourceCulture' =>
true))));
+ $this->language = $query[0];
+ $this->form->setDefault('language',
unserialize($this->language->__get('value', array('sourceCulture' => true))));
}
- $this->form->setValidator('languageOfMaterial', new
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
- $this->form->setWidget('languageOfMaterial', new
sfWidgetFormI18nSelectLanguage(array('culture' =>
$this->context->user->getCulture(), 'multiple' => true)));
+ $this->form->setValidator('language', new
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
+ $this->form->setWidget('language', new
sfWidgetFormI18nSelectLanguage(array('culture' =>
$this->context->user->getCulture(), 'multiple' => true)));
$this->form->setDefault('descriptionDetailId',
$this->informationObject->descriptionDetail->id);
$this->form->setValidator('descriptionDetailId', new sfValidatorInteger);
@@ -190,18 +190,18 @@
$criteria = new Criteria;
$this->informationObject->addPropertysCriteria($criteria);
- $criteria->add(QubitProperty::NAME, 'scriptOfMaterial');
+ $criteria->add(QubitProperty::NAME, 'script');
if (1 == count($query = QubitProperty::get($criteria)))
{
- $this->scriptOfMaterial = $query[0];
- $this->form->setDefault('scriptOfMaterial',
unserialize($this->scriptOfMaterial->__get('value', array('sourceCulture' =>
true))));
+ $this->script = $query[0];
+ $this->form->setDefault('script',
unserialize($this->script->__get('value', array('sourceCulture' => true))));
}
- $this->form->setValidator('scriptOfMaterial', new sfValidatorPass);
+ $this->form->setValidator('script', new sfValidatorPass);
$c = new sfCultureInfo($this->context->user->getCulture());
- $this->form->setWidget('scriptOfMaterial', new
sfWidgetFormSelect(array('choices' => $c->getScripts(), 'multiple' => true)));
+ $this->form->setWidget('script', new sfWidgetFormSelect(array('choices' =>
$c->getScripts(), 'multiple' => true)));
$this->form->setDefault('sources', $this->informationObject->sources);
$this->form->setValidator('sources', new sfValidatorString);
@@ -238,68 +238,44 @@
$this->publicationNote =
$this->informationObject->getNotesByType(array('noteTypeId' =>
QubitTerm::PUBLICATION_NOTE_ID));
}
- protected function processForm()
+ protected function processField($field)
{
- foreach ($this->form as $field)
+ switch ($field->getName())
{
- if (isset($this->request[$field->getName()]))
- {
- switch ($field->getName())
- {
- case 'creatorIds':
- $filtered = $flipped =
array_flip($this->form->getValue('creatorIds'));
+ case 'creatorIds':
+ $filtered = $flipped = array_flip($this->form->getValue('creatorIds'));
- $criteria = new Criteria;
- $this->informationObject->addEventsCriteria($criteria);
- $criteria->add(QubitEvent::ACTOR_ID, null, Criteria::ISNOTNULL);
- $criteria->add(QubitEvent::TYPE_ID, QubitTerm::CREATION_ID);
-
- foreach (QubitEvent::get($criteria) as $event)
- {
- if (isset($flipped[$event->actor->id]))
- {
- unset($filtered[$event->actor->id]);
- }
- else
- {
- $event->delete();
- }
- }
-
- foreach ($filtered as $id => $key)
- {
- $event = new QubitEvent;
- $event->actorId = $id;
- $event->typeId = QubitTerm::CREATION_ID;
-
- $this->informationObject->events[] = $event;
- }
-
- break;
-
- case 'languageOfDescription':
- case 'languageOfMaterial':
- case 'scriptOfDescription':
- case 'scriptOfMaterial':
-
- if (!isset($this[$field->getName()]))
- {
- $this[$field->getName()] = new QubitProperty;
- $this[$field->getName()]->name = $field->getName();
- $this->informationObject->propertys[] = $this[$field->getName()];
- }
+ $criteria = new Criteria;
+ $this->informationObject->addEventsCriteria($criteria);
+ $criteria->add(QubitEvent::ACTOR_ID, null, Criteria::ISNOTNULL);
+ $criteria->add(QubitEvent::TYPE_ID, QubitTerm::CREATION_ID);
- $this[$field->getName()]->__set('value',
serialize($this->form->getValue($field->getName())), array('sourceCulture' =>
true));
+ foreach (QubitEvent::get($criteria) as $event)
+ {
+ if (isset($flipped[$event->actor->id]))
+ {
+ unset($filtered[$event->actor->id]);
+ }
+ else
+ {
+ $event->delete();
+ }
+ }
- break;
+ foreach ($filtered as $id => $key)
+ {
+ $event = new QubitEvent;
+ $event->actorId = $id;
+ $event->typeId = QubitTerm::CREATION_ID;
- default:
- $this->informationObject[$field->getName()] =
$this->form->getValue($field->getName());
+ $this->informationObject->events[] = $event;
}
- }
- }
- return parent::processForm();
+ break;
+
+ default:
+ parent::processField($field);
+ }
}
/**
Modified:
trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
Tue Aug 11 13:02:45 2009 (r3007)
+++ trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
Tue Aug 11 13:39:19 2009 (r3008)
@@ -70,63 +70,42 @@
parent::execute($request);
}
- protected function processForm()
+ protected function processField($field)
{
- foreach ($this->form as $field)
+ switch ($field->getName())
{
- if (isset($this->request[$field->getName()]))
- {
- switch ($field->getName())
- {
- case 'language':
+ case 'typeIds':
+ $filtered = $flipped = array_flip($this->form->getValue('typeIds'));
- if (!isset($this->language))
- {
- $this->language = new QubitProperty;
- $this->language->name = 'language';
- $this->informationObject->propertys[] = $this->language;
- }
-
- $this->language->__set('value',
serialize($this->form->getValue('language')), array('sourceCulture' => true));
-
- break;
-
- case 'typeIds':
- $filtered = $flipped =
array_flip($this->form->getValue('typeIds'));
-
- $criteria = new Criteria;
-
$this->informationObject->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
- QubitTermRelation::addJoinTermCriteria($criteria);
- $criteria->add(QubitTerm::TAXONOMY_ID,
QubitTaxonomy::MODS_RESOURCE_TYPE_ID);
-
- foreach (QubitObjectTermRelation::get($criteria) as $relation)
- {
- if (isset($flipped[$relation->term->id]))
- {
- unset($filtered[$relation->term->id]);
- }
- else
- {
- $relation->delete();
- }
- }
-
- foreach ($filtered as $id => $key)
- {
- $relation = new QubitObjectTermRelation;
- $relation->termId = $id;
+ $criteria = new Criteria;
+
$this->informationObject->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
+ QubitTermRelation::addJoinTermCriteria($criteria);
+ $criteria->add(QubitTerm::TAXONOMY_ID,
QubitTaxonomy::MODS_RESOURCE_TYPE_ID);
- $this->informationObject->objectTermRelationsRelatedByObjectId[]
= $relation;
- }
+ foreach (QubitObjectTermRelation::get($criteria) as $relation)
+ {
+ if (isset($flipped[$relation->term->id]))
+ {
+ unset($filtered[$relation->term->id]);
+ }
+ else
+ {
+ $relation->delete();
+ }
+ }
- break;
+ foreach ($filtered as $id => $key)
+ {
+ $relation = new QubitObjectTermRelation;
+ $relation->termId = $id;
- default:
- $this->informationObject[$field->getName()] =
$this->form->getValue($field->getName());
+ $this->informationObject->objectTermRelationsRelatedByObjectId[] =
$relation;
}
- }
- }
- parent::processForm();
+ break;
+
+ default:
+ parent::processField($field);
+ }
}
}
Modified:
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
Tue Aug 11 13:02:45 2009 (r3007)
+++ trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
Tue Aug 11 13:39:19 2009 (r3008)
@@ -466,95 +466,71 @@
$this->radStandardNumber =
$this->informationObject->getPropertyByName('standard_number',
array('scope'=>'rad'));
}
- protected function processForm()
+ protected function processField($field)
{
- foreach ($this->form as $field)
+ switch ($field->getName())
{
- if (isset($this->request[$field->getName()]))
- {
- switch ($field->getName())
+ 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 'titleProperOfPublishersSeries':
+ case 'titleStatementOfResponsibility':
+
+ if (!isset($this[$field->getName()]))
{
- case 'language':
- case 'languageOfDescription':
- case 'script':
- case 'scriptOfDescription':
-
- if (!isset($this[$field->getName()]))
- {
- $this[$field->getName()] = new QubitProperty;
- $this[$field->getName()]->name = $fiel->getName();
- $this->informationObject->propertys[] = $this[$field->getName()];
- }
-
- $this[$field->getName()]->__set('value',
serialize($this->form->getValue($field->getName())), array('sourceCulture' =>
true));
-
- 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 'titleProperOfPublishersSeries':
- case 'titleStatementOfResponsibility':
-
- if (!isset($this[$field->getName()]))
- {
- $this[$field->getName()] = new QubitProperty;
- $this[$field->getName()]->name = $field->getName();
- $this[$field->getName()]->scope = 'rad';
- $this->informationObject->propertys[] = $this[$field->getName()];
- }
-
- $this[$field->getName()]->value =
serialize($this->form->getValue($field->getName()));
-
- break;
-
- case 'typeIds':
- $filtered = $flipped =
array_flip($this->form->getValue('typeIds'));
-
- $criteria = new Criteria;
-
$this->informationObject->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
- QubitTermRelation::addJoinTermCriteria($criteria);
- $criteria->add(QubitTerm::TAXONOMY_ID,
QubitTaxonomy::MATERIAL_TYPE_ID);
-
- foreach (QubitObjectTermRelation::get($criteria) as $relation)
- {
- if (isset($flipped[$relation->term->id]))
- {
- unset($filtered[$relation->term->id]);
- }
- else
- {
- $relation->delete();
- }
- }
-
- foreach ($filtered as $id => $key)
- {
- $relation = new QubitObjectTermRelation;
- $relation->termId = $id;
+ $this[$field->getName()] = new QubitProperty;
+ $this[$field->getName()]->name = $field->getName();
+ $this[$field->getName()]->scope = 'rad';
+ $this->informationObject->propertys[] = $this[$field->getName()];
+ }
+
+ $this[$field->getName()]->value =
serialize($this->form->getValue($field->getName()));
- $this->informationObject->objectTermRelationsRelatedByObjectId[]
= $relation;
- }
+ break;
- break;
+ case 'typeIds':
+ $filtered = $flipped = array_flip($this->form->getValue('typeIds'));
- default:
- $this->informationObject[$field->getName()] =
$this->form->getValue($field->getName());
+ $criteria = new Criteria;
+
$this->informationObject->addObjectTermRelationsRelatedByObjectIdCriteria($criteria);
+ QubitTermRelation::addJoinTermCriteria($criteria);
+ $criteria->add(QubitTerm::TAXONOMY_ID,
QubitTaxonomy::MATERIAL_TYPE_ID);
+
+ foreach (QubitObjectTermRelation::get($criteria) as $relation)
+ {
+ if (isset($flipped[$relation->term->id]))
+ {
+ unset($filtered[$relation->term->id]);
+ }
+ else
+ {
+ $relation->delete();
+ }
}
- }
- }
- return parent::processForm();
+ foreach ($filtered as $id => $key)
+ {
+ $relation = new QubitObjectTermRelation;
+ $relation->termId = $id;
+
+ $this->informationObject->objectTermRelationsRelatedByObjectId[] =
$relation;
+ }
+
+ break;
+
+ default:
+ parent::processField($field);
+ }
}
protected function updateNotes()
Modified:
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Tue Aug 11 13:02:45 2009 (r3007)
+++ trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Tue Aug 11 13:39:19 2009 (r3008)
@@ -138,9 +138,9 @@
<?php echo
render_field($form->reproductionConditions->label(__('Conditions governing
reproduction')), $informationObject, array('class' => 'resizable')) ?>
- <?php echo $form->languageOfMaterial->renderRow() ?>
+ <?php echo $form->language->renderRow() ?>
- <?php echo $form->scriptOfMaterial->renderRow() ?>
+ <?php echo $form->script->renderRow() ?>
<?php echo render_field($form->physicalCharacteristics->label(__('Physical
characteristics and technical requirements')), $informationObject,
array('class' => 'resizable')) ?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---