Author: david
Date: 2008-11-12 17:15:15 -0800 (Wed, 12 Nov 2008)
New Revision: 1584

Modified:
   
trunk/qubit/apps/qubit/modules/digitalobject/actions/imageflowComponent.class.php
   
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
   trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php
   
trunk/qubit/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php
Log:
Clean up information object context menu - move logic from template into 
action.  Preparation for hiding contextMenu (and grey box) altogether if no 
items shown in context menu.

Modified: 
trunk/qubit/apps/qubit/modules/digitalobject/actions/imageflowComponent.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/digitalobject/actions/imageflowComponent.class.php
   2008-11-12 23:55:51 UTC (rev 1583)
+++ 
trunk/qubit/apps/qubit/modules/digitalobject/actions/imageflowComponent.class.php
   2008-11-13 01:15:15 UTC (rev 1584)
@@ -34,15 +34,8 @@
     $this->getResponse()->addStylesheet('imageflow');
     $this->getResponse()->addJavaScript('imageflow');
 
-    $this->thumbnails = $this->informationObject->getDescendantThumbnails();
-    if (count($this->thumbnails) < 1)
-    {
-
-      return sfView::NONE;
-    }
-    
     // Hack to get parent info object for generic thumbnails. Required because
-    // getTopAncestorOrSelf() method queries database and generic thumbnail 
+    // getTopAncestorOrSelf() method queries database and generic thumbnail
     // objects are not represented in the database.
     foreach ($this->thumbnails as $thumbnail)
     {
@@ -50,10 +43,10 @@
       {
         $parentInfoObject = 
$thumbnail->getParent()->getTopAncestorOrSelf()->getInformationObject();
       }
-      
+
       $informationObjects[] = $parentInfoObject;
     }
-    
+
     $this->informationObjects = $informationObjects;
   }
 }
\ No newline at end of file

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
     2008-11-12 23:55:51 UTC (rev 1583)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
     2008-11-13 01:15:15 UTC (rev 1584)
@@ -24,20 +24,79 @@
   public function execute($request)
   {
     $this->informationObject = $request->getAttribute('informationObject');
+    $this->multiRepository = (sfConfig::get('app_multi_repository') == 0) ? 
false : true;
 
+    //determine if user has edit priviliges
+    $this->editCredentials = 
(SecurityPriviliges::editCredentials($this->getUser(), 'informationObject')) ? 
true : false;
+
+    // Get info object ancestors
     $this->informationObjects = array();
     if (count($this->informationObject->getAncestors()) > 0)
     {
       $this->informationObjects = 
$this->informationObject->getAncestors()->andSelf()->orderBy('lft')->offsetGet(1)->getDescendants()->andSelf();
     }
-    
-    $this->multiRepository = (sfConfig::get('app_multi_repository') == 0) ? 
false : true;
-    
-    //determine if user has edit priviliges
-    $this->editCredentials = false;
-    if (SecurityPriviliges::editCredentials($this->getUser(), 
'informationObject'))
+
+    // Get repository for current object if system is multi-repository
+    // (No point showing repository context if there is only one repository)
+    if ($this->multiRepository)
     {
-      $this->editCredentials = true;
+      if (null === $repository = $this->informationObject->getRepository())
+      {
+        // Ascend up object hierarchy until a related repository is found
+        foreach ($this->informationObject->getAncestors() as $ancestor)
+        {
+          if (null !== $repository = $ancestor->getRepository())
+          {
+            $repositoryOptions['title'] = __('Inherited from %ancestor%', 
array('%ancestor%' => $ancestor));
+            break;
+          }
+        }
+      }
+      $repositoryOptions['id'] = 'repositoryLink';
+      $this->repositoryOptions = $repositoryOptions;
     }
+    $this->repository = $repository;
+
+    // Get Creators
+    if (count($creators = $this->informationObject->getCreators()) < 1)
+    {
+      foreach ($this->informationObject->getAncestors() as $ancestor)
+      {
+        if (count($creators = $ancestor->getCreators()) >= 1)
+        {
+          $creatorOptions['title'] = __('Inherited from %ancestor%', 
array('%ancestor%' => $ancestor));
+          break;
+        }
+      }
+    }
+    $creatorOptions['id'] = 'creatorsLink';
+    $this->creatorOptions = $creatorOptions;
+    $this->creators = $creators;
+
+    // Get digital object thumbnails
+    $this->thumbnails = $this->informationObject->getDescendantThumbnails();
+
+    // Get physical storage locations (only if user has edit privileges)
+    $physicalObjects = array();
+    if ($this->editCredentials == true)
+    {
+      $this->currentInformationObject = 
$request->getAttribute('informationObject');
+      $childInformationObjects = 
$this->currentInformationObject->getDescendants()->andSelf();
+      foreach ($childInformationObjects as $informationObject)
+      {
+        $relatedPhysicalObjects = 
QubitRelation::getRelatedSubjectsByObjectId($informationObject->getId(),
+        array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
+
+        foreach ($relatedPhysicalObjects as $physicalObject)
+        {
+          // Check to make sure this object is not already in the array
+          if (!in_array($physicalObject, $physicalObjects))
+          {
+            $physicalObjects[] = $physicalObject;
+          }
+        }
+      }
+    }
+    $this->physicalObjects = $physicalObjects;
   }
 }

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php
===================================================================
--- trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php 
2008-11-12 23:55:51 UTC (rev 1583)
+++ trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php 
2008-11-13 01:15:15 UTC (rev 1584)
@@ -1,65 +1,41 @@
 <?php use_helper('Javascript') ?>
 
