Author: jablko
Date: Wed Oct 27 14:01:06 2010
New Revision: 8569
Log:
Extend default edit action
Modified:
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
trunk/apps/qubit/modules/informationobject/templates/editPhysicalObjectsSuccess.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
==============================================================================
---
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
Wed Oct 27 13:40:23 2010 (r8568)
+++
trunk/apps/qubit/modules/informationobject/actions/editPhysicalObjectsAction.class.php
Wed Oct 27 14:01:06 2010 (r8569)
@@ -25,7 +25,7 @@
* @author david juhasz <[email protected]>
* @version SVN: $Id
*/
-class InformationObjectEditPhysicalObjectsAction extends sfAction
+class InformationObjectEditPhysicalObjectsAction extends DefaultEditAction
{
public static
$NAMES = array(
@@ -34,6 +34,19 @@
'name',
'type');
+ protected function earlyExecute()
+ {
+ $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+
+ $this->resource = $this->getRoute()->resource;
+
+ // Check that this isn't the root
+ if (!isset($this->resource->parent))
+ {
+ $this->forward404();
+ }
+ }
+
protected function addField($name)
{
switch ($name)
@@ -63,33 +76,13 @@
protected function processForm()
{
- $this->updatePhysicalObjects();
-
$this->deleteRelations();
-
- $this->resource->save();
+ $this->updatePhysicalObjects();
}
public function execute($request)
{
- $this->form = new sfForm;
- $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
-
- $this->resource = $this->getRoute()->resource;
-
- // Check that this isn't the root
- if (!isset($this->resource->parent))
- {
- $this->forward404();
- }
-
- // HACK Use static::$NAMES in PHP 5.3,
- // http://php.net/oop5.late-static-bindings
- $class = new ReflectionClass($this);
- foreach ($class->getStaticPropertyValue('NAMES') as $name)
- {
- $this->addField($name);
- }
+ parent::execute($request);
$this->relations =
QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' =>
QubitTerm::HAS_PHYSICAL_OBJECT_ID));
@@ -101,6 +94,8 @@
{
$this->processForm();
+ $this->resource->save();
+
$this->redirect(array($this->resource, 'module' =>
'informationobject'));
}
}
@@ -161,14 +156,12 @@
*/
public function deleteRelations()
{
- if (is_array($deleteRelations = $this->request->delete_relations) &&
count($deleteRelations))
+ if (isset($this->request->delete_relations))
{
- foreach ($deleteRelations as $thisId => $doDelete)
+ foreach ($this->request->delete_relations as $item)
{
- if ($doDelete == 'delete' && !is_null($relation =
QubitRelation::getById($thisId)))
- {
- $relation->delete();
- }
+ $params = $this->context->routing->parse(Qubit::pathInfo($item));
+ $params['sf_route']->resource->delete();
}
}
}
Modified:
trunk/apps/qubit/modules/informationobject/templates/editPhysicalObjectsSuccess.php
==============================================================================
---
trunk/apps/qubit/modules/informationobject/templates/editPhysicalObjectsSuccess.php
Wed Oct 27 13:40:23 2010 (r8568)
+++
trunk/apps/qubit/modules/informationobject/templates/editPhysicalObjectsSuccess.php
Wed Oct 27 14:01:06 2010 (r8569)
@@ -2,11 +2,15 @@
<h1 class="label"><?php echo render_title($resource) ?></h1>
+<?php echo $form->renderGlobalErrors() ?>
+
<?php echo $form->renderFormTag(url_for(array($resource, 'module' =>
'informationobject', 'action' => 'editPhysicalObjects'))) ?>
+ <?php echo $form->renderHiddenFields() ?>
+
<?php if (0 < count($relations)): ?>
- <div class="form-item">
- <table class="inline" style="width: 98%;">
+ <table class="inline" style="width: 98%;">
+ <thead>
<tr>
<th colspan="2" style="width: 90%;">
<?php echo __('Containers') ?>
@@ -14,6 +18,7 @@
<?php echo image_tag('delete', array('align' => 'top', 'class' =>
'deleteIcon')) ?>
</th>
</tr>
+ </thead><tbody>
<?php foreach ($relations as $item): ?>
<tr class="related_obj_<?php echo $item->id ?>">
<td style="width: 90%"><div class="animateNicely">
@@ -21,42 +26,38 @@
</div></td><td style="width: 20px;"><div class="animateNicely">
<?php echo link_to(image_tag('pencil', array('align' => 'top')),
array($item->subject, 'module' => 'physicalobject', 'action' => 'edit')) ?>
</div></td><td style="width: 20px;"><div class="animateNicely">
- <input type="checkbox" name="delete_relations[<?php echo
$item->id ?>]" value="delete" class="multiDelete"/>
+ <input class="multiDelete" name="delete_relations[]"
type="checkbox" value="<?php echo url_for(array($item, array('module' =>
'relation'))) ?>"/>
</div></td>
</tr>
<?php endforeach; ?>
- </table>
- </div>
+ </tbody>
+ </table>
<?php endif; ?>
- <table class="inline" style="width: 98%;">
- <tr>
- <th colspan="3" style="width: 98%">
- <?php echo __('Add container links (duplicate links will be ignored)')
?>
- </th>
- </tr>
- </table>
-
- <div class="form-item">
- <?php echo $form->containers->renderLabel() ?>
- <?php echo $form->containers->render(array('class' =>
'form-autocomplete')) ?>
- <input class="add" type="hidden" value="<?php echo
url_for(array($resource, 'module' => 'informationobject', 'action' =>
'editPhysicalObjects')) ?> #physicalObjectName"/>
- <input class="list" type="hidden" value="<?php echo url_for(array('module'
=> 'physicalobject', 'action' => 'autocomplete')) ?>"/>
+ <div class="section">
+
+ <h2><?php echo __('Add container links (duplicate links will be ignored)')
?></h2>
+
+ <div class="form-item">
+ <?php echo $form->containers->renderLabel() ?>
+ <?php echo $form->containers->render(array('class' =>
'form-autocomplete')) ?>
+ <input class="add" type="hidden" value="<?php echo
url_for(array($resource, 'module' => 'informationobject', 'action' =>
'editPhysicalObjects')) ?> #physicalObjectName"/>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'physicalobject', 'action' => 'autocomplete')) ?>"/>
+ </div>
+
</div>
- <table class="inline" style="width: 98%;">
- <tr>
- <th colspan="3" style="width: 98%">
- <?php echo __('Or, create a new container') ?>
- </th>
- </tr>
- </table>
+ <div class="section">
- <?php echo $form->name->renderRow() ?>
+ <h2><?php echo __('Or, create a new container') ?></h2>
- <?php echo $form->location->renderRow() ?>
+ <?php echo $form->name->renderRow() ?>
- <?php echo $form->type->renderRow() ?>
+ <?php echo $form->location->renderRow() ?>
+
+ <?php echo $form->type->renderRow() ?>
+
+ </div>
<div class="actions section">
--
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.