|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package midgard.admin.asgard |
|
4
|
|
|
* @author The Midgard Project, http://www.midgard-project.org |
|
5
|
|
|
* @copyright The Midgard Project, http://www.midgard-project.org |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
use midgard\portable\storage\connection; |
|
10
|
|
|
use midcom\datamanager\datamanager; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Simple object deleted page |
|
14
|
|
|
* |
|
15
|
|
|
* @package midgard.admin.asgard |
|
16
|
|
|
*/ |
|
17
|
|
|
class midgard_admin_asgard_handler_object_deleted extends midcom_baseclasses_components_handler |
|
18
|
|
|
{ |
|
19
|
|
|
use midgard_admin_asgard_handler; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Handler for deleted objects |
|
23
|
|
|
* |
|
24
|
|
|
* @param mixed $handler_id The ID of the handler. |
|
25
|
|
|
* @param string $guid The object's GUID |
|
26
|
1 |
|
* @param array $data The local request data. |
|
27
|
|
|
*/ |
|
28
|
1 |
|
public function _handler_deleted($handler_id, $guid, array &$data) |
|
29
|
|
|
{ |
|
30
|
1 |
|
$this->add_breadcrumb($this->router->generate('welcome'), $this->_l10n->get($this->_component)); |
|
31
|
|
|
|
|
32
|
1 |
|
if (midcom::get()->auth->admin) { |
|
33
|
|
|
$this->prepare_admin_view($guid); |
|
34
|
|
|
midgard_admin_asgard_plugin::bind_to_object($data['object'], $handler_id, $data); |
|
35
|
|
|
} |
|
36
|
1 |
|
$data['view_title'] = $this->_l10n->get('object deleted'); |
|
37
|
1 |
|
|
|
38
|
|
|
$this->add_breadcrumb("", $data['view_title']); |
|
39
|
|
|
return $this->get_response(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
private function prepare_admin_view($guid) |
|
43
|
|
|
{ |
|
44
|
|
|
$type = connection::get_em() |
|
45
|
|
|
->createQuery('SELECT r.typename from midgard:midgard_repligard r WHERE r.guid = ?1') |
|
46
|
|
|
->setParameter(1, $guid) |
|
47
|
|
|
->getSingleScalarResult(); |
|
48
|
|
|
|
|
49
|
|
|
$dba_type = midcom::get()->dbclassloader->get_midcom_class_name_for_mgdschema_object($type); |
|
50
|
|
|
|
|
51
|
|
|
$qb = midcom::get()->dbfactory->new_query_builder($dba_type); |
|
52
|
|
|
$qb->include_deleted(); |
|
53
|
|
|
$qb->add_constraint('guid', '=', $guid); |
|
54
|
|
|
|
|
55
|
|
|
$this->_request_data['object'] = $qb->get_result(0); |
|
56
|
|
|
$this->prepare_dm($type); |
|
57
|
|
|
|
|
58
|
|
|
$this->_request_data['asgard_toolbar']->add_item([ |
|
59
|
|
|
MIDCOM_TOOLBAR_URL => $this->router->generate('trash_type', ['type' => $type]), |
|
60
|
|
|
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('undelete'), |
|
61
|
|
|
MIDCOM_TOOLBAR_GLYPHICON => 'recycle', |
|
62
|
|
|
MIDCOM_TOOLBAR_POST => true, |
|
63
|
|
|
MIDCOM_TOOLBAR_POST_HIDDENARGS => [ |
|
64
|
|
|
'undelete[]' => $guid |
|
65
|
|
|
] |
|
66
|
|
|
]); |
|
67
|
|
|
$this->_request_data['asgard_toolbar']->add_item([ |
|
68
|
|
|
MIDCOM_TOOLBAR_URL => $this->router->generate('trash_type', ['type' => $type]), |
|
69
|
|
|
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('purge'), |
|
70
|
|
|
MIDCOM_TOOLBAR_GLYPHICON => 'trash', |
|
71
|
|
|
MIDCOM_TOOLBAR_POST => true, |
|
72
|
|
|
MIDCOM_TOOLBAR_POST_HIDDENARGS => [ |
|
73
|
|
|
'undelete[]' => $guid, |
|
74
|
|
|
'purge' => true |
|
75
|
|
|
] |
|
76
|
|
|
]); |
|
77
|
|
|
$this->add_breadcrumb($this->router->generate('trash'), $this->_l10n->get('trash')); |
|
78
|
|
|
$this->add_breadcrumb($this->router->generate('trash_type', ['type' => $type]), midgard_admin_asgard_plugin::get_type_label($dba_type)); |
|
79
|
|
|
$label = midcom_helper_reflector::get($this->_request_data['object'])->get_object_label($this->_request_data['object']); |
|
80
|
|
|
$this->add_breadcrumb('', $label); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Loads the schemadb from the helper class |
|
85
|
|
|
* |
|
86
|
1 |
|
* @param string $type |
|
87
|
|
|
*/ |
|
88
|
1 |
|
private function prepare_dm($type) |
|
89
|
1 |
|
{ |
|
90
|
|
|
$schema_helper = new midgard_admin_asgard_schemadb($this->_request_data['object'], $this->_config, $type); |
|
91
|
|
|
$schemadb = $schema_helper->create([]); |
|
92
|
|
|
$datamanager = new datamanager($schemadb); |
|
93
|
|
|
$datamanager |
|
94
|
|
|
->set_storage($this->_request_data['object']) |
|
95
|
|
|
->get_form(); // currently needed to add head elements |
|
96
|
|
|
$this->_request_data['datamanager'] = $datamanager; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Output the style element for deleted objects |
|
101
|
|
|
* |
|
102
|
|
|
* @param mixed $handler_id The ID of the handler. |
|
103
|
|
|
* @param array $data The local request data. |
|
104
|
|
|
*/ |
|
105
|
|
|
public function _show_deleted($handler_id, array &$data) |
|
106
|
|
|
{ |
|
107
|
|
|
midcom_show_style('midgard_admin_asgard_object_deleted'); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|