Author: david
Date: Fri Oct 2 17:45:13 2009
New Revision: 3658
Log:
Use new autocomplete control for subject access point.
Added:
trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php
(contents, props changed)
- copied, changed from r3642,
trunk/apps/qubit/modules/actor/actions/autocompleteAction.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
trunk/apps/qubit/modules/informationobject/config/view.yml
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Fri Oct 2 17:20:07 2009 (r3657)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
Fri Oct 2 17:45:13 2009 (r3658)
@@ -313,7 +313,6 @@
//Access Points
$this->newSubjectAccessPoint = new QubitObjectTermRelation;
$this->newPlaceAccessPoint = new QubitObjectTermRelation;
- $this->subjectAccessPoints =
$this->informationObject->getSubjectAccessPoints();
$this->placeAccessPoints =
$this->informationObject->getPlaceAccessPoints();
$this->nameSelectList = QubitActor::getAccessPointSelectList();
$this->nameAccessPoints = array();
Modified:
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Fri Oct 2 17:20:07 2009 (r3657)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
Fri Oct 2 17:45:13 2009 (r3658)
@@ -59,6 +59,7 @@
'scriptOfDescription',
'script',
'sources',
+ 'subjectAccessPoints',
'descriptionStatus',
'publicationStatus',
'title');
@@ -95,6 +96,26 @@
$this->form->setWidget($name, new sfWidgetFormTextarea);
break;
+
+ case 'subjectAccessPoints':
+ $criteria = new Criteria;
+ $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID,
Criteria::INNER_JOIN);
+ $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
+ $criteria->add(QubitObjectTermRelation::OBJECT_ID,
$this->informationObject->id);
+
+ $values = array();
+ $choices = array();
+ foreach (QubitObjectTermRelation::get($criteria) as
$subjectAccessPoint)
+ {
+ $values[] = $this->context->routing->generate(null, array('module'
=> 'term', 'action' => 'show', 'id' => $subjectAccessPoint->term->id));
+ $choices[$this->context->routing->generate(null, array('module' =>
'term', 'action' => 'show', 'id' => $subjectAccessPoint->term->id))] =
$subjectAccessPoint->term;
+ }
+
+ $this->form->setDefault('subjectAccessPoints', $values);
+ $this->form->setValidator('subjectAccessPoints', new sfValidatorPass);
+ $this->form->setWidget('subjectAccessPoints', new
sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
+
+ break;
}
}
@@ -116,7 +137,7 @@
protected function processField($field)
{
- switch ($field->getName())
+ switch ($name = $field->getName())
{
case 'creators':
$filtered = $flipped = array();
@@ -149,6 +170,36 @@
break;
+ case 'subjectAccessPoints':
+ $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'];
+ }
+
+ foreach
($this->informationObject->objectTermRelationsRelatedByobjectId 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/config/view.yml
==============================================================================
--- trunk/apps/qubit/modules/informationobject/config/view.yml Fri Oct 2
17:20:07 2009 (r3657)
+++ trunk/apps/qubit/modules/informationobject/config/view.yml Fri Oct 2
17:45:13 2009 (r3658)
@@ -25,7 +25,18 @@
stylesheets:
/vendor/yui/autocomplete/assets/skins/sam/autocomplete: { position: first }
edit:
- javascripts: [autocomplete, /sfDrupalPlugin/vendor/drupal/misc/collapse,
/sfDrupalPlugin/vendor/drupal/misc/textarea, multiDelete, multiInstanceInput,
multiInstanceSelect, select]
+ javascripts:
+ - /vendor/yui/datasource/datasource-min
+ - /vendor/yui/connection/connection-min
+ - /vendor/yui/animation/animation-min
+ - /vendor/yui/autocomplete/autocomplete-min
+ - autocomplete
+ - /sfDrupalPlugin/vendor/drupal/misc/collapse
+ - /sfDrupalPlugin/vendor/drupal/misc/textarea
+ - multiDelete
+ - multiInstanceInput
+ - multiInstanceSelect
+ - select
editModsSuccess:
stylesheets:
Modified:
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Fri Oct 2 17:20:07 2009 (r3657)
+++ trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
Fri Oct 2 17:45:13 2009 (r3658)
@@ -1,6 +1,5 @@
<?php use_helper('Date') ?>
<?php use_helper('Javascript') ?>
-<?php include_partial('termNameAutoComplete') ?>
<div class="pageTitle"><?php echo __('edit archival description - ISAD(G)')
?></div>
<?php if (isset($sf_request->id)): ?>
@@ -99,12 +98,6 @@
<?php echo $form->creators->render(array('class' =>
'form-autocomplete')) ?>
<?php echo $form->creators->help(__('Record the name of the
organization(s) or the individual(s) responsible for the creation, accumulation
and maintenance of the records in the unit of description. The name should
given in the standardized form as prescribed by international or national
conventions in accordance with the principles of ISAAR(CPF).'))->renderHelp() ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'actor', 'action' => 'create')) ?>
#authorized_form_of_name"/>
- <input class="list" type="hidden" value="<?php echo
url_for(array('module' => 'actor', 'action' => 'autocomplete')) ?>"/>
- </div>
-
- <div class="form-item">
- <?php echo $form->repository->renderLabel() ?>
- <?php echo $form->repository->render(array('class' =>
'form-autocomplete')) ?>
<input class="add" type="hidden" value="<?php echo
url_for(array('module' => 'repository', 'action' => 'create')) ?>
#authorized_form_of_name"/>
<input class="list" type="hidden" value="<?php echo
url_for($repoAcParams) ?>"/>
</div>
@@ -211,36 +204,10 @@
<fieldset class="collapsible collapsed">
<legend><?php echo __('access points') ?></legend>
- <?php include_partial('addAccessPointTermDialog') ?>
-
- <div class="form-item" id="subjectAccessPoints">
- <table class="inline">
- <tr>
- <th style="width: 90%;"><?php echo __('subject access points')
?></th>
- <th style="width: 10%; text-align: right;"><?php echo
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
- </tr>
- <?php if ($subjectAccessPoints): ?>
- <?php foreach ($subjectAccessPoints as $subject): ?>
- <tr class="<?php echo 'related_obj_'.$subject->getId() ?>">
- <td><div class="animateNicely">
- <?php echo $subject->getTerm() ?>
- </div></td>
- <td style="text-align: right"><div class="animateNicely">
- <input type="checkbox" name="delete_object_term_relations[<?php
echo $subject->getId() ?>]" value="delete" class="multiDelete" />
- </div></td>
- </tr>
- <?php endforeach; ?>
- <?php endif; ?>
- <tr>
- <td colspan="2">
- <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>
- </td>
- </tr>
- </table>
+ <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">
Copied and modified:
trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php (from r3642,
trunk/apps/qubit/modules/actor/actions/autocompleteAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/actor/actions/autocompleteAction.class.php Fri Oct
2 11:44:42 2009 (r3642, copy source)
+++ trunk/apps/qubit/modules/term/actions/autocompleteAction.class.php Fri Oct
2 17:45:13 2009 (r3658)
@@ -17,22 +17,31 @@
* along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
*/
-class ActorAutocompleteAction extends sfAction
+class TermAutocompleteAction extends sfAction
{
public function execute($request)
{
+ $this->taxonomy = QubitTaxonomy::getById($request->taxonomyId);
+ if (!isset($this->taxonomy))
+ {
+ $this->forward404();
+ }
+ $this->editCredentials = $this->getUser()->hasCredential('editor');
+
$criteria = new Criteria;
- $criteria->add(QubitActor::CLASS_NAME, 'QubitActor');
- $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME,
$request->query.'%', Criteria::LIKE);
- $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID);
+ $criteria->add(QubitTermI18n::NAME, $request->query.'%', Criteria::LIKE);
+ $criteria->add(QubitTerm::TAXONOMY_ID, $request->taxonomyId,
Criteria::EQUAL);
+ $criteria->add(QubitTermI18n::CULTURE, $this->getUser()->getCulture());
+ $criteria->addAscendingOrderByColumn(QubitTermI18n::NAME);
+ $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
- $this->pager = new QubitPager('QubitActor');
- $this->pager->setCriteria($criteria);
- $this->pager->setPage($request->page);
- $this->pager->init();
+ $this->hitlist = new QubitPager('QubitTerm');
+ $this->hitlist->setCriteria($criteria);
+ $this->hitlist->setPage($request->page);
+ $this->hitlist->init();
- $this->actors = $this->pager->getResults();
+ $this->terms = $this->hitlist->getResults();
- $this->setTemplate('list');
+ $this->setTemplate('listTaxonomy');
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---