Author: jablko
Date: Tue Aug 11 16:19:10 2009
New Revision: 3011

Log:
Move field definitions 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

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php     
Tue Aug 11 15:31:12 2009        (r3010)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php     
Tue Aug 11 16:19:10 2009        (r3011)
@@ -47,8 +47,135 @@
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
   }
 
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'descriptionDetailId':
+        $this->form->setDefault('descriptionDetailId', 
$this->informationObject->descriptionDetail->id);
+        $this->form->setValidator('descriptionDetailId', new 
sfValidatorInteger);
+
+        $choices = array();
+        $choices[null] = null;
+        foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID) as 
$term)
+        {
+          $choices[$term->id] = $term;
+        }
+
+        $this->form->setWidget('descriptionDetailId', new 
sfWidgetFormSelect(array('choices' => $choices)));
+
+        break;
+
+      case 'descriptionStatusId':
+        $this->form->setDefault('descriptionStatusId', 
$this->informationObject->descriptionStatus->id);
+        $this->form->setValidator('descriptionStatusId', new 
sfValidatorInteger);
+
+        $choices = array();
+        $choices[null] = null;
+        foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_STATUS_ID) as $term)
+        {
+          $choices[$term->id] = $term;
+        }
+
+        $this->form->setWidget('descriptionStatusId', new 
sfWidgetFormSelect(array('choices' => $choices)));
+
+        break;
+
+      case 'language':
+      case 'languageOfDescription':
+        $criteria = new Criteria;
+        $this->informationObject->addPropertysCriteria($criteria);
+        $criteria->add(QubitProperty::NAME, $name);
+
+        if (1 == count($query = QubitProperty::get($criteria)))
+        {
+          $this[$name] = $query[0];
+          $this->form->setDefault($name, 
unserialize($this[$name]->__get('value', array('sourceCulture' => true))));
+        }
+
+        $this->form->setValidator($name, new 
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
+        $this->form->setWidget($name, new 
sfWidgetFormI18nSelectLanguage(array('culture' => 
$this->context->user->getCulture(), 'multiple' => true)));
+
+        break;
+
+      case 'repositoryId':
+        $this->form->setDefault('repositoryId', 
$this->informationObject->repository->id);
+        $this->form->setValidator('repositoryId', new sfValidatorInteger);
+
+        $choices = array();
+        $choices[null] = null;
+        foreach (QubitRepository::getAll() as $repository)
+        {
+          $choices[$repository->id] = $repository;
+        }
+
+        $this->form->setWidget('repositoryId', new 
sfWidgetFormSelect(array('choices' => $choices)));
+
+        break;
+
+      case 'script':
+      case 'scriptOfDescription':
+        $criteria = new Criteria;
+        $this->informationObject->addPropertysCriteria($criteria);
+        $criteria->add(QubitProperty::NAME, $name);
+
+        if (1 == count($query = QubitProperty::get($criteria)))
+        {
+          $this[$name] = $query[0];
+          $this->form->setDefault($name, 
unserialize($this[$name]->__get('value', array('sourceCulture' => true))));
+        }
+
+        $this->form->setValidator($name, new sfValidatorPass);
+
+        $c = new sfCultureInfo($this->context->user->getCulture());
+        $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $c->getScripts(), 'multiple' => true)));
+
+        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->informationObject[$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->informationObject[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormInput);
+
+        break;
+    }
+  }
+
   public function execute($request)
   {
+    // HACK: Use static::$NAMES in PHP 5.3,
+    // http://php.net/oop5.late-static-bindings
+    $class = new ReflectionClass($this);
+    foreach ($class->getStaticPropertyValue('NAMES') as $name)
+    {
+      $this->addField($name);
+    }
+
     sfLoader::loadHelpers(array('Qubit'));
 
     $request->setAttribute('informationObject', $this->informationObject);

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php   
Tue Aug 11 15:31:12 2009        (r3010)
+++ trunk/apps/qubit/modules/informationobject/actions/editDcAction.class.php   
Tue Aug 11 16:19:10 2009        (r3011)
@@ -28,11 +28,9 @@
 
 class InformationObjectEditDcAction extends InformationObjectEditAction
 {
-  public function execute($request)
-  {
-    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'dc');
-
-    foreach (array(
+  // Arrays are not allowed in class constants
+  public static
+    $NAMES = array(
       'accessConditions',
       'extentAndMedium',
       'identifier',
@@ -41,75 +39,50 @@
       'relation',
       'scopeAndContent',
       'title',
-      'typeIds') as $name)
-    {
-      switch ($name)
-      {
-        case 'language':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, 'language');
-
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this->language = $query[0];
-            $this->form->setDefault('language', 
unserialize($this->language->__get('value', array('sourceCulture' => true))));
-          }
+      'typeIds');
 
-          $this->form->setValidator('language', new 
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
-          $this->form->setWidget('language', new 
sfWidgetFormI18nSelectLanguage(array('culture' => 
$this->context->user->getCulture(), 'multiple' => true)));
-
-          break;
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'relation':
+        $criteria = new Criteria;
+        $this->informationObject->addPropertysCriteria($criteria);
+        $criteria->add(QubitProperty::NAME, 'relation');
+        $criteria->add(QubitProperty::SCOPE, 'dc');
 
-        case 'relation':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, 'relation');
-          $criteria->add(QubitProperty::SCOPE, 'dc');
+        if (1 == count($query = QubitProperty::get($criteria)))
+        {
+          $this->relation = $query[0];
+          $this->form->setDefault('relation', 
unserialize($this->relation->value));
+        }
 
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this->relation = $query[0];
-            $this->form->setDefault('relation', 
unserialize($this->relation->value));
-          }
+        $this->form->setValidator('relation', new sfValidatorString);
+        $this->form->setWidget('relation', new sfWidgetFormInput);
 
-          $this->form->setValidator('relation', new sfValidatorString);
-          $this->form->setWidget('relation', new sfWidgetFormInput);
+        break;
 
-          break;
+      case 'typeIds':
+        $values = array();
+        foreach (QubitDc::getDcTypes($this->informationObject) as $relation)
+        {
+          $values[] = $relation->term->id;
+        }
 
-        case 'accessConditions':
-        case 'extentAndMedium':
-        case 'locationOfOriginals':
-        case 'scopeAndContent':
-          $this->form->setDefault($name, $this->informationObject[$name]);
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormTextarea);
-
-          break;
-
-        case 'identifier':
-        case 'title':
-          $this->form->setDefault($name, $this->informationObject[$name]);
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormInput);
-
-          break;
-
-        case 'typeIds':
-          $values = array();
-          foreach (QubitDc::getDcTypes($this->informationObject) as $relation)
-          {
-            $values[] = $relation->term->id;
-          }
+        $this->form->setDefault('typeIds', $values);
+        $this->form->setValidator('typeIds', new sfValidatorPass);
+        $this->form->setWidget('typeIds', new 
sfWidgetFormSelect(array('choices' => 
QubitTaxonomy::getTermsById(QubitTaxonomy::MODS_RESOURCE_TYPE_ID)->indexBy('id'),
 'multiple' => true)));
 
