function create_slices() { global $current_user; if ($this->view == 'month') { $days_in_month = $this->date_time->days_in_month; $first_day_of_month = $this->date_time->get_day_by_index_this_month(0); $num_of_prev_days = $first_day_of_month->day_of_week; // do 42 slices (6x7 grid) for ($i = 0; $i < 42; $i++) { $slice = new Slice('day', $this->date_time->get_day_by_index_this_month($i - $num_of_prev_days)); $this->slice_hash[$slice->start_time->get_mysql_date()] = $slice; array_push($this->slices_arr, $slice->start_time->get_mysql_date()); } } else { if ($this->view == 'week' || $this->view == 'shared') { $days_in_week = 7; for ($i = 0; $i < $days_in_week; $i++) { $slice = new Slice('day', $this->date_time->get_day_by_index_this_week($i)); $this->slice_hash[$slice->start_time->get_mysql_date()] = $slice; array_push($this->slices_arr, $slice->start_time->get_mysql_date()); } } else { if ($this->view == 'day') { $hours_in_day = 24; for ($i = 0; $i < $hours_in_day; $i++) { $slice = new Slice('hour', $this->date_time->get_datetime_by_index_today($i)); $this->slice_hash[$slice->start_time->get_mysql_date() . ":" . $slice->start_time->hour] = $slice; $this->slices_arr[] = $slice->start_time->get_mysql_date() . ":" . $slice->start_time->hour; } } else { if ($this->view == 'year') { for ($i = 0; $i < 12; $i++) { $slice = new Slice('month', $this->date_time->get_day_by_index_this_year($i)); $this->slice_hash[$slice->start_time->get_mysql_date()] = $slice; array_push($this->slices_arr, $slice->start_time->get_mysql_date()); } } else { sugar_die("not a valid view:" . $this->view); } } } } }