/
FilesController.php
75 lines (63 loc) · 2.08 KB
/
FilesController.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Omeka
*
* @copyright Copyright 2007-2012 Roy Rosenzweig Center for History and New Media
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
*/
/**
* @package Omeka\Controller
*/
class FilesController extends Omeka_Controller_AbstractActionController
{
protected $_autoCsrfProtection = true;
public $contexts = array(
'show' => array('omeka-xml', 'omeka-json')
);
public function init()
{
$this->_helper->db->setDefaultModelName('File');
}
public function indexAction()
{
throw new Omeka_Controller_Exception_404;
}
public function browseAction()
{
throw new Omeka_Controller_Exception_404;
}
public function addAction()
{
throw new Omeka_Controller_Exception_404;
}
public function editAction()
{
$elementSets = $this->_getFileElementSets();
$this->view->assign(compact('elementSets'));
parent::editAction();
}
protected function _getFileElementSets()
{
// Get element sets assigned to "All" and "File" record types.
$elementSets = $this->_helper->db->getTable('ElementSet')->findByRecordType('File');
// Remove legacy file element sets that will most likely be phased out
// in later versions.
$legacyElementSetNames = array('Omeka Image File', 'Omeka Video File');
foreach ($elementSets as $key => $elementSet) {
if (in_array($elementSet->name, $legacyElementSetNames)) {
unset($elementSets[$key]);
}
}
return $elementSets;
}
protected function _getDeleteConfirmMessage($record)
{
return __('This will delete the file and its associated metadata.');
}
protected function _redirectAfterDelete($record)
{
// Redirect back to the item show page for this file
$this->_helper->flashMessenger(__('The file was successfully deleted.'), 'success');
$this->_helper->redirector('show', 'items', null, array('id'=>$record->item_id));
}
}