-          $this->form->setDefault('typeIds', $values);
-          $this->form->setValidator('typeIds', new sfValidatorPass);
-          $this->form->setWidget('typeIds', new 
sfWidgetFormSelect(array('choices' => 
QubitTaxonomy::getTermsById(QubitTaxonomy::MODS_RESOURCE_TYPE_ID)->indexBy('id'),
 'multiple' => true)));
+        break;
 
-          break;
-      }
+      default:
+        parent::addField($name);
     }
+  }
+
+  public function execute($request)
+  {
+    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'dc');
 
     parent::execute($request);
 

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php 
Tue Aug 11 15:31:12 2009        (r3010)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php 
Tue Aug 11 16:19:10 2009        (r3011)
@@ -28,11 +28,9 @@
  */
 class InformationObjectEditIsadAction extends InformationObjectEditAction
 {
-  public function execute($request)
-  {
-    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'isad');
-
-    foreach (array(
+  // Arrays are not allowed in class constants
+  public static
+    $NAMES = array(
       'accessConditions',
       'accruals',
       'acquisition',
@@ -61,145 +59,46 @@
       'script',
       'sources',
       'descriptionStatusId',
-      'title') as $name)
-    {
-      switch ($name)
-      {
-        case 'creatorIds':
-          $values = array();
-          foreach ($this->informationObject->getCreators() as $actor)
-          {
-            $values[] = $actor->id;
-          }
-
-          $this->form->setDefault('creatorIds', $values);
-          $this->form->setValidator('creatorIds', new sfValidatorPass);
-
-          $criteria = new Criteria;
-          $criteria->addJoin(QubitActor::ID, QubitUser::ID, 'LEFT JOIN');
-          $criteria->add(QubitUser::ID);
-
-          $this->form->setWidget('creatorIds', new 
sfWidgetFormSelect(array('choices' => 
QubitActor::get($criteria)->indexBy('id'), 'multiple' => true)));
-
-          break;
-
-        case 'languageOfDescription':
-        case 'language':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, $name);
-
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this[$name] = $query[0];
-            $this->form->setDefault($name, 
unserialize($this[$name]->__get('value', array('sourceCulture' => true))));
-          }
-
-          $this->form->setValidator($name, new 
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
-          $this->form->setWidget($name, new 
sfWidgetFormI18nSelectLanguage(array('culture' => 
$this->context->user->getCulture(), 'multiple' => true)));
-
-          break;
-
-        case 'descriptionDetailId':
-          $this->form->setDefault('descriptionDetailId', 
$this->informationObject->descriptionDetail->id);
-          $this->form->setValidator('descriptionDetailId', new 
sfValidatorInteger);
-
-          $choices = array();
-          $choices[null] = null;
-          foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID) as 
$term)
-          {
-            $choices[$term->id] = $term;
-          }
-
-          $this->form->setWidget('descriptionDetailId', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-          break;
-
-        case 'repositoryId':
-          $this->form->setDefault('repositoryId', 
$this->informationObject->repository->id);
-          $this->form->setValidator('repositoryId', new sfValidatorInteger);
-
-          $choices = array();
-          $choices[null] = null;
-          foreach (QubitRepository::getAll() as $repository)
-          {
-            $choices[$repository->id] = $repository;
-          }
-
-          $this->form->setWidget('repositoryId', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-          break;
+      'title');
 
-        case 'scriptOfDescription':
-        case 'script':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, $name);
-
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this[$name] = $query[0];
-            $this->form->setDefault($name, 
unserialize($this[$name]->__get('value', array('sourceCulture' => true))));
-          }
-
-          $this->form->setValidator($name, new sfValidatorPass);
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'creatorIds':
+        $values = array();
+        foreach ($this->informationObject->getCreators() as $actor)
+        {
+          $values[] = $actor->id;
+        }
 
