Author: jablko
Date: Sun Oct 17 17:03:30 2010
New Revision: 8202
Log:
Add base component
Added:
trunk/apps/qubit/modules/relation/actions/editComponent.class.php
- copied, changed from r8195,
trunk/apps/qubit/modules/default/actions/editAction.class.php
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordsComponent.class.php
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionsComponent.class.php
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourcesComponent.class.php
Copied and modified:
trunk/apps/qubit/modules/relation/actions/editComponent.class.php (from r8195,
trunk/apps/qubit/modules/default/actions/editAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/default/actions/editAction.class.php Sun Oct
17 12:17:12 2010 (r8195, copy source)
+++ trunk/apps/qubit/modules/relation/actions/editComponent.class.php Sun Oct
17 17:03:30 2010 (r8202)
@@ -17,96 +17,12 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-class DefaultEditAction extends sfAction
+class RelationEditComponent extends sfComponent
{
protected function addField($name)
{
switch ($name)
{
- case 'descriptionDetail':
- $this->form->setDefault('descriptionDetail',
$this->context->routing->generate(null,
array($this->resource->descriptionDetail, 'module' => 'term')));
- $this->form->setValidator('descriptionDetail', new sfValidatorString);
-
- $choices = array();
- $choices[null] = null;
- foreach
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_DETAIL_LEVEL_ID) as
$item)
- {
- $choices[$this->context->routing->generate(null, array($item,
'module' => 'term'))] = $item;
- }
-
- $this->form->setWidget('descriptionDetail', new
sfWidgetFormSelect(array('choices' => $choices)));
-
- break;
-
- case 'descriptionStatus':
- $this->form->setDefault('descriptionStatus',
$this->context->routing->generate(null,
array($this->resource->descriptionStatus, 'module' => 'term')));
- $this->form->setValidator('descriptionStatus', new sfValidatorString);
-
- $choices = array();
- $choices[null] = null;
- foreach
(QubitTaxonomy::getTermsById(QubitTaxonomy::DESCRIPTION_STATUS_ID) as $item)
- {
- $choices[$this->context->routing->generate(null, array($item,
'module' => 'term'))] = $item;
- }
-
- $this->form->setWidget('descriptionStatus', new
sfWidgetFormSelect(array('choices' => $choices)));
-
- break;
-
- case 'language':
- case 'languageOfDescription':
- $this->form->setDefault($name, $this->resource[$name]);
- $this->form->setValidator($name, new
sfValidatorI18nChoiceLanguage(array('multiple' => true)));
- $this->form->setWidget($name, new
sfWidgetFormI18nChoiceLanguage(array('culture' =>
$this->context->user->getCulture(), 'multiple' => true)));
-
- break;
-
- case 'otherName':
- case 'parallelName':
- case 'standardizedName':
- $criteria = new Criteria;
- $criteria = $this->resource->addOtherNamesCriteria($criteria);
- switch ($name)
- {
- case 'otherName':
- $criteria->add(QubitOtherName::TYPE_ID,
QubitTerm::OTHER_FORM_OF_NAME_ID);
-
- break;
-
- case 'parallelName':
- $criteria->add(QubitOtherName::TYPE_ID,
QubitTerm::PARALLEL_FORM_OF_NAME_ID);
-
- break;
-
- case 'standardizedName':
- $criteria->add(QubitOtherName::TYPE_ID,
QubitTerm::STANDARDIZED_FORM_OF_NAME_ID);
-
- break;
- }
-
- $value = $defaults = array();
- foreach ($this[$name] = QubitOtherName::get($criteria) as $item)
- {
- $value[] = $item->id;
- $defaults[$item->id] = $item;
- }
-
- $this->form->setDefault($name, $value);
- $this->form->setValidator($name, new sfValidatorPass);
- $this->form->setWidget($name, new
QubitWidgetFormInputMany(array('defaults' => $defaults)));
-
- break;
-
- case 'script':
- case 'scriptOfDescription':
- $this->form->setDefault($name, $this->resource[$name]);
-
- $c = sfCultureInfo::getInstance($this->context->user->getCulture());
-
- $this->form->setValidator($name, new sfValidatorChoice(array('choices'
=> array_keys($c->getScripts()), 'multiple' => true)));
- $this->form->setWidget($name, new sfWidgetFormSelect(array('choices'
=> $c->getScripts(), 'multiple' => true)));
-
- break;
}
}
@@ -114,62 +30,6 @@
{
switch ($field->getName())
{
- case 'descriptionDetail':
- case 'descriptionStatus':
- unset($this->resource[$field->getName()]);
-
- $value = $this->form->getValue($field->getName());
- if (isset($value))
- {
- $params = $this->context->routing->parse(Qubit::pathInfo($value));
- $this->resource[$field->getName()] = $params['_sf_route']->resource;
- }
-
- break;
-
- case 'otherName':
- case 'parallelName':
- case 'standardizedName':
- $value = $filtered = $this->form->getValue($field->getName());
-
- foreach ($this[$field->getName()] as $item)
- {
- if (isset($value[$item->id]))
- {
- $item->name = $value[$item->id];
- unset($filtered[$item->id]);
- }
- else
- {
- $item->delete();
- }
- }
-
- foreach ($filtered as $item)
- {
- $otherName = new QubitOtherName;
- $otherName->name = $item;
- switch ($field->getName())
- {
- case 'parallelName':
- $otherName->typeId = QubitTerm::PARALLEL_FORM_OF_NAME_ID;
-
- break;
-
- case 'standardizedName':
- $otherName->typeId = QubitTerm::STANDARDIZED_FORM_OF_NAME_ID;
-
- break;
-
- default:
- $otherName->typeId = QubitTerm::OTHER_FORM_OF_NAME_ID;
- }
-
- $this->resource->otherNames[] = $otherName;
- }
-
- break;
-
default:
$this->resource[$field->getName()] =
$this->form->getValue($field->getName());
}
@@ -192,8 +52,6 @@
{
$this->form = new sfForm;
- $this->earlyExecute();
-
// HACK Use static::$NAMES in PHP 5.3,
// http://php.net/oop5.late-static-bindings
$class = new ReflectionClass($this);
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordsComponent.class.php
==============================================================================
---
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordsComponent.class.php
Sun Oct 17 16:48:53 2010 (r8201)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordsComponent.class.php
Sun Oct 17 17:03:30 2010 (r8202)
@@ -17,7 +17,7 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-class sfIsdfPluginRelatedAuthorityRecordsComponent extends sfComponent
+class sfIsdfPluginRelatedAuthorityRecordsComponent extends
RelationEditComponent
{
// Arrays not allowed in class constants
public static
@@ -46,6 +46,10 @@
$this->form->setWidget($name, new sfWidgetFormTextarea);
break;
+
+ default:
+
+ return parent::addFeild($name);
}
}
@@ -57,6 +61,8 @@
public function execute($request)
{
+ parent::execute($request);
+
// Get actors (object) related to this function (subject)
$criteria = new Criteria;
$criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionsComponent.class.php
==============================================================================
---
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionsComponent.class.php
Sun Oct 17 16:48:53 2010 (r8201)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionsComponent.class.php
Sun Oct 17 17:03:30 2010 (r8202)
@@ -17,7 +17,7 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-class sfIsdfPluginRelatedFunctionsComponent extends sfComponent
+class sfIsdfPluginRelatedFunctionsComponent extends RelationEditComponent
{
// Arrays not allowed in class constants
public static
@@ -69,6 +69,10 @@
$this->form->setWidget($name, new sfWidgetFormTextarea);
break;
+
+ default:
+
+ return parent::addField($name);
}
}
@@ -80,6 +84,8 @@
public function execute($request)
{
+ parent::execute($request);
+
// Find function to function relations with current function as subject or
// object
$criteria = new Criteria;
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourcesComponent.class.php
==============================================================================
---
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourcesComponent.class.php
Sun Oct 17 16:48:53 2010 (r8201)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourcesComponent.class.php
Sun Oct 17 17:03:30 2010 (r8202)
@@ -17,7 +17,7 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-class sfIsdfPluginRelatedResourcesComponent extends sfComponent
+class sfIsdfPluginRelatedResourcesComponent extends RelationEditComponent
{
// Arrays not allowed in class constants
public static
@@ -53,6 +53,10 @@
$this->form->setWidget($name, new sfWidgetFormTextarea);
break;
+
+ default:
+
+ return parent::addField($name);
}
}
@@ -60,12 +64,12 @@
{
$this->updateOtherRelations('relatedResource');
$this->deleteRelations();
-
- return parent::processForm();
}
public function execute($request)
{
+ parent::execute($request);
+
// Get information objects (object) related to this function (subject)
$criteria = new Criteria;
$criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id);
--
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.