first import
This commit is contained in:
74
sites/all/modules/calendar/includes/calendar.views.inc
Normal file
74
sites/all/modules/calendar/includes/calendar.views.inc
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Creates calendar displays of Views results.
|
||||
*/
|
||||
/**
|
||||
* Implementation of hook_views_plugins
|
||||
*/
|
||||
function calendar_views_plugins() {
|
||||
$views_path = drupal_get_path('module', 'views');
|
||||
$module_path = drupal_get_path('module', 'calendar');
|
||||
$theme_path = $module_path;
|
||||
module_load_include('inc', 'calendar', 'theme/theme');
|
||||
|
||||
// Limit these plugins to base tables that represent entities.
|
||||
$base = array_keys(date_views_base_tables());
|
||||
|
||||
$data = array(
|
||||
'module' => 'calendar', // This just tells our themes are elsewhere.
|
||||
|
||||
'style' => array(
|
||||
'calendar_style' => array(
|
||||
'title' => t('Calendar'),
|
||||
'help' => t('Present view results as a Calendar.'),
|
||||
'handler' => 'calendar_plugin_style',
|
||||
'path' => "$module_path/includes",
|
||||
'theme' => 'calendar_style',
|
||||
'theme file' => 'theme.inc',
|
||||
'theme path' => "$module_path/theme",
|
||||
'additional themes' => array(
|
||||
'calendar_mini' => 'style',
|
||||
'calendar_day' => 'style',
|
||||
'calendar_week' => 'style',
|
||||
'calendar_month' => 'style',
|
||||
'calendar_year' => 'style',
|
||||
'calendar_day_overlap' => 'style',
|
||||
'calendar_week_overlap' => 'style',
|
||||
),
|
||||
'uses fields' => TRUE,
|
||||
'uses grouping' => FALSE,
|
||||
'uses row plugin' => TRUE,
|
||||
'uses options' => TRUE,
|
||||
'type' => 'normal',
|
||||
'even empty' => TRUE,
|
||||
'base' => $base,
|
||||
),
|
||||
),
|
||||
'row' => array(
|
||||
'calendar_node' => array(
|
||||
'title' => t('Calendar Items (DEPRECATED, switch to Calendar Entities)'),
|
||||
'help' => t('Displays each selected node as a Calendar item.'),
|
||||
'handler' => 'calendar_plugin_row_node',
|
||||
'path' => "$module_path/includes",
|
||||
'base' => array('node'), // only works with 'node' as base.
|
||||
'uses options' => TRUE,
|
||||
'uses fields' => TRUE,
|
||||
'type' => 'normal',
|
||||
),
|
||||
'calendar_entity' => array(
|
||||
'title' => t('Calendar Entities'),
|
||||
'help' => t('Displays each selected entity as a Calendar item.'),
|
||||
'handler' => 'calendar_plugin_row',
|
||||
'path' => "$module_path/includes",
|
||||
'base' => $base,
|
||||
'uses options' => TRUE,
|
||||
'uses fields' => TRUE,
|
||||
'type' => 'normal',
|
||||
),
|
||||
),
|
||||
);
|
||||
return $data;
|
||||
}
|
558
sites/all/modules/calendar/includes/calendar.views_default.inc
Normal file
558
sites/all/modules/calendar/includes/calendar.views_default.inc
Normal file
@@ -0,0 +1,558 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default views for the Calendar module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set up so it can be used as an API to create default calendars for
|
||||
* specific date fields.
|
||||
*
|
||||
* Use variable_set() to establish criteria for default calendars.
|
||||
* Set the variable in custom modules or in settings.
|
||||
*
|
||||
* Example: Add a new default calendar to custom
|
||||
* calendars that are already configured:
|
||||
*
|
||||
* $options = variable_get('calendar_default_view_options', array());
|
||||
* $option = array(
|
||||
* 'name' => 'example_event',
|
||||
* 'description' => 'An example event calendar for the date field.',
|
||||
* 'path' => 'example_event',
|
||||
* 'types' => array('example_content_type'),
|
||||
* 'date_fields' => array('field_example_date'),
|
||||
* );
|
||||
* $options[] = $option;
|
||||
* variable_set('calendar_default_view_options', $options);
|
||||
*
|
||||
*/
|
||||
function calendar_views_default_views() {
|
||||
$views = array();
|
||||
|
||||
// Construct the default view with default options.
|
||||
$view = calendar_views_construct();
|
||||
$views[$view->name] = $view;
|
||||
|
||||
// Then see if there are any custom calendars to be created
|
||||
// using variable_get().
|
||||
$calendar_options = variable_get('calendar_default_view_options', array());
|
||||
foreach ((array) $calendar_options as $calendar_option) {
|
||||
$view = calendar_views_construct($calendar_option);
|
||||
$views[$view->name] = $view;
|
||||
}
|
||||
return $views;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Construct a default calendar to match specified options.
|
||||
* Views calls it without options, so the basic
|
||||
* default view will use the default values.
|
||||
*
|
||||
* @param $options: an optional array of options to
|
||||
* create default calendars.
|
||||
*
|
||||
* Possible options include:
|
||||
* @param string $name:
|
||||
* The view name, if empty, defaults to 'calendar'.
|
||||
* @param string $description:
|
||||
* The view description, if empty, defaults to generic description.
|
||||
* @param string $path:
|
||||
* The view url, if empty, defaults to 'calendar'.
|
||||
* @param array $types:
|
||||
* Array of content types to limit the calendar to those types.
|
||||
* If empty, defaults to no type filter.
|
||||
* @param array $date_fields:
|
||||
* Date fields used to filter the calendar.
|
||||
* If empty, defaults to array('changed') for node.changed.
|
||||
* @param array $display_fields:
|
||||
* Fields to display in the calendar.
|
||||
* If empty, defaults to title and date fields.
|
||||
*
|
||||
* @return the default calendar array.
|
||||
*/
|
||||
function calendar_views_construct($options = NULL) {
|
||||
$name = NULL;
|
||||
$description = NULL;
|
||||
$path = NULL;
|
||||
$types = NULL;
|
||||
$date_fields = NULL;
|
||||
|
||||
if (empty($options)) {
|
||||
$disabled = TRUE;
|
||||
}
|
||||
else {
|
||||
$disabled = FALSE;
|
||||
extract($options);
|
||||
}
|
||||
if (empty($name)) {
|
||||
$name = 'calendar';
|
||||
}
|
||||
if (empty($description)) {
|
||||
$description = 'A multi-dimensional calendar view with back/next navigation.';
|
||||
}
|
||||
if (empty($path)) {
|
||||
$path = 'calendar';
|
||||
}
|
||||
if (empty($types)) {
|
||||
$types = array();
|
||||
}
|
||||
if (empty($date_fields)) {
|
||||
$date_fields = array('changed');
|
||||
}
|
||||
$colors = array();
|
||||
$date_link_type = '';
|
||||
foreach ($types as $type => $label) {
|
||||
$colors[0][$type] = '#ffffff';
|
||||
$date_link_type = $type;
|
||||
variable_set('calendar_date_link_' . $type, $path . '/month');
|
||||
}
|
||||
|
||||
$type = '';
|
||||
if (!empty($types) && is_array($types) && count($types) > 0 ) {
|
||||
$types = array_keys($types);
|
||||
$type = $types[0];
|
||||
}
|
||||
|
||||
// Can handle core node timestamp fields or Field date fields.
|
||||
|
||||
$aliases = array();
|
||||
foreach ($date_fields as $field_name) {
|
||||
if (substr($field_name, 0, 6) == 'field_') {
|
||||
$table = 'field_data_' . $field_name;
|
||||
$alias = $table . '.' . $field_name . '_value';
|
||||
$cck_field = TRUE;
|
||||
}
|
||||
else {
|
||||
$table = 'node';
|
||||
$alias = $table . '.' . $field_name;
|
||||
$cck_field = FALSE;
|
||||
}
|
||||
$aliases[] = $alias;
|
||||
}
|
||||
|
||||
$view = new view;
|
||||
$view->name = $name;
|
||||
$view->description = t("DEPRECATED: Create new calendars using 'add view from template'.") . ' ' . $description;
|
||||
$view->tag = 'Calendar';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = ucfirst($name) . ' ' . t("(DEPRECATED)");
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0-alpha1';
|
||||
$view->disabled = $name == 'calendar' ? TRUE : FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = $name;
|
||||
$handler->display->display_options['link_display'] = 'page_1';
|
||||
$handler->display->display_options['access']['type'] = 'perm';
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'month';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
/* Field: Content: Title */
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['label'] = '';
|
||||
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
|
||||
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
|
||||
/* Field: Content: Datex */
|
||||
|
||||
foreach ($date_fields as $field_name) {
|
||||
if (substr($field_name, 0, 6) == 'field_') {
|
||||
$table = 'field_data_' . $field_name;
|
||||
$cck_field = TRUE;
|
||||
}
|
||||
else {
|
||||
$table = 'node';
|
||||
$cck_field = FALSE;
|
||||
}
|
||||
|
||||
$handler->display->display_options['fields'][$field_name]['id'] = $field_name;
|
||||
$handler->display->display_options['fields'][$field_name]['table'] = $table;
|
||||
$handler->display->display_options['fields'][$field_name]['field'] = $field_name;
|
||||
$handler->display->display_options['fields'][$field_name]['label'] = '';
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields'][$field_name]['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields'][$field_name]['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['hide_alter_empty'] = 0;
|
||||
|
||||
if ($cck_field) {
|
||||
$handler->display->display_options['fields'][$field_name]['settings'] = array(
|
||||
'format_type' => 'short',
|
||||
'fromto' => 'both',
|
||||
'multiple_number' => '',
|
||||
'multiple_from' => '',
|
||||
'multiple_to' => '',
|
||||
'show_repeat_rule' => '',
|
||||
);
|
||||
$handler->display->display_options['fields'][$field_name]['group_rows'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['delta_offset'] = '0';
|
||||
$handler->display->display_options['fields'][$field_name]['delta_reversed'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['field_api_classes'] = 0;
|
||||
|
||||
/* Sort criterion */
|
||||
$handler->display->display_options['sorts'][$field_name . '_value']['id'] = $field_name . '_value';
|
||||
$handler->display->display_options['sorts'][$field_name . '_value']['table'] = $table;
|
||||
$handler->display->display_options['sorts'][$field_name . '_value']['field'] = $field_name . '_value';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
/* Sort criterion */
|
||||
$handler->display->display_options['sorts'][$field_name]['id'] = $field_name;
|
||||
$handler->display->display_options['sorts'][$field_name]['table'] = $table;
|
||||
$handler->display->display_options['sorts'][$field_name]['field'] = $field_name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 0;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
|
||||
/* Display: Month */
|
||||
$handler = $view->new_display('page', 'Month', 'page_1');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'month';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'month';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['row_options']['calendar_date_link'] = $type;
|
||||
$handler->display->display_options['row_options']['colors']['legend'] = 'type';
|
||||
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array();
|
||||
$handler->display->display_options['row_options']['colors']['calendar_colors_vocabulary'] = array();
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
/* Contextual filter: Date: Date (node) */
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/month';
|
||||
$handler->display->display_options['menu']['title'] = 'Month';
|
||||
$handler->display->display_options['menu']['weight'] = '0';
|
||||
$handler->display->display_options['tab_options']['type'] = 'normal';
|
||||
$handler->display->display_options['tab_options']['title'] = 'Month';
|
||||
$handler->display->display_options['tab_options']['weight'] = '0';
|
||||
|
||||
/* Display: Week */
|
||||
$handler = $view->new_display('page', 'Week', 'page_2');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'week';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'week';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['groupby_times'] = 'hour';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
/* Contextual filter: Date: Date (node) */
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/week';
|
||||
$handler->display->display_options['menu']['title'] = 'Week';
|
||||
$handler->display->display_options['menu']['weight'] = '2';
|
||||
|
||||
/* Display: Day */
|
||||
$handler = $view->new_display('page', 'Day', 'page_3');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'day';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'day';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['style_options']['groupby_times'] = 'hour';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
/* Contextual filter: Date: Date (node) */
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = '';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/day';
|
||||
$handler->display->display_options['menu']['title'] = 'Day';
|
||||
$handler->display->display_options['menu']['weight'] = '3';
|
||||
|
||||
/* Display: Year */
|
||||
$handler = $view->new_display('page', 'Year', 'page');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'year';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'year';
|
||||
$handler->display->display_options['style_options']['name_size'] = '1';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
/* Contextual filter: Date: Date (node) */
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/year';
|
||||
$handler->display->display_options['menu']['title'] = 'Year';
|
||||
$handler->display->display_options['menu']['weight'] = '4';
|
||||
|
||||
/* Display: Block */
|
||||
$handler = $view->new_display('block', 'Block', 'block_1');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'mini';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'month';
|
||||
$handler->display->display_options['style_options']['name_size'] = '1';
|
||||
$handler->display->display_options['style_options']['mini'] = '1';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
/* Contextual filter: Date: Date (node) */
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
|
||||
if (module_exists('date_ical')) {
|
||||
|
||||
/* Display: iCal */
|
||||
$handler = $view->new_display('feed', 'iCal', 'feed_1');
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['style_plugin'] = 'date_ical';
|
||||
$handler->display->display_options['row_plugin'] = 'date_ical';
|
||||
$handler->display->display_options['row_options']['date_field'] = $aliases[0];
|
||||
$handler->display->display_options['defaults']['filters'] = FALSE;
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 0;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
/* Filter criterion: Date: Date (node) */
|
||||
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
|
||||
$handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
|
||||
$handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
|
||||
$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
|
||||
$handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
|
||||
$handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['filters']['date_filter']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
|
||||
$handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/ical/%/calendar.ics';
|
||||
$handler->display->display_options['displays'] = array(
|
||||
'page' => 'page',
|
||||
'page_1' => 'page_1',
|
||||
'page_2' => 'page_2',
|
||||
'page_3' => 'page_3',
|
||||
'block_1' => 'block_1',
|
||||
'default' => 0,
|
||||
);
|
||||
|
||||
} // End if module_exists()
|
||||
|
||||
/* Display: Upcoming */
|
||||
$handler = $view->new_display('block', 'Upcoming', 'block_2');
|
||||
$handler->display->display_options['display_description'] = 'Upcoming events block';
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'list';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'fields';
|
||||
$handler->display->display_options['row_options']['links'] = 1;
|
||||
$handler->display->display_options['row_options']['comments'] = 0;
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['filters'] = FALSE;
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 0;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
/* Filter criterion: Date: Date (node) */
|
||||
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
|
||||
$handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
|
||||
$handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
|
||||
$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
|
||||
$handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
|
||||
$handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['filters']['date_filter']['date_fields'] = drupal_map_assoc($aliases);
|
||||
$handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
|
||||
$handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
|
||||
$translatables[$name] = array(
|
||||
t('Master'),
|
||||
t($name),
|
||||
t('more'),
|
||||
t('Apply'),
|
||||
t('Reset'),
|
||||
t('Sort by'),
|
||||
t('Asc'),
|
||||
t('Desc'),
|
||||
t('Year'),
|
||||
t('All'),
|
||||
t('Month'),
|
||||
t('Week'),
|
||||
t('Day'),
|
||||
t('Block'),
|
||||
t('iCal'),
|
||||
t('Upcoming'),
|
||||
t('Upcoming events block'),
|
||||
);
|
||||
|
||||
|
||||
return $view;
|
||||
|
||||
}
|
614
sites/all/modules/calendar/includes/calendar.views_template.inc
Normal file
614
sites/all/modules/calendar/includes/calendar.views_template.inc
Normal file
@@ -0,0 +1,614 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* View templates for the Calendar module.
|
||||
*
|
||||
* Create calendar templates for every date field in the system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_templates().
|
||||
*
|
||||
*/
|
||||
function calendar_views_templates() {
|
||||
|
||||
$views = array();
|
||||
|
||||
// Map the base tables to entity types.
|
||||
$entity_info = entity_get_info();
|
||||
$base_tables = date_views_base_tables();
|
||||
|
||||
// Find all the date fields we know about.
|
||||
|
||||
$processed = array();
|
||||
|
||||
foreach ($entity_info as $entity_type => $info) {
|
||||
if (!$info['fieldable']) {
|
||||
continue;
|
||||
}
|
||||
$items = field_info_instances($entity_type);
|
||||
$views_fields = date_views_fields($info['base table']);
|
||||
foreach ($views_fields['name'] as $name => $data) {
|
||||
|
||||
// For each of the Field date fields, we need to find the bundle and entities this field is used on.
|
||||
if ($data['is_field']) {
|
||||
foreach ($items as $bundle => $widgets) {
|
||||
foreach ($widgets as $field_name => $widget) {
|
||||
$field = field_info_field($field_name);
|
||||
|
||||
// See if this is a date field. Since fields might be shared
|
||||
// across bundles, make sure we haven't already processed this field.
|
||||
$alias = 'field_data_' . $field_name . '.' . $field_name . '_value';
|
||||
if ($alias == $name && !in_array($alias, $processed)) {
|
||||
$base_table = $base_tables[$entity_type];
|
||||
$calendar_option = array(
|
||||
'name' => 'calendar_' . $field_name,
|
||||
'description' => t("A calendar view of the '@field_name' field in the '@base_table' base table.", array('@base_table' => $base_table, '@field_name' => $field_name)),
|
||||
'path' => 'calendar-' . str_replace('_', '-', $field_name),
|
||||
'base_table' => $base_table,
|
||||
'field_name' => $field_name,
|
||||
);
|
||||
$view = calendar_views_template_construct($calendar_option);
|
||||
$views[$view->name] = $view;
|
||||
$processed[] = $alias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For other date fields, we infer the entity type from the base table.
|
||||
else {
|
||||
$parts = explode('.', $name);
|
||||
$base_table = $parts[0];
|
||||
$field_name = $parts[1];
|
||||
$calendar_option = array(
|
||||
'name' => 'calendar_' . $entity_type . '_' . $field_name,
|
||||
'description' => t("A calendar view of the '@field_name' field in the '@base_table' base table.", array('@base_table' => $base_table, '@field_name' => $field_name)),
|
||||
'path' => 'calendar-' . str_replace('_', '-', $field_name),
|
||||
'base_table' => $base_table,
|
||||
'field_name' => $field_name,
|
||||
);
|
||||
$view = calendar_views_template_construct($calendar_option);
|
||||
$views[$view->name] = $view;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $views;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to construct a calendar template from an array of values.
|
||||
*
|
||||
* @param $options:
|
||||
* An array of options to create calendar templates.
|
||||
*
|
||||
* Possible options include:
|
||||
* @param string $base_table:
|
||||
* The base table for the view.
|
||||
* @param string $name:
|
||||
* The view name.
|
||||
* @param string $description:
|
||||
* The view description.
|
||||
* @param string $path:
|
||||
* The view url, if empty, defaults to 'calendar'.
|
||||
* @param string $bundle:
|
||||
* The bundle for this calendar.
|
||||
* @param string $field_name:
|
||||
* Date field used to filter the calendar.
|
||||
*
|
||||
* @return the default template array.
|
||||
*/
|
||||
function calendar_views_template_construct($options = NULL) {
|
||||
|
||||
$name = $options['name'];
|
||||
$description = $options['description'];
|
||||
$path = $options['path'];
|
||||
$base_table = $options['base_table'];
|
||||
$field_name = $options['field_name'];
|
||||
|
||||
$colors = array();
|
||||
|
||||
if (substr($field_name, 0, 6) == 'field_') {
|
||||
$table = 'field_data_' . $field_name;
|
||||
$alias = $table . '.' . $field_name . '_value';
|
||||
$is_field = TRUE;
|
||||
}
|
||||
else {
|
||||
$table = $base_table;
|
||||
$alias = $table . '.' . $field_name;
|
||||
$is_field = FALSE;
|
||||
}
|
||||
$aliases = array($alias => $alias);
|
||||
|
||||
$view = new view;
|
||||
$view->name = $name;
|
||||
$view->description = $description;
|
||||
$view->tag = 'Calendar';
|
||||
$view->base_table = $base_table;
|
||||
$view->human_name = t("Calendar");
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = '';
|
||||
$handler->display->display_options['link_display'] = 'page_1';
|
||||
$handler->display->display_options['access']['type'] = 'perm';
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'month';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
|
||||
/* Field: Title */
|
||||
|
||||
switch ($base_table) {
|
||||
|
||||
case 'node':
|
||||
case 'node_revision':
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = $base_table;
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['label'] = '';
|
||||
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
|
||||
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
|
||||
break;
|
||||
|
||||
case 'users':
|
||||
$handler->display->display_options['fields']['name']['id'] = 'name';
|
||||
$handler->display->display_options['fields']['name']['table'] = 'users';
|
||||
$handler->display->display_options['fields']['name']['field'] = 'name';
|
||||
$handler->display->display_options['fields']['name']['label'] = '';
|
||||
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
|
||||
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* Date Field */
|
||||
|
||||
$handler->display->display_options['fields'][$field_name]['id'] = $field_name;
|
||||
$handler->display->display_options['fields'][$field_name]['table'] = $table;
|
||||
$handler->display->display_options['fields'][$field_name]['field'] = $field_name;
|
||||
$handler->display->display_options['fields'][$field_name]['label'] = '';
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['external'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['replace_spaces'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['trim_whitespace'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['nl2br'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields'][$field_name]['element_default_classes'] = 1;
|
||||
$handler->display->display_options['fields'][$field_name]['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['hide_alter_empty'] = 0;
|
||||
|
||||
if ($is_field) {
|
||||
$handler->display->display_options['fields'][$field_name]['settings'] = array(
|
||||
'format_type' => 'short',
|
||||
'fromto' => 'both',
|
||||
'multiple_number' => '',
|
||||
'multiple_from' => '',
|
||||
'multiple_to' => '',
|
||||
'show_repeat_rule' => '',
|
||||
);
|
||||
$handler->display->display_options['fields'][$field_name]['group_rows'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['delta_offset'] = '0';
|
||||
$handler->display->display_options['fields'][$field_name]['delta_reversed'] = 0;
|
||||
$handler->display->display_options['fields'][$field_name]['field_api_classes'] = 0;
|
||||
|
||||
/* Sort criterion */
|
||||
$handler->display->display_options['sorts'][$field_name . '_value']['id'] = $field_name . '_value';
|
||||
$handler->display->display_options['sorts'][$field_name . '_value']['table'] = $table;
|
||||
$handler->display->display_options['sorts'][$field_name . '_value']['field'] = $field_name . '_value';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
/* Sort criterion */
|
||||
$handler->display->display_options['sorts'][$field_name]['id'] = $field_name;
|
||||
$handler->display->display_options['sorts'][$field_name]['table'] = $table;
|
||||
$handler->display->display_options['sorts'][$field_name]['field'] = $field_name;
|
||||
|
||||
}
|
||||
|
||||
/* Filter criterion: Content: Published */
|
||||
|
||||
switch ($base_table) {
|
||||
|
||||
case 'node':
|
||||
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = $base_table;
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 0;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Display: Month */
|
||||
|
||||
$handler = $view->new_display('page', 'Month', 'page_1');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'month';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'month';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['row_options']['calendar_date_link'] = '';
|
||||
$handler->display->display_options['row_options']['colors']['legend'] = 'type';
|
||||
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array();
|
||||
$handler->display->display_options['row_options']['colors']['calendar_colors_vocabulary'] = array();
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
|
||||
/* Contextual filter: Date */
|
||||
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/month';
|
||||
$handler->display->display_options['menu']['title'] = 'Month';
|
||||
$handler->display->display_options['menu']['weight'] = '0';
|
||||
$handler->display->display_options['tab_options']['type'] = 'normal';
|
||||
$handler->display->display_options['tab_options']['title'] = 'Month';
|
||||
$handler->display->display_options['tab_options']['weight'] = '0';
|
||||
|
||||
/* Display: Week */
|
||||
|
||||
$handler = $view->new_display('page', 'Week', 'page_2');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'week';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'week';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['groupby_times'] = 'hour';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
|
||||
/* Contextual filter: Date */
|
||||
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/week';
|
||||
$handler->display->display_options['menu']['title'] = 'Week';
|
||||
$handler->display->display_options['menu']['weight'] = '2';
|
||||
|
||||
/* Display: Day */
|
||||
|
||||
$handler = $view->new_display('page', 'Day', 'page_3');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'day';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'day';
|
||||
$handler->display->display_options['style_options']['name_size'] = '3';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['style_options']['groupby_times'] = 'hour';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
|
||||
/* Contextual filter: Date */
|
||||
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = '';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/day';
|
||||
$handler->display->display_options['menu']['title'] = 'Day';
|
||||
$handler->display->display_options['menu']['weight'] = '3';
|
||||
|
||||
/* Display: Year */
|
||||
|
||||
$handler = $view->new_display('page', 'Year', 'page');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'year';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'year';
|
||||
$handler->display->display_options['style_options']['name_size'] = '1';
|
||||
$handler->display->display_options['style_options']['mini'] = '0';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
|
||||
/* Contextual filter: Date */
|
||||
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/year';
|
||||
$handler->display->display_options['menu']['title'] = 'Year';
|
||||
$handler->display->display_options['menu']['weight'] = '4';
|
||||
|
||||
/* Display: Block */
|
||||
|
||||
$handler = $view->new_display('block', 'Block', 'block_1');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'date_views_pager';
|
||||
$handler->display->display_options['pager']['options']['date_id'] = 'mini';
|
||||
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
|
||||
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'calendar_style';
|
||||
$handler->display->display_options['style_options']['calendar_type'] = 'month';
|
||||
$handler->display->display_options['style_options']['name_size'] = '1';
|
||||
$handler->display->display_options['style_options']['mini'] = '1';
|
||||
$handler->display->display_options['style_options']['with_weekno'] = '0';
|
||||
$handler->display->display_options['style_options']['multiday_theme'] = '1';
|
||||
$handler->display->display_options['style_options']['theme_style'] = '1';
|
||||
$handler->display->display_options['style_options']['max_items'] = '0';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'calendar_entity';
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['arguments'] = FALSE;
|
||||
|
||||
/* Contextual filter: Date */
|
||||
|
||||
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
|
||||
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
|
||||
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
|
||||
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
|
||||
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
|
||||
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
|
||||
|
||||
if (module_exists('date_ical')) {
|
||||
|
||||
/* Display: iCal */
|
||||
|
||||
$handler = $view->new_display('feed', 'iCal', 'feed_1');
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['style_plugin'] = 'date_ical';
|
||||
$handler->display->display_options['row_plugin'] = 'date_ical';
|
||||
$handler->display->display_options['row_options']['date_field'] = $alias;
|
||||
$handler->display->display_options['defaults']['filters'] = FALSE;
|
||||
|
||||
/* Filter criterion: Content: Published */
|
||||
|
||||
switch ($base_table) {
|
||||
|
||||
case 'node':
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = $base_table;
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 0;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Filter criterion: Date */
|
||||
|
||||
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['table'] = $base_table;
|
||||
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
|
||||
$handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
|
||||
$handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
|
||||
$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
|
||||
$handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
|
||||
$handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['filters']['date_filter']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
|
||||
$handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
|
||||
$handler->display->display_options['path'] = $path . '/ical/%/calendar.ics';
|
||||
$handler->display->display_options['displays'] = array(
|
||||
'page' => 'page',
|
||||
'page_1' => 'page_1',
|
||||
'page_2' => 'page_2',
|
||||
'page_3' => 'page_3',
|
||||
'block_1' => 'block_1',
|
||||
'default' => 0,
|
||||
);
|
||||
|
||||
} // End if module_exists()
|
||||
|
||||
/* Display: Upcoming */
|
||||
|
||||
$handler = $view->new_display('block', 'Upcoming', 'block_2');
|
||||
$handler->display->display_options['display_description'] = 'Upcoming events block';
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
|
||||
$handler->display->display_options['style_plugin'] = 'list';
|
||||
$handler->display->display_options['defaults']['style_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
|
||||
$handler->display->display_options['row_plugin'] = 'fields';
|
||||
$handler->display->display_options['row_options']['links'] = 1;
|
||||
$handler->display->display_options['row_options']['comments'] = 0;
|
||||
$handler->display->display_options['defaults']['row_options'] = FALSE;
|
||||
$handler->display->display_options['defaults']['filters'] = FALSE;
|
||||
|
||||
/* Filter criterion: Content: Published */
|
||||
|
||||
switch ($base_table) {
|
||||
|
||||
case 'node':
|
||||
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = $base_table;
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 0;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Filter criterion: Date */
|
||||
|
||||
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['table'] = $base_table;
|
||||
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
|
||||
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
|
||||
$handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
|
||||
$handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
|
||||
$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
|
||||
$handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
|
||||
$handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
|
||||
$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
|
||||
$handler->display->display_options['filters']['date_filter']['date_fields'] = $aliases;
|
||||
$handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
|
||||
$handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
|
||||
|
||||
$translatables[$name] = array(
|
||||
t('Master'),
|
||||
t($name),
|
||||
t('more'),
|
||||
t('Apply'),
|
||||
t('Reset'),
|
||||
t('Sort by'),
|
||||
t('Asc'),
|
||||
t('Desc'),
|
||||
t('Year'),
|
||||
t('All'),
|
||||
t('Month'),
|
||||
t('Week'),
|
||||
t('Day'),
|
||||
t('Block'),
|
||||
t('iCal'),
|
||||
t('Upcoming'),
|
||||
t('Upcoming events block'),
|
||||
);
|
||||
|
||||
|
||||
return $view;
|
||||
|
||||
}
|
631
sites/all/modules/calendar/includes/calendar_plugin_row.inc
Normal file
631
sites/all/modules/calendar/includes/calendar_plugin_row.inc
Normal file
@@ -0,0 +1,631 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains the Calendar row style plugin.
|
||||
*
|
||||
* This plugin takes the view results, finds the date value for each,
|
||||
* then compares that date to the date range for the current view.
|
||||
* Items that started before or ended after the current date range
|
||||
* are shortened to the current range. Items that extend over more
|
||||
* than one day are cloned to create a calendar item for each day.
|
||||
* The resulting array of results (which may have a different number
|
||||
* of items than the original view result) are then passed back
|
||||
* to the style plugin so they can be displayed in a calendar.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin which creates a view on the resulting object
|
||||
* and formats it as a Calendar node.
|
||||
*/
|
||||
class calendar_plugin_row extends views_plugin_row {
|
||||
|
||||
// Stores the entities loaded with pre_render.
|
||||
var $entities = array();
|
||||
|
||||
function init(&$view, &$display, $options = NULL) {
|
||||
parent::init($view, $display, $options);
|
||||
$this->base_table = $view->base_table;
|
||||
$this->base_field = $view->base_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to find the date argument handler for this view.
|
||||
*/
|
||||
function date_argument_handler() {
|
||||
foreach ($this->view->argument as $name => $handler) {
|
||||
if (date_views_handler_is_date($handler, 'argument')) {
|
||||
return $handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['date_fields'] = array('default' => array());
|
||||
$options['calendar_date_link'] = array('default' => '');
|
||||
$options['colors'] = array(
|
||||
'contains' => array(
|
||||
'legend' => array('default' => ''),
|
||||
'calendar_colors_type' => array('default' => array()),
|
||||
'taxonomy_field' => array('default' => ''),
|
||||
'calendar_colors_vocabulary' => array('default' => array()),
|
||||
'calendar_colors_taxonomy' => array('default' => array()),
|
||||
'calendar_colors_group' => array('default' => array()),
|
||||
));
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['markup']['#markup'] = t("The calendar row plugin will format view results as calendar items. Make sure this display has a 'Calendar' format and uses a 'Date' contextual filter, or this plugin will not work correctly.");
|
||||
$form['calendar_date_link'] = array(
|
||||
'#title' => t('Add new date link'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $this->options['calendar_date_link'],
|
||||
'#options' => array('' => t('No link')) + node_type_get_names(),
|
||||
'#description' => t('Display a link to add a new date of the specified content type. Displayed only to users with appropriate permissions.'),
|
||||
);
|
||||
$form['colors'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Legend Colors'),
|
||||
'#description' => t('Set a hex color value (like #ffffff) to use in the calendar legend for each content type. Items with empty values will have no stripe in the calendar and will not be added to the legend.'),
|
||||
);
|
||||
$options = array(
|
||||
'' => t('None')
|
||||
);
|
||||
if ($this->view->base_table == 'node') {
|
||||
$options['type'] = t('Based on Content Type');
|
||||
}
|
||||
if (module_exists('taxonomy')) {
|
||||
$options['taxonomy'] = t('Based on Taxonomy');
|
||||
}
|
||||
if (module_exists('og')) {
|
||||
$options['group'] = t('Based on Organic Group');
|
||||
}
|
||||
// If none of the options but the None option is available, stop here.
|
||||
if (count($options) == 1) {
|
||||
return;
|
||||
}
|
||||
$form['colors']['legend'] = array(
|
||||
'#title' => t('Stripes'),
|
||||
'#description' => t('Add stripes to calendar items.'),
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['colors']['legend'],
|
||||
);
|
||||
if ($this->view->base_table == 'node') {
|
||||
$colors = $this->options['colors']['calendar_colors_type'];
|
||||
$type_names = node_type_get_names();
|
||||
foreach ($type_names as $key => $name) {
|
||||
$form['colors']['calendar_colors_type'][$key] = array(
|
||||
'#title' => check_plain($name),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($colors[$key]) ? $colors[$key] : '#ffffff',
|
||||
'#size' => 7,
|
||||
'#maxlength' => 7,
|
||||
'#element_validate' => array('calendar_validate_hex_color'),
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('type')),
|
||||
'#prefix' => '<div class="calendar-colorpicker-wrapper">',
|
||||
'#suffix' => '<div class="calendar-colorpicker"></div></div>',
|
||||
'#attributes' => array('class' => array('edit-calendar-colorpicker')),
|
||||
'#attached' => array(
|
||||
// Add Farbtastic color picker.
|
||||
'library' => array(
|
||||
array('system', 'farbtastic'),
|
||||
),
|
||||
// Add javascript to trigger the colorpicker.
|
||||
'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (module_exists('taxonomy')) {
|
||||
$vocab_field_options = array();
|
||||
$fields = $this->display->handler->get_option('fields');
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['type']) && $field['type'] == 'taxonomy_term_reference_link') {
|
||||
$vocab_field_options[$field['field']] = $field['field'];
|
||||
}
|
||||
}
|
||||
$form['colors']['taxonomy_field'] = array(
|
||||
'#title' => t('Term field'),
|
||||
'#type' => !empty($vocab_field_options) ? 'select' : 'hidden',
|
||||
'#default_value' => $this->options['colors']['taxonomy_field'],
|
||||
'#description' => t("Select the taxonomy term field to use when setting stripe colors. This works best for vocabularies with only a limited number of possible terms."),
|
||||
'#options' => $vocab_field_options,
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
|
||||
);
|
||||
if (empty($vocab_field_options)) {
|
||||
$form['colors']['taxonomy_field']['#options'] = array('' => '');
|
||||
$form['colors']['taxonomy_field']['#suffix'] = t('You must add a term field to this view to use taxonomy stripe values. This works best for vocabularies with only a limited number of possible terms.');
|
||||
}
|
||||
$taxonomy_field = field_info_field($this->options['colors']['taxonomy_field']);
|
||||
$vocab_names[] = array();
|
||||
foreach ((array) $taxonomy_field['settings']['allowed_values'] as $delta => $options) {
|
||||
$vocab_names[] = $options['vocabulary'];
|
||||
}
|
||||
$taxonomies = taxonomy_get_vocabularies();
|
||||
foreach ($taxonomies as $vid => $vocab) {
|
||||
if (in_array($vocab->machine_name, $vocab_names)) {
|
||||
$this->options['colors']['calendar_colors_vocabulary'][] = $vid;
|
||||
}
|
||||
}
|
||||
$form['colors']['calendar_colors_vocabulary'] = array(
|
||||
'#title' => t('Vocabulary Legend Types'),
|
||||
'#type' => 'value',
|
||||
'#value' => $this->options['colors']['calendar_colors_vocabulary'],
|
||||
);
|
||||
|
||||
$vocabularies = (array) $this->options['colors']['calendar_colors_vocabulary'];
|
||||
$term_colors = $this->options['colors']['calendar_colors_taxonomy'];
|
||||
foreach ($vocabularies as $vid) {
|
||||
$vocab = taxonomy_get_tree($vid);
|
||||
foreach ($vocab as $tid => $term) {
|
||||
$form['colors']['calendar_colors_taxonomy'][$term->tid] = array(
|
||||
'#title' => check_plain(t($term->name)),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($term_colors[$term->tid]) ? $term_colors[$term->tid] : '#ffffff',
|
||||
'#size' => 7,
|
||||
'#maxlength' => 7,
|
||||
'#access' => !empty($vocab_field_options),
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
|
||||
'#element_validate' => array('calendar_validate_hex_color'),
|
||||
'#prefix' => '<div class="calendar-colorpicker-wrapper">',
|
||||
'#suffix' => '<div class="calendar-colorpicker"></div></div>',
|
||||
'#attributes' => array('class' => array('edit-calendar-colorpicker')),
|
||||
'#attached' => array(
|
||||
// Add Farbtastic color picker.
|
||||
'library' => array(
|
||||
array('system', 'farbtastic'),
|
||||
),
|
||||
// Add javascript to trigger the colorpicker.
|
||||
'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (module_exists('og')) {
|
||||
$colors_group = $this->options['colors']['calendar_colors_group'];
|
||||
$groups = og_get_all_group();
|
||||
foreach ($groups as $gid) {
|
||||
$form['colors']['calendar_colors_group'][$gid] = array(
|
||||
'#title' => check_plain(t(og_label($gid))),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($colors_group[$gid]) ? $colors_group[$gid] : '#ffffff',
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('group')),
|
||||
'#element_validate' => array('calendar_validate_hex_color'),
|
||||
'#prefix' => '<div class="calendar-colorpicker-wrapper">',
|
||||
'#suffix' => '<div class="calendar-colorpicker"></div></div>',
|
||||
'#attributes' => array('class' => array('edit-calendar-colorpicker')),
|
||||
'#attached' => array(
|
||||
// Add Farbtastic color picker.
|
||||
'library' => array(
|
||||
array('system', 'farbtastic'),
|
||||
),
|
||||
// Add javascript to trigger the colorpicker.
|
||||
'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) {
|
||||
parent::options_submit($form, $form_state);
|
||||
|
||||
if ($this->view->base_table == 'node') {
|
||||
$path = $this->view->display_handler->get_option('path');
|
||||
calendar_clear_link_path($path);
|
||||
if (!empty($form_state['values']['row_options']['calendar_date_link'])) {
|
||||
$node_type = $form_state['values']['row_options']['calendar_date_link'];
|
||||
calendar_set_link('node', $node_type, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pre_render($values) {
|
||||
|
||||
// @TODO When the date is coming in through a relationship, the nid
|
||||
// of the view is not the right node to use, then we need the related node.
|
||||
// Need to sort out how that should be handled.
|
||||
|
||||
// Preload each entity used in this view from the cache.
|
||||
// Provides all the entity values relatively cheaply, and we don't
|
||||
// need to do it repeatedly for the same entity if there are
|
||||
// multiple results for one entity.
|
||||
$ids = array();
|
||||
foreach ($values as $row) {
|
||||
// Use the $id as the key so we don't create more than one value per entity.
|
||||
$id = $row->{$this->field_alias};
|
||||
|
||||
// Node revisions need special loading.
|
||||
if ($this->view->base_table == 'node_revision') {
|
||||
$this->entities[$id] = node_load(NULL, $id);
|
||||
}
|
||||
// For other entities we just create an array of ids to pass
|
||||
// to entity_load().
|
||||
else {
|
||||
$ids[$id] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
$base_tables = date_views_base_tables();
|
||||
$this->entity_type = $base_tables[$this->view->base_table];
|
||||
if (!empty($ids)) {
|
||||
$this->entities = entity_load($this->entity_type, $ids);
|
||||
}
|
||||
|
||||
// Let the style know if a link to create a new date is required.
|
||||
$this->view->date_info->calendar_date_link = $this->options['calendar_date_link'];
|
||||
|
||||
// Identify the date argument and fields that apply to this view.
|
||||
// Preload the Date Views field info for each field, keyed by the
|
||||
// field name, so we know how to retrieve field values from the cached node.
|
||||
$data = date_views_fields($this->view->base_table);
|
||||
$data = $data['name'];
|
||||
$date_fields = array();
|
||||
foreach ($this->view->argument as $handler) {
|
||||
if (date_views_handler_is_date($handler, 'argument')) {
|
||||
// If this is the complex Date argument, the date fields are stored in the handler options,
|
||||
// otherwise we are using the simple date field argument handler.
|
||||
if ($handler->definition['handler'] != 'date_views_argument_handler') {
|
||||
$alias = $handler->table_alias . '.' . $handler->field;
|
||||
$info = $data[$alias];
|
||||
$field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
|
||||
$date_fields[$field_name] = $info;
|
||||
}
|
||||
else {
|
||||
foreach ($handler->options['date_fields'] as $alias) {
|
||||
$info = $data[$alias];
|
||||
$field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
|
||||
|
||||
// This is ugly and hacky but I can't figure out any generic way to
|
||||
// recognize that the node module is going to give some the revision timestamp
|
||||
// a different field name on the entity than the actual column name in the database.
|
||||
if ($this->view->base_table == 'node_revision' && $field_name == 'timestamp') {
|
||||
$field_name = 'revision_timestamp';
|
||||
}
|
||||
|
||||
$date_fields[$field_name] = $info;
|
||||
}
|
||||
}
|
||||
$this->date_argument = $handler;
|
||||
$this->date_fields = $date_fields;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the language for this view.
|
||||
$this->language = $this->display->handler->get_option('field_language');
|
||||
$substitutions = views_views_query_substitutions($this->view);
|
||||
if (array_key_exists($this->language, $substitutions)) {
|
||||
$this->language = $substitutions[$this->language];
|
||||
}
|
||||
}
|
||||
|
||||
function render($row) {
|
||||
global $base_url;
|
||||
$rows = array();
|
||||
$date_info = $this->date_argument->view->date_info;
|
||||
$id = $row->{$this->field_alias};
|
||||
if (!is_numeric($id)) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
// There could be more than one date field in a view
|
||||
// so iterate through all of them to find the right values
|
||||
// for this view result.
|
||||
foreach ($this->date_fields as $field_name => $info) {
|
||||
|
||||
// Load the specified node:
|
||||
// We have to clone this or nodes on other views on this page,
|
||||
// like an Upcoming block on the same page as a calendar view,
|
||||
// will end up acquiring the values we set here.
|
||||
$entity = clone($this->entities[$id]);
|
||||
if (empty($entity)) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$table_name = $info['table_name'];
|
||||
$delta_field = $info['delta_field'];
|
||||
$tz_handling = $info['tz_handling'];
|
||||
$tz_field = $info['timezone_field'];
|
||||
$rrule_field = $info['rrule_field'];
|
||||
$is_field = $info['is_field'];
|
||||
|
||||
$info = entity_get_info($this->entity_type);
|
||||
$this->id_field = $info['entity keys']['id'];
|
||||
$this->id = $entity->{$this->id_field};
|
||||
$this->type = !empty($info['entity keys']['bundle']) ? $info['entity keys']['bundle'] : $this->entity_type;
|
||||
$this->title = entity_label($this->entity_type, $entity);
|
||||
$uri = entity_uri($this->entity_type, $entity);
|
||||
$uri['options']['absolute'] = TRUE;
|
||||
$this->url = url($uri['path'], $uri['options']);
|
||||
|
||||
// Retrieve the field value(s) that matched our query from the cached node.
|
||||
// Find the date and set it to the right timezone.
|
||||
|
||||
$entity->date_id = array();
|
||||
$item_start_date = NULL;
|
||||
$item_end_date = NULL;
|
||||
$granularity = 'second';
|
||||
$increment = 1;
|
||||
if ($is_field) {
|
||||
|
||||
$delta = isset($row->$delta_field) ? $row->$delta_field : 0;
|
||||
$items = field_get_items($this->view->base_table, $entity, $field_name, $this->language);
|
||||
$item = $items[$delta];
|
||||
$db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
$to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
|
||||
// Set the date_id for the node, used to identify which field value to display for
|
||||
// fields that have multiple values. The theme expects it to be an array.
|
||||
$entity->date_id = array('calendar.' . $id . '.' . $field_name . '.' . $delta);
|
||||
|
||||
if (!empty($item['value'])) {
|
||||
$item_start_date = new dateObject($item['value'], $db_tz);
|
||||
$item_end_date = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
|
||||
}
|
||||
|
||||
$cck_field = field_info_field($field_name);
|
||||
$instance = field_info_instance($this->view->base_table, $field_name, $entity->type);
|
||||
$granularity = date_granularity_precision($cck_field['settings']['granularity']);
|
||||
$increment = $instance['widget']['settings']['increment'];
|
||||
|
||||
}
|
||||
elseif (!empty($entity->$field_name)) {
|
||||
$item = $entity->$field_name;
|
||||
$db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
$to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
$item_start_date = new dateObject($item, $db_tz);
|
||||
$item_end_date = $item_start_date;
|
||||
$entity->date_id = array('calendar.' . $id . '.' . $field_name . '.0');
|
||||
}
|
||||
|
||||
// If we don't have a date value, go no further.
|
||||
if (empty($item_start_date)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the item date to the proper display timezone;
|
||||
$item_start_date->setTimezone(new dateTimezone($to_zone));
|
||||
$item_end_date->setTimezone(new dateTimezone($to_zone));
|
||||
|
||||
$event = new stdClass();
|
||||
$event->id = $this->id;
|
||||
$event->title = $this->title;
|
||||
$event->type = $this->type;
|
||||
$event->date_start = $item_start_date;
|
||||
$event->date_end = $item_end_date;
|
||||
$event->db_tz = $db_tz;
|
||||
$event->to_zone = $to_zone;
|
||||
$event->granularity = $granularity;
|
||||
$event->increment = $increment;
|
||||
$event->field = $is_field ? $item : NULL;
|
||||
$event->url = $this->url;
|
||||
$event->row = $row;
|
||||
$event->entity = $entity;
|
||||
|
||||
// All calendar row plugins should provide a date_id that the theme can use.
|
||||
$event->date_id = $entity->date_id[0];
|
||||
|
||||
$entities = $this->explode_values($event);
|
||||
foreach ($entities as $entity) {
|
||||
switch ($this->options['colors']['legend']) {
|
||||
case 'type':
|
||||
$this->calendar_node_type_stripe($entity);
|
||||
break;
|
||||
case 'taxonomy':
|
||||
$this->calendar_taxonomy_stripe($entity);
|
||||
break;
|
||||
case 'group':
|
||||
$this->calendar_group_stripe($entity);
|
||||
break;
|
||||
}
|
||||
$rows[] = $entity;
|
||||
}
|
||||
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function explode_values($event) {
|
||||
$rows = array();
|
||||
|
||||
$date_info = $this->date_argument->view->date_info;
|
||||
$item_start_date = $event->date_start;
|
||||
$item_end_date = $event->date_end;
|
||||
$to_zone = $event->to_zone;
|
||||
$db_tz = $event->db_tz;
|
||||
$granularity = $event->granularity;
|
||||
$increment = $event->increment;
|
||||
|
||||
// Now that we have an 'entity' for each view result, we need
|
||||
// to remove anything outside the view date range,
|
||||
// and possibly create additional nodes so that we have a 'node'
|
||||
// for each day that this item occupies in this view.
|
||||
$now = max($date_info->min_zone_string, $item_start_date->format(DATE_FORMAT_DATE));
|
||||
$to = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
|
||||
$next = new DateObject($now . ' 00:00:00', $date_info->display_timezone);
|
||||
if ($date_info->display_timezone_name != $to_zone) {
|
||||
// Make $start and $end (derived from $node) use the timezone $to_zone, just as the original dates do.
|
||||
date_timezone_set($next, timezone_open($to_zone));
|
||||
}
|
||||
if (empty($to) || $now > $to) {
|
||||
$to = $now;
|
||||
}
|
||||
// $now and $next are midnight (in display timezone) on the first day where node will occur.
|
||||
// $to is midnight on the last day where node will occur.
|
||||
// All three were limited by the min-max date range of the view.
|
||||
$pos = 0;
|
||||
while (!empty($now) && $now <= $to) {
|
||||
$entity = clone($event);
|
||||
|
||||
// Get start and end of current day.
|
||||
$start = $next->format(DATE_FORMAT_DATETIME);
|
||||
date_modify($next, '+1 day');
|
||||
date_modify($next, '-1 second');
|
||||
$end = $next->format(DATE_FORMAT_DATETIME);
|
||||
|
||||
// Get start and end of item, formatted the same way.
|
||||
$item_start = $item_start_date->format(DATE_FORMAT_DATETIME);
|
||||
$item_end = $item_end_date->format(DATE_FORMAT_DATETIME);
|
||||
|
||||
// Get intersection of current day and the node value's duration (as strings in $to_zone timezone).
|
||||
$entity->calendar_start = $item_start < $start ? $start : $item_start;
|
||||
$entity->calendar_end = !empty($item_end) ? ($item_end > $end ? $end : $item_end) : $node->calendar_start;
|
||||
|
||||
// Make date objects
|
||||
$entity->calendar_start_date = date_create($entity->calendar_start, timezone_open($to_zone));
|
||||
$entity->calendar_end_date = date_create($entity->calendar_end, timezone_open($to_zone));
|
||||
|
||||
// Change string timezones into
|
||||
// calendar_start and calendar_end are UTC dates as formatted strings
|
||||
$entity->calendar_start = date_format($entity->calendar_start_date, DATE_FORMAT_DATETIME);
|
||||
$entity->calendar_end = date_format($entity->calendar_end_date, DATE_FORMAT_DATETIME);
|
||||
$entity->calendar_all_day = date_is_all_day($entity->calendar_start, $entity->calendar_end, $granularity, $increment);
|
||||
|
||||
unset($entity->calendar_fields);
|
||||
if (isset($entity) && (empty($entity->calendar_start))) {
|
||||
// if no date for the node and no date in the item
|
||||
// there is no way to display it on the calendar
|
||||
unset($entity);
|
||||
}
|
||||
else {
|
||||
$entity->date_id .= '.' . $pos;
|
||||
|
||||
$rows[] = $entity;
|
||||
unset($entity);
|
||||
}
|
||||
date_modify($next, '+1 second');
|
||||
$now = date_format($next, DATE_FORMAT_DATE);
|
||||
$pos++;
|
||||
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stripe base on node type.
|
||||
*/
|
||||
function calendar_node_type_stripe(&$entity) {
|
||||
$colors = isset($this->options['colors']['calendar_colors_type']) ? $this->options['colors']['calendar_colors_type'] : array();
|
||||
if (empty($colors)) {
|
||||
return;
|
||||
}
|
||||
if (empty($entity->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$type_names = node_type_get_names();
|
||||
$type = $entity->type;
|
||||
$label = '';
|
||||
$stripe = '';
|
||||
if (!(isset($entity->stripe))) {
|
||||
$entity->stripe = array();
|
||||
$entity->stripe_label = array();
|
||||
}
|
||||
if (array_key_exists($type, $type_names)) {
|
||||
$label = $type_names[$type];
|
||||
}
|
||||
if (array_key_exists($type, $colors)) {
|
||||
$stripe = $colors[$type];
|
||||
}
|
||||
|
||||
$entity->stripe[] = $stripe;
|
||||
$entity->stripe_label[] = $label;
|
||||
return $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stripe based on a taxonomy term.
|
||||
*/
|
||||
|
||||
function calendar_taxonomy_stripe(&$entity) {
|
||||
$term_colors = isset($this->options['colors']['calendar_colors_taxonomy']) ? $this->options['colors']['calendar_colors_taxonomy'] : array();
|
||||
if (empty($term_colors)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$terms = array();
|
||||
if ($this->options['colors']['legend'] == 'taxonomy') {
|
||||
$term_field_name = $this->options['colors']['taxonomy_field'];
|
||||
|
||||
if ($term_field = field_get_items($this->view->base_table, $entity->entity, $term_field_name)) {
|
||||
foreach ($term_field as $delta => $items) {
|
||||
foreach ($items as $item) {
|
||||
$terms[] = $item['tid'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($terms)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(isset($entity->stripe))) {
|
||||
$entity->stripe = array();
|
||||
$entity->stripe_label = array();
|
||||
}
|
||||
if (count($terms)) {
|
||||
foreach ($terms as $tid) {
|
||||
$term_for_entity = taxonomy_term_load($tid);
|
||||
if (!array_key_exists($term_for_entity->tid, $term_colors)) {
|
||||
continue;
|
||||
}
|
||||
$stripe = $term_colors[$term_for_entity->tid];
|
||||
$stripe_label = $term_for_entity->name;
|
||||
$entity->stripe[] = $stripe;
|
||||
$entity->stripe_label[] = $stripe_label;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$entity->stripe[] = '';
|
||||
$entity->stripe_label[] = '';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stripe based on group.
|
||||
*/
|
||||
function calendar_group_stripe(&$entity) {
|
||||
$colors_group = isset($this->options['colors']['calendar_colors_group']) ? $this->options['colors']['calendar_colors_group'] : array();
|
||||
|
||||
if (empty($colors_group)) {
|
||||
return;
|
||||
}
|
||||
if (!function_exists('og_get_entity_groups')) {
|
||||
return;
|
||||
}
|
||||
$groups_for_entity = og_get_entity_groups($this->view->base_table, $entity);
|
||||
if (!(isset($entity->stripe))) {
|
||||
$entity->stripe = array();
|
||||
$entity->stripe_label = array();
|
||||
}
|
||||
if (count($groups_for_entity)) {
|
||||
foreach ($groups_for_entity as $gid => $group_name) {
|
||||
if (!array_key_exists($gid, $colors_group)) {
|
||||
continue;
|
||||
}
|
||||
$stripe = $colors_group[$gid];
|
||||
$stripe_label = $group_name;
|
||||
$entity->stripe[] = $stripe;
|
||||
$entity->stripe_label[] = $stripe_label;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$entity->stripe[] = '';
|
||||
$entity->stripe_label[] = '';
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
586
sites/all/modules/calendar/includes/calendar_plugin_row_node.inc
Normal file
586
sites/all/modules/calendar/includes/calendar_plugin_row_node.inc
Normal file
@@ -0,0 +1,586 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains the Calendar row style plugin.
|
||||
*
|
||||
* This plugin takes the view results, finds the date value for each,
|
||||
* then compares that date to the date range for the current view.
|
||||
* Items that started before or ended after the current date range
|
||||
* are shortened to the current range. Items that extend over more
|
||||
* than one day are cloned to create a calendar item for each day.
|
||||
* The resulting array of results (which may have a different number
|
||||
* of items than the original view result) are then passed back
|
||||
* to the style plugin so they can be displayed in a calendar.
|
||||
*
|
||||
* Row plugins are specific to entity types. To create a row plugin
|
||||
* for other types of entities, this class can be extended or copied,
|
||||
* adjusting the parts that are specific to nodes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin which creates a view on the resulting object
|
||||
* and formats it as a Calendar node.
|
||||
*/
|
||||
class calendar_plugin_row_node extends views_plugin_row {
|
||||
|
||||
// Basic properties that let the row style follow relationships.
|
||||
var $base_table = 'node';
|
||||
var $base_field = 'nid';
|
||||
|
||||
// Stores the nodes loaded with pre_render.
|
||||
var $nodes = array();
|
||||
|
||||
/**
|
||||
* Helper function to find the date argument handler for this view.
|
||||
*/
|
||||
function date_argument_handler() {
|
||||
foreach ($this->view->argument as $name => $handler) {
|
||||
if (date_views_handler_is_date($handler, 'argument')) {
|
||||
return $handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['date_fields'] = array('default' => array());
|
||||
$options['calendar_date_link'] = array('default' => '');
|
||||
$options['colors'] = array(
|
||||
'contains' => array(
|
||||
'legend' => array('default' => ''),
|
||||
'calendar_colors_type' => array('default' => array()),
|
||||
'taxonomy_field' => array('default' => ''),
|
||||
'calendar_colors_vocabulary' => array('default' => array()),
|
||||
'calendar_colors_taxonomy' => array('default' => array()),
|
||||
'calendar_colors_group' => array('default' => array()),
|
||||
));
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['markup']['#markup'] = t("The calendar row plugin will format view results as calendar items. Make sure this display has a 'Calendar' format and uses a 'Date' contextual filter, or this plugin will not work correctly.");
|
||||
$form['calendar_date_link'] = array(
|
||||
'#title' => t('Add new date link'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $this->options['calendar_date_link'],
|
||||
'#options' => array('' => t('No link')) + node_type_get_names(),
|
||||
'#description' => t('Display a link to add a new date of the specified content type. Displayed only to users with appropriate permissions.'),
|
||||
);
|
||||
$form['colors'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Legend Colors'),
|
||||
'#description' => t('Set a hex color value (like #ffffff) to use in the calendar legend for each content type. Items with empty values will have no stripe in the calendar and will not be added to the legend.'),
|
||||
);
|
||||
$form['colors']['legend'] = array(
|
||||
'#title' => t('Stripes'),
|
||||
'#description' => t('Add stripes to calendar items.'),
|
||||
'#type' => 'select',
|
||||
'#options' => array('' => t('None'), 'type' => t('Based on Content Type'), 'taxonomy' => t('Based on Taxonomy'), 'group' => t('Based on Organic Group')),
|
||||
'#default_value' => $this->options['colors']['legend'],
|
||||
);
|
||||
if (!module_exists('og')) {
|
||||
unset($form['colors']['legend']['#options']['group']);
|
||||
}
|
||||
$colors = $this->options['colors']['calendar_colors_type'];
|
||||
$type_names = node_type_get_names();
|
||||
foreach ($type_names as $key => $name) {
|
||||
$form['colors']['calendar_colors_type'][$key] = array(
|
||||
'#title' => check_plain($name),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($colors[$key]) ? $colors[$key] : '#ffffff',
|
||||
'#size' => 7,
|
||||
'#maxlength' => 7,
|
||||
'#element_validate' => array('calendar_validate_hex_color'),
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('type')),
|
||||
'#prefix' => '<div class="calendar-colorpicker-wrapper">',
|
||||
'#suffix' => '<div class="calendar-colorpicker"></div></div>',
|
||||
'#attributes' => array('class' => array('edit-calendar-colorpicker')),
|
||||
'#attached' => array(
|
||||
// Add Farbtastic color picker.
|
||||
'library' => array(
|
||||
array('system', 'farbtastic'),
|
||||
),
|
||||
// Add javascript to trigger the colorpicker.
|
||||
'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (module_exists('taxonomy')) {
|
||||
$vocab_field_options = array();
|
||||
$fields = $this->display->handler->get_option('fields');
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!empty($field['type']) && $field['type'] == 'taxonomy_term_reference_link') {
|
||||
$vocab_field_options[$field['field']] = $field['field'];
|
||||
}
|
||||
}
|
||||
$form['colors']['taxonomy_field'] = array(
|
||||
'#title' => t('Term field'),
|
||||
'#type' => !empty($vocab_field_options) ? 'select' : 'hidden',
|
||||
'#default_value' => $this->options['colors']['taxonomy_field'],
|
||||
'#description' => t("Select the taxonomy term field to use when setting stripe colors. This works best for vocabularies with only a limited number of possible terms."),
|
||||
'#options' => $vocab_field_options,
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
|
||||
);
|
||||
if (empty($vocab_field_options)) {
|
||||
$form['colors']['taxonomy_field']['#options'] = array('' => '');
|
||||
$form['colors']['taxonomy_field']['#suffix'] = t('You must add a term field to this view to use taxonomy stripe values. This works best for vocabularies with only a limited number of possible terms.');
|
||||
}
|
||||
$taxonomy_field = field_info_field($this->options['colors']['taxonomy_field']);
|
||||
$vocab_names[] = array();
|
||||
foreach ((array) $taxonomy_field['settings']['allowed_values'] as $delta => $options) {
|
||||
$vocab_names[] = $options['vocabulary'];
|
||||
}
|
||||
$taxonomies = taxonomy_get_vocabularies();
|
||||
foreach ($taxonomies as $vid => $vocab) {
|
||||
if (in_array($vocab->name, $vocab_names)) {
|
||||
$this->options['colors']['calendar_colors_vocabulary'][] = $vid;
|
||||
}
|
||||
}
|
||||
$form['colors']['calendar_colors_vocabulary'] = array(
|
||||
'#title' => t('Vocabulary Legend Types'),
|
||||
'#type' => 'value',
|
||||
'#value' => $this->options['colors']['calendar_colors_vocabulary'],
|
||||
);
|
||||
|
||||
$vocabularies = (array) $this->options['colors']['calendar_colors_vocabulary'];
|
||||
$term_colors = $this->options['colors']['calendar_colors_taxonomy'];
|
||||
foreach ($vocabularies as $vid) {
|
||||
$vocab = taxonomy_get_tree($vid);
|
||||
foreach ($vocab as $tid => $term) {
|
||||
$form['colors']['calendar_colors_taxonomy'][$term->tid] = array(
|
||||
'#title' => check_plain(t($term->name)),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($term_colors[$term->tid]) ? $term_colors[$term->tid] : '#ffffff',
|
||||
'#size' => 7,
|
||||
'#maxlength' => 7,
|
||||
'#access' => !empty($vocab_field_options),
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
|
||||
'#element_validate' => array('calendar_validate_hex_color'),
|
||||
'#prefix' => '<div class="calendar-colorpicker-wrapper">',
|
||||
'#suffix' => '<div class="calendar-colorpicker"></div></div>',
|
||||
'#attributes' => array('class' => array('edit-calendar-colorpicker')),
|
||||
'#attached' => array(
|
||||
// Add Farbtastic color picker.
|
||||
'library' => array(
|
||||
array('system', 'farbtastic'),
|
||||
),
|
||||
// Add javascript to trigger the colorpicker.
|
||||
'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (module_exists('og')) {
|
||||
$colors_group = $this->options['colors']['calendar_colors_group'];
|
||||
$groups = og_get_all_group();
|
||||
foreach ($groups as $gid) {
|
||||
$form['colors']['calendar_colors_group'][$gid] = array(
|
||||
'#title' => check_plain(t(og_label($gid))),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($colors_group[$gid]) ? $colors_group[$gid] : '#ffffff',
|
||||
'#dependency' => array('edit-row-options-colors-legend' => array('group')),
|
||||
'#element_validate' => array('calendar_validate_hex_color'),
|
||||
'#prefix' => '<div class="calendar-colorpicker-wrapper">',
|
||||
'#suffix' => '<div class="calendar-colorpicker"></div></div>',
|
||||
'#attributes' => array('class' => array('edit-calendar-colorpicker')),
|
||||
'#attached' => array(
|
||||
// Add Farbtastic color picker.
|
||||
'library' => array(
|
||||
array('system', 'farbtastic'),
|
||||
),
|
||||
// Add javascript to trigger the colorpicker.
|
||||
'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) {
|
||||
parent::options_submit($form, $form_state);
|
||||
$path = $this->view->display_handler->get_option('path');
|
||||
calendar_clear_link_path($path);
|
||||
if (!empty($form_state['values']['row_options']['calendar_date_link'])) {
|
||||
$node_type = $form_state['values']['row_options']['calendar_date_link'];
|
||||
calendar_set_link('node', $node_type, $path);
|
||||
}
|
||||
}
|
||||
|
||||
function pre_render($values) {
|
||||
// @TODO When the date is coming in through a relationship, the nid
|
||||
// of the view is not the right node to use, then we need the related node.
|
||||
// Need to sort out how that should be handled.
|
||||
|
||||
// Preload each node used in this view from the cache.
|
||||
// Provides all the node values relatively cheaply, and we don't
|
||||
// need to do it repeatedly for the same node if there are
|
||||
// multiple results for one node.
|
||||
$nids = array();
|
||||
foreach ($values as $row) {
|
||||
// Use the $nid as the key so we don't create more than one value per node.
|
||||
$nid = $row->{$this->field_alias};
|
||||
$nids[$nid] = $nid;
|
||||
}
|
||||
if (!empty($nids)) {
|
||||
$this->nodes = node_load_multiple($nids);
|
||||
}
|
||||
// Let the style know if a link to create a new date is required.
|
||||
$this->view->date_info->calendar_date_link = $this->options['calendar_date_link'];
|
||||
|
||||
// Identify the date argument and fields that apply to this view.
|
||||
// Preload the Date Views field info for each field, keyed by the
|
||||
// field name, so we know how to retrieve field values from the cached node.
|
||||
$data = date_views_fields('node');
|
||||
$data = $data['name'];
|
||||
$date_fields = array();
|
||||
foreach ($this->view->argument as $handler) {
|
||||
if (date_views_handler_is_date($handler, 'argument')) {
|
||||
// If this is the complex Date argument, the date fields are stored in the handler options,
|
||||
// otherwise we are using the simple date field argument handler.
|
||||
if ($handler->definition['handler'] != 'date_views_argument_handler') {
|
||||
$alias = $handler->table_alias . '.' . $handler->field;
|
||||
$info = $data[$alias];
|
||||
$field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
|
||||
$date_fields[$field_name] = $info;
|
||||
}
|
||||
else {
|
||||
foreach ($handler->options['date_fields'] as $alias) {
|
||||
$info = $data[$alias];
|
||||
$field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
|
||||
$date_fields[$field_name] = $info;
|
||||
}
|
||||
}
|
||||
$this->date_argument = $handler;
|
||||
$this->date_fields = $date_fields;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the language for this view.
|
||||
$this->language = $this->display->handler->get_option('field_language');
|
||||
$substitutions = views_views_query_substitutions($this->view);
|
||||
if (array_key_exists($this->language, $substitutions)) {
|
||||
$this->language = $substitutions[$this->language];
|
||||
}
|
||||
}
|
||||
|
||||
function render($row) {
|
||||
global $base_url;
|
||||
$rows = array();
|
||||
$date_info = $this->date_argument->view->date_info;
|
||||
$nid = $row->{$this->field_alias};
|
||||
if (!is_numeric($nid)) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
// There could be more than one date field in a view
|
||||
// so iterate through all of them to find the right values
|
||||
// for this view result.
|
||||
foreach ($this->date_fields as $field_name => $info) {
|
||||
|
||||
// Load the specified node:
|
||||
// We have to clone this or nodes on other views on this page,
|
||||
// like an Upcoming block on the same page as a calendar view,
|
||||
// will end up acquiring the values we set here.
|
||||
$node = clone($this->nodes[$nid]);
|
||||
if (empty($node)) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$table_name = $info['table_name'];
|
||||
$delta_field = $info['delta_field'];
|
||||
$tz_handling = $info['tz_handling'];
|
||||
$tz_field = $info['timezone_field'];
|
||||
$rrule_field = $info['rrule_field'];
|
||||
$is_field = $info['is_field'];
|
||||
|
||||
// Retrieve the field value that matched our query from the cached node.
|
||||
// Find the date and set it to the right timezone.
|
||||
|
||||
$node->date_id = array();
|
||||
$item_start_date = NULL;
|
||||
$item_end_date = NULL;
|
||||
$granularity = 'second';
|
||||
$increment = 1;
|
||||
|
||||
if ($is_field) {
|
||||
|
||||
$delta = isset($row->$delta_field) ? $row->$delta_field : 0;
|
||||
$items = field_get_items('node', $node, $field_name, $this->language);
|
||||
$item = $items[$delta];
|
||||
$db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
$to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
|
||||
// Set the date_id for the node, used to identify which field value to display for
|
||||
// fields that have multiple values. The theme expects it to be an array.
|
||||
$node->date_id = array('calendar.' . $node->nid . '.' . $field_name . '.' . $delta);
|
||||
|
||||
if (!empty($item['value'])) {
|
||||
$item_start_date = new dateObject($item['value'], $db_tz);
|
||||
$item_end_date = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
|
||||
}
|
||||
|
||||
$cck_field = field_info_field($field_name);
|
||||
$instance = field_info_instance($this->view->base_table, $field_name, $node->type);
|
||||
$granularity = date_granularity_precision($cck_field['settings']['granularity']);
|
||||
$increment = $instance['widget']['settings']['increment'];
|
||||
|
||||
}
|
||||
elseif (!empty($node->$field_name)) {
|
||||
$item = $node->$field_name;
|
||||
$db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
$to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
|
||||
$item_start_date = new dateObject($item, $db_tz);
|
||||
$item_end_date = $item_start_date;
|
||||
$node->date_id = array('calendar.' . $node->nid . '.' . $field_name . '.0');
|
||||
}
|
||||
|
||||
// If we don't have date value, go no further.
|
||||
if (empty($item_start_date)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the item date to the proper display timezone;
|
||||
$item_start_date->setTimezone(new dateTimezone($to_zone));
|
||||
$item_end_date->setTimezone(new dateTimezone($to_zone));
|
||||
|
||||
$event = new stdClass();
|
||||
$event->nid = $node->nid;
|
||||
$event->title = $node->title;
|
||||
$event->type = $node->type;
|
||||
$event->date_start = $item_start_date;
|
||||
$event->date_end = $item_end_date;
|
||||
$event->db_tz = $db_tz;
|
||||
$event->to_zone = $to_zone;
|
||||
$event->granularity = $granularity;
|
||||
$event->increment = $increment;
|
||||
$event->field = $is_field ? $item : NULL;
|
||||
$event->row = $row;
|
||||
$event->node = $node;
|
||||
|
||||
// All calendar row plugins should provide a date_id that the theme can use.
|
||||
$event->date_id = $node->date_id[0];
|
||||
|
||||
$nodes = $this->explode_values($event);
|
||||
foreach ($nodes as $node) {
|
||||
switch ($this->options['colors']['legend']) {
|
||||
case 'type':
|
||||
$this->calendar_node_type_stripe($node);
|
||||
break;
|
||||
case 'taxonomy':
|
||||
$this->calendar_node_taxonomy_stripe($node);
|
||||
break;
|
||||
case 'group':
|
||||
$this->calendar_node_group_stripe($node);
|
||||
break;
|
||||
}
|
||||
$rows[] = $node;
|
||||
}
|
||||
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function explode_values($event) {
|
||||
$rows = array();
|
||||
|
||||
$date_info = $this->date_argument->view->date_info;
|
||||
$item_start_date = $event->date_start;
|
||||
$item_end_date = $event->date_end;
|
||||
$to_zone = $event->to_zone;
|
||||
$db_tz = $event->db_tz;
|
||||
$granularity = $event->granularity;
|
||||
$increment = $event->increment;
|
||||
|
||||
// Now that we have a 'node' for each view result, we need
|
||||
// to remove anything outside the view date range,
|
||||
// and possibly create additional nodes so that we have a 'node'
|
||||
// for each day that this item occupies in this view.
|
||||
$now = max($date_info->min_zone_string, $item_start_date->format(DATE_FORMAT_DATE));
|
||||
$to = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
|
||||
$next = new DateObject($now . ' 00:00:00', $date_info->display_timezone);
|
||||
if ($date_info->display_timezone_name != $to_zone) {
|
||||
// Make $start and $end (derived from $node) use the timezone $to_zone, just as the original dates do.
|
||||
date_timezone_set($next, timezone_open($to_zone));
|
||||
}
|
||||
if (empty($to) || $now > $to) {
|
||||
$to = $now;
|
||||
}
|
||||
// $now and $next are midnight (in display timezone) on the first day where node will occur.
|
||||
// $to is midnight on the last day where node will occur.
|
||||
// All three were limited by the min-max date range of the view.
|
||||
$pos = 0;
|
||||
while (!empty($now) && $now <= $to) {
|
||||
$node = clone($event);
|
||||
$node->url = url('node/' . $node->nid, array('absolute' => TRUE));
|
||||
|
||||
// Get start and end of current day.
|
||||
$start = $next->format(DATE_FORMAT_DATETIME);
|
||||
date_modify($next, '+1 day');
|
||||
date_modify($next, '-1 second');
|
||||
$end = $next->format(DATE_FORMAT_DATETIME);
|
||||
|
||||
// Get start and end of item, formatted the same way.
|
||||
$item_start = $item_start_date->format(DATE_FORMAT_DATETIME);
|
||||
$item_end = $item_end_date->format(DATE_FORMAT_DATETIME);
|
||||
|
||||
// Get intersection of current day and the node value's duration (as strings in $to_zone timezone).
|
||||
$node->calendar_start = $item_start < $start ? $start : $item_start;
|
||||
$node->calendar_end = !empty($item_end) ? ($item_end > $end ? $end : $item_end) : $node->calendar_start;
|
||||
|
||||
// Make date objects
|
||||
$node->calendar_start_date = date_create($node->calendar_start, timezone_open($to_zone));
|
||||
$node->calendar_end_date = date_create($node->calendar_end, timezone_open($to_zone));
|
||||
|
||||
// Change string timezones into
|
||||
// calendar_start and calendar_end are UTC dates as formatted strings
|
||||
$node->calendar_start = date_format($node->calendar_start_date, DATE_FORMAT_DATETIME);
|
||||
$node->calendar_end = date_format($node->calendar_end_date, DATE_FORMAT_DATETIME);
|
||||
$node->calendar_all_day = date_is_all_day($node->calendar_start, $node->calendar_end, $granularity, $increment);
|
||||
|
||||
unset($node->calendar_fields);
|
||||
if (isset($node) && (empty($node->calendar_start))) {
|
||||
// if no date for the node and no date in the item
|
||||
// there is no way to display it on the calendar
|
||||
unset($node);
|
||||
}
|
||||
else {
|
||||
$node->date_id .= '.' . $pos;
|
||||
|
||||
$rows[] = $node;
|
||||
unset($node);
|
||||
}
|
||||
date_modify($next, '+1 second');
|
||||
$now = date_format($next, DATE_FORMAT_DATE);
|
||||
$pos++;
|
||||
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stripe base on node type.
|
||||
*/
|
||||
function calendar_node_type_stripe(&$node) {
|
||||
$colors = isset($this->options['colors']['calendar_colors_type']) ? $this->options['colors']['calendar_colors_type'] : array();
|
||||
if (empty($colors)) {
|
||||
return;
|
||||
}
|
||||
if (empty($node->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$type_names = node_type_get_names();
|
||||
$type = $node->type;
|
||||
if (!(isset($node->stripe))) {
|
||||
$node->stripe = array();
|
||||
$node->stripe_label = array();
|
||||
}
|
||||
if (array_key_exists($type, $type_names)) {
|
||||
$label = $type_names[$type];
|
||||
}
|
||||
if (array_key_exists($type, $colors)) {
|
||||
$stripe = $colors[$type];
|
||||
}
|
||||
else {
|
||||
$stripe = '';
|
||||
}
|
||||
|
||||
$node->stripe[] = $stripe;
|
||||
$node->stripe_label[] = $label;
|
||||
return $stripe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stripe based on a taxonomy term.
|
||||
*/
|
||||
|
||||
function calendar_node_taxonomy_stripe(&$event) {
|
||||
$term_colors = isset($this->options['colors']['calendar_colors_taxonomy']) ? $this->options['colors']['calendar_colors_taxonomy'] : array();
|
||||
if (empty($term_colors)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$node = $event->node;
|
||||
$terms = array();
|
||||
if ($this->options['colors']['legend'] == 'taxonomy') {
|
||||
$term_field_name = $this->options['colors']['taxonomy_field'];
|
||||
if ($term_field = field_get_items('node', $node, $term_field_name)) {
|
||||
foreach ($term_field as $delta => $items) {
|
||||
foreach ($items as $item) {
|
||||
$terms[] = $item['tid'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($terms)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(isset($event->stripe))) {
|
||||
$event->stripe = array();
|
||||
$event->stripe_label = array();
|
||||
}
|
||||
if (count($terms)) {
|
||||
foreach ($terms as $tid) {
|
||||
$term_for_node = taxonomy_term_load($tid);
|
||||
if (!array_key_exists($term_for_node->tid, $term_colors)) {
|
||||
continue;
|
||||
}
|
||||
$stripe = $term_colors[$term_for_node->tid];
|
||||
$stripe_label = $term_for_node->name;
|
||||
$event->stripe[] = $stripe;
|
||||
$event->stripe_label[] = $stripe_label;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$event->stripe[] = '';
|
||||
$event->stripe_label[] = '';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stripe based on group.
|
||||
*/
|
||||
function calendar_node_group_stripe(&$node) {
|
||||
$colors_group = isset($this->options['colors']['calendar_colors_group']) ? $this->options['colors']['calendar_colors_group'] : array();
|
||||
|
||||
if (empty($colors_group)) {
|
||||
return;
|
||||
}
|
||||
if (!function_exists('og_get_entity_groups')) {
|
||||
return;
|
||||
}
|
||||
$groups_for_node = og_get_entity_groups('node', $node);
|
||||
if (!(isset($node->stripe))) {
|
||||
$node->stripe = array();
|
||||
$node->stripe_label = array();
|
||||
}
|
||||
if (count($groups_for_node)) {
|
||||
foreach ($groups_for_node as $gid => $group_name) {
|
||||
if (!array_key_exists($gid, $colors_group)) {
|
||||
continue;
|
||||
}
|
||||
$stripe = $colors_group[$gid];
|
||||
$stripe_label = $group_name;
|
||||
$node->stripe[] = $stripe;
|
||||
$node->stripe_label[] = $stripe_label;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$node->stripe[] = '';
|
||||
$node->stripe_label[] = '';
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
948
sites/all/modules/calendar/includes/calendar_plugin_style.inc
Normal file
948
sites/all/modules/calendar/includes/calendar_plugin_style.inc
Normal file
@@ -0,0 +1,948 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views style plugin for the Calendar module.
|
||||
*
|
||||
* The style plugin is responsible for setting global values needed by
|
||||
* the row plugin. It then gathers up an array of view results (as restructured
|
||||
* by the row plugin) and organizes them into year/month/day/time
|
||||
* arrays that the theme can use to display the results in a calendar.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default style plugin to render an iCal feed.
|
||||
*/
|
||||
class calendar_plugin_style extends views_plugin_style {
|
||||
|
||||
var $date_info;
|
||||
var $items;
|
||||
var $curday;
|
||||
|
||||
function init(&$view, &$display, $options = NULL) {
|
||||
parent::init($view, $display, $options);
|
||||
if (empty($view->date_info)) {
|
||||
$this->date_info = new stdClass();
|
||||
}
|
||||
$this->date_info = &$this->view->date_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom option definitions.
|
||||
*/
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['calendar_type'] = array('default' => 'month');
|
||||
$options['name_size'] = array('default' => 3);
|
||||
$options['mini'] = array('default' => 0);
|
||||
$options['with_weekno'] = array('default' => 0);
|
||||
$options['multiday_theme'] = array('default' => 1);
|
||||
$options['theme_style'] = array('default' => 1);
|
||||
$options['max_items'] = array('default' => 0);
|
||||
$options['max_items_behavior'] = array('default' => 'more');
|
||||
$options['groupby_times'] = array('default' => 'hour');
|
||||
$options['groupby_times_custom'] = array('default' => '');
|
||||
$options['groupby_field'] = array('default' => '');
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['calendar_type'] = array(
|
||||
'#title' => t('Calendar type'),
|
||||
'#type' => 'select',
|
||||
'#description' => t('Select the calendar time period for this display.'),
|
||||
'#default_value' => $this->options['calendar_type'],
|
||||
'#options' => calendar_display_types(),
|
||||
);
|
||||
$form['mini'] = array(
|
||||
'#title' => t('Display as mini calendar'),
|
||||
'#default_value' => $this->options['mini'],
|
||||
'#type' => 'radios',
|
||||
'#options' => array(0 => t('No'), 1 => t('Yes')),
|
||||
'#description' => t('Display the mini style calendar, with no item details. Suitable for a calendar displayed in a block.'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('month')),
|
||||
);
|
||||
$form['name_size'] = array(
|
||||
'#title' => t('Calendar day of week names'),
|
||||
'#default_value' => $this->options['name_size'],
|
||||
'#type' => 'radios',
|
||||
'#options' => array(1 => t('First letter of name'), 2 => t('First two letters of name'), 3 => t('Abbreviated name'), 99 => t('Full name')),
|
||||
'#description' => t('The way day of week names should be displayed in a calendar.'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('month', 'week', 'year')),
|
||||
);
|
||||
$form['with_weekno'] = array(
|
||||
'#title' => t('Show week numbers'),
|
||||
'#default_value' => $this->options['with_weekno'],
|
||||
'#type' => 'radios',
|
||||
'#options' => array(0 => t('No'), 1 => t('Yes')),
|
||||
'#description' => t('Whether or not to show week numbers in the left column of calendar weeks and months.'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('month')),
|
||||
);
|
||||
$form['max_items'] = array(
|
||||
'#title' => t('Maximum items'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(0 => t('Unlimited'), 1 => t('1 item'), 3 => t('3 items'), 5 => t('5 items'), 10 => t('10 items')),
|
||||
'#default_value' => $this->options['calendar_type'] != 'day' ? $this->options['max_items'] : 0,
|
||||
'#description' => t('Maximum number of items to show in calendar cells, used to keep the calendar from expanding to a huge size when there are lots of items in one day.'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('month')),
|
||||
);
|
||||
$form['max_items_behavior'] = array(
|
||||
'#title' => t('Too many items'),
|
||||
'#type' => 'select',
|
||||
'#options' => array('more' => t("Show maximum, add 'more' link"), 'hide' => t('Hide all, add link to day')),
|
||||
'#default_value' => $this->options['calendar_type'] != 'day' ? $this->options['max_items_behavior'] : 'more',
|
||||
'#description' => t('Behavior when there are more than the above number of items in a single day. When there more items than this limit, a link to the day view will be displayed.'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('month')),
|
||||
);
|
||||
$form['groupby_times'] = array(
|
||||
'#title' => t('Time grouping'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $this->options['groupby_times'],
|
||||
'#description' => t("Group items together into time periods based on their start time."),
|
||||
'#options' => array('' => t('None'), 'hour' => t('Hour'), 'half' => t('Half hour'), 'custom' => t('Custom')),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('day', 'week')),
|
||||
);
|
||||
$form['groupby_times_custom'] = array(
|
||||
'#title' => t('Custom time grouping'),
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => $this->options['groupby_times_custom'],
|
||||
'#description' => t("When choosing the 'custom' Time grouping option above, create custom time period groupings as a comma-separated list of 24-hour times in the format HH:MM:SS, like '00:00:00,08:00:00,18:00:00'. Be sure to start with '00:00:00'. All items after the last time will go in the final group."),
|
||||
'#dependency' => array('edit-style-options-groupby-times' => array('custom')),
|
||||
);
|
||||
$form['theme_style'] = array(
|
||||
'#title' => t('Overlapping time style'),
|
||||
'#default_value' => $this->options['theme_style'],
|
||||
'#type' => 'select',
|
||||
'#options' => array(0 => t('Do not display overlapping items'), 1 => t('Display overlapping items, with scrolling'), 2 => t('Display overlapping items, no scrolling')),
|
||||
'#description' => t('Select whether calendar items are displayed as overlapping items. Use scrolling to shrink the window and focus on the selected items, or omit scrolling to display the whole day. This only works if hour or half hour time grouping is chosen!'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('day', 'week')),
|
||||
);
|
||||
|
||||
// Create a list of fields that are available for grouping,
|
||||
$field_options = array();
|
||||
$i = 1;
|
||||
$fields = $this->display->handler->get_option('fields');
|
||||
foreach ($fields as $field_name => $field) {
|
||||
$field_options[$i] = $field['field'];
|
||||
$i++;
|
||||
}
|
||||
$form['groupby_field'] = array(
|
||||
'#title' => t('Field grouping'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $this->options['groupby_field'],
|
||||
'#description' => t("Optionally group items into columns by a field value, for instance select the content type to show items for each content type in their own column, or use a location field to organize items into columns by location. NOTE! This is incompatible with the overlapping style option."),
|
||||
'#options' => array('' => '') + $field_options,
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('day')),
|
||||
);
|
||||
$form['multiday_theme'] = array(
|
||||
'#title' => t('Multi-day style'),
|
||||
'#default_value' => $this->options['multiday_theme'],
|
||||
'#type' => 'select',
|
||||
'#options' => array(0 => t('Display multi-day item as a single column'), 1 => t('Display multi-day item as a multiple column row')),
|
||||
'#description' => t('If selected, items which span multiple days will displayed as a multi-column row. If not selected, items will be displayed as an individual column.'),
|
||||
'#dependency' => array('edit-style-options-calendar-type' => array('month', 'week')),
|
||||
);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
$values = $form_state['values']['style_options'];
|
||||
if ($values['groupby_times'] == 'custom' && empty($values['groupby_times_custom'])) {
|
||||
form_set_error('style_options][groupby_times_custom', t('Custom groupby times cannot be empty.'));
|
||||
}
|
||||
if (!empty($values['theme_style']) && (empty($values['groupby_times']) || !in_array($values['groupby_times'], array('hour', 'half')))) {
|
||||
form_set_error('style_options][theme_style', t('Overlapping items only work with hour or half hour groupby times.'));
|
||||
}
|
||||
if (!empty($values['theme_style']) && !empty($values['groupby_field'])) {
|
||||
form_set_error('style_options][theme_style', t('You cannot use overlapping items and also try to group by a field value.'));
|
||||
}
|
||||
if ($values['groupby_times'] != 'custom') {
|
||||
form_set_value($form['groupby_times_custom'], NULL, $form_state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to find the date argument handler for this view.
|
||||
*/
|
||||
function date_argument_handler() {
|
||||
$i = 0;
|
||||
foreach ($this->view->argument as $name => $handler) {
|
||||
if (date_views_handler_is_date($handler, 'argument')) {
|
||||
$this->date_info->date_arg_pos = $i;
|
||||
return $handler;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspect argument and view information to see which calendar
|
||||
* period we should show. The argument tells us what to use
|
||||
* if there is no value, the view args tell us what to use
|
||||
* if there are values.
|
||||
*/
|
||||
function granularity() {
|
||||
|
||||
if (!$handler = $this->date_argument_handler()) {
|
||||
return 'month';
|
||||
}
|
||||
$default_granularity = !empty($handler) && !empty($handler->granularity) ? $handler->granularity : 'month';
|
||||
$wildcard = !empty($handler) ? $handler->options['exception']['value'] : '';
|
||||
$argument = $handler->argument;
|
||||
|
||||
// TODO Anything else we need to do for 'all' arguments?
|
||||
if ($argument == $wildcard) {
|
||||
$this->view_granularity = $default_granularity;
|
||||
}
|
||||
elseif (!empty($argument)) {
|
||||
module_load_include('inc', 'date_api', 'date_api_sql');
|
||||
|
||||
$date_handler = new date_sql_handler();
|
||||
$this->view_granularity = $date_handler->arg_granularity($argument);
|
||||
}
|
||||
else {
|
||||
$this->view_granularity = $default_granularity;
|
||||
}
|
||||
return $this->view_granularity;
|
||||
}
|
||||
|
||||
function has_calendar_row_plugin() {
|
||||
return $this->row_plugin instanceof calendar_plugin_row || $this->row_plugin instanceof calendar_plugin_row_node;
|
||||
}
|
||||
|
||||
function render() {
|
||||
if (empty($this->row_plugin) || !$this->has_calendar_row_plugin()) {
|
||||
debug('calendar_plugin_style: The calendar row plugin is required when using the calendar style, but it is missing.');
|
||||
return;
|
||||
}
|
||||
if (!$argument = $this->date_argument_handler()) {
|
||||
debug('calendar_plugin_style: A date argument is required when using the calendar style, but it is missing or is not using the default date.');
|
||||
return;
|
||||
}
|
||||
|
||||
// There are date arguments that have not been added by Date Views.
|
||||
// They will be missing the information we would need to render the field.
|
||||
if (empty($argument->min_date)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add information from the date argument to the view.
|
||||
$this->date_info->granularity = $this->granularity();
|
||||
$this->date_info->calendar_type = $this->options['calendar_type'];
|
||||
$this->date_info->date_arg = $argument->argument;
|
||||
$this->date_info->year = date_format($argument->min_date, 'Y');
|
||||
$this->date_info->month = date_format($argument->min_date, 'n');;
|
||||
$this->date_info->day = date_format($argument->min_date, 'j');
|
||||
$this->date_info->week = date_week(date_format($argument->min_date, DATE_FORMAT_DATE));
|
||||
$this->date_info->date_range = $argument->date_range;
|
||||
$this->date_info->min_date = $argument->min_date;
|
||||
$this->date_info->max_date = $argument->max_date;
|
||||
$this->date_info->limit = $argument->limit;
|
||||
$this->date_info->url = $this->view->get_url();
|
||||
$this->date_info->min_date_date = date_format($this->date_info->min_date, DATE_FORMAT_DATE);
|
||||
$this->date_info->max_date_date = date_format($this->date_info->max_date, DATE_FORMAT_DATE);
|
||||
$this->date_info->forbid = isset($argument->forbid) ? $argument->forbid : FALSE;
|
||||
|
||||
// Add calendar style information to the view.
|
||||
$this->date_info->calendar_popup = $this->display->handler->get_option('calendar_popup');
|
||||
$this->date_info->style_name_size = $this->options['name_size'];
|
||||
$this->date_info->mini = $this->options['mini'];
|
||||
$this->date_info->style_with_weekno = $this->options['with_weekno'];
|
||||
$this->date_info->style_multiday_theme = $this->options['multiday_theme'];
|
||||
$this->date_info->style_theme_style = $this->options['theme_style'];
|
||||
$this->date_info->style_max_items = $this->options['max_items'];
|
||||
$this->date_info->style_max_items_behavior = $this->options['max_items_behavior'];
|
||||
if (!empty($this->options['groupby_times_custom'])) {
|
||||
$this->date_info->style_groupby_times = explode(',', $this->options['groupby_times_custom']);
|
||||
}
|
||||
else {
|
||||
$this->date_info->style_groupby_times = calendar_groupby_times($this->options['groupby_times']);
|
||||
}
|
||||
$this->date_info->style_groupby_field = $this->options['groupby_field'];
|
||||
|
||||
// TODO make this an option setting.
|
||||
$this->date_info->style_show_empty_times = !empty($this->options['groupby_times_custom']) ? TRUE : FALSE;
|
||||
|
||||
// Set up parameters for the current view that can be used by the row plugin.
|
||||
$display_timezone = date_timezone_get($this->date_info->min_date);
|
||||
$this->date_info->display_timezone = $display_timezone;
|
||||
$this->date_info->display_timezone_name = timezone_name_get($display_timezone);
|
||||
$date = clone($this->date_info->min_date);
|
||||
date_timezone_set($date, $display_timezone);
|
||||
$this->date_info->min_zone_string = date_format($date, DATE_FORMAT_DATE);
|
||||
$date = clone($this->date_info->max_date);
|
||||
date_timezone_set($date, $display_timezone);
|
||||
$this->date_info->max_zone_string = date_format($date, DATE_FORMAT_DATE);
|
||||
|
||||
// Identify the fields that need to be displayed on each item.
|
||||
$keys = array();
|
||||
foreach ($this->view->field as $key => $handler) {
|
||||
if (empty($handler->options['exclude'])) {
|
||||
$keys[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke the row plugin to massage each result row into calendar items.
|
||||
// Gather the row items into an array grouped by date and time.
|
||||
$items = array();
|
||||
foreach ($this->view->result as $row_index => $row) {
|
||||
$this->view->row_index = $row_index;
|
||||
foreach ($this->row_plugin->render($row) as $item) {
|
||||
$item->granularity = $this->date_info->granularity;
|
||||
$rendered_fields = array();
|
||||
$item_start = date_format($item->calendar_start_date, DATE_FORMAT_DATE);
|
||||
$item_end = date_format($item->calendar_end_date, DATE_FORMAT_DATE);
|
||||
$time_start = date_format($item->calendar_start_date, 'H:i:s');
|
||||
foreach ($keys as $field) {
|
||||
$rendered_fields[] = $this->get_field($row_index, $field);
|
||||
}
|
||||
$item->rendered_fields = $rendered_fields;
|
||||
$items[$item_start][$time_start][] = $item;
|
||||
$this->view->row_index++;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($items);
|
||||
|
||||
$rows = array();
|
||||
$this->curday = clone($this->date_info->min_date);
|
||||
$this->items = $items;
|
||||
|
||||
// Retrieve the results array using a the right method for the granularity of the display.
|
||||
switch ($this->options['calendar_type']) {
|
||||
case 'year':
|
||||
$rows = array();
|
||||
$this->view->date_info->mini = TRUE;
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$rows[$i] = $this->calendar_build_mini_month();
|
||||
}
|
||||
$this->view->date_info->mini = FALSE;
|
||||
break;
|
||||
case 'month':
|
||||
$rows = !empty($this->date_info->mini) ? $this->calendar_build_mini_month() : $this->calendar_build_month();
|
||||
break;
|
||||
case 'day':
|
||||
$rows = $this->calendar_build_day();
|
||||
break;
|
||||
case 'week':
|
||||
$rows = $this->calendar_build_week();
|
||||
// Merge the day names in as the first row.
|
||||
$rows = array_merge(array(calendar_week_header($this->view)), $rows);
|
||||
break;
|
||||
}
|
||||
|
||||
// Send the sorted rows to the right theme for this type of calendar.
|
||||
$this->definition['theme'] = 'calendar_' . $this->options['calendar_type'];
|
||||
|
||||
// Adjust the theme to match the currently selected default.
|
||||
// Only the month view needs the special 'mini' class,
|
||||
// which is used to retrieve a different, more compact, theme.
|
||||
if ($this->options['calendar_type'] == 'month' && !empty($this->view->date_info->mini)) {
|
||||
$this->definition['theme'] = 'calendar_mini';
|
||||
}
|
||||
// If the overlap option was selected, choose the overlap version of the theme.
|
||||
elseif (in_array($this->options['calendar_type'], array('week', 'day')) && !empty($this->options['multiday_theme']) && !empty($this->options['theme_style'])) {
|
||||
$this->definition['theme'] .= '_overlap';
|
||||
}
|
||||
|
||||
$output = theme($this->theme_functions(),
|
||||
array(
|
||||
'view' => $this->view,
|
||||
'options' => $this->options,
|
||||
'rows' => $rows
|
||||
));
|
||||
unset($this->view->row_index);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build one month.
|
||||
*/
|
||||
function calendar_build_month() {
|
||||
$month = date_format($this->curday, 'n');
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$weekdays = calendar_untranslated_days($this->items, $this->view);
|
||||
date_modify($this->curday, '-' . strval(date_format($this->curday, 'j')-1) . ' days');
|
||||
$rows = array();
|
||||
do {
|
||||
$init_day = clone($this->curday);
|
||||
$today = date_format(date_now(date_default_timezone()), DATE_FORMAT_DATE);
|
||||
$month = date_format($this->curday, 'n');
|
||||
$week = date_week($curday_date);
|
||||
$first_day = variable_get('date_first_day', 0);
|
||||
$week_rows = $this->calendar_build_week(TRUE);
|
||||
$multiday_buckets = $week_rows['multiday_buckets'];
|
||||
$singleday_buckets = $week_rows['singleday_buckets'];
|
||||
$total_rows = $week_rows['total_rows'];
|
||||
|
||||
// Theme each row
|
||||
$output = "";
|
||||
$final_day = clone($this->curday);
|
||||
|
||||
$iehint = 0;
|
||||
$max_multirow_cnt = 0;
|
||||
$max_singlerow_cnt = 0;
|
||||
|
||||
for ($i = 0; $i < intval($total_rows + 1); $i++) {
|
||||
$inner = "";
|
||||
|
||||
// If we're displaying the week number, add it as the
|
||||
// first cell in the week.
|
||||
if ($i == 0 && !empty($this->date_info->style_with_weekno) && !in_array($this->date_info->granularity, array('day', 'week'))) {
|
||||
$url = $this->view->get_path() . '/' . $this->date_info->year . '-W' . $week;
|
||||
if (!empty($this->date_info->display_types['week'])) {
|
||||
$weekno = l($week, $url, array('query' => !empty($this->date_info->append) ? $this->date_info->append : ''));
|
||||
}
|
||||
else {
|
||||
// Do not link week numbers, if Week views are disabled.
|
||||
$weekno = $week;
|
||||
}
|
||||
$item = array(
|
||||
'entry' => $weekno,
|
||||
'colspan' => 1,
|
||||
'rowspan' => $total_rows + 1,
|
||||
'id' => $this->view->name . '-weekno-' . $curday_date,
|
||||
'class' => 'week'
|
||||
);
|
||||
$inner .= theme('calendar_month_col', array('item' => $item));
|
||||
}
|
||||
|
||||
$this->curday = clone($init_day);
|
||||
|
||||
// move backwards to the first day of the week
|
||||
$day_wday = date_format($this->curday, 'w');
|
||||
date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
|
||||
|
||||
for ( $wday = 0; $wday < 7; $wday++) {
|
||||
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$class = strtolower($weekdays[$wday]);
|
||||
$item = NULL;
|
||||
$in_month = !($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month);
|
||||
|
||||
// Add the datebox
|
||||
if ($i == 0) {
|
||||
$variables = array(
|
||||
'date' => $curday_date,
|
||||
'view' => $this->view,
|
||||
'items' => $this->items,
|
||||
'selected' => $in_month ? count($multiday_buckets[$wday]) + count($singleday_buckets[$wday]) : FALSE,
|
||||
);
|
||||
$item = array(
|
||||
'entry' => theme('calendar_datebox', $variables),
|
||||
'colspan' => 1,
|
||||
'rowspan' => 1,
|
||||
'class' => 'date-box',
|
||||
'date' => $curday_date,
|
||||
'id' => $this->view->name . '-' . $curday_date . '-date-box'
|
||||
);
|
||||
$item['class'] .= ($curday_date == $today && $in_month ? ' today' : '') .
|
||||
($curday_date < $today ? ' past' : '') .
|
||||
($curday_date > $today ? ' future' : '');
|
||||
}
|
||||
else {
|
||||
$index = $i - 1;
|
||||
$multi_count = count($multiday_buckets[$wday]);
|
||||
|
||||
// Process multiday buckets first. If there is a multiday-bucket item in this row...
|
||||
if ($index < $multi_count) {
|
||||
// If this item is filled with either a blank or an entry...
|
||||
if ($multiday_buckets[$wday][$index]['filled']) {
|
||||
|
||||
// Add item and add class
|
||||
$item = $multiday_buckets[$wday][$index];
|
||||
$item['class'] = 'multi-day';
|
||||
$item['date'] = $curday_date;
|
||||
|
||||
// Is this an entry?
|
||||
if (!$multiday_buckets[$wday][$index]['avail']) {
|
||||
|
||||
// If the item either starts or ends on today,
|
||||
// then add tags so we can style the borders
|
||||
if ($curday_date == $today && $in_month) {
|
||||
$item['class'] .= ' starts-today';
|
||||
}
|
||||
|
||||
// Calculate on which day of this week this item ends on..
|
||||
$end_day = clone($this->curday);
|
||||
$span = $item['colspan'] - 1;
|
||||
date_modify($end_day, '+' . $span . ' day');
|
||||
$endday_date = date_format($end_day, DATE_FORMAT_DATE);
|
||||
|
||||
// If it ends today, add class
|
||||
if ($endday_date == $today && $in_month) {
|
||||
$item['class'] .= ' ends-today';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is an actual entry, add classes regarding the state of the
|
||||
// item
|
||||
if ($multiday_buckets[$wday][$index]['avail']) {
|
||||
$item['class'] .= ' ' . $wday . ' ' . $index . ' no-entry ' . ($curday_date == $today && $in_month ? ' today' : '') .
|
||||
($curday_date < $today ? ' past' : '') .
|
||||
($curday_date > $today ? ' future' : '');
|
||||
}
|
||||
|
||||
// Else, process the single day bucket - we only do this once per day
|
||||
}
|
||||
elseif ($index == $multi_count) {
|
||||
$single_day_cnt = 0;
|
||||
// If it's empty, add class
|
||||
if (count($singleday_buckets[$wday]) == 0) {
|
||||
$single_days = " ";
|
||||
if ($max_multirow_cnt == 0 ) {
|
||||
$class = ($multi_count > 0 ) ? 'single-day no-entry noentry-multi-day' : 'single-day no-entry';
|
||||
}
|
||||
else {
|
||||
$class = 'single-day';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$single_days = "";
|
||||
foreach ($singleday_buckets[$wday] as $day) {
|
||||
foreach ($day as $event) {
|
||||
$single_day_cnt++;
|
||||
$single_days .= (isset($event['more_link'])) ? '<div class="calendar-more">' . $event['entry'] . '</div>' : $event['entry'];
|
||||
}
|
||||
}
|
||||
$class = 'single-day';
|
||||
}
|
||||
|
||||
$rowspan = $total_rows - $index;
|
||||
// Add item...
|
||||
$item = array(
|
||||
'entry' => $single_days,
|
||||
'colspan' => 1,
|
||||
'rowspan' => $rowspan,
|
||||
'class' => $class,
|
||||
'date' => $curday_date,
|
||||
'id' => $this->view->name . '-' . $curday_date . '-' . $index
|
||||
);
|
||||
|
||||
// Hack for ie to help it properly space single day rows
|
||||
if ($rowspan > 1 && $in_month && $single_day_cnt > 0) {
|
||||
$max_multirow_cnt = max($max_multirow_cnt, $single_day_cnt);
|
||||
}
|
||||
else {
|
||||
$max_singlerow_cnt = max($max_singlerow_cnt, $single_day_cnt);
|
||||
}
|
||||
|
||||
// If the singlerow is bigger than the multi-row, then null out
|
||||
// ieheight - I'm estimating that a single row is twice the size of
|
||||
// multi-row. This is really the best that can be done with ie
|
||||
if ($max_singlerow_cnt >= $max_multirow_cnt || $max_multirow_cnt <= $multi_count / 2 ) {
|
||||
$iehint = 0;
|
||||
}
|
||||
elseif ($rowspan > 1 && $in_month && $single_day_cnt > 0) {
|
||||
$iehint = max($iehint, $rowspan - 1); // How many rows to adjust for?
|
||||
}
|
||||
|
||||
// Set the class
|
||||
$item['class'] .= ($curday_date == $today && $in_month ? ' today' : '') .
|
||||
($curday_date < $today ? ' past' : '') .
|
||||
($curday_date > $today ? ' future' : '');
|
||||
}
|
||||
}
|
||||
|
||||
// If there isn't an item, then add empty class
|
||||
if ($item != NULL) {
|
||||
if (!$in_month) {
|
||||
$item['class'] .= ' empty';
|
||||
}
|
||||
// Style this entry - it will be a <td>.
|
||||
$inner .= theme('calendar_month_col', array('item' => $item));
|
||||
}
|
||||
|
||||
date_modify($this->curday, '+1 day');
|
||||
}
|
||||
|
||||
if ($i == 0) {
|
||||
$output .= theme('calendar_month_row', array(
|
||||
'inner' => $inner,
|
||||
'class' => 'date-box',
|
||||
'iehint' => $iehint,
|
||||
));
|
||||
}
|
||||
elseif ($i == $total_rows) {
|
||||
$output .= theme('calendar_month_row', array(
|
||||
'inner' => $inner,
|
||||
'class' => 'single-day',
|
||||
'iehint' => $iehint,
|
||||
));
|
||||
$iehint = 0;
|
||||
$max_singlerow_cnt = 0;
|
||||
$max_multirow_cnt = 0;
|
||||
}
|
||||
else {
|
||||
// Style all the columns into a row
|
||||
$output .= theme('calendar_month_row', array(
|
||||
'inner' => $inner,
|
||||
'class' => 'multi-day',
|
||||
'iehint' => 0,
|
||||
));
|
||||
}
|
||||
|
||||
} // End foreach
|
||||
|
||||
$this->curday = $final_day;
|
||||
|
||||
// Add the row into the row array....
|
||||
$rows[] = array('data' => $output);
|
||||
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$curday_month = date_format($this->curday, 'n');
|
||||
} while ($curday_month == $month && $curday_date <= $this->date_info->max_date_date);
|
||||
// Merge the day names in as the first row.
|
||||
$rows = array_merge(array(calendar_week_header($this->view)), $rows);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build one week row.
|
||||
*/
|
||||
function calendar_build_week($check_month = FALSE) {
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$weekdays = calendar_untranslated_days($this->items, $this->view);
|
||||
$month = date_format($this->curday, 'n');
|
||||
$first_day = variable_get('date_first_day', 0);
|
||||
|
||||
// Set up buckets
|
||||
$total_rows = 0;
|
||||
$multiday_buckets = array( array(), array(), array(), array(), array(), array(), array());
|
||||
$singleday_buckets = array( array(), array(), array(), array(), array(), array(), array());
|
||||
|
||||
// move backwards to the first day of the week
|
||||
$day_wday = date_format($this->curday, 'w');
|
||||
date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
|
||||
$class = strtolower($weekdays[$i]) . ' empty';
|
||||
$singleday_buckets[$i][][] = array(
|
||||
'entry' => theme('calendar_empty_day', array(
|
||||
'curday' => $curday_date,
|
||||
'view' => $this->view,
|
||||
)),
|
||||
'item' => NULL
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->calendar_build_week_day($i, $multiday_buckets, $singleday_buckets);
|
||||
}
|
||||
$total_rows = max(count($multiday_buckets[$i]) + 1, $total_rows);
|
||||
date_modify($this->curday, '+1 day');
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
}
|
||||
|
||||
$rows = array(
|
||||
'multiday_buckets' => $multiday_buckets,
|
||||
'singleday_buckets' => $singleday_buckets,
|
||||
'total_rows' => $total_rows);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the contents of a single day for the $rows results.
|
||||
*/
|
||||
function calendar_build_week_day($wday, &$multiday_buckets, &$singleday_buckets) {
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$max_events = $this->date_info->calendar_type == 'month' && !empty($this->date_info->style_max_items) ? $this->date_info->style_max_items : 0;
|
||||
$hide = !empty($this->date_info->style_max_items_behavior) ? ($this->date_info->style_max_items_behavior == 'hide') : FALSE;
|
||||
$multiday_theme = !empty($this->date_info->style_multiday_theme) && $this->date_info->style_multiday_theme == '1';
|
||||
$first_day = variable_get('date_first_day', 0);
|
||||
$cur_cnt = 0;
|
||||
$total_cnt = 0;
|
||||
$ids = array();
|
||||
|
||||
// If we are hiding, count before processing further
|
||||
if ($max_events != CALENDAR_SHOW_ALL) {
|
||||
foreach ($this->items as $date => $day) {
|
||||
if ($date == $curday_date) {
|
||||
foreach ($day as $time => $hour) {
|
||||
foreach ($hour as $key => $item) {
|
||||
$total_cnt++;
|
||||
$ids[] = $item->date_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we haven't already exceeded the max or we'll showing all, then process the items
|
||||
if ($max_events == CALENDAR_SHOW_ALL || !$hide || $total_cnt < $max_events) {
|
||||
// Count currently filled items
|
||||
foreach ($multiday_buckets[$wday] as $bucket) {
|
||||
if (!$bucket['avail']) {
|
||||
$cur_cnt++;
|
||||
}
|
||||
}
|
||||
foreach ($this->items as $date => $day) {
|
||||
if ($date == $curday_date) {
|
||||
ksort($day);
|
||||
foreach ($day as $time => $hour) {
|
||||
foreach ($hour as $key => $item) {
|
||||
$all_day = $item->calendar_all_day;
|
||||
|
||||
// Parse out date part
|
||||
$start_ydate = date_format($item->date_start, DATE_FORMAT_DATE);
|
||||
$end_ydate = date_format($item->date_end, DATE_FORMAT_DATE);
|
||||
$cur_ydate = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
|
||||
$is_multi_day = ($start_ydate < $cur_ydate || $end_ydate > $cur_ydate);
|
||||
|
||||
// Does this event span multi-days?
|
||||
if ($multiday_theme && ($is_multi_day || $all_day)) {
|
||||
|
||||
// Remove multiday items from the total count. We can't hide them or they will break.
|
||||
$total_cnt--;
|
||||
|
||||
// If this the first day of the week, or is the start date of the multi-day event,
|
||||
// then record this item, otherwise skip over
|
||||
$day_no = date_format($this->curday, 'd');
|
||||
if ($wday == 0 || $start_ydate == $cur_ydate || ($this->date_info->granularity == 'month' && $day_no == 1) || ($all_day && !$is_multi_day)) {
|
||||
// Calculate the colspan for this event
|
||||
|
||||
// If the last day of this event exceeds the end of the current month or week,
|
||||
// truncate the remaining days
|
||||
$diff = $this->curday->difference($this->date_info->max_date, 'days');
|
||||
$remaining_days = ($this->date_info->granularity == 'month') ? min(6 - $wday, $diff) : $diff - 1;
|
||||
// The bucket_cnt defines the colspan. colspan = bucket_cnt + 1
|
||||
$days = $this->curday->difference($item->date_end, 'days');
|
||||
$bucket_cnt = max(0, min($days, $remaining_days));
|
||||
|
||||
// See if there is an available slot to add an event. This will allow
|
||||
// an event to precede a row filled up by a previous day event
|
||||
$avail = FALSE;
|
||||
$bucket_index = count($multiday_buckets[$wday]);
|
||||
for ($i = 0; $i < $bucket_index; $i++) {
|
||||
if ($multiday_buckets[$wday][$i]['avail']) {
|
||||
$bucket_index = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add continuation attributes
|
||||
$item->continuation = ($item->date_start < $this->curday);
|
||||
$item->continues = ( $days > $bucket_cnt );
|
||||
|
||||
// Assign the item to the available bucket
|
||||
$multiday_buckets[$wday][$bucket_index] = array(
|
||||
'colspan' => $bucket_cnt + 1,
|
||||
'rowspan' => 1,
|
||||
'filled' => TRUE,
|
||||
'avail' => FALSE,
|
||||
'all_day' => $all_day,
|
||||
'item' => $item,
|
||||
'wday' => $wday,
|
||||
'entry' => theme('calendar_item', array('view' => $this->view, 'rendered_fields' => $item->rendered_fields, 'item' => $item)),
|
||||
);
|
||||
|
||||
// Block out empty buckets for the next days in this event for this week
|
||||
for ($i = 0; $i < $bucket_cnt; $i++) {
|
||||
$bucket = &$multiday_buckets[$i + $wday + 1];
|
||||
$bucket_row_count = count($bucket);
|
||||
$row_diff = $bucket_index - $bucket_row_count;
|
||||
|
||||
// Fill up the preceding buckets - these are available for future
|
||||
// events
|
||||
for ( $j = 0; $j < $row_diff; $j++) {
|
||||
$bucket[($bucket_row_count + $j) ] = array(
|
||||
'entry' => ' ',
|
||||
'colspan' => 1,
|
||||
'rowspan' => 1,
|
||||
'filled' => TRUE,
|
||||
'avail' => TRUE,
|
||||
'wday' => $wday,
|
||||
'item' => NULL
|
||||
);
|
||||
}
|
||||
$bucket[$bucket_index] = array(
|
||||
'filled' => FALSE,
|
||||
'avail' => FALSE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($max_events == CALENDAR_SHOW_ALL || $cur_cnt < $max_events) {
|
||||
$cur_cnt++;
|
||||
// Assign to single day bucket
|
||||
$singleday_buckets[$wday][$time][] = array(
|
||||
'entry' => theme('calendar_item', array('view' => $this->view, 'rendered_fields' => $item->rendered_fields, 'item' => $item)),
|
||||
'item' => $item,
|
||||
'colspan' => 1,
|
||||
'rowspan' => 1,
|
||||
'filled' => TRUE,
|
||||
'avail' => FALSE,
|
||||
'wday' => $wday,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a more link if necessary
|
||||
if ($max_events != CALENDAR_SHOW_ALL && $total_cnt > 0 && $cur_cnt < $total_cnt) {
|
||||
$entry = theme('calendar_' . $this->date_info->calendar_type . '_multiple_entity', array(
|
||||
'curday' => $curday_date,
|
||||
'count' => $total_cnt,
|
||||
'view' => $this->view,
|
||||
'ids' => $ids,
|
||||
));
|
||||
if (!empty($entry)) {
|
||||
$singleday_buckets[$wday][][] = array(
|
||||
'entry' => $entry,
|
||||
'more_link' => TRUE,
|
||||
'item' => NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the contents of a single day for the $rows results.
|
||||
*/
|
||||
function calendar_build_day() {
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$selected = FALSE;
|
||||
$max_events = !empty($this->date_info->style_max_items) ? $this->date_info->style_max_items : 0;
|
||||
$ids = array();
|
||||
$inner = array();
|
||||
$all_day = array();
|
||||
$empty = '';
|
||||
$link = '';
|
||||
$count = 0;
|
||||
foreach ($this->items as $date => $day) {
|
||||
if ($date == $curday_date) {
|
||||
$count = 0;
|
||||
$selected = TRUE;
|
||||
ksort($day);
|
||||
foreach ($day as $time => $hour) {
|
||||
foreach ($hour as $key => $item) {
|
||||
$count++;
|
||||
if (isset($item->type)) {
|
||||
$ids[$item->type] = $item;
|
||||
}
|
||||
if (empty($this->date_info->mini) && ($max_events == CALENDAR_SHOW_ALL || $count <= $max_events || ($count > 0 && $max_events == CALENDAR_HIDE_ALL))) {
|
||||
if ($item->calendar_all_day) {
|
||||
$all_day[] = $item;
|
||||
}
|
||||
else {
|
||||
$key = date_format($item->calendar_start_date, 'H:i:s');
|
||||
$inner[$key][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($inner);
|
||||
|
||||
if (empty($inner) && empty($all_day)) {
|
||||
$empty = theme('calendar_empty_day', array('curday' => $curday_date, 'view' => $this->view));
|
||||
}
|
||||
// We have hidden events on this day, use the theme('calendar_multiple_') to show a link.
|
||||
if ($max_events != CALENDAR_SHOW_ALL && $count > 0 && $count > $max_events && $this->date_info->calendar_type != 'day' && !$this->date_info->mini) {
|
||||
if ($this->date_info->style_max_items_behavior == 'hide' || $max_events == CALENDAR_HIDE_ALL) {
|
||||
$all_day = array();
|
||||
$inner = array();
|
||||
}
|
||||
$link = theme('calendar_' . $this->date_info->calendar_type . '_multiple_node', array(
|
||||
'curday' => $curday_date,
|
||||
'count' => $count,
|
||||
'view' => $this->view,
|
||||
'ids' => $ids,
|
||||
));
|
||||
}
|
||||
|
||||
$content = array(
|
||||
'date' => $curday_date,
|
||||
'datebox' => theme('calendar_datebox', array(
|
||||
'date' => $curday_date,
|
||||
'view' => $this->view,
|
||||
'items' => $this->items,
|
||||
'selected' => $selected,
|
||||
)),
|
||||
'empty' => $empty,
|
||||
'link' => $link,
|
||||
'all_day' => $all_day,
|
||||
'items' => $inner,
|
||||
);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build one mini month.
|
||||
*/
|
||||
function calendar_build_mini_month() {
|
||||
$month = date_format($this->curday, 'n');
|
||||
date_modify($this->curday, '-' . strval(date_format($this->curday, 'j')-1) . ' days');
|
||||
$rows = array();
|
||||
do {
|
||||
$rows = array_merge($rows, $this->calendar_build_mini_week());
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$curday_month = date_format($this->curday, 'n');
|
||||
} while ($curday_month == $month && $curday_date <= $this->date_info->max_date_date);
|
||||
// Merge the day names in as the first row.
|
||||
$rows = array_merge(array(calendar_week_header($this->view)), $rows);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build one week row.
|
||||
*/
|
||||
function calendar_build_mini_week($check_month = TRUE) {
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$weekdays = calendar_untranslated_days($this->items, $this->view);
|
||||
$today = date_format(date_now(date_default_timezone()), DATE_FORMAT_DATE);
|
||||
$month = date_format($this->curday, 'n');
|
||||
$week = date_week($curday_date);
|
||||
$first_day = variable_get('date_first_day', 0);
|
||||
// move backwards to the first day of the week
|
||||
$day_wday = date_format($this->curday, 'w');
|
||||
date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$curday_date = date_format($this->curday, DATE_FORMAT_DATE);
|
||||
$class = strtolower($weekdays[$i] . ' mini');
|
||||
if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
|
||||
$class .= ' empty';
|
||||
$variables = array(
|
||||
'curday' => $curday_date,
|
||||
'view' => $this->view,
|
||||
);
|
||||
|
||||
$content = array(
|
||||
'date' => '',
|
||||
'datebox' => '',
|
||||
'empty' => theme('calendar_empty_day', $variables),
|
||||
'link' => '',
|
||||
'all_day' => array(),
|
||||
'items' => array(),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$content = $this->calendar_build_day();
|
||||
$class .= ($curday_date == $today ? ' today' : '') .
|
||||
($curday_date < $today ? ' past' : '') .
|
||||
($curday_date > $today ? ' future' : '') .
|
||||
(empty($this->items[$curday_date]) ? ' has-no-events' : ' has-events');
|
||||
}
|
||||
$rows[$week][] = array(
|
||||
'data' => $content,
|
||||
'class' => $class,
|
||||
'id' => $this->view->name . '-' . $curday_date,
|
||||
);
|
||||
date_modify($this->curday, '+1 day');
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user