-          $c = new sfCultureInfo($this->context->user->getCulture());
-          $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $c->getScripts(), 'multiple' => true)));
+        $this->form->setDefault('creatorIds', $values);
+        $this->form->setValidator('creatorIds', new sfValidatorPass);
 
-          break;
+        $criteria = new Criteria;
+        $criteria->addJoin(QubitActor::ID, QubitUser::ID, 'LEFT JOIN');
+        $criteria->add(QubitUser::ID);
 
-        case 'accessConditions':
-        case 'accruals':
-        case 'acquisition':
-        case 'appraisal':
-        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->informationObject[$name]);
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormTextarea);
-
-          break;
-
-        case 'descriptionStatusId':
-          $this->form->setDefault('descriptionStatusId', 
$this->informationObject->descriptionStatus->id);
-          $this->form->setValidator('descriptionStatusId', new 
sfValidatorInteger);
-
-          $choices = array();
-          $choices[null] = null;
-          foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_STATUS_ID) as $term)
-          {
-            $choices[$term->id] = $term;
-          }
+        $this->form->setWidget('creatorIds', new 
sfWidgetFormSelect(array('choices' => 
QubitActor::get($criteria)->indexBy('id'), 'multiple' => true)));
 
-          $this->form->setWidget('descriptionStatusId', new 
sfWidgetFormSelect(array('choices' => $choices)));
+        break;
 
-          break;
+      case 'appraisal':
+        $this->form->setDefault($name, $this->informationObject[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormTextarea);
 
-        case 'descriptionIdentifier':
-        case 'identifier':
-        case 'institutionResponsibleIdentifier':
-        case 'title':
-          $this->form->setDefault($name, $this->informationObject[$name]);
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormInput);
+        break;
 
-          break;
-      }
+      default:
+        parent::addField($name);
     }
+  }
+
+  public function execute($request)
+  {
+    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'isad');
 
