Author: jablko
Date: Wed Oct 27 17:29:38 2010
New Revision: 8580

Log:
Use $route->resource

Modified:
   
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
   trunk/apps/qubit/modules/physicalobject/actions/autocompleteAction.class.php
   trunk/apps/qubit/modules/physicalobject/actions/boxListAction.class.php
   
trunk/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php
   trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
   trunk/apps/qubit/modules/physicalobject/actions/indexAction.class.php
   trunk/apps/qubit/modules/physicalobject/templates/_contextMenu.php
   trunk/apps/qubit/modules/physicalobject/templates/boxListSuccess.php
   trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php
   trunk/apps/qubit/modules/physicalobject/templates/editSuccess.php
   trunk/apps/qubit/modules/physicalobject/templates/indexSuccess.php

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
      Wed Oct 27 17:23:26 2010        (r8579)
+++ 
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
      Wed Oct 27 17:29:38 2010        (r8580)
@@ -69,6 +69,10 @@
         $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' 
=> QubitTerm::getIndentedChildTree(QubitTerm::CONTAINER_ID, ' ', 
array('returnObjectInstances' => true)))));
 
         break;
+
+      default:
+
+        return parent::addField($name);
     }
   }
 
@@ -114,7 +118,6 @@
     if ($request->isMethod('post'))
     {
       $this->form->bind($request->getPostParameters());
-
       if ($this->form->isValid())
       {
         $this->processForm();

Modified: 
trunk/apps/qubit/modules/physicalobject/actions/autocompleteAction.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/physicalobject/actions/autocompleteAction.class.php    
    Wed Oct 27 17:23:26 2010        (r8579)
+++ 
trunk/apps/qubit/modules/physicalobject/actions/autocompleteAction.class.php    
    Wed Oct 27 17:29:38 2010        (r8580)
@@ -35,7 +35,8 @@
     $criteria = new Criteria;
     $criteria->addJoin(QubitPhysicalObject::ID, QubitPhysicalObjectI18n::ID);
     $criteria->add(QubitPhysicalObjectI18n::CULTURE, 
$this->context->user->getCulture());
-    $criteria->add(QubitPhysicalObjectI18n::NAME, $request->query.'%', 
Criteria::LIKE);
+    $criteria->add(QubitPhysicalObjectI18n::NAME, "$request->query%", 
Criteria::LIKE);
+
     $criteria->addAscendingOrderByColumn(QubitPhysicalObjectI18n::NAME);
 
     $this->pager = new QubitPager('QubitPhysicalObject');

Modified: 
trunk/apps/qubit/modules/physicalobject/actions/boxListAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/actions/boxListAction.class.php     
Wed Oct 27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/actions/boxListAction.class.php     
Wed Oct 27 17:29:38 2010        (r8580)
@@ -26,12 +26,7 @@
       $request->limit = sfConfig::get('app_hits_per_page');
     }
 
-    $this->resource = QubitPhysicalObject::getById($request->id);
-
-    if (!isset($this->resource))
-    {
-      $this->forward404();
-    }
+    $this->resource = $this->getRoute()->resource;
 
     $criteria = new Criteria;
     $criteria->add(QubitRelation::SUBJECT_ID, $request->id);

Modified: 
trunk/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php  
    Wed Oct 27 17:23:26 2010        (r8579)
+++ 
trunk/apps/qubit/modules/physicalobject/actions/contextMenuComponent.class.php  
    Wed Oct 27 17:29:38 2010        (r8580)
@@ -29,14 +29,12 @@
 {
   public function execute($request)
   {
+    $this->resource = $request->getAttribute('sf_route')->resource;
+
     $this->physicalObjects = array();
-    foreach 
(QubitRelation::getRelatedSubjectsByObjectId('QubitPhysicalObject', 
$this->resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)) as 
$physicalObject)
+    foreach 
(QubitRelation::getRelatedSubjectsByObjectId('QubitPhysicalObject', 
$this->resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)) as 
$item)
     {
-      // Check physical object is unique
-      if (!in_array($physicalObject, $this->physicalObjects))
-      {
-        $this->physicalObjects[] = $physicalObject;
-      }
+      $this->physicalObjects[$item->id] = $item;
     }
 
     if (1 > count($this->physicalObjects))

Modified: trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php      
Wed Oct 27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php      
Wed Oct 27 17:29:38 2010        (r8580)
@@ -31,12 +31,7 @@
   {
     $this->form = new sfForm;
 
-    $this->resource = QubitPhysicalObject::getById($request->id);
-
-    if (!isset($this->resource))
-    {
-      $this->forward404();
-    }
+    $this->resource = $this->getRoute()->resource;
 
     $criteria = new Criteria;
     $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
@@ -54,7 +49,8 @@
 
       $this->resource->delete();
 
-      if (null !== $next = $this->form->getValue('next'))
+      $next = $this->form->getValue('next');
+      if (isset($next))
       {
         $this->redirect($next);
       }

Modified: trunk/apps/qubit/modules/physicalobject/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/actions/indexAction.class.php       
Wed Oct 27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/actions/indexAction.class.php       
Wed Oct 27 17:29:38 2010        (r8580)
@@ -21,11 +21,6 @@
 {
   public function execute($request)
   {
-    $this->resource = QubitPhysicalObject::getById($request->id);
-
-    if (!isset($this->resource))
-    {
-      $this->forward404();
-    }
+    $this->resource = $this->getRoute()->resource;
   }
 }

Modified: trunk/apps/qubit/modules/physicalobject/templates/_contextMenu.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/templates/_contextMenu.php  Wed Oct 
27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/templates/_contextMenu.php  Wed Oct 
27 17:29:38 2010        (r8580)
@@ -2,15 +2,19 @@
   <h3><?php echo sfConfig::get('app_ui_label_physicalobject') ?></h3>
   <div>
     <ul>
-      <?php foreach($physicalObjects as $physicalObject): ?>
+      <?php foreach ($physicalObjects as $item): ?>
         <li>
-          <?php if (isset($physicalObject->type)): ?>
-            <?php echo $physicalObject->type ?>:
+
+          <?php if (isset($item->type)): ?>
+            <?php echo $item->type ?>:
           <?php endif; ?>
-          <?php echo link_to_if(QubitAcl::check($resource, 'update'), 
render_title($physicalObject), array($physicalObject, 'module' => 
'physicalobject')) ?>
-          <?php if (isset($physicalObject->location)): ?>
-            - <?php echo $physicalObject->getLocation(array('cultureFallback' 
=> 'true')) ?>
+
+          <?php echo link_to_if(QubitAcl::check($resource, 'update'), 
render_title($item), array($item, 'module' => 'physicalobject')) ?>
+
+          <?php if (isset($item->location)): ?>
+            - <?php echo $item->getLocation(array('cultureFallback' => 
'true')) ?>
           <?php endif; ?>
+
         </li>
       <?php endforeach; ?>
     </ul>

Modified: trunk/apps/qubit/modules/physicalobject/templates/boxListSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/templates/boxListSuccess.php        
Wed Oct 27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/templates/boxListSuccess.php        
Wed Oct 27 17:29:38 2010        (r8580)
@@ -22,15 +22,15 @@
       </th>
     </tr>
   </thead><tbody>
-    <?php foreach ($informationObjects as $informationObject): ?>
+    <?php foreach ($informationObjects as $item): ?>
       <tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>">
         <td>
-          <?php $isad = new sfIsadPlugin($informationObject); echo 
render_value($isad->referenceCode) ?>
+          <?php $isad = new sfIsadPlugin($item); echo 
render_value($isad->referenceCode) ?>
         </td><td>
-          <?php echo link_to(render_title($informationObject), 
array($informationObject, 'module' => 'informationobject')) ?>
+          <?php echo link_to(render_title($item), array($item, 'module' => 
'informationobject')) ?>
         </td><td>
           <ul>
-            <?php foreach ($informationObject->getDates() as $date): ?>
+            <?php foreach ($item->getDates() as $date): ?>
               <li>
                 <?php echo 
Qubit::renderDateStartEnd($date->getDate(array('cultureFallback' => true)), 
$date->startDate, $date->endDate) ?> (<?php echo 
$date->getType(array('cultureFallback' => true)) ?>)
                 <?php if (isset($date->actor)): ?>
@@ -40,11 +40,11 @@
             <?php endforeach; ?>
           </ul>
         </td><td>
-          <?php if ($informationObject->getCollectionRoot()->id != 
$informationObject->id): ?>
-            <?php echo 
link_to(render_title($informationObject->getCollectionRoot()), array('module' 
=> 'informationobject', 'id' => $informationObject->getCollectionRoot()->id)) ?>
+          <?php if ($item->getCollectionRoot()->id != $item->id): ?>
+            <?php echo link_to(render_title($item->getCollectionRoot()), 
array('module' => 'informationobject', 'id' => $item->getCollectionRoot()->id)) 
?>
           <?php endif; ?>
         </td><td>
-          <?php echo 
render_value($informationObject->getAccessConditions(array('cultureFallback' => 
true))) ?>
+          <?php echo 
render_value($item->getAccessConditions(array('cultureFallback' => true))) ?>
         </td>
       </tr>
     <?php endforeach; ?>

Modified: trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php Wed Oct 
27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php Wed Oct 
27 17:29:38 2010        (r8580)
@@ -3,24 +3,29 @@
 <?php if (0 < count($informationObjects)): ?>
   <h2><?php echo __('Click Confirm to delete this physical storage from the 
system. This will also remove the physical storage location from the following 
records:') ?></h2>
   <ul>
-    <?php foreach ($informationObjects as $informationObject): ?>
-      <li><?php echo link_to(render_title($informationObject), 
array($informationObject, 'module' => 'informationobject')) ?></li>
+    <?php foreach ($informationObjects as $item): ?>
+      <li><?php echo link_to(render_title($item), array($item, 'module' => 
'informationobject')) ?></li>
     <?php endforeach; ?>
   </ul>
 <?php endif; ?>
 
+<?php echo $form->renderGlobalErrors() ?>
+
 <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 
'physicalobject', 'action' => 'delete')), array('method' => 'delete')) ?>
 
   <?php echo $form->renderHiddenFields() ?>
 
   <div class="actions section">
