Author: jablko
Date: Sun Oct 17 12:17:12 2010
New Revision: 8195
Log:
Doh, gotta add ISDF edit and index actions, or get_partial('relatedFunctions')
still tries "function" vs. "sfIsdfPlugin" module
Added:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/editAction.class.php
- copied, changed from r8194,
trunk/apps/qubit/modules/function/actions/editAction.class.php
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/indexAction.class.php
- copied, changed from r8194,
trunk/apps/qubit/modules/function/actions/indexAction.class.php
Modified:
trunk/apps/qubit/config/routing.yml
trunk/apps/qubit/modules/function/actions/editAction.class.php
trunk/apps/qubit/modules/function/actions/indexAction.class.php
Modified: trunk/apps/qubit/config/routing.yml
==============================================================================
--- trunk/apps/qubit/config/routing.yml Sun Oct 17 10:59:05 2010 (r8194)
+++ trunk/apps/qubit/config/routing.yml Sun Oct 17 12:17:12 2010 (r8195)
@@ -112,9 +112,22 @@
url: /:id;isdf
class: QubitResourceRoute
param:
- module: function
+ module: sfIsdfPlugin
action: index
+createIsdf:
+ url: /;create/isdf
+ param:
+ module: sfIsdfPlugin
+ action: edit
+
+edtIsdf:
+ url: /:id;edit/isdf
+ class: QubitResourceRoute
+ param:
+ module: sfIsdfPlugin
+ action: edit
+
indexIsdiah:
url: /:id;isdiah
class: QubitResourceRoute
@@ -260,6 +273,26 @@
module: actor
action: edit
+functionIndex:
+ url: /:id;isdf
+ class: QubitResourceRoute
+ param:
+ module: function
+ action: index
+
+functionCreate:
+ url: /;create/isdf
+ param:
+ module: function
+ action: create
+
+functionEdit:
+ url: /:id;edit/isdf
+ class: QubitResourceRoute
+ param:
+ module: function
+ action: edit
+
repositoryIndex:
url: /:id;:repository_template
class: QubitResourceRoute
Modified: trunk/apps/qubit/modules/function/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/function/actions/editAction.class.php Sun Oct
17 10:59:05 2010 (r8194)
+++ trunk/apps/qubit/modules/function/actions/editAction.class.php Sun Oct
17 12:17:12 2010 (r8195)
@@ -27,45 +27,6 @@
*/
class FunctionEditAction extends DefaultEditAction
{
- // Arrays not allowed in class constants
- public static
- $NAMES = array(
- 'type',
- 'authorizedFormOfName',
- 'parallelName',
- 'otherName',
- 'classification',
- 'dates',
- 'description',
- 'history',
- 'legislation',
- 'descriptionIdentifier',
- 'institutionIdentifier',
- 'rules',
- 'descriptionStatus',
- 'descriptionDetail',
- 'revisionHistory',
- 'language',
- 'script',
- 'sources',
- 'maintenanceNotes',
- 'relation[authorizedFormOfName]',
- 'relation[category]',
- 'relation[description]',
- 'relation[startDate]',
- 'relation[endDate]',
- 'relation[dateDisplay]',
- 'relatedEntity[object]',
- 'relatedEntity[description]',
- 'relatedEntity[startDate]',
- 'relatedEntity[endDate]',
- 'relatedEntity[dateDisplay]',
- 'relatedResource[object]',
- 'relatedResource[description]',
- 'relatedResource[startDate]',
- 'relatedResource[endDate]',
- 'relatedResource[dateDisplay]');
-
protected function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
@@ -80,218 +41,6 @@
$this->form->setValidator('serialNumber', new sfValidatorInteger);
$this->form->setWidget('serialNumber', new sfWidgetFormInputHidden);
}
-
- // Find function to function relations with current function as subject or
- // object
- $criteria = new Criteria;
- $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);
- $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->add(QubitRelation::SUBJECT_ID, $this->resource->id);
- $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->add(QubitRelation::SUBJECT_ID, $this->resource->id);
- $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID);
-
- $this->infoObjectRelations = QubitRelation::get($criteria);
- }
-
- /**
- * Add fields to form
- *
- * @param $name string
- * @return void
- */
- protected function addField($name)
- {
- switch ($name)
- {
- case 'type':
- $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
$item)
- {
- $choices[$this->context->routing->generate(null, array($item,
'module' => 'term'))] = $item;
- }
-
- $this->form->setWidget('type', new sfWidgetFormSelect(array('choices'
=> $choices)));
-
- break;
-
- case 'maintenanceNotes':
- $this->maintenanceNote = null;
-
- // Check for existing maintenance note related to this object
- $criteria = new Criteria;
- $criteria = $this->resource->addnotesCriteria($criteria);
- $criteria->add(QubitNote::TYPE_ID, QubitTerm::MAINTENANCE_NOTE_ID);
- $note = QubitNote::getOne($criteria);
-
- if (null !== $note)
- {
- $this->form->setDefault('maintenanceNotes', $note->content);
- $this->maintenanceNote = $note;
- }
- $this->form->setValidator('maintenanceNotes', new sfValidatorString);
- $this->form->setWidget('maintenanceNotes', new sfWidgetFormTextarea);
-
- break;
-
- case 'relation[authorizedFormOfName]':
- case 'relatedEntity[object]':
- case 'relatedResource[object]':
- $choices = array();
-
- $this->form->setValidator($name, new sfValidatorString);
- $this->form->setWidget($name, new sfWidgetFormSelect(array('choices'
=> $choices)));
-
- break;
-
- case 'relation[category]':
- $this->form->setValidator($name, new sfValidatorString);
-
- $choices = array();
- $choices[null] = null;
-
- foreach
(QubitTaxonomy::getTermsById(QubitTaxonomy::ISDF_RELATION_TYPE_ID) as $term)
- {
- $choices[$this->context->routing->generate(null, array($term,
'module' => 'term'))] = $term;
- }
-
- $this->form->setWidget($name, new sfWidgetFormSelect(array('choices'
=> $choices)));
-
- break;
-
- case 'authorizedFormOfName':
- case 'classification':
- case 'dates':
- case 'descriptionIdentifier':
- case 'institutionIdentifier':
- $this->form->setDefault($name, $this->resource[$name]);
- $this->form->setValidator($name, new sfValidatorString);
- $this->form->setWidget($name, new sfWidgetFormInput);
-
- break;
-
- case 'history':
- case 'description':
- case 'legislation':
- case 'rules':
- case 'revisionHistory':
- case 'sources':
- $this->form->setDefault($name, $this->resource[$name]);
- $this->form->setValidator($name, new sfValidatorString);
- $this->form->setWidget($name, new sfWidgetFormTextarea);
-
- break;
-
- case 'relation[startDate]':
- case 'relation[endDate]':
- case 'relation[dateDisplay]':
- case 'relatedEntity[startDate]':
- case 'relatedEntity[endDate]':
- case 'relatedEntity[dateDisplay]':
- case 'relatedResource[startDate]':
- case 'relatedResource[endDate]':
- case 'relatedResource[dateDisplay]':
- $this->form->setValidator($name, new sfValidatorString);
- $this->form->setWidget($name, new sfWidgetFormInput);
-
- break;
-
- case 'relation[description]':
- case 'relatedEntity[description]':
- case 'relatedResource[description]':
- $this->form->setValidator($name, new sfValidatorString);
- $this->form->setWidget($name, new sfWidgetFormTextarea);
-
- break;
-
- default:
-
- return parent::addField($name);
- }
- }
-
- /**
- * Process form fields
- *
- * @param $field mixed symfony form widget
- * @return void
- */
- protected function processField($field)
- {
- switch ($field->getName())
- {
- case 'type':
- 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;
-
- case 'maintenanceNotes':
- // Check for existing maintenance note related to this object
- $criteria = new Criteria;
- $criteria = $this->resource->addnotesCriteria($criteria);
- $criteria->add(QubitNote::TYPE_ID, QubitTerm::MAINTENANCE_NOTE_ID);
- $note = QubitNote::getOne($criteria);
-
- if (null === $note)
- {
- // Create a maintenance note for this object if one doesn't exist
- $note = new QubitNote;
- $note->typeId = QubitTerm::MAINTENANCE_NOTE_ID;
- }
-
- $note->content = $this->form->getValue('maintenanceNotes');
-
- $this->resource->notes[] = $note;
-
- break;
-
- default:
-
- return parent::processField($field);
- }
- }
-
- /**
- * Process form
- *
- * @return void
- */
- protected function processForm()
- {
- $this->updateRelations();
- $this->updateOtherRelations('relatedEntity');
- $this->updateOtherRelations('relatedResource');
- $this->deleteRelations();
-
- return parent::processForm();
}
/**
@@ -315,180 +64,6 @@
}
}
- $this->moduleName = 'sfIsdfPlugin';
-
QubitDescription::addAssets($this->response);
}
-
- /**
- * Update function relationships
- */
- protected function updateRelations()
- {
- if (isset($this->request->relations))
- {
- // JavaScript (multiple) relationship update
- $relationsData = $this->request->relations;
- }
- else if (isset($this->request->relation))
- {
- // Non-JavaScript (single) relationship update
- $relationsData = array($this->request->relation);
- }
- else
- {
- return;
- }
-
- // Loop through func events
- foreach ($relationsData as $relationData)
- {
- // Get related function
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['authorizedFormOfName']));
- $relatedFuncId = (isset($params['id'])) ? $params['id'] : null;
- if (null === $relatedFunction = QubitFunction::getById($relatedFuncId))
- {
- continue; // If no related function, skip update
- }
-
- // Get relation
- if (isset($relationData['id']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
- if (null === $relation = QubitRelation::getById($params['id']))
- {
- // If a relation id is passed, but relation object doesn't exist then
- // skip this row
- continue;
- }
- }
- else
- {
- $relation = new QubitRelation;
- }
-
- // Set category (typeId)
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['category']));
- $typeId = (isset($params['id'])) ? $params['id'] : null;
- $relation->typeId = $typeId;
-
- $relation->startDate = $relationData['startDate'];
- $relation->endDate = $relationData['endDate'];
-
- // Add notes
- $relation->updateNote($relationData['description'],
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
- $relation->updateNote($relationData['dateDisplay'],
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
- // Default to current function as subject of relationship
- if ($relation->subjectId == $this->resource->id || null ==
$relation->subjectId)
- {
- $relation->object = $relatedFunction;
- $this->resource->relationsRelatedBysubjectId[] = $relation;
- }
- else
- {
- $relation->subject = $relatedFunction;
- $this->resource->relationsRelatedByobjectId[] = $relation;
- }
- }
-
- return $this;
- }
-
- /**
- * Update entity relationships
- */
- protected function updateOtherRelations($formName)
- {
- if (isset($this->request["{$formName}s"]))
- {
- // JavaScript (multiple) relationship update
- $relationsData = $this->request["{$formName}s"];
- }
- else if (isset($this->request[$formName]))
- {
- // Non-JavaScript (single) relationship update
- $relationsData = array($this->request[$formName]);
- }
- else
- {
- return;
- }
-
- // Loop through relation rows
- foreach ($relationsData as $relationData)
- {
- // Get relation
- if (isset($relationData['id']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
- if (null === $relation = QubitRelation::getById($params['id']))
- {
- continue; // If we can't find an existing relation, skip this row
- }
- }
- else
- {
- $relation = new QubitRelation;
- }
-
- // Get related information object (object)
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['object']));
- $objectId = (isset($params['id'])) ? $params['id'] : null;
-
- switch ($formName)
- {
- case 'relatedEntity':
- $object = QubitActor::getById($objectId);
-
- break;
-
- case 'relatedResource':
- $object = QubitInformationObject::getById($objectId);
-
- break;
- }
-
- if (null === $object)
- {
- continue; // If no related object, skip update
- }
- else
- {
- $relation->object = $object;
- }
-
- $relation->startDate = $relationData['startDate'];
- $relation->endDate = $relationData['endDate'];
-
- // Add notes
- $relation->updateNote($relationData['description'],
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
- $relation->updateNote($relationData['dateDisplay'],
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
- $this->resource->relationsRelatedBysubjectId[] = $relation;
- }
-
- return $this;
- }
-
- /**
- * Delete all relationships marked for deletion
- */
- protected function deleteRelations()
- {
- if (is_array($deleteRelations = $this->request->deleteRelations))
- {
- foreach ($deleteRelations as $deleteId => $doDelete)
- {
- if (null !== ($relation = QubitRelation::getById($deleteId)))
- {
- $relation->delete();
- }
- }
- }
-
- return $this;
- }
}
Modified: trunk/apps/qubit/modules/function/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/function/actions/indexAction.class.php Sun Oct
17 10:59:05 2010 (r8194)
+++ trunk/apps/qubit/modules/function/actions/indexAction.class.php Sun Oct
17 12:17:12 2010 (r8195)
@@ -22,74 +22,5 @@
public function execute($request)
{
$this->resource = $this->getRoute()->resource;
-
- $this->maintenanceNotes =
$this->resource->getNotesByType(array('noteTypeId' =>
QubitTerm::MAINTENANCE_NOTE_ID));
-
- // 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->addAscendingOrderByColumn(QubitRelation::TYPE_ID);
- $this->resourcetionRelations = 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');
- $this->infoObjectRelations = 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');
- $this->actorRelations = QubitRelation::get($criteria);
-
- // ISDF validation rules
- if (QubitAcl::check($this->resource, 'update'))
- {
- $validatorSchema = new sfValidatorSchema;
- $values = array();
-
- $validatorSchema->type = new sfValidatorString(array(
- 'required' => true), array(
- 'required' => $this->context->i18n->__('%1%Type%2% - This is a
%3%mandatory%4% element.', array('%1%' => '<a
href="http://ica-atom.org/doc/RS-4#Type_of_description">', '%2%' => '</a>',
'%3%' => '<a href="http://ica-atom.org/doc/RS-4#Structure_and_use_4.7">', '%4%'
=> '</a>'))));
- $values['type'] = $resource->type;
-
- $validatorSchema->authorizedFormOfName = new sfValidatorString(array(
- 'required' => true), array(
- 'required' => $this->context->i18n->__('%1%Authorized form of name%2%
- This is a %3%mandatory%4% element.', array('%1%' => '<a
href="http://ica-atom.org/doc/RS-4#Authorised_name">', '%2%' => '</a>', '%3%'
=> '<a href="http://ica-atom.org/doc/RS-4#Structure_and_use_4.7">', '%4%' =>
'</a>'))));
- $values['authorizedFormOfName'] =
$this->resource->getAuthorizedFormOfName(array('cultureFallback' => true));
-
- $validatorSchema->descriptionIdentifier = new sfValidatorString(array(
- 'required' => true), array(
- 'required' => $this->context->i18n->__('%1%Description identifier%2% -
This is a %3%mandatory%4% element.', array('%1%' => '<a
href="http://ica-atom.org/doc/RS-4#Function.2Factivity_description_identifier">',
'%2%' => '</a>', '%3%' => '<a
href="http://ica-atom.org/doc/RS-4#Structure_and_use_4.7">', '%4%' =>
'</a>'))));
- $values['descriptionIdentifier'] =
$this->resource->descriptionIdentifier;
-
- try
- {
- $validatorSchema->clean($values);
- }
- catch (sfValidatorErrorSchema $e)
- {
- $this->errorSchema = $e;
- }
- }
-
- $this->moduleName = 'sfIsdfPlugin';
}
}
Copied and modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/editAction.class.php
(from r8194, trunk/apps/qubit/modules/function/actions/editAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/function/actions/editAction.class.php Sun Oct
17 10:59:05 2010 (r8194, copy source)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/editAction.class.php
Sun Oct 17 12:17:12 2010 (r8195)
@@ -17,15 +17,7 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * Controller for editing func information.
- *
- * @package qubit
- * @subpackage function
- * @version svn: $Id$
- * @author David Juhasz <[email protected]>
- */
-class FunctionEditAction extends DefaultEditAction
+class sfIsdfEditAction extends FunctionEditAction
{
// Arrays not allowed in class constants
public static
@@ -68,18 +60,7 @@
protected function earlyExecute()
{
- $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
-
- $this->resource = new QubitFunction;
- if (isset($this->getRoute()->resource))
- {
- $this->resource = $this->getRoute()->resource;
-
- // Add optimistic lock
- $this->form->setDefault('serialNumber', $this->resource->serialNumber);
- $this->form->setValidator('serialNumber', new sfValidatorInteger);
- $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden);
- }
+ parent::earlyExecute();
// Find function to function relations with current function as subject or
// object
@@ -295,32 +276,6 @@
}
/**
- * Execute edit action
- *
- * @param $request sfWebRequest
- * @see lib/vendor/symfony/lib/action/sfAction
- */
- public function execute($request)
- {
- parent::execute($request);
-
- if ($request->isMethod('post'))
- {
- $this->form->bind($request->getPostParameters());
- if ($this->form->isValid())
- {
- $this->processForm();
-
- $this->redirect(array($this->resource, 'module' => 'function'));
- }
- }
-
- $this->moduleName = 'sfIsdfPlugin';
-
- QubitDescription::addAssets($this->response);
- }
-
- /**
* Update function relationships
*/
protected function updateRelations()
Copied and modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/indexAction.class.php
(from r8194, trunk/apps/qubit/modules/function/actions/indexAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/function/actions/indexAction.class.php Sun Oct
17 10:59:05 2010 (r8194, copy source)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/indexAction.class.php
Sun Oct 17 12:17:12 2010 (r8195)
@@ -17,11 +17,11 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-class FunctionIndexAction extends sfAction
+class sfIsdfIndexAction extends FunctionIndexAction
{
public function execute($request)
{
- $this->resource = $this->getRoute()->resource;
+ parent::execute($request);
$this->maintenanceNotes =
$this->resource->getNotesByType(array('noteTypeId' =>
QubitTerm::MAINTENANCE_NOTE_ID));
@@ -89,7 +89,5 @@
$this->errorSchema = $e;
}
}
-
- $this->moduleName = 'sfIsdfPlugin';
}
}
--
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.