-    // run the core informationObject edit action commands
     parent::execute($request);
 
     // Get ISAD specific event types

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php 
Tue Aug 11 15:31:12 2009        (r3010)
+++ trunk/apps/qubit/modules/informationobject/actions/editModsAction.class.php 
Tue Aug 11 16:19:10 2009        (r3011)
@@ -28,64 +28,37 @@
 
 class InformationObjectEditModsAction extends InformationObjectEditAction
 {
-  public function execute($request)
-  {
-    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'mods');
-
-    foreach (array(
+  // Arrays are not allowed in class constants
+  public static
+    $NAMES = array(
       'accessConditions',
       'identifier',
       'language',
       'title',
-      'typeIds') as $name)
-    {
-      switch ($name)
-      {
-        case 'accessConditions':
-          $this->form->setDefault('accessConditions', 
$this->informationObject->accessConditions);
-          $this->form->setValidator('accessConditions', new sfValidatorString);
-          $this->form->setWidget('accessConditions', new sfWidgetFormTextarea);
-
-          break;
-
-        case 'language':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, 'language');
-
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this->language = $query[0];
-            $this->form->setDefault('language', 
unserialize($this->language->__get('value', array('sourceCulture' => true))));
-          }
-
-          $this->form->setValidator('language', new 
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
-          $this->form->setWidget('language', new 
sfWidgetFormI18nSelectLanguage(array('culture' => 
$this->context->user->getCulture(), 'multiple' => true)));
+      'typeIds');
 
-          break;
-
-        case 'identifier':
-        case 'title':
-          $this->form->setDefault($name, $this->informationObject[$name]);
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormInput);
-
-          break;
-
-        case 'typeIds':
-          $values = array();
-          foreach (QubitMods::getTypes($this->informationObject) as $relation)
-          {
-            $values[] = $relation->term->id;
-          }
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'typeIds':
+        $values = array();
+        foreach (QubitMods::getTypes($this->informationObject) as $relation)
+        {
+          $values[] = $relation->term->id;
+        }
 
-          $this->form->setDefault('typeIds', $values);
-          $this->form->setValidator('typeIds', new sfValidatorPass);
-          $this->form->setWidget('typeIds', new 
sfWidgetFormSelect(array('choices' => 
QubitTaxonomy::getTermsById(QubitTaxonomy::MODS_RESOURCE_TYPE_ID)->indexBy('id'),
 'multiple' => true)));
+        $this->form->setDefault('typeIds', $values);
+        $this->form->setValidator('typeIds', new sfValidatorPass);
+        $this->form->setWidget('typeIds', new 
sfWidgetFormSelect(array('choices' => 
QubitTaxonomy::getTermsById(QubitTaxonomy::MODS_RESOURCE_TYPE_ID)->indexBy('id'),
 'multiple' => true)));
 
-          break;
-      }
+        break;
     }
