I'm trying to filter some metadata values in the public view. What I want is to append information to a metadata code. This code is a reference to an Identifier of another Item Type. Sometimes there are multiple codes for the item, so it has to repeat the function that appends information to this code.
I found out that whenever I call metadata in the last function (get_type_description()), the subsequent values are not filtered. It just doesn't execute subject_info() anymore and I can't figure out why. Am I doing something wrong? Do you have a solution for this?
What I did was (short version):
class DataLinkerPlugin extends Omeka_Plugin_AbstractPlugin{
protected $_hooks = array('public_head');
public function hookPublicHead($args){
add_filter(array('Display', 'Item', 'Dublin Core', 'Subject'), 'subject_info', 7);
}
}
function subject_info($args){
$type_information = get_type_description($args);
$html = $args . " - " $type_information;
return $html;
}
function get_type_description($search_string){
$db = get_db();
$sql = " SELECT items.id
FROM {$db->Item} items
JOIN {$db->ElementText} element_texts
ON items.id = element_texts.record_id
JOIN {$db->Element} elements
ON element_texts.element_id = elements.id
JOIN {$db->ElementSet} element_sets
ON elements.element_set_id = element_sets.id
WHERE element_sets.name = 'Dublin Core'
AND elements.name = 'Identifier'
AND element_texts.text = ?";
_log("3 BEFORE FETCHING: ");
$itemIds = $db->fetchAll($sql, $search_string);
if (count($itemIds) > 0){
$found_item = get_record_by_id('item', $itemIds[0]["id"]);
$temp_return = metadata($found_item, array('Dublin Core', 'Title'));
return $temp_return;
}
return "Type doesn't exist";
}
Thanks!