Author: sevein
Date: Tue Aug 14 13:43:47 2012
New Revision: 12103

Log:
Make languageNotes a single-value note field, fixes issue 2310.

Modified:
   trunk/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php
   trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php
   trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/editSuccess.php
   trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/indexSuccess.php

Modified: trunk/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php
==============================================================================
--- trunk/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php       Tue Aug 14 
13:20:45 2012        (r12102)
+++ trunk/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php       Tue Aug 14 
13:43:47 2012        (r12103)
@@ -79,17 +79,14 @@
     return implode(' - ', $string);
   }
 
-  public function offsetExists($offset)
-  {
-    $args = func_get_args();
-
-    return call_user_func_array(array($this, '__isset'), $args);
-  }
-
   public function __get($name)
   {
     switch ($name)
     {
+      case 'languageNotes':
+
+        return $this->resource->getNotesByType(array('noteTypeId' => 
QubitTerm::LANGUAGE_NOTE_ID))->offsetGet(0);
+
       case 'referenceCode':
 
         return $this->resource->referenceCode;
@@ -100,6 +97,40 @@
     }
   }
 
+  public function __set($name, $value)
+  {
+    switch ($name)
+    {
+      case 'languageNotes':
+
+        // Stop if the string is empty
+        if (0 == strlen($value))
+        {
+          break;
+        }
+
+        if (0 == count($note = 
$this->resource->getNotesByType(array('noteTypeId' => 
QubitTerm::LANGUAGE_NOTE_ID))->offsetGet(0)))
+        {
+          $note = new QubitNote;
+          $note->typeId = QubitTerm::LANGUAGE_NOTE_ID;
+          $note->userId = 
sfContext::getInstance()->user->getAttribute('user_id');
+
+          $this->resource->notes[] = $note;
+        }
+
+        $note->content = $value;
+
+        return $this;
+    }
+  }
+
+  public function offsetExists($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__isset'), $args);
+  }
+
   public function offsetGet($offset)
   {
     $args = func_get_args();

Modified: 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php
==============================================================================
--- 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php    
    Tue Aug 14 13:20:45 2012        (r12102)
+++ 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/actions/editAction.class.php    
    Tue Aug 14 13:43:47 2012        (r12103)
@@ -44,8 +44,9 @@
       'findingAids',
       'identifier',
       'institutionResponsibleIdentifier',
-      'languageOfDescription',
       'language',
+      'languageNotes',
+      'languageOfDescription',
       'levelOfDescription',
       'locationOfCopies',
       'locationOfOriginals',
@@ -123,6 +124,14 @@
 
         break;
 
+      case 'languageNotes':
+
+        $this->form->setDefault('languageNotes', $this->isad['languageNotes']);
+        $this->form->setValidator('languageNotes', new sfValidatorString);
+        $this->form->setWidget('languageNotes', new sfWidgetFormTextarea);
+
+        break;
+
       default:
 
         return parent::addField($name);
@@ -165,6 +174,12 @@
 
         break;
 
+      case 'languageNotes':
+
+        $this->isad['languageNotes'] = $this->form->getValue('languageNotes');
+
+        break;
+
       default:
 
         return parent::processField($field);
@@ -199,11 +214,6 @@
         $this->request->new_archivist_note = 
$this->request->getParameterHolder()->get('newArchivistNote');
       }
 
-      if ($this->request->getParameterHolder()->has('newLanguageNote'))
-      {
-        $this->request->new_language_note = 
$this->request->getParameterHolder()->get('newLanguageNote');
-      }
-
       if ($this->request->getParameterHolder()->has('newPublicationNote'))
       {
         $this->request->new_publication_note = 
$this->request->getParameterHolder()->get('newPublicationNote');
@@ -229,20 +239,6 @@
       }
     }
 
