@@ -25,7 +25,8 @@ |
||
25 | 25 | { |
26 | 26 | try { |
27 | 27 | $viewer->register_plugin_namespace('__feeds', array('rss' => array('class' => __CLASS__))); |
28 | - } catch (midcom_error $e) { |
|
28 | + } |
|
29 | + catch (midcom_error $e) { |
|
29 | 30 | $e->log(); |
30 | 31 | } |
31 | 32 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function _load_schemadb() |
62 | 62 | { |
63 | - $this->_schemadb =& $this->_request_data['schemadb']; |
|
64 | - if ( $this->_config->get('simple_name_handling') |
|
63 | + $this->_schemadb = & $this->_request_data['schemadb']; |
|
64 | + if ($this->_config->get('simple_name_handling') |
|
65 | 65 | && !midcom::get()->auth->admin) { |
66 | 66 | foreach (array_keys($this->_schemadb) as $name) { |
67 | 67 | $this->_schemadb[$name]->fields['name']['readonly'] = true; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $this->_load_schemadb(); |
78 | 78 | $this->_controller = midcom_helper_datamanager2_controller::create('simple'); |
79 | - $this->_controller->schemadb =& $this->_schemadb; |
|
79 | + $this->_controller->schemadb = & $this->_schemadb; |
|
80 | 80 | $this->_controller->set_storage($this->_article); |
81 | 81 | if (!$this->_controller->initialize()) { |
82 | 82 | throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_article->id}."); |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function load_schemadb() |
63 | 63 | { |
64 | - $this->_schemadb =& $this->_request_data['schemadb']; |
|
65 | - if ( $this->_config->get('simple_name_handling') |
|
64 | + $this->_schemadb = & $this->_request_data['schemadb']; |
|
65 | + if ($this->_config->get('simple_name_handling') |
|
66 | 66 | && !midcom::get()->auth->can_user_do('midcom:urlname')) { |
67 | 67 | foreach (array_keys($this->_schemadb) as $name) { |
68 | 68 | $this->_schemadb[$name]->fields['name']['readonly'] = true; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | if (!$this->_article->create()) { |
88 | 88 | debug_print_r('We operated on this object:', $this->_article); |
89 | - throw new midcom_error('Failed to create a new article. Last Midgard error was: '. midcom_connection::get_error_string()); |
|
89 | + throw new midcom_error('Failed to create a new article. Last Midgard error was: ' . midcom_connection::get_error_string()); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // Callback possibility |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $qb->add_constraint('name', '<>', ''); |
47 | 47 | |
48 | 48 | // Unless in Auto-Index mode or the index article is hidden, we skip the index article. |
49 | - if ( !$this->_config->get('autoindex') |
|
49 | + if (!$this->_config->get('autoindex') |
|
50 | 50 | && !$this->_config->get('indexinnav')) { |
51 | 51 | $qb->add_constraint('name', '<>', 'index'); |
52 | 52 | } |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | */ |
54 | 54 | private function _load_schemadb() |
55 | 55 | { |
56 | - $this->_schemadb =& $this->_request_data['schemadb']; |
|
57 | - if ( $this->_config->get('simple_name_handling') |
|
56 | + $this->_schemadb = & $this->_request_data['schemadb']; |
|
57 | + if ($this->_config->get('simple_name_handling') |
|
58 | 58 | && !midcom::get()->auth->admin) { |
59 | 59 | foreach (array_keys($this->_schemadb) as $name) { |
60 | 60 | $this->_schemadb[$name]->fields['name']['readonly'] = true; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $this->_load_schemadb(); |
73 | 73 | $controller = midcom_helper_datamanager2_controller::create('simple'); |
74 | - $controller->schemadb =& $this->_schemadb; |
|
74 | + $controller->schemadb = & $this->_schemadb; |
|
75 | 75 | $controller->set_storage($this->_article); |
76 | 76 | |
77 | 77 | if (!$controller->initialize()) { |
@@ -174,7 +174,7 @@ |
||
174 | 174 | $filename = "{$article->name}/{$data['filename']}"; |
175 | 175 | $view[$filename] = $this->_get_attachment_data($filename, $data); |
176 | 176 | } |
177 | - } elseif ( $datamanager->types[$name] instanceof midcom_helper_datamanager2_type_image |
|
177 | + } elseif ($datamanager->types[$name] instanceof midcom_helper_datamanager2_type_image |
|
178 | 178 | && $datamanager->types[$name]->attachments_info) { |
179 | 179 | $data = $datamanager->types[$name]->attachments_info['main']; |
180 | 180 | $filename = "{$article->name}/{$data['filename']}"; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | private function _populate_node_toolbar() |
27 | 27 | { |
28 | 28 | $buttons = array(); |
29 | - if ( $this->_topic->can_do('midgard:update') |
|
29 | + if ($this->_topic->can_do('midgard:update') |
|
30 | 30 | && $this->_topic->can_do('midcom:component_config')) { |
31 | 31 | $workflow = $this->get_workflow('datamanager2'); |
32 | 32 | $buttons[] = $workflow->get_button('config/', array( |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png', |
35 | 35 | )); |
36 | 36 | } |
37 | - if ( $this->_topic->can_do('midgard:update') |
|
37 | + if ($this->_topic->can_do('midgard:update') |
|
38 | 38 | && $this->_topic->can_do('net.nehmer.comments:moderation')) { |
39 | 39 | $buttons[] = array( |
40 | 40 | MIDCOM_TOOLBAR_URL => 'moderate/reported_abuse/', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $toolbar = new midcom_helper_toolbar(); |
82 | 82 | $buttons = array(); |
83 | - if ( midcom::get()->auth->user |
|
83 | + if (midcom::get()->auth->user |
|
84 | 84 | && $comment->status < net_nehmer_comments_comment::MODERATED) { |
85 | 85 | if (!$comment->can_do('net.nehmer.comments:moderation')) { |
86 | 86 | // Regular users can only report abuse |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | if (!$this->_schemadb) { |
95 | 95 | $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb')); |
96 | 96 | |
97 | - if ( $this->_config->get('use_captcha') |
|
98 | - || ( !midcom::get()->auth->user |
|
97 | + if ($this->_config->get('use_captcha') |
|
98 | + || (!midcom::get()->auth->user |
|
99 | 99 | && $this->_config->get('use_captcha_if_anonymous'))) { |
100 | 100 | $this->_schemadb['comment']->append_field( |
101 | 101 | 'captcha', |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
112 | - if ( $this->_config->get('ratings_enable') |
|
112 | + if ($this->_config->get('ratings_enable') |
|
113 | 113 | && array_key_exists('rating', $this->_schemadb['comment']->fields)) { |
114 | 114 | $this->_schemadb['comment']->fields['rating']['hidden'] = false; |
115 | 115 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->_post_controller = midcom_helper_datamanager2_controller::create('create'); |
132 | - $this->_post_controller->schemadb =& $this->_schemadb; |
|
132 | + $this->_post_controller->schemadb = & $this->_schemadb; |
|
133 | 133 | $this->_post_controller->schema = 'comment'; |
134 | 134 | $this->_post_controller->defaults = $defaults; |
135 | - $this->_post_controller->callback_object =& $this; |
|
135 | + $this->_post_controller->callback_object = & $this; |
|
136 | 136 | |
137 | 137 | if (!$this->_post_controller->initialize()) { |
138 | 138 | throw new midcom_error('Failed to initialize a DM2 create controller.'); |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | |
167 | 167 | if (!$this->_new_comment->create()) { |
168 | 168 | debug_print_r('We operated on this object:', $this->_new_comment); |
169 | - throw new midcom_error('Failed to create a new comment, cannot continue. Last Midgard error was: '. midcom_connection::get_error_string()); |
|
169 | + throw new midcom_error('Failed to create a new comment, cannot continue. Last Midgard error was: ' . midcom_connection::get_error_string()); |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( isset($_POST['subscribe']) |
|
172 | + if (isset($_POST['subscribe']) |
|
173 | 173 | && midcom::get()->auth->user) { |
174 | 174 | // User wants to subscribe to receive notifications about this comments thread |
175 | 175 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $this->_comments = $this->_comments->execute(); |
231 | 231 | } |
232 | 232 | |
233 | - if ( midcom::get()->auth->user |
|
233 | + if (midcom::get()->auth->user |
|
234 | 234 | || $this->_config->get('allow_anonymous')) { |
235 | 235 | $this->_init_post_controller(); |
236 | 236 | $this->_process_post(); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $this->_init_display_datamanager(); |
241 | 241 | } |
242 | 242 | |
243 | - if ( $handler_id == 'view-comments-custom' |
|
243 | + if ($handler_id == 'view-comments-custom' |
|
244 | 244 | && count($args) > 1) { |
245 | 245 | midcom::get()->skip_page_style = true; |
246 | 246 | $this->custom_view = $args[1]; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $this->_prepare_request_data(); |
250 | 250 | midcom::get()->metadata->set_request_metadata($this->_get_last_modified(), $this->_objectguid); |
251 | 251 | |
252 | - if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) |
|
252 | + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) |
|
253 | 253 | && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { |
254 | 254 | midcom::get()->skip_page_style = true; |
255 | 255 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | private function _process_post() |
286 | 286 | { |
287 | - if ( !midcom::get()->auth->user |
|
287 | + if (!midcom::get()->auth->user |
|
288 | 288 | && !midcom::get()->auth->request_sudo('net.nehmer.comments')) { |
289 | 289 | throw new midcom_error('We were anonymous but could not acquire SUDO privileges, aborting'); |
290 | 290 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | private function _get_last_modified() |
316 | 316 | { |
317 | - return array_reduce($this->_comments, function ($carry, net_nehmer_comments_comment $item) { |
|
317 | + return array_reduce($this->_comments, function($carry, net_nehmer_comments_comment $item) { |
|
318 | 318 | return max($item->metadata->revised, $carry); |
319 | 319 | }, 0); |
320 | 320 | } |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | $data['comment_toolbar'] = $this->_master->_populate_post_toolbar($comment); |
347 | 347 | midcom_show_style('comments-item'); |
348 | 348 | |
349 | - if ( midcom::get()->auth->admin |
|
350 | - || ( midcom::get()->auth->user |
|
349 | + if (midcom::get()->auth->admin |
|
350 | + || (midcom::get()->auth->user |
|
351 | 351 | && $comment->can_do('midgard:delete'))) { |
352 | 352 | midcom_show_style('comments-admintoolbar'); |
353 | 353 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | midcom_show_style('comments-nonefound'); |
358 | 358 | } |
359 | 359 | |
360 | - if ( midcom::get()->auth->user |
|
360 | + if (midcom::get()->auth->user |
|
361 | 361 | || $this->_config->get('allow_anonymous')) { |
362 | 362 | midcom_show_style('post-comment'); |
363 | 363 | } else { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $this->_object = $object; |
47 | 47 | $this->get_object_path(); |
48 | - $this->_request_data =& $request_data; |
|
48 | + $this->_request_data = & $request_data; |
|
49 | 49 | |
50 | 50 | $this->root_types = midcom_helper_reflector_tree::get_root_classes(); |
51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // we go through the path bottom up and show the first root type we find |
60 | 60 | foreach (array_reverse($this->_object_path) as $object) { |
61 | 61 | foreach ($this->root_types as $root_type) { |
62 | - if ( is_a($object, $root_type) |
|
62 | + if (is_a($object, $root_type) |
|
63 | 63 | || midcom_helper_reflector::is_same_class($root_type, $object->__midcom_class_name__)) { |
64 | 64 | $this->expanded_root_types[] = $root_type; |
65 | 65 | break; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function _is_collapsed($type, $total) |
101 | 101 | { |
102 | - return ( $total > $this->_config->get('max_navigation_entries') |
|
102 | + return ($total > $this->_config->get('max_navigation_entries') |
|
103 | 103 | && empty($_GET['show_all_' . $type])); |
104 | 104 | } |
105 | 105 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | foreach ($ref->get_child_classes() as $class) { |
116 | 116 | $qb = $ref->_child_objects_type_qb($class, $object, false); |
117 | 117 | |
118 | - if ( !$qb |
|
118 | + if (!$qb |
|
119 | 119 | || !($count = $qb->count_unchecked())) { |
120 | 120 | continue; |
121 | 121 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | $qb = $ref->_root_objects_qb(false); |
165 | 165 | |
166 | - if ( !$qb |
|
166 | + if (!$qb |
|
167 | 167 | || !($total = $qb->count_unchecked())) { |
168 | 168 | return; |
169 | 169 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | { |
199 | 199 | $ref = midcom_helper_reflector::get($type); |
200 | 200 | if (!empty($this->_object_path[$level])) { |
201 | - if ( $this->_object_path[$level]->__mgdschema_class_name__ == $type |
|
201 | + if ($this->_object_path[$level]->__mgdschema_class_name__ == $type |
|
202 | 202 | && !array_key_exists($this->_object_path[$level]->guid, $this->shown_objects)) { |
203 | 203 | $label = htmlspecialchars($ref->get_object_label($this->_object_path[$level])); |
204 | 204 | $this->_draw_element($this->_object_path[$level], $label, $level); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | echo "<a href=\"" . midcom_connection::get_url('self') . "__mfa/asgard/object/{$mode}/{$object->guid}/\" title=\"GUID: {$object->guid}, ID: {$object->id}\">{$icon}{$label}</a>\n"; |
235 | - if ( $selected |
|
235 | + if ($selected |
|
236 | 236 | || $autoexpand) { |
237 | 237 | $this->_list_child_elements($object, $level + 1); |
238 | 238 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | |
255 | - if ( method_exists($class, 'navigation') |
|
255 | + if (method_exists($class, 'navigation') |
|
256 | 256 | && ($this->_request_data['plugin_name'] == "asgard_{$component}")) { |
257 | 257 | $this->_request_data['expanded'] = true; |
258 | 258 | midcom_show_style('midgard_admin_asgard_navigation_section_header'); |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | if ($this->_is_selected($object)) { |
287 | 287 | $css_class .= ' selected'; |
288 | 288 | } |
289 | - if ( is_object($this->_object) |
|
290 | - && ( $object->guid == $this->_object->guid |
|
291 | - || ( is_a($this->_object, 'midcom_db_parameter') |
|
289 | + if (is_object($this->_object) |
|
290 | + && ($object->guid == $this->_object->guid |
|
291 | + || (is_a($this->_object, 'midcom_db_parameter') |
|
292 | 292 | && $object->guid == $this->_object->parentguid))) { |
293 | 293 | $css_class .= ' current'; |
294 | 294 | } |
295 | - if ( !$object->can_do('midgard:update')) { |
|
295 | + if (!$object->can_do('midgard:update')) { |
|
296 | 296 | $css_class .= ' readonly'; |
297 | 297 | } |
298 | 298 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $types = array(); |
309 | 309 | |
310 | 310 | // Get the types that might have special display conditions |
311 | - if ( $this->_config->get('midgard_types') |
|
311 | + if ($this->_config->get('midgard_types') |
|
312 | 312 | && preg_match_all('/\|([a-z0-9\.\-_]+)/', $this->_config->get('midgard_types'), $regs)) { |
313 | 313 | $types = $regs[1]; |
314 | 314 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | // Override with user selected |
317 | 317 | // @TODO: Should this just include to the configuration selection, although it would break the consistency |
318 | 318 | // of other similar preference sets, which simply override the global settings? |
319 | - if ( midgard_admin_asgard_plugin::get_preference('midgard_types') |
|
319 | + if (midgard_admin_asgard_plugin::get_preference('midgard_types') |
|
320 | 320 | && preg_match_all('/\|([a-z0-9\.\-_]+)/', midgard_admin_asgard_plugin::get_preference('midgard_types'), $regs)) { |
321 | 321 | $types = $regs[1]; |
322 | 322 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $label_mapping = array(); |
349 | 349 | foreach ($types as $root_type) { |
350 | 350 | // If the regular expression has been set, check which types should be shown |
351 | - if ( $regexp !== '//' |
|
351 | + if ($regexp !== '//' |
|
352 | 352 | && (boolean) preg_match($regexp, $root_type) == $exclude) { |
353 | 353 | continue; |
354 | 354 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * click if nothing is expanded |
384 | 384 | */ |
385 | 385 | $types_shown = false; |
386 | - if ( sizeof($expanded_types) > 0 |
|
386 | + if (sizeof($expanded_types) > 0 |
|
387 | 387 | && midgard_admin_asgard_plugin::get_preference('navigation_type') === 'dropdown') { |
388 | 388 | $this->_draw_select_navigation(); |
389 | 389 | $types_shown = true; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | echo " <li class=\"mgdschema-type\">"; |
422 | 422 | |
423 | 423 | $dbaclass = midcom::get()->dbclassloader->get_midcom_class_name_for_mgdschema_object($type); |
424 | - if ( $dbaclass |
|
424 | + if ($dbaclass |
|
425 | 425 | && class_exists($dbaclass)) { |
426 | 426 | $object = new $dbaclass; |
427 | 427 | } else { |