Class | CalendarController |
In: |
app/controllers/calendar_controller.rb
|
Parent: | ApplicationController |
CALENDAR_RETURN_TO | = | { :calendar_test => {:controller => "calendar", :action => "test"}, }.with_indifferent_access | allow registered return_to only because do not redirect to any url | |
CALENDAR_ERROR_RETURN_TO | = | "/" |
カレンダーを表示する。
# File app/controllers/calendar_controller.rb, line 19 19: def calendar 20: @year = (params[:year] || flash[:year] || Time.now.year).to_i 21: @month = (params[:month] || flash[:month] || Time.now.month).to_i 22: unless Date.valid_date?(@year, @month, 1) 23: @year = Time.now.year 24: @month = Time.now.month 25: end 26: @this = Date.new(@year, @month, 1) 27: 28: if params[:previous_year] 29: @this = (@this << 12) unless params[:previous_month] 30: elsif params[:previous_month] 31: @this = (@this << 1) 32: elsif params[:next_month] 33: @this = (@this >> 1) 34: elsif params[:next_year] 35: @this = (@this >> 12) 36: end 37: 38: @year = @this.year 39: @month = @this.month 40: 41: @prev_month = (@this << 1) 42: @next_month = (@this >> 1) 43: @prev_year = (@this << 12) 44: @next_year = (@this >> 12) 45: 46: @holidays = Hash.new(nil) 47: 48: # ToDo: select only the holidays during the specified month 49: Holiday.find(:all, :select => "day", :conditions => ["year = ? AND month = ?", @year, @month]).each do |holiday| 50: @holidays[holiday.day] = true 51: end 52: 53: @return_format = params[:return_format] ? params[:return_format] : "yyyy/mm/dd" 54: @alert_holiday = params[:alert_holiday] 55: 56: pass_params 57: end