I was working on refactoring the code in calendar_plugin_style.inc and in trying to reduce duplicated code I started looking for code that is written more than once.

The "more link" seems to exist in 2 places:

  1. calendar_build_week_day
  2. calendar_build_day

In the latter function, the code seems to be useless:
line 861:


    // 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,
      ));
    }

I looked at all the display settings relating to the calendar_build_day() function and there is never a case where the "max_events" has any affect. The calendar_build_day() is only called on mini-months, and these mini displays never show "items" or "events" or whatever you want to call them... The mini days only show a link to the day.

Please correct me if I'm wrong.

I assume the fact that this code is never called is why the other part of this was never noticed: the code down there uses theme('calendar_' . $this->date_info->calendar_type . '_multiple_node' where in calendar_build_week_day we have theme('calendar_' . $this->date_info->calendar_type . '_multiple_entity'

The "_multiple_node" theme is no more, so if this code were to be executed, there'd be a problem.

Comments

tmsimont’s picture

more un-used code line 633:
$class = strtolower($weekdays[$i]) . ' empty';
The $class variable is never used.

tmsimont’s picture

similarly in line 842 there is this code:

            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) {
                $item->is_multi_day = TRUE;
                $all_day[] = $item;
              }
              else {
                $key = date_format($item->calendar_start_date, 'H:i:s');
                $inner[$key][] = $item;
              }
            }

as far as I can tell it's more unused code.

There are two places calendar_build_day is actively used:

  1. building mini months
  2. building individual days

individual days have no max_events setting, so i'm pretty sure this case is never encountered.

tmsimont’s picture

nvm on #2.... the rest i'm still pretty sure about

Neslee Canil Pinto’s picture

Status: Active » Closed (outdated)