Author: sevein
Date: Fri Aug 19 11:45:29 2011
New Revision: 9548

Log:
Remove old contactinformation fields in favour of contactinformation component

Modified:
   trunk/apps/qubit/modules/repository/actions/editAction.class.php
   trunk/plugins/sfIsdiahPlugin/modules/sfIsdiahPlugin/templates/editSuccess.php

Modified: trunk/apps/qubit/modules/repository/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/repository/actions/editAction.class.php    Fri Aug 
19 11:43:57 2011        (r9547)
+++ trunk/apps/qubit/modules/repository/actions/editAction.class.php    Fri Aug 
19 11:45:29 2011        (r9548)
@@ -64,6 +64,10 @@
         QubitAcl::forwardUnauthorized();
       }
     }
+
+    $this->relatedContactInformationComponent = new 
ContactInformationRelatedContactInformationComponent($this->context, 
'contactinformation', 'relatedContactInformation');
+    $this->relatedContactInformationComponent->resource = $this->resource;
+    $this->relatedContactInformationComponent->execute($this->request);
   }
 
   protected function addField($name)
@@ -163,12 +167,6 @@
     }
   }
 
-  /**
-   * Process form fields
-   *
-   * @param $field mixed symfony form widget
-   * @return void
-   */
   protected function processField($field)
   {
     switch ($field->getName())
@@ -227,9 +225,6 @@
   {
     parent::execute($request);
 
-    $this->form->setValidator('countryCode', new sfValidatorI18nChoiceCountry);
-    $this->form->setWidget('countryCode', new 
sfWidgetFormI18nChoiceCountry(array('add_empty' => true, 'culture' => 
$this->context->user->getCulture())));
-
     if ($request->hasParameter('csvimport'))
     {
       $this->form->bind($request->getParameterHolder()->getAll());
@@ -239,7 +234,40 @@
 
         $this->resource->save();
 
-        $this->updateContactInformation();
+        if ($this->request->contact_type
+            || $this->request->contactPerson
+            || $this->request->streetAddress
+            || $this->request->city
+            || $this->request->region
+            || $this->request->countryCode
+            || $this->request->postalCode
+            || $this->request->telephone
+            || $this->request->fax
+            || $this->request->email
+            || $this->request->website)
+        {
+          $contactInformation = new QubitContactInformation;
+          $contactInformation->actor = $this->resource;
+          $contactInformation->contactType = $this->request->contactType;
+          $contactInformation->contactPerson = $this->request->contactPerson;
+          $contactInformation->streetAddress = $this->request->streetAddress;
+          $contactInformation->city = $this->request->city;
+          $contactInformation->region = $this->request->region;
+          $contactInformation->countryCode = $this->request->countryCode;
+          $contactInformation->postalCode = $this->request->postalCode;
+          $contactInformation->telephone = $this->request->telephone;
+          $contactInformation->fax = $this->request->fax;
+          $contactInformation->email = $this->request->email;
+          $contactInformation->website = $this->request->website;
+          $contactInformation->note = $this->request->contactInformationNote;
+
+          $contactInformation->save();
+
+          if ($this->request->primaryContact)
+          {
+            $contactInformation->makePrimaryContact();
+          }
+        }
       }
 
     }
@@ -248,54 +276,16 @@
       $this->form->bind($request->getPostParameters());
       if ($this->form->isValid())
       {
+        $this->relatedContactInformationComponent->processForm();
+
         $this->processForm();
 
         $this->resource->save();
 
-        $this->updateContactInformation();
-
         $this->redirect(array($this->resource, 'module' => 'repository'));
       }
     }
 
     QubitDescription::addAssets($this->response);
   }
-
-  protected function updateContactInformation()
-  {
-    if ($this->request->contact_type
-        || $this->request->contactPerson
-        || $this->request->streetAddress
-        || $this->request->city
-        || $this->request->region
-        || $this->request->countryCode
-        || $this->request->postalCode
-        || $this->request->telephone
-        || $this->request->fax
-        || $this->request->email
-        || $this->request->website)
-    {
-      $contactInformation = new QubitContactInformation;
-      $contactInformation->actor = $this->resource;
-      $contactInformation->contactType = $this->request->contactType;
-      $contactInformation->contactPerson = $this->request->contactPerson;
-      $contactInformation->streetAddress = $this->request->streetAddress;
-      $contactInformation->city = $this->request->city;
-      $contactInformation->region = $this->request->region;
-      $contactInformation->countryCode = $this->request->countryCode;
-      $contactInformation->postalCode = $this->request->postalCode;
-      $contactInformation->telephone = $this->request->telephone;
-      $contactInformation->fax = $this->request->fax;
-      $contactInformation->email = $this->request->email;
-      $contactInformation->website = $this->request->website;
-      $contactInformation->note = $this->request->contactInformationNote;
-
-      $contactInformation->save();
-
-      if ($this->request->primaryContact)
-      {
-        $contactInformation->makePrimaryContact();
-      }
-    }
-  }
 }

