Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions controllers/LookupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ public function indexAction()
// error_log(microtime());
$db = get_db();

if (!$this->_hasParam('subject_id')) {
$this->_setParam('subject_id', -1);
if (!$this->hasParam('subject_id')) {
$this->setParam('subject_id', -1);
}
if (!$this->_hasParam('partial')) {
$this->_setParam('partial', '');
if (!$this->hasParam('partial')) {
$this->setParam('partial', '');
}
if (!$this->_hasParam('id_limit')) {
$this->_setParam('id_limit', '');
if (!$this->hasParam('id_limit')) {
$this->setParam('id_limit', '');
}
if (!$this->_hasParam('item_type')) {
$this->_setParam('item_type', -1);
if (!$this->hasParam('item_type')) {
$this->setParam('item_type', -1);
}
if (!$this->_hasParam('collection')) {
$this->_setParam('collection', -1);
if (!$this->hasParam('collection')) {
$this->setParam('collection', -1);
}
if (!$this->_hasParam('sort')) {
$this->_setParam('sort', 'mod_desc');
if (!$this->hasParam('sort')) {
$this->setParam('sort', 'mod_desc');
}
if (!$this->_hasParam('page')) {
$this->_setParam('page', 0);
if (!$this->hasParam('page')) {
$this->setParam('page', 0);
}
if (!$this->_hasParam('per_page')) {
$this->_setParam('per_page', 15);
if (!$this->hasParam('per_page')) {
$this->setParam('per_page', 15);
}

$subject_id = intval($this->_getParam('subject_id'));
Expand All @@ -54,16 +54,18 @@ public function indexAction()
}

$where_id_limit = '';
if (preg_match("/\s*(\d+)(?:-(\d+))?\s*/", $this->_getParam('id_limit'), $matches)) {
$fromId = $matches[1];
$toId = @$matches[2];
if (!$toId) { $toId = $fromId; }
if ($fromId > $toId) {
$tmpId = $toId;
$toId = $fromId;
$fromId = $tmpId;
}
$where_id_limit = "AND items.id BETWEEN $fromId AND $toId";
if (preg_match('/\s*(\d+)(?:-(\d+))?\s*/', $this->getParam('id_limit'), $matches)) {
$fromId = (integer) $matches[1];
$toId = (integer) @$matches[2];
if (!$toId) {
$toId = $fromId;
}
if ($fromId > $toId) {
$tmpId = $toId;
$toId = $fromId;
$fromId = $tmpId;
}
$where_id_limit = "AND items.id BETWEEN $fromId AND $toId";
}

$item_type = intval($this->_getParam('item_type'));
Expand Down
2 changes: 1 addition & 1 deletion plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name="Item Relations"
author="Roy Rosenzweig Center for History and New Media"
description="Allows administrators to define relations between items."
link="https://omeka.org/codex/Plugins/ItemRelations"
link="https://omeka.org/codex/Plugins/ItemRelations_2.0"
support_link="https://omeka.org/forums/forum/plugins"
license="GPLv3"
omeka_minimum_version="2.0"
Expand Down
242 changes: 127 additions & 115 deletions views/shared/common/item-relations-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
$thisItemId = $item->id;
$colspan = ($provideRelationComments ? 4 : 3);
$lastVocab = -1;
foreach ($allRelations as $relation) {
foreach ($allRelations as $relation) { ?>
<tr>
<?php
if ($lastVocab != $relation['vocabulary_id']) {
echo "<tr><th colspan='$colspan'>"
. "<span title='" . $relation['vocabulary_desc'] . "'>"
Expand All @@ -32,7 +34,6 @@
}
$subjectRelation = $relation['subject_item_id'] == $thisItemId;
$objectRelation = $relation['object_item_id'] == $thisItemId;
echo '<tr>';
echo '<td>'
. ($subjectRelation
? __('This Item')
Expand Down Expand Up @@ -73,8 +74,8 @@
echo '</td>';
} ?>
<td><input type="checkbox" name="item_relations_item_relation_delete[]" value="<?php echo $relation['item_relation_id']; ?>" /></td>
</tr>
<?php
echo '</tr>';
} ?>
<tr>
<th colspan="<?php echo $colspan; ?>">
Expand Down Expand Up @@ -107,137 +108,148 @@

<a href="#item-relation-selector" class="green button" data-lity><?php echo __('Add a Relation'); ?></a>

<div id="item-relation-selector" style="overflow: auto; padding: 20px; border-radius: 6px; background: #fff" class="lity-hide container-twelve">
<div class="field">
<div class="two columns alpha">
<?php echo $this->formLabel('new_relation_property_id', __('This Subject')); ?>
</div>
<div class="inputs one column">
<span id="subject_id" class="subject-id" <?php echo empty($item->id) ? '' : 'data-subject-id="' . $item->id . '"'; ?>><?php echo empty($item->id) ? __('[New]') : '#' . $item->id; ?></span>
</div>
<div class="nine columns omega">
<?php echo empty($item->id) ? '' : metadata('item', array('Dublin Core', 'Title')); ?>
</div>
</div>
<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_property_id', __('Is Related By')); ?>
</div>
<div class="nine columns omega">
<?php echo $this->formSelect('new_relation_property_id',
null, array('multiple' => false), $formSelectProperties); ?>
</div>
</div>
<div class="field">
<div class="inputs two columns alpha">
<?php echo $this->formLabel('object_title', __('With Object')); ?>
</div>
<div class="inputs one column">
<span id="object_id" class="object-id" data-base-url="<?php echo CURRENT_BASE_URL; ?>"></span>
<div id="item-relation-selector" style="overflow: auto; overflow-x: hidden; border-radius: 6px; background: #fff; padding:20px;" class="lity-hide">
<div class="container container-twelve">
<div class="field">
<div class="two columns alpha">
<?php echo $this->formLabel('new_relation_property_id', __('This Subject')); ?>
</div>
<div class="inputs one column">
<span id="subject_id" class="subject-id" <?php echo empty($item->id) ? '' : 'data-subject-id="' . $item->id . '"'; ?>><?php echo empty($item->id) ? __('[New]') : '#' . $item->id; ?></span>
</div>
<div class="nine columns omega">
<?php echo empty($item->id) ? '' : metadata('item', array('Dublin Core', 'Title')); ?>
</div>
</div>
<div class="inputs nine columns omega">
<span id="object_title"><i><?php echo __('[Search and Select Below]'); ?></i></span>

<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_property_id', __('Is Related By')); ?>
</div>
<div class="nine columns omega">
<?php echo $this->formSelect('new_relation_property_id',
null, array('multiple' => false), $formSelectProperties); ?>
</div>
</div>
</div>

<?php if ($provideRelationComments): ?>
<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('relation_comment', __('Comment')); ?>
<div class="field">
<div class="two columns alpha">
<?php echo $this->formLabel('object_title', __('With Object')); ?>
</div>
<div class="inputs one column">
<span id="object_id" class="object-id" data-base-url="<?php echo CURRENT_BASE_URL; ?>"></span>
</div>
<div class="inputs nine columns omega">
<span id="object_title"><i><?php echo __('[Search and Select Below]'); ?></i></span>
</div>
</div>
<div class="inputs nine columns omega">
<?php echo $this->formText('relation_comment', null); ?>

<?php if ($provideRelationComments): ?>
<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('relation_comment', __('Comment')); ?>
</div>
<div class="inputs nine columns omega">
<?php echo $this->formText('relation_comment', null); ?>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

<input id="new_relation_object_item_id" type="hidden">
<input id="new_relation_object_item_id" type="hidden">

<div class="action">
<div class="nine columns alpha">
<a href="#" id="add-relation" class="green button" data-lity-close><?php echo __('Add this Relation'); ?></a>
</div>
<div class="three columns omega">
<div class="right">
<a href="#" id="cancel-relation" class="red button" data-lity-close><?php echo __('Cancel'); ?></a>
<div class="action row">
<div class="nine columns alpha">
<a href="#" id="add-relation" class="green button" data-lity-close><?php echo __('Add this Relation'); ?></a>
</div>
<div class="three columns omega">
<div class="right">
<a href="#" id="cancel-relation" class="red button" data-lity-close><?php echo __('Cancel'); ?></a>
</div>
</div>
</div>
</div>

<div class="nine columns alpha">
<h3><?php echo __('Search and Select a Record'); ?></h3>
</div>
<div class="action three columns omega">
<div class="right">
<a href="<?php echo url('/items/add'); ?>" id="create-record" class="blue button" target="_blank"><?php echo __('Create a new Item'); ?></a>
</div>
<div class="right">
<a href="#" id="refresh-results" class="green button"><?php echo __('Refresh'); ?></a>
</div>
</div>
<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_object_item_type_id', __('By Item Types')); ?>
</div>
<div class="inputs nine columns omega">
<?php echo $this->formSelect('new_relation_object_item_type_id',
null, array('multiple' => false), array()); ?>
</div>
</div>
<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_object_collection_id', __('By Collection')); ?>
<div>
<div class="six columns alpha">
<h3><?php echo __('Search and Select a Record'); ?></h3>
</div>
<div class="action six columns omega">
<div class="right">
<a href="<?php echo url('/items/add'); ?>" id="create-record" class="blue button" target="_blank"><?php echo __('Create a new Item'); ?></a>
</div>
<div class="right">
<a href="#" id="refresh-results" class="green button"><?php echo __('Refresh'); ?></a>
</div>
</div>
</div>
<div class="inputs nine columns omega">
<?php echo $this->formSelect('new_relation_object_collection_id',
null, array('multiple' => false), array()); ?>

<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_object_item_type_id', __('By Item Types')); ?>
</div>
<div class="inputs nine columns omega">
<?php echo $this->formSelect('new_relation_object_item_type_id',
null, array('multiple' => false), array()); ?>
</div>
</div>
</div>

<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('partial_object_title', __('By Partial Title')); ?>
<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_object_collection_id', __('By Collection')); ?>
</div>
<div class="inputs nine columns omega">
<?php echo $this->formSelect('new_relation_object_collection_id',
null, array('multiple' => false), array()); ?>
</div>
</div>
<fieldset class="inputs four columns">
<?php echo $this->formText('partial_object_title', null, array('size' => 10, 'maxlength' => 60)); ?>
</fieldset>
<fieldset class="inputs five columns omega">
<div class="three columns alpha">
<?php echo $this->formLabel('id_limit', __('Limit Item IDs (“x” or “x-y”)')); ?>
</div>
<div class="inputs two columns omega">
<?php echo $this->formText('id_limit', null, array('size' => 10, 'maxlength' => 60)); ?>
</div>
</fieldset>
</div>

<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_item_sort', __('Sort By')); ?>
<div class="field">
<fieldset class="six columns alpha">
<div class="three columns alpha">
<?php echo $this->formLabel('partial_object_title', __('By Partial Title')); ?>
</div>
<div class="inputs three columns omega">
<?php echo $this->formText('partial_object_title', null, array('size' => 10, 'maxlength' => 60)); ?>
</div>
</fieldset>

<fieldset class="six columns omega">
<div class="three columns alpha ">
<?php echo $this->formLabel('id_limit', __('Limit Item IDs (“x” or “x-y”)')); ?>
</div>
<div class="inputs three columns omega">
<?php echo $this->formText('id_limit', null, array('size' => 10, 'maxlength' => 60)); ?>
</div>
</fieldset>
</div>
<fieldset class="inputs nine columns omega">
<div class="four columns alpha">
<input type="radio" name="itemsListSort" id="new_selectObjectSortTimestamp" value="timestamp" checked>
<label for="new_selectObjectSortTimestamp"><?php echo __("Most recently updated"); ?></label>
</div>
<div class="four columns omega">
<input type="radio" name="itemsListSort" id="new_selectObjectSortName" value="name">
<label for="new_selectObjectSortName"><?php echo __("Alphabetically"); ?></label>

<div class="field">
<div class="three columns alpha">
<?php echo $this->formLabel('new_relation_item_sort', __('Sort By')); ?>
</div>
<fieldset class="inputs nine columns omega">
<div class="four columns alpha">
<input type="radio" name="itemsListSort" id="new_selectObjectSortTimestamp" value="timestamp" checked>
<label for="new_selectObjectSortTimestamp"><?php echo __("Most recently updated"); ?></label>
</div>
</fieldset>
</div>
<div class="four columns omega">
<input type="radio" name="itemsListSort" id="new_selectObjectSortName" value="name">
<label for="new_selectObjectSortName"><?php echo __("Alphabetically"); ?></label>
</div>
</fieldset>
</div>

<br class="clear" />
<div>
<ul id="lookup-results"></ul>
</div>
<br class="clear" />
<div class="twelve columns alpha omega">
<ul id="lookup-results"></ul>
</div>

<div class="twelve columns">
<div class="two columns">
<ul class="pagination" class="left">
<li id="selector-previous-page" class="pg_disabled pagination_previous"><a href="#">&lt;</a></li>
<li id="selector-next-page" class="pg_disabled pagination_next"><a href="#">&gt;</a></li>
</ul>
<div class="twelve columns alpha omega">
<div class="offset-by-five two columns">
<ul class="pagination" class="left">
<li id="selector-previous-page" class="pg_disabled pagination_previous"><a href="#">&lt;</a></li>
<li id="selector-next-page" class="pg_disabled pagination_next"><a href="#">&gt;</a></li>
</ul>
</div>
</div>
</div>
</div>
Loading