+<?php 
$sf_response->addJavaScript('/vendor/yui/yahoo-dom-event/yahoo-dom-event') ?>
+<?php $sf_response->addJavaScript('/vendor/yui/container/container-min') ?>
+<?php 
$sf_response->addStylesheet('/vendor/yui/container/assets/skins/sam/container') 
?>
+
 <div class="context-column-box">
   <div class="contextMenu">
-    <?php $options = array() ?>
-    <?php if (null === $repository = $informationObject->getRepository()): ?>
-      <?php foreach ($informationObject->getAncestors() as $ancestor): ?>
-        <?php if (null === $repository = $ancestor->getRepository()): ?>
-          <?php continue ?>
-        <?php endif; ?>
-        <?php 
$sf_response->addJavaScript('/vendor/yui/yahoo-dom-event/yahoo-dom-event') ?>
-        <?php 
$sf_response->addJavaScript('/vendor/yui/container/container-min') ?>
-        <?php 
$sf_response->addStylesheet('/vendor/yui/container/assets/skins/sam/container') 
?>
-        <?php echo javascript_tag(<<<EOF
+    <?php if (isset($repository)): ?>
+      <?php echo javascript_tag(<<<EOF
 var repositoryTooltip = new YAHOO.widget.Tooltip('repositoryTooltip', {
   context: 'repositoryLink'});
 EOF
 ) ?>
-        <?php $options['id'] = 'repositoryLink' ?>
-        <?php $options['title'] = __('Inherited from %ancestor%', 
array('%ancestor%' => $ancestor)) ?>
-        <?php break ?>
-      <?php endforeach; ?>
-    <?php endif; ?>
-    <?php if (isset($repository) && $multiRepository): ?>
       <div class="label">
         <?php echo sfConfig::get('app_ui_label_repository') ?>
       </div>
-      <?php echo link_to($repository, 
'repository/show?id='.$repository->getId(), $options) ?>
+      <?php echo link_to($repository, 
'repository/show?id='.$repository->getId(), 
$sf_data->getRaw('repositoryOptions')) ?>
     <?php endif; ?>
 
-    <?php $options = array() ?>
-    <?php if (count($creators = $informationObject->getCreators()) < 1): ?>
-      <?php foreach ($informationObject->getAncestors() as $ancestor): ?>
-        <?php if (count($creators = $ancestor->getCreators()) < 1): ?>
-          <?php continue ?>
-        <?php endif; ?>
-        <?php 
$sf_response->addJavaScript('/vendor/yui/yahoo-dom-event/yahoo-dom-event') ?>
-        <?php 
$sf_response->addJavaScript('/vendor/yui/container/container-min') ?>
-        <?php 
$sf_response->addStylesheet('/vendor/yui/container/assets/skins/sam/container') 
?>
-        <?php echo javascript_tag(<<<EOF
+    <?php if (count($creators) > 0): ?>
+      <?php echo javascript_tag(<<<EOF
 var repositoryTooltip = new YAHOO.widget.Tooltip('creatorsTooltip', {
   context: 'creatorsLink'});
 EOF
 ) ?>
-        <?php $options['id'] = 'creatorsLink' ?>
-        <?php $options['title'] = __('Inherited from %ancestor%', 
array('%ancestor%' => $ancestor)) ?>
-        <?php break ?>
-      <?php endforeach; ?>
-    <?php endif; ?>
-    <?php if (count($creators) > 0): ?>
       <div class="label">
         <?php echo sfConfig::get('app_ui_label_creator') ?>
       </div>
       <ul>
         <?php foreach ($creators as $creator): ?>
-          <li><?php echo link_to($creator, 'actor/show?id='.$creator->getId(), 
$options) ?></li>
+          <li><?php echo link_to($creator, 'actor/show?id='.$creator->getId(), 
$sf_data->getRaw('creatorOptions')) ?></li>
         <?php endforeach; ?>
       </ul>
     <?php endif; ?>
 
-    <?php if (count($informationObjects) > 1): ?>
-      <?php include_component('digitalobject', 'imageflow', 
array('informationObject' => $informationObject)) ?>
+    <?php if (count($thumbnails) > 1): ?>
+      <?php include_component('digitalobject', 'imageflow', array('thumbnails' 
=> $thumbnails)) ?>
     <?php endif; ?>
 
     <?php if (count($informationObjects) > 1): ?>
@@ -69,9 +45,8 @@
       <?php include_component('informationobject', 'treeView', 
array('informationObjects' => $informationObjects)) ?>
     <?php endif; ?>
     
-    <?php if (count($informationObjects) > 1 && $editCredentials == true): ?>
-      <?php include_component('physicalobject', 'contextMenu', 
array('informationObjects' => $informationObjects)) ?>
+    <?php if (count($physicalObjects)): ?>
+      <?php include_component('physicalobject', 'contextMenu', 
array('physicalObjects' => $physicalObjects)) ?>
     <?php endif; ?>
-    
   </div>
 </div>

Modified: 
trunk/qubit/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php
        2008-11-12 23:55:51 UTC (rev 1583)
+++ 
trunk/qubit/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php
        2008-11-13 01:15:15 UTC (rev 1584)
@@ -31,33 +31,6 @@
 {
   public function execute($request)
   {
-    $this->currentInformationObject = 
$request->getAttribute('informationObject');
-    
-    $childInformationObjects = 
$this->currentInformationObject->getDescendants()->andSelf();
-    
-    $physicalObjects = array();
-    foreach($childInformationObjects as $informationObject)
-    {
-      $relatedPhysicalObjects = 
QubitRelation::getRelatedSubjectsByObjectId($informationObject->getId(),
-        array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
-      
-      foreach ($relatedPhysicalObjects as $physicalObject)
-      {
-        
-        // Check to make sure this object is not already in the array
-        if (!in_array($physicalObject, $physicalObjects))
-        {
-         $physicalObjects[] = $physicalObject;
-        }
-      }
-    }
-    
-    if (count($physicalObjects) < 1)
-    {
-      
-      return sfView::NONE;
-    }
-    
-    $this->physicalObjects = $physicalObjects;
+    //$this->physicalObjects = $physicalObjects;
   }
 }
\ No newline at end of file


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