-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReplaceDCFieldsPlugin.php
More file actions
41 lines (34 loc) · 1.28 KB
/
ReplaceDCFieldsPlugin.php
File metadata and controls
41 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
class ReplaceDCFieldsPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array(
'itemTitleSwitch' => array('Display', 'Item', 'Dublin Core', 'Title'),
'admin_items_form_tabs'
);
protected $_hooks = array('after_save_item');
public function hookAfterSaveItem($args) {
$item = $args['record'];
$searchText = get_db()->getTable('SearchText')->findByRecord('Item', $item->id);
$pbCoreTitle = metadata($item, array('PBCore', 'Title'));
$searchText->title = $pbCoreTitle;
$searchText->save();
}
public function filterAdminItemsFormTabs($tabs)
{
unset($tabs['Dublin Core']);
unset($tabs['Item Type Metadata']);
return $tabs;
}
public function itemTitleSwitch($title, $args)
{
/**
* Replace the title of all items in public/admin view with a different field.
* For use with element sets other than PBCore, change the new field to whatever field you want, and activate the plugin.
*/
$request = Zend_Controller_Front::getInstance()->getRequest();
// Replace title field here.
$item = $args['record'];
$title = metadata($item, array('PBCore', 'Title'));
return $title;
}
}