1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
class PanelizerEntityNode extends PanelizerEntityDefault {
|
13 |
|
|
public $entity_admin_root = 'admin/structure/types/manage/%panelizer_node_type';
|
14 |
|
|
public $entity_admin_bundle = 4;
|
15 |
|
|
public $views_table = 'node';
|
16 |
|
|
public $uses_page_manager = TRUE;
|
17 |
e5e66f93
|
Assos Assos
|
public $supports_revisions = TRUE;
|
18 |
85ad3d82
|
Assos Assos
|
|
19 |
|
|
public function entity_access($op, $entity) {
|
20 |
|
|
|
21 |
|
|
return node_access($op, $entity);
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
public function entity_save($entity) {
|
28 |
|
|
node_save($entity);
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
public function entity_identifier($entity) {
|
32 |
|
|
return t('This node');
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
public function entity_bundle_label() {
|
36 |
|
|
return t('Node type');
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
public function entity_allows_revisions($entity) {
|
43 |
|
|
$retval = array();
|
44 |
|
|
|
45 |
|
|
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
|
46 |
|
|
|
47 |
|
|
$node_options = variable_get('node_options_' . $bundle, array('status', 'promote'));
|
48 |
|
|
|
49 |
e5e66f93
|
Assos Assos
|
|
50 |
|
|
$retval[0] = TRUE;
|
51 |
85ad3d82
|
Assos Assos
|
|
52 |
e5e66f93
|
Assos Assos
|
|
53 |
|
|
$retval[1] = user_access('administer nodes');
|
54 |
85ad3d82
|
Assos Assos
|
|
55 |
e5e66f93
|
Assos Assos
|
|
56 |
|
|
$retval[2] = in_array('revision', $node_options);
|
57 |
85ad3d82
|
Assos Assos
|
|
58 |
e5e66f93
|
Assos Assos
|
return $retval;
|
59 |
85ad3d82
|
Assos Assos
|
}
|
60 |
|
|
|
61 |
e5e66f93
|
Assos Assos
|
|
62 |
|
|
|
63 |
|
|
|
64 |
85ad3d82
|
Assos Assos
|
function get_default_display($bundle, $view_mode) {
|
65 |
|
|
$display = parent::get_default_display($bundle, $view_mode);
|
66 |
|
|
|
67 |
|
|
$display->title = '%node:title';
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
$pane = panels_new_pane('node_links', 'node_links', TRUE);
|
71 |
|
|
$pane->css['css_class'] = 'link-wrapper';
|
72 |
|
|
$pane->configuration['build_mode'] = $view_mode;
|
73 |
|
|
$pane->configuration['context'] = 'panelizer';
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
$display->add_pane($pane, 'center');
|
77 |
|
|
|
78 |
e5e66f93
|
Assos Assos
|
unset($pane);
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
if (module_exists('webform')) {
|
83 |
|
|
if ($view_mode == 'page_manager') {
|
84 |
|
|
if (variable_get('webform_node_' . $bundle)) {
|
85 |
|
|
$pane = panels_new_pane('entity_field_extra', 'node:webform', TRUE);
|
86 |
|
|
$pane->configuration['context'] = 'panelizer';
|
87 |
|
|
$pane->configuration['view_mode'] = 'full';
|
88 |
|
|
$display->add_pane($pane, 'center');
|
89 |
|
|
unset($pane);
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
if (module_exists('book')) {
|
97 |
|
|
if ($view_mode == 'page_manager') {
|
98 |
|
|
$pane = panels_new_pane('node_book_nav', 'node_book_nav', TRUE);
|
99 |
|
|
$pane->configuration['context'] = 'panelizer';
|
100 |
|
|
$display->add_pane($pane, 'center');
|
101 |
|
|
unset($pane);
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
85ad3d82
|
Assos Assos
|
return $display;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
public function hook_default_page_manager_handlers(&$handlers) {
|
115 |
|
|
$handler = new stdClass;
|
116 |
|
|
$handler->disabled = FALSE;
|
117 |
|
|
$handler->api_version = 1;
|
118 |
|
|
$handler->name = 'node_view_panelizer';
|
119 |
|
|
$handler->task = 'node_view';
|
120 |
|
|
$handler->subtask = '';
|
121 |
|
|
$handler->handler = 'panelizer_node';
|
122 |
|
|
$handler->weight = -100;
|
123 |
|
|
$handler->conf = array(
|
124 |
|
|
'title' => t('Node panelizer'),
|
125 |
|
|
'context' => 'argument_entity_id:node_1',
|
126 |
|
|
'access' => array(),
|
127 |
|
|
);
|
128 |
|
|
$handlers['node_view_panelizer'] = $handler;
|
129 |
|
|
|
130 |
|
|
return $handlers;
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
public function hook_form_alter(&$form, &$form_state, $form_id) {
|
139 |
|
|
if ($form_id == 'node_type_form') {
|
140 |
|
|
if (isset($form['#node_type'])) {
|
141 |
|
|
$bundle = $form['#node_type']->type;
|
142 |
|
|
$this->add_bundle_setting_form($form, $form_state, $bundle, array('type'));
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
public function hook_page_alter(&$page) {
|
148 |
e5e66f93
|
Assos Assos
|
|
149 |
|
|
if ($_GET['q'] == 'admin/structure/types') {
|
150 |
|
|
|
151 |
|
|
if (!empty($page['content']['system_main']['node_table'])) {
|
152 |
|
|
|
153 |
|
|
$table = &$page['content']['system_main']['node_table'];
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
$operationsCol = end($table['#header']);
|
158 |
|
|
if (!empty($operationsCol['colspan'])) {
|
159 |
|
|
$operationsColKey = key($table['#header']);
|
160 |
|
|
$table['#header'][$operationsColKey]['colspan']++;
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
$types = node_type_get_types();
|
166 |
|
|
$names = node_type_get_names();
|
167 |
|
|
$row_index = 0;
|
168 |
|
|
foreach ($names as $bundle => $name) {
|
169 |
|
|
$type = $types[$bundle];
|
170 |
|
|
if (node_hook($type->type, 'form')) {
|
171 |
|
|
$type_url_str = str_replace('_', '-', $type->type);
|
172 |
|
|
if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
|
173 |
|
|
$table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
|
174 |
|
|
}
|
175 |
|
|
else {
|
176 |
|
|
$table['#rows'][$row_index][] = array('data' => '');
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
$row_index++;
|
180 |
85ad3d82
|
Assos Assos
|
}
|
181 |
|
|
}
|
182 |
|
|
}
|
183 |
|
|
}
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
public function preprocess_panelizer_view_mode(&$vars, $entity, $element, $panelizer, $info) {
|
187 |
|
|
parent::preprocess_panelizer_view_mode($vars, $entity, $element, $panelizer, $info);
|
188 |
|
|
|
189 |
|
|
if (!empty($entity->promote)) {
|
190 |
|
|
$vars['classes_array'][] = 'node-promoted';
|
191 |
|
|
}
|
192 |
|
|
if (!empty($entity->sticky)) {
|
193 |
|
|
$vars['classes_array'][] = 'node-sticky';
|
194 |
|
|
}
|
195 |
|
|
if (empty($entity->status)) {
|
196 |
|
|
$vars['classes_array'][] = 'node-unpublished';
|
197 |
|
|
}
|
198 |
|
|
}
|
199 |
|
|
|
200 |
e5e66f93
|
Assos Assos
|
function render_entity($entity, $view_mode, $langcode = NULL, $args = array(), $address = NULL, $extra_contexts = array()) {
|
201 |
|
|
$info = parent::render_entity($entity, $view_mode, $langcode, $args, $address, $extra_contexts);
|
202 |
|
|
if (!empty($entity->promote)) {
|
203 |
|
|
$info['classes_array'][] = 'node-promoted';
|
204 |
|
|
}
|
205 |
|
|
if (!empty($entity->sticky)) {
|
206 |
|
|
$info['classes_array'][] = 'node-sticky';
|
207 |
|
|
}
|
208 |
|
|
if (empty($entity->status)) {
|
209 |
|
|
$info['classes_array'][] = 'node-unpublished';
|
210 |
|
|
}
|
211 |
|
|
return $info;
|
212 |
|
|
}
|
213 |
|
|
|
214 |
85ad3d82
|
Assos Assos
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
function hook_views_plugins_alter(&$plugins) {
|
218 |
e5e66f93
|
Assos Assos
|
|
219 |
|
|
|
220 |
|
|
|
221 |
85ad3d82
|
Assos Assos
|
|
222 |
|
|
$path = drupal_get_path('module', 'panelizer') . '/plugins/views';
|
223 |
|
|
$plugins['row']['panelizer_node_view'] = array(
|
224 |
|
|
'title' => t('Panelizer display'),
|
225 |
|
|
'help' => t('Render entities using the panels display for any that have been panelized.'),
|
226 |
|
|
'handler' => 'panelizer_plugin_row_panelizer_node_view',
|
227 |
|
|
'parent' => 'node',
|
228 |
|
|
'base' => array('node'),
|
229 |
|
|
'path' => $path,
|
230 |
|
|
'uses options' => TRUE,
|
231 |
e5e66f93
|
Assos Assos
|
'module' => 'panelizer',
|
232 |
85ad3d82
|
Assos Assos
|
'type' => 'normal',
|
233 |
|
|
'register theme' => FALSE,
|
234 |
|
|
'name' => 'panelizer_node_view',
|
235 |
|
|
);
|
236 |
|
|
}
|
237 |
|
|
} |