Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_ct_event
Commits
10943469
Commit
10943469
authored
Aug 30, 2018
by
Liam Morland
Browse files
Prevent undefined index errors
parent
d988db2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
uw_ct_event.module
View file @
10943469
...
...
@@ -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
);
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment