### Eclipse Workspace Patch 1.0 #P drupal-event Index: event.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/event/event.module,v retrieving revision 1.405 diff -u -r1.405 event.module --- event.module 5 Jul 2009 00:34:15 -0000 1.405 +++ event.module 1 Aug 2009 09:35:50 -0000 @@ -124,41 +124,43 @@ if (!isset($node->filter)) { $node->filter = ''; } - $links['event_month'] = array('title' => t('Month'), - 'href' => $base .'month/'. $node->filter, - 'attributes' => array('title' => t('Month view'))); - $links['event_week'] = array('title' => t('Week'), - 'href' => $base .'week/'. $node->filter, - 'attributes' => array('title' => t('Week view'))); - $links['event_day'] = array('title' => t('Day'), - 'href' => $base .'day/'. $node->filter, - 'attributes' => array('title' => t('Day view'))); - $links['event_table'] = array('title' => t('Table'), - 'href' => $base .'table/'. $node->filter, - 'attributes' => array('title' => t('Table view'))); - $links['event_list'] = array('title' => t('List'), - 'href' => $base .'list/'. $node->filter, - 'attributes' => array('title' => t('List view'))); - - // ...then subtract out the one we're viewing. - switch ($type) { - case 'event_month': - unset($links['event_month']); - break; - case 'event_week': - unset($links['event_week']); - break; - case 'event_day': - unset($links['event_day']); - break; - case 'event_table': - unset($links['event_table']); - break; - case 'event_list': - unset($links['event_list']); - break; - default: - $links = array(); + + $visibleOverviews = variable_get('visible_event_overviews', + array('day', 'week', 'month', 'table', 'list')); + if (in_array('month', $visibleOverviews)) { + $links['event_month'] = array('title' => t('Month'), + 'href' => $base .'month/'. $node->filter, + 'attributes' => array('title' => t('Month view'))); + } + if (in_array('week', $visibleOverviews)) { + $links['event_week'] = array('title' => t('Week'), + 'href' => $base .'week/'. $node->filter, + 'attributes' => array('title' => t('Week view'))); + } + if (in_array('day', $visibleOverviews)) { + $links['event_day'] = array('title' => t('Day'), + 'href' => $base .'day/'. $node->filter, + 'attributes' => array('title' => t('Day view'))); + } + if (in_array('table', $visibleOverviews)) { + $links['event_table'] = array('title' => t('Table'), + 'href' => $base .'table/'. $node->filter, + 'attributes' => array('title' => t('Table view'))); + } + if (in_array('list', $visibleOverviews)) { + $links['event_list'] = array('title' => t('List'), + 'href' => $base .'list/'. $node->filter, + 'attributes' => array('title' => t('List view'))); + } + + if (!array_key_exists($type, $links)) { + if(variable_get('event_overview_hide_current', 1)) { + // ... then subtract out the one we're viewing ... + unset($links[$type]); + } else { + // ... or mark the current one as active. + $links[$type]['class'] = 'active'; + } } } @@ -350,21 +352,37 @@ '#maxlength' => 5, '#size' => 2, '#description' => t('Limit the amount of events displayed in the upcoming events block by this amount.')); - - $form['event_overview'] = array( + + $form['event_overview_set'] = array( + '#type' => 'fieldset', + '#title' => t('Overview')); + + $form['event_overview_set']['visible_event_overviews'] = array( + '#type' => 'select', + '#title' => t('Visible overview'), + '#default_value' => variable_get('visible_event_overviews', array('day', 'week', 'month', 'table', 'list')), + '#options' => array('day' => t('Day'), 'week' => t('Week'), 'month' => t('Month'), 'table' => t('Table'), 'list' => t('List')), + '#multiple' => TRUE, + '#description' => t('Ctrl-click (Windows) or Command-click (Mac) to select more than one value.')); + $form['event_overview_set']['event_overview_hide_current'] = array( + '#type' => 'checkbox', + '#title' => t('Hide current overview'), + '#default_value' => variable_get("event_overview_hide_current", 1)); + + $form['event_overview_set']['event_overview'] = array( '#type' => 'radios', '#title' => t('Default overview'), '#default_value' => variable_get('event_overview', 'month'), '#options' => array('day' => t('Day'), 'week' => t('Week'), 'month' => t('Month'), 'table' => t('Table'), 'list' => t('List')), - '#description' => t('The default event view to display when no format is specifically requested. This is also the view that will be displayed from the block calendar links.')); - $form['event_table_duration'] = array( + '#description' => t('The default event view to display when no format is specifically requested. This is also the view that will be displayed from the block calendar links.')); + $form['event_overview_set']['event_table_duration'] = array( '#type' => 'textfield', '#title' => t('Table view default period'), '#default_value' => variable_get('event_table_duration', '30'), '#maxlength' => 5, '#size' => 3, '#description' => t('The default number of days to display in the table view. You can specify a different number of days in the url. More info on the event url format !link', array('!link' => l(t('here'), 'admin/help/event#url-format')))); - + if (module_exists('taxonomy')) { $form['event_taxonomy_control'] = array( '#type' => 'radios', @@ -412,9 +430,18 @@ if (isset($_POST['event_type_select'])) { drupal_goto('event/'. $year .'/'. $month .'/'. $day .'/'. $view .'/'. check_plain($_POST['event_type_select']) .'/'. $tids .'/'. check_plain($duration)); } - - if (isset($_POST['event_term_select'])) { - drupal_goto('event/'. $year .'/'. $month .'/'. $day .'/'. $view .'/'. ($types ? $types : 'all') .'/'. check_plain($_POST['event_term_select']) .'/'. check_plain($duration)); + + $tidsPost = array(); + $vs = _event_get_filter_taxonomies(); + foreach ($vs as $vid => $vocab) { + if (isset($_POST['event_term_select_' . $vid])) { + if (is_numeric($_POST['event_term_select_' . $vid])) { + $tidsPost[] = check_plain($_POST['event_term_select_' . $vid]); + } + } + } + if (count($tidsPost) > 0) { + drupal_goto('event/'. $year .'/'. $month .'/'. $day .'/'. $view .'/'. ($types ? $types : 'all') .'/'. implode(',', $tidsPost) .'/'. check_plain($duration)); } $breadcrumbs[] = l(t('Home'), NULL); @@ -563,7 +590,7 @@ $next = _event_nav($date, 'next', $view, $types, $terms, $duration); // setup calendar table header - $caption = $prev .' '. $caption .' '. $next; + $caption = $prev .' '. $caption .' && '. $next; $node->event = array(); $node->event['start_exploded'] = array('year' => $year, 'month' => $month, 'day' => $day); $node->event['filter'] = ($types ? implode('+', $types) : 'all') .'/'. ($terms ? implode('+', $terms) : 'all'); @@ -650,7 +677,10 @@ case 'block': // create caption and navigation links - $caption = _event_nav($date, 'prev', 'block', $types, $terms) .' '. l(event_format_date($date, 'custom', t('F Y')), 'event/'. _event_format_url($date) .'/month') .' '. _event_nav($date, 'next', 'block', $types, $terms); + $caption = _event_nav($date, 'prev', 'block', $types, $terms) . ' ' . + l(event_format_date($date, 'custom', t('F Y')), + 'event/'. _event_format_url($date) .'/month') .' || '. + _event_nav($date, 'next', 'block', $types, $terms); $callback = 'event_render_day_single'; $view = 'block'; @@ -1847,41 +1877,27 @@ * @return An array representing the form. */ function event_taxonomy_filter_form($form_state, $curterm, $autosubmit) { - - $types = event_get_types(); - $vs = array(); - foreach ($types['all'] as $type) { - $results = taxonomy_get_vocabularies($type); - foreach ($results as $vocab) { - $vs[$vocab->vid] = $vocab; - } - } - - $results = null; - foreach ($types['solo'] as $type) { - $results = taxonomy_get_vocabularies($type); - foreach ($results as $vocab) { - $vs[$vocab->vid] = $vocab; - } - } - - $items['all'] = t('(all)'); + + $vs = _event_get_filter_taxonomies(); foreach ($vs as $vid => $vocab) { $tree = taxonomy_get_tree($vid); + + $items = array(); + $items['all'] = t('(all)'); foreach ($tree as $term) { - $items[$term->tid] = $vocab->name .' - '. $term->name; + $items[$term->tid] = str_repeat('-', $term->depth) . $term->name; } - } - - $form['event_term_select'] = array( + + $form['event_term_select_' . $vid] = array( '#type' => 'select', + '#title' => $vocab->name, '#default_value' => $curterm, '#options' => $items, '#description' => t('Select event terms to filter by')); - if ($autosubmit) { - $form['event_term_select']['#attributes'] = array('onchange' => 'this.form.submit()'); + if ($autosubmit) { + $form['event_term_select_' . $vid]['#attributes'] = array('onchange' => 'this.form.submit()'); + } } - return $form; } @@ -3363,3 +3379,30 @@ ); } +/** + * Returns an array of taxonomies which can be filtered. Used for displaying the + * different taxonomy-filters if more than one taxonomy was assigned to event. + * + * @return array + */ +function _event_get_filter_taxonomies() +{ + $types = event_get_types(); + $vs = array(); + foreach ($types['all'] as $type) { + $results = taxonomy_get_vocabularies($type); + foreach ($results as $vocab) { + $vs[$vocab->vid] = $vocab; + } + } + + $results = null; + foreach ($types['solo'] as $type) { + $results = taxonomy_get_vocabularies($type); + foreach ($results as $vocab) { + $vs[$vocab->vid] = $vocab; + } + } + + return $vs; +} \ No newline at end of file