+
     <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
     <div class="content">
       <ul class="clearfix links">
         <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'physicalobject')) ?></li>
         <li><input class="form-submit" type="submit" value="<?php echo 
__('Confirm') ?>"/></li>
       </ul>
     </div>
+
   </div>
 
 </form>

Modified: trunk/apps/qubit/modules/physicalobject/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/templates/editSuccess.php   Wed Oct 
27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/templates/editSuccess.php   Wed Oct 
27 17:29:38 2010        (r8580)
@@ -4,7 +4,7 @@
 
 <?php echo $form->renderGlobalErrors() ?>
 
-<?php if (isset($sf_request->id)): ?>
+<?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
   <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 
'physicalobject', 'action' => 'edit'))) ?>
 <?php else: ?>
   <?php echo $form->renderFormTag(url_for(array('module' => 'physicalobject', 
'action' => 'add'))) ?>

Modified: trunk/apps/qubit/modules/physicalobject/templates/indexSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/templates/indexSuccess.php  Wed Oct 
27 17:23:26 2010        (r8579)
+++ trunk/apps/qubit/modules/physicalobject/templates/indexSuccess.php  Wed Oct 
27 17:29:38 2010        (r8580)
@@ -12,8 +12,8 @@
     <h3><?php echo __('Related resources') ?></h3>
     <div>
       <ul>
-        <?php foreach 
(QubitRelation::getRelatedObjectsBySubjectId('QubitInformationObject', 
$resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)) as 
$informationObject): ?>
-          <li><?php echo link_to(render_title($informationObject), 
array($informationObject, 'module' => 'informationobject')) ?></li>
+        <?php foreach 
(QubitRelation::getRelatedObjectsBySubjectId('QubitInformationObject', 
$resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)) as $item): 
?>
+          <li><?php echo link_to(render_title($item), array($item, 'module' => 
'informationobject')) ?></li>
         <?php endforeach; ?>
       </ul>
     </div>

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