diff --git a/controllers/LookupController.php b/controllers/LookupController.php index 9201fec..ac42fa3 100644 --- a/controllers/LookupController.php +++ b/controllers/LookupController.php @@ -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')); @@ -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')); diff --git a/plugin.ini b/plugin.ini index 6c80805..de3d28d 100644 --- a/plugin.ini +++ b/plugin.ini @@ -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" diff --git a/views/shared/common/item-relations-form.php b/views/shared/common/item-relations-form.php index 0639117..5a9c0b0 100644 --- a/views/shared/common/item-relations-form.php +++ b/views/shared/common/item-relations-form.php @@ -22,7 +22,9 @@ $thisItemId = $item->id; $colspan = ($provideRelationComments ? 4 : 3); $lastVocab = -1; - foreach ($allRelations as $relation) { + foreach ($allRelations as $relation) { ?> + + " . "" @@ -32,7 +34,6 @@ } $subjectRelation = $relation['subject_item_id'] == $thisItemId; $objectRelation = $relation['object_item_id'] == $thisItemId; - echo ''; echo '' . ($subjectRelation ? __('This Item') @@ -73,8 +74,8 @@ echo ''; } ?> + '; } ?> @@ -107,137 +108,148 @@ -
-
-
- formLabel('new_relation_property_id', __('This Subject')); ?> -
-
- id) ? '' : 'data-subject-id="' . $item->id . '"'; ?>>id) ? __('[New]') : '#' . $item->id; ?> -
-
- id) ? '' : metadata('item', array('Dublin Core', 'Title')); ?> -
-
-
-
- formLabel('new_relation_property_id', __('Is Related By')); ?> -
-
- formSelect('new_relation_property_id', - null, array('multiple' => false), $formSelectProperties); ?> -
-
-
-
- formLabel('object_title', __('With Object')); ?> -
-
- +
+
+
+
+ formLabel('new_relation_property_id', __('This Subject')); ?> +
+
+ id) ? '' : 'data-subject-id="' . $item->id . '"'; ?>>id) ? __('[New]') : '#' . $item->id; ?> +
+
+ id) ? '' : metadata('item', array('Dublin Core', 'Title')); ?> +
-
- + +
+
+ formLabel('new_relation_property_id', __('Is Related By')); ?> +
+
+ formSelect('new_relation_property_id', + null, array('multiple' => false), $formSelectProperties); ?> +
-
- -
-
- formLabel('relation_comment', __('Comment')); ?> +
+
+ formLabel('object_title', __('With Object')); ?> +
+
+ +
+
+ +
-
- formText('relation_comment', null); ?> + + +
+
+ formLabel('relation_comment', __('Comment')); ?> +
+
+ formText('relation_comment', null); ?> +
-
- + - + -
-
- -
-
-
- +
+
+ +
+
+
+ +
-
-
-

-
-
-
- -
-
- -
-
-
-
- formLabel('new_relation_object_item_type_id', __('By Item Types')); ?> -
-
- formSelect('new_relation_object_item_type_id', - null, array('multiple' => false), array()); ?> -
-
-
-
- formLabel('new_relation_object_collection_id', __('By Collection')); ?> +
+
+

