Author: david
Date: 2008-11-07 15:21:11 -0800 (Fri, 07 Nov 2008)
New Revision: 1537

Modified:
   
trunk/qubit/apps/qubit/modules/informationobject/actions/editRadAction.class.php
   
trunk/qubit/apps/qubit/modules/informationobject/actions/updateRadAction.class.php
   
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
   trunk/qubit/apps/qubit/modules/informationobject/templates/editRadSuccess.php
   trunk/qubit/lib/model/QubitInformationObject.php
   trunk/qubit/lib/model/QubitProperty.php
Log:
Add QubitProperty objects for RAD descriptions that don't map to 
QubitInformationObject schema
- Add QubitInformationObject methods for getting and setting related properties.
- Add QubitProperty::getSourceTextForTranslation() method
- Change name of QubitProperty::getProperty() method to isPropertyExistent() to 
avoid confusion as to function
- Add shortcut method for getting property by object_id and name

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/editRadAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/editRadAction.class.php
    2008-11-07 20:32:37 UTC (rev 1536)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/editRadAction.class.php
    2008-11-07 23:21:11 UTC (rev 1537)
@@ -35,10 +35,40 @@
     // run the core informationObject edit action commands
     parent::execute($request);
 
+    $infoObject = $this->informationObject;
+
     // add RAD specific commands
     $this->radNotes = $this->informationObject->getNotesByTaxonomy($options = 
array('taxonomyId' => QubitTaxonomy::RAD_NOTE_ID));
     $this->radTitleNotes = 
$this->informationObject->getNotesByTaxonomy($options = array('taxonomyId' => 
QubitTaxonomy::RAD_TITLE_NOTE_ID));
     $this->radTitleNoteTypes = 
QubitTerm::getOptionsForSelectList(QubitTaxonomy::RAD_TITLE_NOTE_ID);
     $this->radNoteTypes = 
QubitTerm::getOptionsForSelectList(QubitTaxonomy::RAD_NOTE_ID);
+
+    // Rad 1.1 properties
+    $this->radOtherTitleInformation = 
$infoObject->getPropertyByName('other_title_information', 
array('scope'=>'rad'));
+    $this->radTitleStatementOfResponsibility = 
$infoObject->getPropertyByName('title_statement_of_responsibility', 
array('scope'=>'rad'));
+
+    // RAD 1.2 properties
+    $this->radEditionStatementOfResponsibility = 
$infoObject->getPropertyByName('edition_statement_of_responsibility', 
array('scope'=>'rad'));
+
+    // RAD 1.3 properties
+    $this->radStatementOfScaleCartographic = 
$infoObject->getPropertyByName('statement_of_scale_cartographic', 
array('scope'=>'rad'));
+    $this->radStatementOfProjection = 
$infoObject->getPropertyByName('statement_of_projection', 
array('scope'=>'rad'));
+    $this->radStatementOfCoordinates = 
$infoObject->getPropertyByName('statement_of_coordinates', 
array('scope'=>'rad'));
+    $this->radStatementOfScaleArchitectural = 
$infoObject->getPropertyByName('statement_of_scale_architectural', 
array('scope'=>'rad'));
+    $this->radIssuingJursidictionAndDenomination = 
$infoObject->getPropertyByName('issuing_jursidiction_and_denomination', 
array('scope'=>'rad'));
+
+    // RAD 1.6 properties
+    $this->radTitleProperOfPublishersSeries = 
$infoObject->getPropertyByName('title_proper_of_publishers_series', 
array('scope'=>'rad'));
+    $this->radParallelTitlesOfPublishersSeries = 
$infoObject->getPropertyByName('parallel_titles_of_publishers_series', 
array('scope'=>'rad'));
+    $this->radOtherTitleInformationOfPublishersSeries = 
$infoObject->getPropertyByName('other_title_information_of_publishers_series', 
array('scope'=>'rad'));
+    $this->radStatementOfResponsibilityRelatingToPublishersSeries = 
$infoObject->getPropertyByName('statement_of_responsibility_relating_to_publishers_series',
 array('scope'=>'rad'));
