Author: david
Date: Mon Oct 5 16:19:02 2009
New Revision: 3669
Log:
Implement new subject and place autocompletes on RAD template.
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Mon Oct 5 16:03:29 2009 (r3668)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Mon Oct 5 16:19:02 2009 (r3669)
@@ -188,12 +188,42 @@
$this->form->setWidget($name, new sfWidgetFormInput);
break;
+
+ case 'subjectAccessPoints':
+ case 'placeAccessPoints':
+ $criteria = new Criteria;
+ $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID,
Criteria::INNER_JOIN);
+ $criteria->add(QubitObjectTermRelation::OBJECT_ID,
$this->informationObject->id);
+
+ switch($name)
+ {
+ case 'subjectAccessPoints':
+ $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
+ break;
+ case 'placeAccessPoints':
+ $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
+ break;
+ }
+
+ $values = array();
+ $choices = array();
+ foreach (QubitObjectTermRelation::get($criteria) as $otRelation)
+ {
+ $values[] = $this->context->routing->generate(null, array('module'
=> 'term', 'action' => 'show', 'id' => $otRelation->term->id));
+ $choices[$this->context->routing->generate(null, array('module' =>
'term', 'action' => 'show', 'id' => $otRelation->term->id))] =
$otRelation->term;
+ }
+
+ $this->form->setDefault($name, $values);
+ $this->form->setValidator($name, new sfValidatorPass);
+ $this->form->setWidget($name, new sfWidgetFormSelect(array('choices'
=> $choices, 'multiple' => true)));
+
+ break;
}
}
protected function processField($field)
{
- switch ($field->getName())
+ switch ($name = $field->getName())
{
case 'descriptionDetail':
case 'descriptionStatus':
@@ -205,6 +235,51 @@
break;
+ case 'subjectAccessPoints':
+ case 'placeAccessPoints':
+ $filtered = $selected = array();
+ foreach ($this->form->getValue($name) as $value)
+ {
+ $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
+ $filtered[$params['id']] = $selected[$params['id']] = $params['id'];
+ }
+
+ $criteria = new Criteria;
+ $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
+ $criteria->add(QubitObjectTermRelation::OBJECT_ID,
$this->informationObject->id);
+
+ switch ($name)
+ {
+ case 'subjectAccessPoints':
+ $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
+ break;
+ case 'placeAccessPoints':
+ $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
+ break;
+ }
+
+ foreach (QubitObjectTermRelation::get($criteria) as
$objectTermRelation)
+ {
+ if (isset($selected[$objectTermRelation->term->id]))
+ {
+ unset($filtered[$objectTermRelation->term->id]);
+ }
+ else
+ {
+ $objectTermRelation->delete();
+ }
+ }
+
+ foreach ($filtered as $id)
+ {
+ $objectTermRelation = new QubitObjectTermRelation;
+ $objectTermRelation->termId = $id;
+
+ $this->informationObject->objectTermRelationsRelatedByobjectId[] =
$objectTermRelation;
+ }
+
+ break;
+
default:
$this->informationObject[$field->getName()] =
$this->form->getValue($field->getName());
}
@@ -397,35 +472,6 @@
}
}
- // Add subject access points
- if (0 < strlen($subjectIds = $this->getRequestParameter('subjectId')))
- {
- // Make sure that $subjectId is an array, even if it's only got one value
- $subjectIds = (is_array($subjectIds)) ? $subjectIds : array($subjectIds);
- foreach ($subjectIds as $subjectId)
- {
- if (null !== ($preferredTerm = QubitTerm::getById($subjectId)))
- {
- $this->informationObject->addTermRelation($preferredTerm->id);
- }
- }
- }
-
- // Add place access points
- if ($placeIds = $this->getRequestParameter('placeId'))
- {
- // Make sure that $placeId is an array, even if it's only got one value
- $placeIds = (is_array($placeIds)) ? $placeIds : array($placeIds);
-
- foreach ($placeIds as $placeId)
- {
- if (intval($placeId))
- {
- $this->informationObject->addTermRelation($placeId);
- }
- }
- }
-
// Add material types
if ($material_type_ids = $this->getRequestParameter('material_type_id'))
{
@@ -440,7 +486,6 @@
}
}
}
-
}
/**
Modified:
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Mon Oct 5 16:03:29 2009 (r3668)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Mon Oct 5 16:19:02 2009 (r3669)
@@ -97,36 +97,6 @@
$this->form->setWidget($name, new sfWidgetFormTextarea);
break;
-
- case 'subjectAccessPoints':
- case 'placeAccessPoints':
- $criteria = new Criteria;
- $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID,
Criteria::INNER_JOIN);
- $criteria->add(QubitObjectTermRelation::OBJECT_ID,
$this->informationObject->id);
-
- switch($name)
- {
- case 'subjectAccessPoints':
- $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
- break;
- case 'placeAccessPoints':
- $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
- break;
- }
-
- $values = array();
- $choices = array();
- foreach (QubitObjectTermRelation::get($criteria) as $otRelation)
- {
- $values[] = $this->context->routing->generate(null, array('module'
=> 'term', 'action' => 'show', 'id' => $otRelation->term->id));
- $choices[$this->context->routing->generate(null, array('module' =>
'term', 'action' => 'show', 'id' => $otRelation->term->id))] =
$otRelation->term;
- }
-
- $this->form->setDefault($name, $values);
- $this->form->setValidator($name, new sfValidatorPass);
- $this->form->setWidget($name, new sfWidgetFormSelect(array('choices'
=> $choices, 'multiple' => true)));
-
- break;
}
}
@@ -181,51 +151,6 @@
break;
- case 'subjectAccessPoints':
- case 'placeAccessPoints':
- $filtered = $selected = array();
- foreach ($this->form->getValue($name) as $value)
- {
- $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $value));
- $filtered[$params['id']] = $selected[$params['id']] = $params['id'];
- }
-
- $criteria = new Criteria;
- $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
- $criteria->add(QubitObjectTermRelation::OBJECT_ID,
$this->informationObject->id);
-
- switch ($name)
- {
- case 'subjectAccessPoints':
- $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
- break;
- case 'placeAccessPoints':
- $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
- break;
- }
-
- foreach (QubitObjectTermRelation::get($criteria) as
$objectTermRelation)
- {
- if (isset($selected[$objectTermRelation->term->id]))
- {
- unset($filtered[$objectTermRelation->term->id]);
- }
- else
- {
- $objectTermRelation->delete();
- }
- }
-
- foreach ($filtered as $id)
- {
- $objectTermRelation = new QubitObjectTermRelation;
- $objectTermRelation->termId = $id;
-
- $this->informationObject->objectTermRelationsRelatedByobjectId[] =
$objectTermRelation;
- }
-
- break;
-
default:
parent::processField($field);
}
Modified:
trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
Mon Oct 5 16:03:29 2009 (r3668)
+++ trunk/apps/qubit/modules/informationobject/actions/editRadAction.class.php
Mon Oct 5 16:19:02 2009 (r3669)
@@ -57,6 +57,7 @@
'otherTitleInformationOfPublishersSeries',
'parallelTitleOfPublishersSeries',
'physicalCharacteristics',
+ 'placeAccessPoints',
'relatedUnitsOfDescription',
'repository',
'reproductionConditions',
@@ -72,6 +73,7 @@
'statementOfResponsibilityRelatingToPublishersSeries',
'statementOfScaleArchitectural',
'statementOfScaleCartographic',
+ 'subjectAccessPoints',
'descriptionStatus',
'title',
'titleStatementOfResponsibility',
Modified:
trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
Mon Oct 5 16:03:29 2009 (r3668)
+++ trunk/apps/qubit/modules/informationobject/templates/editRadSuccess.php
Mon Oct 5 16:19:02 2009 (r3669)
@@ -277,29 +277,16 @@
<fieldset class="collapsible collapsed">
<legend><?php echo __('access points') ?></legend>
- <?php include_partial('addAccessPointTermDialog') ?>
- <div class="form-item" id="subjectAccessPoints">
- <label for="subject_id"><?php echo __('subject access points') ?><?php
if($editTaxonomyCredentials): ?><span id="addSubjectAccessPointLink"
style="font-weight:normal"></span><?php endif; ?></label>
- <?php if ($subjectAccessPoints): ?>
- <?php foreach ($subjectAccessPoints as $subject): ?>
- <?php echo $subject->getTerm() ?> <?php echo
link_to(image_tag('delete', 'align=top'),
'informationobject/deleteTermRelation?TermRelationId='.$subject->getId().'&returnTemplate=rad')
?><br/>
- <?php endforeach; ?>
- <input id="subjectId" type="hidden" name="subjectId" />
- <div id="subjectAutoComplete" style="padding-bottom:2em; width:95%">
- <input id="subjectAcInput" type="text" name="subjectTerm" />
- <div id="subjectAcList"></div>
- </div>
- <?php endif; ?>
+ <div class="form-item">
+ <?php echo $form->subjectAccessPoints->label(__('subject access
points'))->renderLabel() ?>
+ <?php echo $form->subjectAccessPoints->render(array('class' =>
'form-autocomplete')) ?>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomyId' =>
QubitTaxonomy::SUBJECT_ID)) ?>"/>
</div>
- <div class="form-item" id="placeAccessPoints">
- <label for="place_id"><?php echo __('place access points') ?><?php
if($editTaxonomyCredentials): ?><span id="addPlaceAccessPointLink"
style="font-weight:normal"></span><?php endif; ?></label>
- <?php if ($placeAccessPoints): ?>
- <?php foreach ($placeAccessPoints as $place): ?>
- <?php echo $place->getTerm() ?> <?php echo
link_to(image_tag('delete', 'align=top'),
'informationobject/deleteTermRelation?TermRelationId='.$place->getId().'&returnTemplate=rad')
?><br/>
- <?php endforeach; ?>
- <?php endif; ?>
- <?php echo object_select_tag($newPlaceAccessPoint, 'getTermId',
array('name' => 'place_id', 'id' => 'place_id', 'include_blank' => true,
'peer_method' => 'getPlaces', 'class'=>'multiInstance')) ?>
+ <div class="form-item">
+ <?php echo $form->placeAccessPoints->label(__('place access
points'))->renderLabel() ?>
+ <?php echo $form->placeAccessPoints->render(array('class' =>
'form-autocomplete')) ?>
+ <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomyId' =>
QubitTaxonomy::PLACE_ID)) ?>"/>
</div>
<div class="form-item">
--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---