+
+
+
+ +
+
+ +
+
-
- formSelect('new_relation_object_collection_id', - null, array('multiple' => false), array()); ?> + +
+
+ formLabel('new_relation_object_item_type_id', __('By Item Types')); ?> +
+
+ formSelect('new_relation_object_item_type_id', + null, array('multiple' => false), array()); ?> +
-
-
-
- formLabel('partial_object_title', __('By Partial Title')); ?> +
+
+ formLabel('new_relation_object_collection_id', __('By Collection')); ?> +
+
+ formSelect('new_relation_object_collection_id', + null, array('multiple' => false), array()); ?> +
-
- formText('partial_object_title', null, array('size' => 10, 'maxlength' => 60)); ?> -
-
-
- formLabel('id_limit', __('Limit Item IDs (“x” or “x-y”)')); ?> -
-
- formText('id_limit', null, array('size' => 10, 'maxlength' => 60)); ?> -
-
-
-
-
- formLabel('new_relation_item_sort', __('Sort By')); ?> +
+
+
+ formLabel('partial_object_title', __('By Partial Title')); ?> +
+
+ formText('partial_object_title', null, array('size' => 10, 'maxlength' => 60)); ?> +
+
+ +
+
+ formLabel('id_limit', __('Limit Item IDs (“x” or “x-y”)')); ?> +
+
+ formText('id_limit', null, array('size' => 10, 'maxlength' => 60)); ?> +
+
-
-
- - -
-
- - + +
+
+ formLabel('new_relation_item_sort', __('Sort By')); ?> +
+
+
+ +
-
-
+
+ + +
+
+
-
-
-
    -
    +
    +
    +
      +
      -
      -
      -
        -
      • <
      • -
      • >
      • -
      +
      +
      +
        +
      • <
      • +
      • >
      • +
      +
      diff --git a/views/shared/common/item-relations-show-table.php b/views/shared/common/item-relations-show-table.php index 98ead07..c6ecf26 100644 --- a/views/shared/common/item-relations-show-table.php +++ b/views/shared/common/item-relations-show-table.php @@ -1,48 +1,47 @@ id; +$provideRelationComments = get_option('item_relations_provide_relation_comments'); +$colspan = ($provideRelationComments ? 4 : 3); +$lastVocab = -1; +$thisItemId = $item-> id; - $relVocabShowHide = __("Show / Hide"); - $relVocabShowHideAll = __("Show / Hide All"); - echo " - - "; - - $jsFile = WEB_PLUGIN."/ItemRelations/views/shared/javascripts/item-relations-vocab-toggle.js"; - echo ""; - - echo ""; - $colspan = ($provideRelationComments ? 4 : 3); - $lastVocab = -1; - foreach ($allRelations as $relation) { +$relVocabShowHide = __("Show / Hide"); +$relVocabShowHideAll = __("Show / Hide All"); +?> + + +
      +"; + $lastVocab = $relation["vocabulary_id"]; + echo ""; } echo ""; - echo ""; + echo "'; echo ""; - echo ""; + echo "'; if ($provideRelationComments) { - echo ""; + echo ""; } - echo ""; - } # foreach - echo "
      " - ."" - .$relation["vocabulary"] - ."
      " + . "" + . $relation["vocabulary"] + . "
      " . - ( $relation['subject_item_id']==$thisItemId ? __('This Item') - : "". - $relation['subject_item_title'] . "" - ) . - "" + . ($relation['subject_item_id'] == $thisItemId + ? __('This Item') + : "" . $relation['subject_item_title'] . "" + ) + . '" . $relation['relation_text'] . "" . - ( $relation['object_item_id']==$thisItemId ? __('This Item') - : "". - $relation['object_item_title'] . "" - ). - "" + . ($relation['object_item_id'] == $thisItemId + ? __('This Item') + : "" . $relation['object_item_title'] . "" + ) + . '(".$relation['relation_comment'].")(" . $relation['relation_comment'] . ")
      "; + echo ''; +} # foreach ?> + diff --git a/views/shared/css/item-relations.css b/views/shared/css/item-relations.css index f619ffa..8270bfc 100644 --- a/views/shared/css/item-relations.css +++ b/views/shared/css/item-relations.css @@ -22,12 +22,12 @@ ul#lookup-results li:hover { } span.relListItemId { - display: inline-block; - text-align: right; - vertical-align: bottom; - overflow: hidden; - margin-right: 1em; - width: 4em; - font-size: 80%; - color: #aaa; + display: inline-block; + text-align: right; + vertical-align: bottom; + overflow: hidden; + margin-right: 1em; + width: 4em; + font-size: 80%; + color: #aaa; } diff --git a/views/shared/javascripts/item-relations-vocab-toggle.js b/views/shared/javascripts/item-relations-vocab-toggle.js index bba90c0..eee580b 100644 --- a/views/shared/javascripts/item-relations-vocab-toggle.js +++ b/views/shared/javascripts/item-relations-vocab-toggle.js @@ -1,39 +1,38 @@ jQuery(document).ready(function () { - var $ = jQuery; + var $ = jQuery; - $(".relVocabHead").each(function(element) { - var curVocab = $(this).data("vocab"); - var rowClass = "relVocab_"+curVocab; - var rowCount = $("."+rowClass).size(); - $("th", this).append( - " "+ - "["+relVocabShowHide +" ("+rowCount+")]"+ - "" - ); - // $("."+rowClass).toggle(); - }); - - $(".relVocabShowHideBtn").click(function(e) { - e.preventDefault(); - var curVocab = $(this).data("vocab"); - var rowClass = "relVocab_"+curVocab; - $("."+rowClass).toggle(); - }); + $(".relVocabHead").each(function(element) { + var curVocab = $(this).data("vocab"); + var rowClass = "relVocab_"+curVocab; + var rowCount = $("."+rowClass).size(); + $("th", this).append( + " "+ + "["+relVocabShowHide +" ("+rowCount+")]"+ + "" + ); + // $("."+rowClass).toggle(); + }); - var allShowHide = false; - $(".relVocabRow").hide(); + $(".relVocabShowHideBtn").click(function(e) { + e.preventDefault(); + var curVocab = $(this).data("vocab"); + var rowClass = "relVocab_"+curVocab; + $("."+rowClass).toggle(); + }); - var colspan = $(".relVocabHead th").first().attr('colSpan'); - $("#relVocabTable tbody").prepend( - ""+ - "["+relVocabShowHideAll+"]"+ - "" - ); + var allShowHide = false; + $(".relVocabRow").hide(); - $("#relVocabShowHideAllBtn").click(function(e){ - e.preventDefault(); - allShowHide = !allShowHide; - if (allShowHide) { $(".relVocabRow").show() } else { $(".relVocabRow").hide(); } - }); + var colspan = $(".relVocabHead th").first().attr('colSpan'); + $("#relVocabTable tbody").prepend( + ""+ + "["+relVocabShowHideAll+"]"+ + "" + ); + $("#relVocabShowHideAllBtn").click(function(e){ + e.preventDefault(); + allShowHide = !allShowHide; + if (allShowHide) { $(".relVocabRow").show() } else { $(".relVocabRow").hide(); } + }); }); diff --git a/views/shared/javascripts/item-relations.js b/views/shared/javascripts/item-relations.js index c961dfc..405c536 100644 --- a/views/shared/javascripts/item-relations.js +++ b/views/shared/javascripts/item-relations.js @@ -39,12 +39,17 @@ jQuery(document).ready(function () { } function updateChoices() { - if (updateTimer != null) { clearTimeout(updateTimer); } - updateTimer = setTimeout(updateChoicesCore, 1000); + if (updateTimer != null) { + clearTimeout(updateTimer); + } + updateTimer = setTimeout(updateChoicesCore, 1000); } function updateChoicesCore() { - if (updateTimer != null) { clearTimeout(updateTimer); updateTimer = null; } + if (updateTimer != null) { + clearTimeout(updateTimer); + updateTimer = null; + } options['partial'] = $('#partial_object_title').val(); options['id_limit'] = $('#id_limit').val(); @@ -74,9 +79,9 @@ jQuery(document).ready(function () { $('#lookup-results').find('li').remove(); for (i = 0; i < data['items'].length; ++i) { // items.push('
    • ' + data['items'][i]['label'] + '
    • '); - items.push('
    • ' + - '#' + data['items'][i]['value'] + " " + - data['items'][i]['label'] + '
    • '); + items.push('
    • ' + + '#' + data['items'][i]['value'] + " " + + data['items'][i]['label'] + '
    • '); } $('#lookup-results').append(items.join('')); @@ -282,16 +287,16 @@ jQuery(document).ready(function () { $('#lookup-results').on('click', 'li', function () { $('#new_relation_object_item_id').val($(this).attr('data-value')); $('#object_id').html( - '#' + - $(this).attr('data-value') + - '' + '#' + + $(this).attr('data-value') + + '' ); var htmlSansSpan = $(this).html(); htmlSansSpan = htmlSansSpan.substr(htmlSansSpan.indexOf("")+8); $('#object_title').html( - '' + - htmlSansSpan + - '' + '' + + htmlSansSpan + + '' ); updateAddButton(); }); @@ -300,5 +305,7 @@ jQuery(document).ready(function () { updateAddButton(); }); - $('#cancel-relation').click(function(e) { e.preventDefault(); }); + $('#cancel-relation').click(function(e) { + e.preventDefault(); + }); });