Skip to content

Commit

Permalink
Merge pull request #2 from Daniel-KM/new_improvements
Browse files Browse the repository at this point in the history
New improvements
  • Loading branch information
GerZah committed Mar 22, 2016
2 parents f069a4f + daf8118 commit 7c5f2c1
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 153 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Copyright

* Copyright Center for History and New Media, 2011-2015
* Copyright GerZah, 2015
* Copyright Daniel Berthereau, 2015
* Copyright Daniel Berthereau, 2015-2016


[Item Relations]: https://github.com/omeka/plugin-ItemRelations
Expand Down
26 changes: 24 additions & 2 deletions controllers/LookupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ public function indexAction()
{
$db = get_db();

if (!$this->_hasParam('subject_id')) {
$this->_setParam('subject_id', -1);
}
if (!$this->_hasParam('partial')) {
$this->_setParam('partial', '');
}
if (!$this->_hasParam('item_type')) {
$this->_setParam('item_type', -1);
}
if (!$this->_hasParam('collection')) {
$this->_setParam('collection', -1);
}
if (!$this->_hasParam('sort')) {
$this->_setParam('sort', 'mod_desc');
}
Expand All @@ -31,6 +37,12 @@ public function indexAction()
$this->_setParam('per_page', 15);
}

$subject_id = intval($this->_getParam('subject_id'));
$where_subject_id = '';
if ($subject_id > 0) {
$where_subject_id = "AND items.id != $subject_id";
}

$partial = preg_replace('/[^ \.,\!\?\p{L}\p{N}\p{Mc}]/ui', '', $this->_getParam('partial'));
$where_text = '';
if (strlen($partial) > 0) {
Expand All @@ -43,6 +55,12 @@ public function indexAction()
$where_item_type = "AND items.item_type_id = $item_type";
}

$collection = intval($this->_getParam('collection'));
$where_collection = '';
if ($collection > 0) {
$where_collection = "AND items.collection_id = $collection";
}

$per_page = intval($this->_getParam('per_page'));
$page = intval($this->_getParam('page'));
$offset = $page * $per_page;
Expand Down Expand Up @@ -71,9 +89,11 @@ public function indexAction()
SELECT count(*) AS count
FROM {$db->Item} items
LEFT JOIN {$db->Element_Texts} elementtexts
ON (items.id = elementtexts.record_id)
ON (items.id = elementtexts.record_id) AND (elementtexts.record_type = 'Item')
WHERE elementtexts.element_id = $titleId
$where_subject_id
$where_item_type
$where_collection
$where_text
GROUP BY elementtexts.record_id
QCOUNT;
Expand All @@ -89,9 +109,11 @@ public function indexAction()
SELECT items.id AS id, text
FROM {$db->Item} items
LEFT JOIN {$db->Element_Texts} elementtexts
ON (items.id = elementtexts.record_id)
ON (items.id = elementtexts.record_id) AND (elementtexts.record_type = 'Item')
WHERE elementtexts.element_id = $titleId
$where_subject_id
$where_item_type
$where_collection
$where_text
GROUP BY elementtexts.record_id
$order_clause
Expand Down
8 changes: 4 additions & 4 deletions plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name="Item Relations"
author="Roy Rosenzweig Center for History and New Media"
description="Allows administrators to define relations between items."
link="http://omeka.org/codex/Plugins/ItemRelations"
support_link="http://omeka.org/forums/forum/plugins"
link="https://omeka.org/codex/Plugins/ItemRelations"
support_link="https://omeka.org/forums/forum/plugins"
license="GPLv3"
omeka_minimum_version="2.0"
omeka_target_version="2.0"
version="2.0.2.1"
omeka_target_version="2.4"
version="2.0.2.2"
tags="item,relation,rdf"
1 change: 0 additions & 1 deletion views/admin/plugins/item-relations-config-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div class="two columns alpha">
<?php echo $this->formLabel('item_relations_allow_vocabularies',
__('Limit Relations to Vocabularies')); ?>
</p>
</div>
<div class="inputs five columns omega">
<p class="explanation">
Expand Down
Loading

0 comments on commit 7c5f2c1

Please sign in to comment.