+  }
+
+  public function execute($request)
+  {
+    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'mods');
 
     parent::execute($request);
   }

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php  
Tue Aug 11 15:31:12 2009        (r3010)
+++ trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php  
Tue Aug 11 16:19:10 2009        (r3011)
@@ -28,11 +28,9 @@
  */
 class InformationObjectEditRadAction extends InformationObjectEditAction
 {
-  public function execute($request)
-  {
-    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'rad');
-
-    foreach (array(
+  // Arrays are not allowed in class constants
+  public static
+    $NAMES = array(
       'accessConditions',
       'accruals',
       'acquisition',
@@ -77,170 +75,72 @@
       'title',
       'titleStatementOfResponsibility',
       'titleProperOfPublishersSeries',
-      'typeIds') as $name)
-    {
-      switch ($name)
-      {
-        case 'language':
-        case 'languageOfDescription':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, $name);
-
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this[$name] = $query[0];
-            $this->form->setDefault($name, 
unserialize($this[$name]->__get('value', array('sourceCulture' => true))));
-          }
-
-          $this->form->setValidator($name, new 
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
-          $this->form->setWidget($name, new 
sfWidgetFormI18nSelectLanguage(array('culture' => 
$this->context->user->getCulture(), 'multiple' => true)));
+      'typeIds');
 
-          break;
-
-        case 'descriptionDetailId':
-          $this->form->setDefault('descriptionDetailId', 
$this->informationObject->descriptionDetail->id);
-          $this->form->setValidator('descriptionDetailId', new 
sfValidatorInteger);
-
-          $choices = array();
-          $choices[null] = null;
-          foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID) as 
$term)
-          {
-            $choices[$term->id] = $term;
-          }
-
-          $this->form->setWidget('descriptionDetailId', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-          break;
-
-        case 'repositoryId':
-          $this->form->setDefault('repositoryId', 
$this->informationObject->repository->id);
-          $this->form->setValidator('repositoryId', new sfValidatorInteger);
-
-          $choices = array();
-          $choices[null] = null;
-          foreach (QubitRepository::getAll() as $repository)
-          {
-            $choices[$repository->id] = $repository;
-          }
-
-          $this->form->setWidget('repositoryId', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-          break;
-
-        case 'script':
-        case 'scriptOfDescription':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, $name);
-
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this[$name] = $query[0];
-            $this->form->setDefault($name, 
unserialize($this[$name]->__get('value', array('sourceCulture' => true))));
-          }
-
-          $this->form->setValidator($name, new sfValidatorPass);
-
-          $c = new sfCultureInfo($this->context->user->getCulture());
-          $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $c->getScripts(), 'multiple' => true)));
-
-          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->informationObject[$name]);
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormTextarea);
-
-          break;
-
-        case 'descriptionStatusId':
-          $this->form->setDefault('descriptionStatusId', 
$this->informationObject->descriptionStatus->id);
-          $this->form->setValidator('descriptionStatusId', new 
sfValidatorInteger);
-
-          $choices = array();
-          $choices[null] = null;
-          foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_STATUS_ID) as $term)
-          {
-            $choices[$term->id] = $term;
-          }
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'alternateTitle':
+      case 'edition':
+        $this->form->setDefault($name, $this->informationObject[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormInput);
 
-          $this->form->setWidget('descriptionStatusId', new 
sfWidgetFormSelect(array('choices' => $choices)));
+        break;
 
-          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':
+        $criteria = new Criteria;
+        $this->informationObject->addPropertysCriteria($criteria);
+        $criteria->add(QubitProperty::NAME, $name);
+        $criteria->add(QubitProperty::SCOPE, 'rad');
 
-        case 'alternateTitle':
-        case 'descriptionIdentifier':
-        case 'edition':
-        case 'identifier':
-        case 'institutionResponsibleIdentifier':
-        case 'title':
-          $this->form->setDefault($name, $this->informationObject[$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':
-          $criteria = new Criteria;
-          $this->informationObject->addPropertysCriteria($criteria);
-          $criteria->add(QubitProperty::NAME, $name);
-          $criteria->add(QubitProperty::SCOPE, 'rad');
+        if (1 == count($query = QubitProperty::get($criteria)))
+        {
+          $this[$name] = $query[0];
+          $this->form->setDefault($name, unserialize($this[$name]->value));
+        }
 
-          if (1 == count($query = QubitProperty::get($criteria)))
-          {
-            $this[$name] = $query[0];
-            $this->form->setDefault($name, unserialize($this[$name]->value));
-          }
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormInput);
 
-          $this->form->setValidator($name, new sfValidatorString);
-          $this->form->setWidget($name, new sfWidgetFormInput);
+        break;
 
-          break;
+      case 'typeIds':
+        $values = array();
+        foreach ($this->informationObject->getMaterialTypes() as $relation)
+        {
+          $values[] = $relation->term->id;
+        }
 
-        case 'typeIds':
-          $values = array();
-          foreach ($this->informationObject->getMaterialTypes() as $relation)
-          {
-            $values[] = $relation->term->id;
-          }
+        $this->form->setDefault('typeIds', $values);
+        $this->form->setValidator('typeIds', new sfValidatorPass);
+        $this->form->setWidget('typeIds', new 
sfWidgetFormSelect(array('choices' => 
QubitTaxonomy::getTermsById(QubitTaxonomy::MATERIAL_TYPE_ID)->indexBy('id'), 
'multiple' => true)));
 
-          $this->form->setDefault('typeIds', $values);
-          $this->form->setValidator('typeIds', new sfValidatorPass);
-          $this->form->setWidget('typeIds', new 
sfWidgetFormSelect(array('choices' => 
QubitTaxonomy::getTermsById(QubitTaxonomy::MATERIAL_TYPE_ID)->indexBy('id'), 
'multiple' => true)));
+        break;
 
-          break;
-      }
+      default:
+        parent::addField($name);
     }
+  }
+
+  public function execute($request)
+  {
+    
$this->context->getRouting()->setDefaultParameter('informationobject_template', 
'rad');
 
     parent::execute($request);
 

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to