function calendar_granularity_path in Calendar 7.3
Same name and namespace in other branches
- 8 calendar.module \calendar_granularity_path()
Find the path for the calendar display that has a specific granularity.
5 calls to calendar_granularity_path()
- calendar_plugin_style::calendar_build_mini_week in includes/
calendar_plugin_style.inc - Build one week row.
- calendar_plugin_style::calendar_build_month in includes/
calendar_plugin_style.inc - Build one month.
- template_preprocess_calendar_datebox in theme/
theme.inc - Create the calendar date box.
- template_preprocess_calendar_mini in theme/
theme.inc - Display a mini month view.
- template_preprocess_calendar_month_multiple_entity in theme/
theme.inc - Format an calendar month node for display.
File
- ./
calendar.module, line 500 - Adds calendar filtering and displays to Views.
Code
function calendar_granularity_path(&$view, $granularity) {
$paths =& drupal_static(__FUNCTION__, array());
if (!array_key_exists($view->name, $paths) || !array_key_exists($granularity, $paths[$view->name])) {
$paths[$view->name][$granularity] = '';
foreach ($view->display as $id => $display) {
// Check for !empty() in case the view is not fully formed or has displays that are marked to be deleted
if (!empty($display->deleted) || empty($display->display_options['style_plugin']) || isset($display->display_options['enabled']) && $display->display_options['enabled'] == FALSE) {
continue;
}
if ($display->display_plugin != 'feed' && !empty($display->display_options['path']) && !empty($display->display_options['arguments'])) {
// Set to the default value, reset below if another value is found.
$type = 'month';
foreach ($display->display_options['arguments'] as $name => $argument) {
if (!empty($argument['granularity'])) {
$type = $argument['granularity'];
}
}
if ($type == $granularity) {
$part_path = $display->display_options['path'];
$parts = explode('/', $part_path);
if (in_array('%', $parts)) {
$current_path = parse_url($_GET['q']);
$current_parts = explode('/', $current_path['path']);
foreach ($parts as $key => $part) {
if ($part == '%' && !empty($current_parts[$key])) {
$parts[$key] = $current_parts[$key];
}
}
$part_path = implode('/', $parts);
}
$paths[$view->name][$granularity] = $part_path;
}
}
}
}
return $paths[$view->name][$granularity];
}