Modified: 
trunk/plugins/sfIsdiahPlugin/modules/sfIsdiahPlugin/templates/editSuccess.php
==============================================================================
--- 
trunk/plugins/sfIsdiahPlugin/modules/sfIsdiahPlugin/templates/editSuccess.php   
    Fri Aug 19 11:43:57 2011        (r9547)
+++ 
trunk/plugins/sfIsdiahPlugin/modules/sfIsdiahPlugin/templates/editSuccess.php   
    Fri Aug 19 11:45:29 2011        (r9548)
@@ -41,124 +41,16 @@
 
   </fieldset>
 
- <fieldset class="collapsible collapsed" id="contactArea">
+  <fieldset class="collapsible collapsed" id="contactArea">
 
-   <legend><?php echo __('Contact area') ?></legend>
+    <legend><?php echo __('Contact area') ?></legend>
 
-   <div class="section">
-
-      <h3><?php echo __('Contact information') ?> <span class="form-required" 
title="<?php echo __('This is a mandatory element.') ?>">*</span></h3>
-
-      <?php foreach ($resource->contactInformations as $item): ?>
-
-        <table>
-          <tr>
-            <th style="margin-top: 5px; border-top: 2px solid #999999; width: 
90%">
-              <?php echo $item->getContactType(array('cultureFallback' => 
true)) ?><?php if ($item->getPrimaryContact()): ?> (<?php echo __('Primary 
contact') ?>)<?php endif; ?>
-            </th><td style="width: 20px; border-top: 2px solid #cccccc; 
border-bottom: 1px solid #cccccc">
-              <?php echo link_to(image_tag('pencil'), array($item, 'module' => 
'actor', 'action' => 'editContactInformation')) ?>
-            </td><td style="width: 20px; border-top: 2px solid #cccccc; 
border-bottom: 1px solid #cccccc">
-              <?php echo link_to(image_tag('delete'), array($item, 'module' => 
'actor', 'action' => 'deleteContactInformation')) ?>
-            </td>
-          </tr>
-        </table>
-
-        <?php echo get_partial('actor/contactInformation', 
array('contactInformation' => $item)) ?>
-
-      <?php endforeach; ?>
-
-      <table>
-        <tr>
-          <th colspan="4" style="margin-top: 5px; border-top: 2px solid 
#999999; width: 95%">
-            <?php echo __('Add new contact information') ?>
-          </th>
-        </tr><tr>
-          <th>
-            <?php echo __('Street address') ?>
-          </th><td>
-            <textarea name="streetAddress"></textarea>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('City') ?>
-          </th><td>
-            <input name="city"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Region/province') ?>
-          </th><td>
-            <input name="region"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Country') ?>
-          </th><td>
-            <?php echo $form->countryCode->render() ?>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Postal code') ?>
-          </th><td>
-            <input name="postalCode"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Telephone') ?>
-          </th><td>
-            <input name="telephone"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Fax') ?>
-          </th><td>
-            <input name="fax"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Email') ?>
-          </th><td>
-            <input name="email"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Website') ?>
-          </th><td>
-            <input name="website"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Contact person') ?>
-          </th><td>
-            <input name="contactPerson"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Primary contact') ?>
-          </th><td>
-            <input type="checkbox" name="primaryContact"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Contact type') ?>
-          </th><td>
-            <input name="contactType"/>
-          </td>
-        </tr><tr>
-          <th>
-            <?php echo __('Note') ?>
-          </th><td>
-            <textarea name="contactInformationNote" class="resizable" 
size="30x3"></textarea>
-          </td>
-        </tr>
-      </table>
-
-      <div class="description">
-        <?php echo __('See ISDIAH 5.2 for contact area information and 
examples.') ?>
-      </div>
+    <?php echo get_partial('contactinformation/relatedContactInformation', 
$relatedContactInformationComponent->getVarHolder()->getAll()) ?>
 
+    <div class="description">
+      <?php echo __('See ISDIAH 5.2 for contact area information and 
examples.') ?>
     </div>
-
+    
   </fieldset>
 
   <fieldset class="collapsible collapsed" id="descriptionArea">

-- 
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.com/group/qubit-commits?hl=en.

Reply via email to