+    $this->radNumberingWithinPublishersSeries = 
$infoObject->getPropertyByName('numbering_within_publishers_series', 
array('scope'=>'rad'));
+    $this->radNoteOnPublishersSeries = 
$infoObject->getPropertyByName('note_on_publishers_series', 
array('scope'=>'rad'));
+
+    // RAD 1.9 properties
+    $this->radStandardNumber = 
$infoObject->getPropertyByName('standard_number', array('scope'=>'rad'));
+
+    // overwrite the default edit template
+    $this->setTemplate('editRad');
   }
 }

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateRadAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateRadAction.class.php
  2008-11-07 20:32:37 UTC (rev 1536)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateRadAction.class.php
  2008-11-07 23:21:11 UTC (rev 1537)
@@ -46,6 +46,9 @@
       $this->informationObject->setNote($options = array('userId' => 
$this->getUser()->getAttribute('user_id'), 'note' => 
$this->getRequestParameter('rad_note'), 'noteTypeId' => 
$this->getRequestParameter('rad_note_type')));
     }
 
+    // Update RAD Properties
+    $this->updateRadProperties($request);
+
     // update informationObject in the search index
     if (!$this->foreignKeyUpdate)
     {
@@ -56,7 +59,91 @@
       SearchIndex::updateTranslatedLanguages($this->informationObject);
     }
 
-   // return to RAD edit template
-   return $this->redirect(array('module' => 'informationobject', 'action' => 
'edit', 'informationobject_template' => 'rad', 'id' => 
$this->informationObject->getId()));
+    // return to RAD edit template
+    return $this->redirect(array('module' => 'informationobject', 'action' => 
'edit', 'informationobject_template' => 'rad', 'id' => 
$this->informationObject->getId()));
   }
