Author: david
Date: 2008-11-13 10:54:58 -0800 (Thu, 13 Nov 2008)
New Revision: 1586

Modified:
   
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/templates/_contextMenu.php
Log:
Don't show context menu component (or grey surrounding box) when there are no 
context items to show.

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
     2008-11-13 01:20:40 UTC (rev 1585)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
     2008-11-13 18:54:58 UTC (rev 1586)
@@ -21,7 +21,7 @@
 
 /**
  * Context menu for information objects
- * 
+ *
  * @package qubit
  * @subpackage information object
  * @version svn: $Id$
@@ -32,6 +32,7 @@
 {
   public function execute($request)
   {
+    $showContextMenu = false;
     $this->informationObject = $request->getAttribute('informationObject');
     $this->multiRepository = (sfConfig::get('app_multi_repository') == 0) ? 
false : true;
 
@@ -39,14 +40,17 @@
     $this->editCredentials = 
(SecurityPriviliges::editCredentials($this->getUser(), 'informationObject')) ? 
true : false;
 
     // Get info object ancestors
-    $this->informationObjects = array();
-    if (count($this->informationObject->getAncestors()) > 0)
+    $this->informationObjects = null;
+    if (count($this->informationObject->getAncestors()) > 1 || 
count($this->informationObject->getDescendants()) > 0)
     {
       $this->informationObjects = 
$this->informationObject->getAncestors()->andSelf()->orderBy('lft')->offsetGet(1)->getDescendants()->andSelf();
+      $showContextMenu = true;
     }
 
     // Get repository for current object if system is multi-repository
     // (No point showing repository context if there is only one repository)
+    $this->repository = null;
+    $this->repositoryOptions = null;
     if ($this->multiRepository)
     {
       if (null === $repository = $this->informationObject->getRepository())
@@ -57,16 +61,22 @@
           if (null !== $repository = $ancestor->getRepository())
           {
             $repositoryOptions['title'] = __('Inherited from %ancestor%', 
array('%ancestor%' => $ancestor));
+            $repositoryOptions['id'] = 'repositoryLink';
+            $this->repositoryOptions = $repositoryOptions;
             break;
           }
         }
       }
-      $repositoryOptions['id'] = 'repositoryLink';
-      $this->repositoryOptions = $repositoryOptions;
     }
-    $this->repository = $repository;
+    if (null !== $repository)
+    {
+      $this->repository = $repository;
+      $showContextMenu = true;
+    }
 
     // Get Creators
+    $this->creators = null;
+    $this->creatorOptions = null;
     if (count($creators = $this->informationObject->getCreators()) < 1)
     {
       foreach ($this->informationObject->getAncestors() as $ancestor)
@@ -74,23 +84,33 @@
         if (count($creators = $ancestor->getCreators()) >= 1)
         {
           $creatorOptions['title'] = __('Inherited from %ancestor%', 
array('%ancestor%' => $ancestor));
+          $creatorOptions['id'] = 'creatorsLink';
+          $this->creatorOptions = $creatorOptions;
           break;
         }
       }
     }
-    $creatorOptions['id'] = 'creatorsLink';
-    $this->creatorOptions = $creatorOptions;
-    $this->creators = $creators;
+    if (count($creators))
+    {
+      $this->creators = $creators;
+      $showContextMenu = true;
+    }
 
     // Get digital object thumbnails
-    $this->thumbnails = $this->informationObject->getDescendantThumbnails();
+    $this->thumbnails = null;
+    $thumbnails = $this->informationObject->getDescendantThumbnails();
+    if (count($thumbnails))
+    {
+      $this->thumbnails = $thumbnails;
+      $showContextMenu = true;
+    }
 
     // Get physical storage locations (only if user has edit privileges)
-    $physicalObjects = array();
+    $this->physicalObjects = null;
     if ($this->editCredentials == true)
     {
-      $this->currentInformationObject = 
$request->getAttribute('informationObject');
-      $childInformationObjects = 
$this->currentInformationObject->getDescendants()->andSelf();
+      $physicalObjects = array();
+      $childInformationObjects = 
$this->informationObject->getDescendants()->andSelf();
       foreach ($childInformationObjects as $informationObject)
       {
         $relatedPhysicalObjects = 
QubitRelation::getRelatedSubjectsByObjectId($informationObject->getId(),
@@ -105,7 +125,19 @@
           }
         }
       }
+
+      if (count($physicalObjects))
+      {
+        $this->physicalObjects = $physicalObjects;
+        $showContextMenu = true;
+      }
     }
-    $this->physicalObjects = $physicalObjects;
+
+    // If no context items found, don't show context menu
+    if (!$showContextMenu)
+    {
+
+      return sfView::NONE;
+    }
   }
 }

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php
===================================================================
--- trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php 
2008-11-13 01:20:40 UTC (rev 1585)
+++ trunk/qubit/apps/qubit/modules/informationobject/templates/_contextMenu.php 
2008-11-13 18:54:58 UTC (rev 1586)
@@ -46,7 +46,7 @@
     <?php endif; ?>
     
     <?php if (count($physicalObjects)): ?>
-      <?php include_component('physicalobject', 'contextMenu', 
array('physicalObjects' => $physicalObjects)) ?>
+      <?php include_component('physicalobject', 'contextMenu', 
array('physicalObjects' => $physicalObjects, 'informationObject' => 
$informationObject)) ?>
     <?php endif; ?>
   </div>
-</div>
+</div>
\ No newline at end of file

Modified: 
trunk/qubit/apps/qubit/modules/physicalobject/templates/_contextMenu.php
===================================================================
--- trunk/qubit/apps/qubit/modules/physicalobject/templates/_contextMenu.php    
2008-11-13 01:20:40 UTC (rev 1585)
+++ trunk/qubit/apps/qubit/modules/physicalobject/templates/_contextMenu.php    
2008-11-13 18:54:58 UTC (rev 1586)
@@ -8,7 +8,7 @@
   <?php if($type = $physicalObject->getType()) echo $type.': '; ?>
   <?php echo link_to($physicalObject->getName(array('cultureFallback' => 
'true')),
     array('module' => 'physicalobject', 'action' => 'edit', 'id' => 
$physicalObject->getId()), 
-    array('query_string' => 'next='.url_for(array('module' => 
'informationobject', 'action' => 'edit', 'id' => 
$currentInformationObject->getId())))
+    array('query_string' => 'next='.url_for(array('module' => 
'informationobject', 'action' => 'edit', 'id' => $informationObject->getId())))
   ) ?>
   <?php if($location = $physicalObject->getLocation(array('cultureFallback' => 
'true'))) echo ' - '.$location; ?>
 </td></tr>


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