View source
<?php
use Eluceo\iCal\Component\Calendar;
use Eluceo\iCal\Component\Timezone;
function views_ical_preprocess_views_view_ical(&$variables) {
module_load_include('inc', 'views', 'views.theme');
$view = $variables['view'];
$view
->getResponse()->headers
->set('Content-Type', 'text/calendar; charset=utf-8');
if ($view->display_handler
->getOption('sitename_title')) {
$config = \Drupal::config('system.site');
$title = $config
->get('name');
if ($slogan = $config
->get('slogan')) {
$title .= ' - ' . $slogan;
}
}
else {
$title = $view
->getTitle();
}
$variables['title'] = $title;
template_preprocess_views_view_unformatted($variables);
}
function views_ical_preprocess_views_view_icalwizard(&$variables) {
return;
$view = $variables['view'];
$view
->getResponse()->headers
->set('Content-Type', 'text/calendar; charset=utf-8');
if ($view->display_handler
->getOption('sitename_title')) {
$config = \Drupal::config('system.site');
$title = $config
->get('name');
if ($slogan = $config
->get('slogan')) {
$title .= ' - ' . $slogan;
}
}
else {
$title = $view
->getTitle();
}
$variables['title'] = $title;
$calendar = new Calendar('-//Drupal iCal API//EN');
$user_timezone = \drupal_get_user_timezone();
$v_timezone = new Timezone($user_timezone);
$calendar
->setTimezone($v_timezone);
foreach ($variables['rows'] as $row) {
$calendar
->addComponent($row);
}
$variables['ical'] = $calendar
->render();
if (false) {
module_load_include('inc', 'views', 'views.theme');
$view = $variables['view'];
if ($view->display_handler
->getOption('sitename_title')) {
$title = $config
->get('name');
if ($slogan = $config
->get('slogan')) {
$title .= ' - ' . $slogan;
}
}
else {
$title = $view
->getTitle();
}
$variables['title'] = $title;
}
template_preprocess_views_view_fields($variables);
}
function views_ical_preprocess_views_view_ical_fields(&$variables) {
module_load_include('inc', 'views', 'views.theme');
template_preprocess_views_view_fields($variables);
}