Author: jablko
Date: Fri Oct 15 15:05:40 2010
New Revision: 8171
Log:
Use $route->resource
Modified:
trunk/apps/qubit/modules/function/actions/editAction.class.php
Modified: trunk/apps/qubit/modules/function/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/function/actions/editAction.class.php Fri Oct
15 14:53:54 2010 (r8170)
+++ trunk/apps/qubit/modules/function/actions/editAction.class.php Fri Oct
15 15:05:40 2010 (r8171)
@@ -84,35 +84,30 @@
// Find function to function relations with current function as subject or
// object
$criteria = new Criteria;
- $criteria->addAlias('ro', QubitObject::TABLE_NAME);
- $criteria->addAlias('rs', QubitObject::TABLE_NAME);
- $criteria->addJoin(QubitRelation::OBJECT_ID, 'ro.id');
- $criteria->addJoin(QubitRelation::SUBJECT_ID, 'rs.id');
$criterion1 = $criteria->getNewCriterion(QubitRelation::OBJECT_ID,
$this->resource->id, Criteria::EQUAL);
$criterion2 = $criteria->getNewCriterion(QubitRelation::SUBJECT_ID,
$this->resource->id, Criteria::EQUAL);
$criterion1->addOr($criterion2);
- $criterion3 = $criteria->getNewCriterion('ro.class_name', 'QubitFunction',
Criteria::EQUAL);
- $criterion4 = $criteria->getNewCriterion('rs.class_name', 'QubitFunction',
Criteria::EQUAL);
- $criterion3->addAnd($criterion4);
- $criterion1->addAnd($criterion3);
$criteria->add($criterion1);
+ $criteria->addAlias('ro', QubitFunction::TABLE_NAME);
+ $criteria->addJoin(QubitRelation::OBJECT_ID, 'ro.id');
+ $criteria->addAlias('rs', QubitFunction::TABLE_NAME);
+ $criteria->addJoin(QubitRelation::SUBJECT_ID, 'rs.id');
$criteria->addAscendingOrderByColumn(QubitRelation::TYPE_ID);
+
$this->relatedFunctions = QubitRelation::get($criteria);
// Get actors (object) related to this function (subject)
$criteria = new Criteria;
- $criteria->addAlias('ro', QubitObject::TABLE_NAME);
- $criteria->addJoin(QubitRelation::OBJECT_ID, 'ro.id',
Criteria::INNER_JOIN);
$criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
- $criteria->add('ro.class_name', 'QubitActor');
+ $criteria->addJoin(QubitRelation::OBJECT_ID, QubitActor::ID);
+
$this->actorRelations = QubitRelation::get($criteria);
// Get information objects (object) related to this function (subject)
$criteria = new Criteria;
- $criteria->addAlias('ro', QubitObject::TABLE_NAME);
- $criteria->addJoin(QubitRelation::OBJECT_ID, 'ro.id',
Criteria::INNER_JOIN);
$criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
- $criteria->add('ro.class_name', 'QubitInformationObject');
+ $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID);
+
$this->infoObjectRelations = QubitRelation::get($criteria);
}
@@ -127,19 +122,14 @@
switch ($name)
{
case 'type':
-
- if (null !== $this->resource->type)
- {
- $this->form->setDefault('type',
$this->context->routing->generate(null, array($this->resource->type, 'module'
=> 'term')));
- }
+ $this->form->setDefault('type',
$this->context->routing->generate(null, array($this->resource->type, 'module'
=> 'term')));
$this->form->setValidator('type', new sfValidatorString);
$choices = array();
$choices[null] = null;
-
- foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::FUNCTION_ID) as
$term)
+ foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::FUNCTION_ID) as
$item)
{
- $choices[$this->context->routing->generate(null, array($term,
'module' => 'term'))] = $term;
+ $choices[$this->context->routing->generate(null, array($item,
'module' => 'term'))] = $item;
}
$this->form->setWidget('type', new sfWidgetFormSelect(array('choices'
=> $choices)));
@@ -249,12 +239,17 @@
*/
protected function processField($field)
{
- switch ($name = $field->getName())
+ switch ($field->getName())
{
case 'type':
- $params =
$this->context->routing->parse(Qubit::pathInfo($this->form->getValue($name)));
- $fieldId = (isset($params['id'])) ? $params['id'] : null;
- $this->resource[$name.'Id'] = $fieldId;
+ unset($this->resource->type);
+
+ $value = $this->form->getValue($field->getName());
+ if (isset($value))
+ {
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
+ $this->resource->type = $params['_sf_route']->resource;
+ }
break;
@@ -278,55 +273,6 @@
break;
- case 'parallelName':
- case 'otherName':
- $defaults = $this->form->getWidget($name)->getOption('defaults');
-
- if (null !== $this->form->getValue($name))
- {
- foreach ($this->form->getValue($name) as $key => $thisName)
- {
- if ('new' == substr($key, 0, 3) && 0 < strlen(trim($thisName)))
- {
- $otherName = new QubitOtherName;
-
- if ('parallelName' == $name)
- {
- $otherName->typeId = QubitTerm::PARALLEL_FORM_OF_NAME_ID;
- }
- else
- {
- $otherName->typeId = QubitTerm::OTHER_FORM_OF_NAME_ID;
- }
- }
- else
- {
- $otherName = QubitOtherName::getById($key);
- if (null === $otherName)
- {
- continue;
- }
-
- // Don't delete this name
- unset($defaults[$key]);
- }
-
- $otherName->name = $thisName;
- $this->resource->otherNames[] = $otherName;
- }
- }
-
- // Delete any names that are missing from form data
- foreach ($defaults as $key => $val)
- {
- if (null !== ($otherName = QubitOtherName::getById($key)))
- {
- $otherName->delete();
- }
- }
-
- break;
-
default:
return parent::processField($field);
@@ -370,6 +316,7 @@
if ($this->form->isValid())
{
$this->processForm();
+
$this->redirect(array($this->resource, 'module' => 'function'));
}
}
--
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.