+
+  protected function updateRadProperties($request)
+  {
+    // Rad 1.1 properties
+    if ($newValue = $this->getRequestParameter('rad_other_title_information'))
+    {
+      $this->informationObject->saveProperty('other_title_information', 
$newValue, array('scope'=>'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_title_statement_of_responsibility'))
+    {
+      
$this->informationObject->saveProperty('title_statement_of_responsibility', 
$newValue, array('scope' => 'rad'));
+    }
+
+    // Rad 1.2 properties
+    if ($newValue = 
$this->getRequestParameter('rad_edition_statement_of_responsibility'))
+    {
+      
$this->informationObject->saveProperty('edition_statement_of_responsibility', 
$newValue, array('scope' => 'rad'));
+    }
+
+    // Rad 1.3 properties
+    if ($newValue = 
$this->getRequestParameter('rad_statement_of_scale_cartographic'))
+    {
+      
$this->informationObject->saveProperty('statement_of_scale_cartographic', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = $this->getRequestParameter('rad_statement_of_projection'))
+    {
+      $this->informationObject->saveProperty('statement_of_projection', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = $this->getRequestParameter('rad_statement_of_coordinates'))
+    {
+      $this->informationObject->saveProperty('statement_of_coordinates', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_statement_of_scale_architectural'))
+    {
+      
$this->informationObject->saveProperty('statement_of_scale_architectural', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_issuing_jursidiction_and_denomination'))
+    {
+      
$this->informationObject->saveProperty('issuing_jursidiction_and_denomination', 
$newValue, array('scope' => 'rad'));
+    }
+
+    // Rad 1.6 properties
+    if ($newValue = 
$this->getRequestParameter('rad_title_proper_of_publishers_series'))
+    {
+      
$this->informationObject->saveProperty('title_proper_of_publishers_series', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_parallel_titles_of_publishers_series'))
+    {
+      
$this->informationObject->saveProperty('parallel_titles_of_publishers_series', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_other_title_information_of_publishers_series'))
+    {
+      
$this->informationObject->saveProperty('other_title_information_of_publishers_series',
 $newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_statement_of_responsibility_relating_to_publishers_series'))
+    {
+      
$this->informationObject->saveProperty('statement_of_responsibility_relating_to_publishers_series',
 $newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_numbering_within_publishers_series'))
+    {
+      
$this->informationObject->saveProperty('numbering_within_publishers_series', 
$newValue, array('scope' => 'rad'));
+    }
+
+    if ($newValue = 
$this->getRequestParameter('rad_note_on_publishers_series'))
+    {
+      $this->informationObject->saveProperty('note_on_publishers_series', 
$newValue, array('scope' => 'rad'));
+    }
+
+    // Rad 1.9 properties
+    if ($newValue = $this->getRequestParameter('rad_standard_number'))
+    {
+      $this->informationObject->saveProperty('standard_number', $newValue, 
array('scope' => 'rad'));
+    }
+
+  }
 }

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php  
    2008-11-07 20:32:37 UTC (rev 1536)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/templates/editIsadSuccess.php  
    2008-11-07 23:21:11 UTC (rev 1537)
@@ -122,6 +122,7 @@
           <td style= "width: 40%; color: #999999; font-weight: bold"><?php 
echo __('Creation date(s)') ?></td>
           <td style="width:5%"></td>
         </tr>
+        <?php if(count($creationEvents)): ?>
         <?php foreach ($creationEvents as $creationEvent): ?>
         <tr>
           <td>
@@ -135,6 +136,7 @@
           </td>
         </tr>
         <?php endforeach; ?>
+        <?php endif; ?>
       </table>
     </div>
 

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/templates/editRadSuccess.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/templates/editRadSuccess.php   
    2008-11-07 20:32:37 UTC (rev 1536)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/templates/editRadSuccess.php   
    2008-11-07 23:21:11 UTC (rev 1537)
@@ -51,12 +51,18 @@
 
     <div class="form-item">
       <label for="other title information"><?php echo __('other title 
information'); ?></label>
-      <strong>TODO: add QubitProperty 'other_title_information'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radOtherTitleInformation->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radOtherTitleInformation, 'getValue', 
array('name' => 'rad_other_title_information', 'size' => 20)) ?>
     </div>
 
     <div class="form-item">
       <label for="statements of responsibility"><?php echo __('statements of 
responsibility'); ?></label>
-      <strong>TODO: add QubitProperty 
'title_statement_of_responsibility'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radTitleStatementOfResponsibility->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radTitleStatementOfResponsibility, 
'getValue', array('name' => 'rad_title_statement_of_responsibility', 'size' => 
20)) ?>
     </div>
 
     <div class="form-item">
@@ -82,23 +88,28 @@
         </tr>
       </table>
     </div>
+    
+    <table style="border: 0; width: 98%; margin: 0; padding: 0;">
+      <tr>
+        <td style="width: 150px;">
+          <div class="form-item">
+            <label for="level_of_description_id"><?php echo __('level of 
description'); ?></label>
+            <?php echo object_select_tag($informationObject, 
'getLevelOfDescriptionId', array('related_class' => 'QubitTerm', 
'include_blank' => true, 'peer_method' => 'getLevelsOfDescription')) ?>
+          </div>
+        </td>
+        <td style="padding-left: 10px;">
+          <div class="form-item">
+            <label for="parent_id"><?php echo __('parent level'); ?></label>
+            <?php echo object_select_tree(
+              $informationObject, 'getParentId', array('disabled' => 
$informationObject->getDescendants()->andSelf()->indexBy('id'),
+              'include_blank' => true, 'peer_method' => 'getDescendants',
+              'related_class' => 
QubitInformationObject::getOne(QubitInformationObject::addRootsCriteria(new 
Criteria)))) ?>
+          </div>
+        </td>
+      </tr>
+    </table>
 
-    <table style="border: 0; width: 98%; margin: 0; padding: 0;"><tr><td 
style="width: 150px;">
     <div class="form-item">
-      <label for="level_of_description_id"><?php echo __('level of 
description'); ?></label>
-      <?php echo object_select_tag($informationObject, 
'getLevelOfDescriptionId', array('related_class' => 'QubitTerm', 
'include_blank' => true, 'peer_method' => 'getLevelsOfDescription')) ?>
-    </div>
-
-    </td><td style="padding-left: 10px;">
-
-    <div class="form-item">
-      <label for="parent_id"><?php echo __('parent level'); ?></label>
-      <?php echo object_select_tree($informationObject, 'getParentId', 
array('disabled' => 
$informationObject->getDescendants()->andSelf()->indexBy('id'), 'include_blank' 
=> true, 'peer_method' => 'getDescendants', 'related_class' => 
QubitInformationObject::getOne(QubitInformationObject::addRootsCriteria(new 
Criteria)))) ?>
-    </div>
-
-  </td></tr></table>
-
-     <div class="form-item">
       <label for="repository_id"><?php echo __('repository'); ?></label>
       <?php echo object_select_tag($informationObject, 'getRepositoryId', 
array('include_blank' => true,)) ?>
     </div>
@@ -114,8 +125,6 @@
         <?php echo QubitRad::getReferenceCode($informationObject) ?>
       </div>
     <?php endif; ?>
-
-
   </fieldset>
 
 
@@ -132,7 +141,10 @@
 
     <div class="form-item">
       <label for="statements of responsibility"><?php echo __('statements of 
responsibility'); ?></label>
-      <strong>TODO: add QubitProperty 
'edition_statement_of_responsibility'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radEditionStatementOfResponsibility->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radEditionStatementOfResponsibility, 
'getValue', array('name' => 'rad_edition_statement_of_responsibility', 'size' 
=> 20)) ?>
     </div>
 
    </fieldset>
@@ -142,29 +154,43 @@
 
     <div class="form-item">
       <label for="statement of scale (cartographic)"><?php echo __('statement 
of scale (cartographic)'); ?></label>
-      <strong>TODO: add QubitProperty 
'statement_of_scale_cartographic'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radStatementOfScaleCartographic->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radStatementOfScaleCartographic, 
'getValue', array('name' => 'rad_statement_of_scale_cartographic', 'size' => 
20)) ?>
     </div>
 
     <div class="form-item">
       <label for="statement of projection"><?php echo __('statement of 
projection'); ?></label>
-      <strong>TODO: add QubitProperty 'statement_of_projection'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radStatementOfProjection->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radStatementOfProjection, 'getValue', 
array('name' => 'rad_statement_of_projection', 'size' => 20)) ?>
     </div>
 
     <div class="form-item">
       <label for="statement of coordinates"><?php echo __('statement of 
coordinates'); ?></label>
-      <strong>TODO: add QubitProperty 'statement_of_coordinates'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radStatementOfCoordinates->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radStatementOfCoordinates, 'getValue', 
array('name' => 'rad_statement_of_coordinates', 'size' => 20)) ?>
     </div>
 
     <div class="form-item">
       <label for="statement of scale (architectural)"><?php echo __('statement 
of scale (architectural)'); ?></label>
-      <strong>TODO: add QubitProperty 
'statement_of_scale_architectural'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radStatementOfScaleArchitectural->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radStatementOfScaleArchitectural, 
'getValue', array('name' => 'rad_statement_of_scale_architectural', 'size' => 
20)) ?>
     </div>
 
     <div class="form-item">
       <label for="issuing jurisdiction and denomination"><?php echo 
__('issuing jursdiction and denomination'); ?></label>
-      <strong>TODO: add QubitProperty 
'issuing_jursidiction_and_denomination'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radIssuingJursidictionAndDenomination->getSourceTextForTranslation($sf_user->getCulture()))):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radIssuingJursidictionAndDenomination, 
'getValue', array('name' => 'rad_issuing_jursidiction_and_denomination', 'size' 
=> 20)) ?>
     </div>
-
    </fieldset>
 
 
@@ -241,32 +267,50 @@
 
     <div class="form-item">
       <label for="Title proper of publisher's series"><?php echo __("Title 
proper of publisher's series"); ?></label>
-      <strong>TODO: add QubitProperty 
'title_proper_of_publishers_series'</strong>
+      <?php if ($sourceCultureValue = 
$radTitleProperOfPublishersSeries->getSourceTextForTranslation($sf_user->getCulture())):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radTitleProperOfPublishersSeries, 
'getValue', array('name' => 'rad_title_proper_of_publishers_series', 'size' => 
'20')) ?>
     </div>
 
     <div class="form-item">
       <label for="Parallel titles of publisher's series"><?php echo 
__("Parallel titles of publisher's series"); ?></label>
-      <strong>TODO: add QubitProperty 
'parallel_titles_of_publishers_series'</strong>
+      <?php if ($sourceCultureValue = 
$radParallelTitlesOfPublishersSeries->getSourceTextForTranslation($sf_user->getCulture())):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radParallelTitlesOfPublishersSeries, 
'getValue', array('name' => 'rad_parallel_titles_of_publishers_series', 'size' 
=> '20')) ?>
     </div>
 
     <div class="form-item">
       <label for="Other title information of publisher's series"><?php echo 
__("Other title information of publisher's series"); ?></label>
-      <strong>TODO: add QubitProperty 
'other_title_information_of_publishers_series'</strong>
+      <?php if ($sourceCultureValue = 
$radOtherTitleInformationOfPublishersSeries->getSourceTextForTranslation($sf_user->getCulture())):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radOtherTitleInformationOfPublishersSeries, 
'getValue', array('name' => 'rad_other_title_information_of_publishers_series', 
'size' => '20')) ?>
     </div>
 
     <div class="form-item">
       <label for="Statement of responsibility relating to publisher's 
series"><?php echo __("Statement of responsibility relating to publisher's 
series"); ?></label>
-      <strong>TODO: add QubitProperty 
'statement_of_responsibility_relating_to_publishers_series'</strong>
+      <?php if ($sourceCultureValue = 
$radStatementOfResponsibilityRelatingToPublishersSeries->getSourceTextForTranslation($sf_user->getCulture())):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo 
object_input_tag($radStatementOfResponsibilityRelatingToPublishersSeries, 
'getValue', array('name' => 
'rad_statement_of_responsibility_relating_to_publishers_series', 'size' => 
'20')) ?>
     </div>
 
     <div class="form-item">
       <label for="Numbering within publisher's series"><?php echo 
__("Numbering within publisher's series"); ?></label>
-      <strong>TODO: add QubitProperty 
'numbering_within_publishers_series'</strong>
+      <?php if ($sourceCultureValue = 
$radNumberingWithinPublishersSeries->getSourceTextForTranslation($sf_user->getCulture())):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radNumberingWithinPublishersSeries, 
'getValue', array('name' => 'rad_numbering_within_publishers_series', 'size' => 
'20')) ?>
     </div>
 
      <div class="form-item">
       <label for="Note on publisher's series"><?php echo __("Note on 
publisher's series"); ?></label>
-      <strong>TODO: add QubitProperty 'note_on_publishers_series'</strong>
+      <?php if ($sourceCultureValue = 
$radNoteOnPublishersSeries->getSourceTextForTranslation($sf_user->getCulture())):
 ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_textarea_tag($radNoteOnPublishersSeries, 'getValue', 
array('name' => 'rad_note_on_publishers_series', 'size' => '30x3')) ?>
     </div>
     </fieldset>
 
@@ -428,7 +472,10 @@
 
    <div class="form-item">
       <label for="statement of coordinates"><?php echo __('standard number'); 
?></label>
-      <strong>TODO: add QubitProperty 'standard_number'</strong>
+      <?php if (strlen($sourceCultureValue = 
$radStandardNumber->getSourceTextForTranslation($sf_user->getCulture()))): ?>
+      <div class="default-translation"><?php echo nl2br($sourceCultureValue) 
?></div>
+      <?php endif; ?>
+      <?php echo object_input_tag($radStandardNumber, 'getValue', array('name' 
=> 'rad_standard_number', 'size' => 20)) ?>
    </div>
 
   </fieldset>

Modified: trunk/qubit/lib/model/QubitInformationObject.php
===================================================================
--- trunk/qubit/lib/model/QubitInformationObject.php    2008-11-07 20:32:37 UTC 
(rev 1536)
+++ trunk/qubit/lib/model/QubitInformationObject.php    2008-11-07 23:21:11 UTC 
(rev 1537)
@@ -73,7 +73,7 @@
   protected function deletePhysicalObjectRelations()
   {
     $relations = QubitRelation::getRelationsByObjectId($this->getId(),
-      array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
+    array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
 
     foreach ($relations as $relation)
     {
@@ -113,7 +113,7 @@
     /*
     if ($informationObject->getDates($eventType = 'creation'))
     {
-      $label .= ' ['.$informationObject->getDates($eventType = 'creation').']';
+    $label .= ' ['.$informationObject->getDates($eventType = 'creation').']';
     }
     */
 
@@ -241,13 +241,13 @@
     $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID);
     $criteria->add(QubitNote::OBJECT_ID, $this->getId());
     if (isset($options['noteTypeId']))
-      {
+    {
       $criteria->add(QubitNote::TYPE_ID, $options['noteTypeId']);
-      }
+    }
     if (isset($options['excludeNoteTypeId']))
-      {
+    {
       $criteria->add(QubitNote::TYPE_ID, $options['excludeNoteTypeId'], 
Criteria::NOT_EQUAL);
-      }
+    }
 
     return QubitNote::get($criteria);
   }
@@ -258,9 +258,9 @@
     $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID);
     $criteria->add(QubitNote::OBJECT_ID, $this->getId());
     if (isset($options['taxonomyId']))
-      {
+    {
       $criteria->add(QubitTerm::TAXONOMY_ID, $options['taxonomyId']);
-      }
+    }
 
     return QubitNote::get($criteria);
   }
@@ -296,9 +296,9 @@
     $criteria = new Criteria;
     $criteria->add(QubitEvent::INFORMATION_OBJECT_ID, $this->getId());
     if ($typeId)
-     {
-     $criteria->add(QubitEvent::TYPE_ID, $typeId);
-     }
+    {
+      $criteria->add(QubitEvent::TYPE_ID, $typeId);
+    }
     $criteria->addDescendingOrderByColumn(QubitEvent::START_DATE);
 
     return QubitEvent::get($criteria);
@@ -353,11 +353,11 @@
     $criteria = new Criteria;
     $criteria->add(QubitEvent::INFORMATION_OBJECT_ID, $this->getId());
     switch ($eventType)
-      {
-        case 'creation' :
+    {
+      case 'creation' :
         $criteria->add(QubitEvent::TYPE_ID, QubitTerm::CREATION_ID);
         break;
-      }
+    }
     $criteria->addDescendingOrderByColumn(QubitEvent::START_DATE);
     $events = QubitEvent::get($criteria);
 
@@ -372,17 +372,17 @@
 
   public function getDatesOfDescription()
   {
-  //from system event object
+    //from system event object
 
-  return null;
+    return null;
   }
 
   /**
    * Add a many-to-many Term relation to this information object.
-   * 
+   *
    * @param integer $termId primary key of QubitTerm
    * @param string  $relationNote descriptive string (optional)
-   * @return QubitInformationObject $this  
+   * @return QubitInformationObject $this
    */
   public function addTermRelation($termId, $relationNote = null)
   {
@@ -392,8 +392,8 @@
       $newTermRelation = new QubitObjectTermRelation;
       $newTermRelation->setObject($this);
       $newTermRelation->setTermId($termId);
-  //TODO: move to QubitNote
-  //  $newTermRelation->setRelationNote($relationNote);
+      //TODO: move to QubitNote
+      //  $newTermRelation->setRelationNote($relationNote);
       $newTermRelation->save();
     }
 
@@ -416,8 +416,8 @@
 
   /**
    * Get related term object by id (should be unique)
-   * 
-   * @param 
+   *
+   * @param
    */
   public function getTermRelation($termId)
   {
@@ -430,7 +430,7 @@
 
   /**
    * Add a property related to this information object
-   * 
+   *
    * @param string $name  Name of property
    * @param string $value Value of property
    * @param string $options array of optional parameters
@@ -446,10 +446,10 @@
   /**
    * Return all properties related to this information object,
    * with option of filtering by name and/or scope
-   * 
+   *
    * @param string $name filter results by name (optional)
    * @param string $scope filter results by scope (optional)
-   * @return QubitQuery list of QubitProperty objects matching criteria 
+   * @return QubitQuery list of QubitProperty objects matching criteria
    */
   public function getProperties($name = null, $scope = null)
   {
@@ -492,7 +492,7 @@
 
   /**
    * Add a name access point to this info object
-   * 
+   *
    * @param integer $actorId primary key of actor
    * @param integer $actorRoleId foriegn key to QubitTerm for actor role 
taxonomy
    * @return QubitInformationObject this object
@@ -515,7 +515,7 @@
 
   /**
    * Get an array of name access points related to this InformationObject.
-   * 
+   *
    * @return array of related QubitEvent objects.
    */
   public function getNameAccessPoints()
@@ -533,7 +533,7 @@
 
   /**
    * Get name access point by $actorId and $actorRoleId (should be unique)
-   * 
+   *
    * @param integer $actorId foreign key to QubitActor::ID
    * @param integer $actorRoleId foreign key to QubitTerm (actor role taxonomy)
    * @return QubitEvent object or NULL if no matching relation found
@@ -573,107 +573,107 @@
     return $this->getTermRelations(QubitTaxonomy::MATERIAL_TYPE_ID);
   }
 
-public function getRepositoryCountry()
+  public function getRepositoryCountry()
   {
-  if ($this->getRepositoryId())
+    if ($this->getRepositoryId())
     {
-    return $this->getRepository()->getCountry();
+      return $this->getRepository()->getCountry();
+    }
+    else
+    {
+      return null;
+    }
   }
-  else
-  {
-    return null;
-    }
-}
 
-//generate strings for search index:
-public function getCreatorsNameString()
+  //generate strings for search index:
+  public function getCreatorsNameString()
   {
-  if ($this->getCreators())
+    if ($this->getCreators())
     {
-    $creatorNameString = '';
-    $creators = $this->getCreators();
-    foreach ($creators as $creator)
-    {
-      $creatorNameString .= $creator->getAuthorizedFormOfName().' ';
-      foreach ($creator->getOtherNames() as $otherName)
+      $creatorNameString = '';
+      $creators = $this->getCreators();
+      foreach ($creators as $creator)
       {
-        $creatorNameString .= $otherName->getName().' ';
+        $creatorNameString .= $creator->getAuthorizedFormOfName().' ';
+        foreach ($creator->getOtherNames() as $otherName)
+        {
+          $creatorNameString .= $otherName->getName().' ';
+        }
       }
-    }
 
-    return $creatorNameString;
-  }
-  else
-  {
-    return null;
+      return $creatorNameString;
     }
+    else
+    {
+      return null;
+    }
   }
 
-public function getCreatorsHistoryString()
+  public function getCreatorsHistoryString()
   {
-  if ($this->getCreators())
+    if ($this->getCreators())
     {
-    $creatorHistoryString = '';
-    $creators = $this->getCreators();
-    foreach ($creators as $creator)
+      $creatorHistoryString = '';
+      $creators = $this->getCreators();
+      foreach ($creators as $creator)
       {
-      $creatorHistoryString .= $creator->getHistory().' ';
+        $creatorHistoryString .= $creator->getHistory().' ';
       }
 
-    return $creatorHistoryString;
-  }
-  else
-  {
-    return null;
+      return $creatorHistoryString;
     }
+    else
+    {
+      return null;
+    }
   }
 
-public function getSubjectsString($language)
+  public function getSubjectsString($language)
   {
-  $subjectString = '';
+    $subjectString = '';
 
-  $subjects = $this->getSubjectAccessPoints();
-  if ($subjects)
+    $subjects = $this->getSubjectAccessPoints();
+    if ($subjects)
     {
-    foreach ($subjects as $subject)
+      foreach ($subjects as $subject)
       {
-      $subjectString .= $subject->getTerm(array('culture' => $language)).' ';
+        $subjectString .= $subject->getTerm(array('culture' => $language)).' ';
       }
     }
 
-  return $subjectString;
+    return $subjectString;
   }
 
-public function getPlacesString($language)
+  public function getPlacesString($language)
   {
-  $placeString = '';
+    $placeString = '';
 
-  $places = $this->getPlaceAccessPoints();
-  if ($places)
+    $places = $this->getPlaceAccessPoints();
+    if ($places)
     {
-    foreach ($places as $place)
+      foreach ($places as $place)
       {
-      $placeString .= $place->getTerm(array('culture' => $language)).' ';
+        $placeString .= $place->getTerm(array('culture' => $language)).' ';
       }
     }
 
-  return $placeString;
+    return $placeString;
   }
 
   public function getNameAccessPointsString($language)
   {
-  $nameAccessPointString = '';
+    $nameAccessPointString = '';
 
-  $names = $this->getActors();
-  if ($names)
+    $names = $this->getActors();
+    if ($names)
     {
-    foreach ($names as $name)
+      foreach ($names as $name)
       {
-      $nameAccessPointString .= $name->getAuthorizedFormOfName(array('culture' 
=> $language)).' ';
+        $nameAccessPointString .= 
$name->getAuthorizedFormOfName(array('culture' => $language)).' ';
       }
     }
 
-  return $nameAccessPointString;
+    return $nameAccessPointString;
   }
 
   /**
@@ -695,10 +695,6 @@
     }
   }
 
-  // -------------------------------------------------------------------------
-  // Physical Object Relationship
-  // -------------------------------------------------------------------------
-
   /**
    * Add a relation from this info object to a phyical object. Check to make
    * sure the relationship is unique.
@@ -724,7 +720,7 @@
 
   /**
    * Get a physical object related to this info object
-   * 
+   *
    * @param integer $physicalObjectId the id of the related physical object
    * @return mixed the QubitRelation object on success, null if no match found
    */
@@ -736,4 +732,53 @@
 
     return QubitRelation::getOne($criteria);
   }
+
+  /**
+   * Get first matching related property by name (optionally scope).
+   * Return an empty QubitProperty object if a matching one doesn't exist.
+   *
+   * @param string $name
+   * @param array $options
+   * @return QubitProperty
+   */
+  public function getPropertyByName($name, $options = array())
+  {
+    if (null === $property = 
QubitProperty::getOneByObjectIdAndName($this->getId(), $name, $options))
+    {
+      $property = new QubitProperty;
+    }
+
+    return $property;
+  }
+
+  /**
+   * Save a related property and create a new property if a matching one 
doesn't
+   * already exist.
+   *
+   * @param string $name name of property
+   * @param string $value new value to set
+   * @param array $options array of options
+   * @return QubitInformationObject
+   */
+  public function saveProperty($name, $value, $options = array())
+  {
+    // Get existing property if possible
+    if (null === ($property = 
QubitProperty::getOneByObjectIdAndName($this->getId(), $name, $options)))
+    {
+      // Create a new property if required
+      $property = new QubitProperty;
+      $property->setObjectId($this->getId());
+      $property->setName($name);
+
+      if (isset($options['scope']))
+      {
+        $property->setScope($options['scope']);
+      }
+    }
+
+    $property->setValue($value, $options);
+    $property->save();
+
+    return $this;
+  }
 }

Modified: trunk/qubit/lib/model/QubitProperty.php
===================================================================
--- trunk/qubit/lib/model/QubitProperty.php     2008-11-07 20:32:37 UTC (rev 
1536)
+++ trunk/qubit/lib/model/QubitProperty.php     2008-11-07 23:21:11 UTC (rev 
1537)
@@ -50,41 +50,47 @@
   }
 
   /**
-   * Add a property related to this information object
+   * Get source culture text for "value" column for this property to aid in
+   * translation on the front-end.
    *
-   * @param integer $objectId foreign key to QubitObject::ID
-   * @param string $name  Name of property
-   * @param string $value Value of property
-   * @param string $options array of optional parameters
-   * @return QubitInformationObject this information object
+   * @param string $sfUserCulture current culture selected by user
+   * @return string source culture value
    */
-  public static function addProperty($objectId, $name, $value, $options = 
array())
+  public function getSourceTextForTranslation($sfUserCulture)
   {
-    // Only add this property if an identical one does NOT exist already
-    if (QubitProperty::isPropertyExistent($objectId, $name, $value, $options))
+    if (strlen($sourceCultureValue = $this->getValue(array('sourceCulture' => 
'true'))) > 0 && $sfUserCulture != $this->getSourceCulture())
     {
 
-      return null;
+      return $sourceCultureValue;
     }
 
-    // Save property
-    $newProperty = new QubitProperty;
-    $newProperty->setObjectId($objectId);
-    $newProperty->setName($name);
-    $newProperty->setValue($value, $options);
+    return null;
+  }
 
+  /**
+   * Get a unique property associated with object identified by $objectId
+   *
+   * @param integer $objectId foreign key to related object
+   * @param string $name name of property
+   * @param array $options optional parameter array
+   * @return QubitProperty matching property (if any)
+   */
+  public static function getOneByObjectIdAndName($objectId, $name, $options = 
array())
+  {
+    $criteria = new Criteria;
+    $criteria->add(QubitProperty::OBJECT_ID, $objectId);
+    $criteria->add(QubitProperty::NAME, $name);
+
     if (isset($options['scope']))
     {
-      $newProperty->setScope($options['scope']);
+      $criteria->add(QubitProperty::SCOPE, $options['scope']);
     }
 
-    $newProperty->save();
-
-    return $newProperty;
+    return QubitProperty::getOne($criteria);
   }
 
   /**
-   * Get an existing property related to this information object.
+   * Determine if a property matching passed values already exists.
    *
    * @param integer $objectId foreign key to QubitObject::ID
    * @param string $name  name of property


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