-    // Update language notes (multiple)
-    foreach ((array) $this->request->new_language_note as $content)
-    {
-      if (0 < strlen($content))
-      {
-        $note = new QubitNote;
-        $note->content = $content;
-        $note->typeId = QubitTerm::LANGUAGE_NOTE_ID;
-        $note->userId = $this->context->user->getAttribute('user_id');
-
-        $this->resource->notes[] = $note;
-      }
-    }
-
     // Update publication notes (multiple)
     foreach ((array) $this->request->new_publication_note as $content)
     {

Modified: 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/editSuccess.php
==============================================================================
--- trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/editSuccess.php   
Tue Aug 14 13:20:45 2012        (r12102)
+++ trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/editSuccess.php   
Tue Aug 14 13:43:47 2012        (r12103)
@@ -125,49 +125,10 @@
       ->label(__('Script of material'))
       ->renderRow(array('class' => 'form-autocomplete')) ?>
 
-    <div class="form-item">
-
-      <table>
-        <thead>
-          <tr>
-            <th style="width: 90%">
-              <?php echo __('Language and script notes') ?>
-            </th><th style="width: 10%; text-align: right">
-              <?php echo image_tag('delete', array('align' => 'top', 'class' 
=> 'deleteIcon')) ?>
-            </th>
-          </tr>
-        </thead><tbody>
-
-          <?php foreach ($resource->getNotesByType(array('noteTypeId' => 
QubitTerm::LANGUAGE_NOTE_ID)) as $item): ?>
-            <tr class="<?php echo 'related_obj_'.$item->id ?>">
-              <td>
-                <div class="animateNicely">
-                  <?php echo $item->getContent(array('cultureFallback' => 
'true')) ?>
-                </div>
-              </td><td style="text-align: right">
-                <div class="animateNicely">
-                  <input type="checkbox" name="delete_notes[<?php echo 
$item->id ?>]" value="delete" class="multiDelete"/>
-                </div>
-              </td>
-            </tr>
-          <?php endforeach; ?>
-
-          <tr>
-            <td>
-              <textarea name="new_language_note" class="multiInstanceTr 
resizable" size="30x2"></textarea>
-            </td><td style="text-align: right">
-              &nbsp;
-            </td>
-          </tr>
-
-        </tbody>
-      </table>
-
-      <div class="description">
-        <?php echo __('Note any distinctive alphabets, scripts, symbol systems 
or abbreviations employed. (ISAD 3.4.3)') ?>
-      </div>
-
-    </div>
+    <?php echo $form->languageNotes
+      ->help(__('Note any distinctive alphabets, scripts, symbol systems or 
abbreviations employed. (ISAD 3.4.3)'))
+      ->label(__('Language and script notes'))
+      ->renderRow() ?>
 
     <?php echo render_field($form->physicalCharacteristics
       ->help(__('Indicate any important physical conditions, such as 
preservation requirements, that affect the use of the unit of description. Note 
any software and/or hardware required to access the unit of description.'))

Modified: 
trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/indexSuccess.php
==============================================================================
--- trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/indexSuccess.php  
Tue Aug 14 13:20:45 2012        (r12102)
+++ trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/indexSuccess.php  
Tue Aug 14 13:43:47 2012        (r12103)
@@ -126,9 +126,7 @@
     </div>
   </div>
 
-  <?php foreach ($resource->getNotesByType(array('noteTypeId' => 
QubitTerm::LANGUAGE_NOTE_ID)) as $item): ?>
-    <?php echo render_show(__('Language and script note'), 
render_value($item->getContent(array('cultureFallback' => true)))) ?>
-  <?php endforeach; ?>
+  <?php echo render_show(__('Language and script notes'), 
render_value($isad->languageNotes)) ?>
 
   <?php if 
(check_field_visibility('app_element_visibility_isad_physical_condition')): ?>
     <?php echo render_show(__('Physical characteristics and technical 
requirements'), 
render_value($resource->getPhysicalCharacteristics(array('cultureFallback' => 
true)))) ?>

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