Commit 10943469 authored by Liam Morland's avatar Liam Morland
Browse files

Prevent undefined index errors

parent d988db2c
......@@ -33,7 +33,7 @@ function uw_ct_event_preprocess_node(&$vars) {
// If there is a summary remove the images from it and set variable.
if ($body['summary'] !== '') {
$vars['content']['body_to_display'] = _uw_ct_event_remove_images_from_text($body['safe_summary']);
$vars['content']['body_to_display'] = _uw_ct_event_remove_images_from_text(isset($body['safe_summary']) ? $body['safe_summary'] : NULL);
}
// If there is a value in the body remove
// the images from it and set variable.
......@@ -73,14 +73,14 @@ function uw_ct_event_preprocess_node(&$vars) {
// Get the entity wrapper for the individual event node.
// This is required to get the timezone.
$event_wrapper = entity_metadata_wrapper('node', $vars['view']->result[$vars['id'] - 1]->nid);
$event_wrapper = isset($vars['view']) ? entity_metadata_wrapper('node', $vars['view']->result[$vars['id'] - 1]->nid) : NULL;
// Replace the two date values from the view results
// into the 0th element of field_event_date.
// Also, add in the timezone.
$event_date = array(
'value' => $vars['view']->result[$vars['id'] - 1]->field_data_field_event_date_field_event_date_value,
'value2' => $vars['view']->result[$vars['id'] - 1]->field_data_field_event_date_field_event_date_value2,
'value' => isset($vars['view']) ? $vars['view']->result[$vars['id'] - 1]->field_data_field_event_date_field_event_date_value : NULL,
'value2' => isset($vars['view']) ? $vars['view']->result[$vars['id'] - 1]->field_data_field_event_date_field_event_date_value2 : NULL,
'timezone' => $event_wrapper->field_event_date->value()[0]['timezone'],
'timezone_db' => $event_wrapper->field_event_date->value()[0]['timezone_db'],
);
......@@ -92,10 +92,10 @@ function uw_ct_event_preprocess_node(&$vars) {
$vars['content']['output'] = field_view_value('node', $node, $field_name, $event_date, $display);
// Drop the re-occuring rule if it is present.
$vars['content']['output']['#markup'] = preg_replace('/\<div class=\"date-repeat-rule\"\>(.*?)\<\/div\>/', '', $vars['content']['output']['#markup']);
$vars['content']['output']['#markup'] = preg_replace('/\<div class=\"date-repeat-rule\"\>(.*?)\<\/div\>/', '', isset($vars['view']) ? $vars['content']['output']['#markup'] : NULL);
// Remove the second end date if over multiple dates.
$vars['content']['output']['#markup'] = preg_replace('/ to <span.*?<\/span>/', '', $vars['content']['output']['#markup']);
$vars['content']['output']['#markup'] = preg_replace('/ to <span.*?<\/span>/', '', isset($vars['view']) ? $vars['content']['output']['#markup'] : NULL);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment