Class: ArchivePageTreeStructure::ArchiveMonthTreePage

Inherits:
ArchiveTreePage show all
Defined in:
lib/archive_page_tree_structure.rb

Instance Method Summary collapse

Methods inherited from ArchiveTreePage

#allowed_children_cache, #children, #class_name, display_name, #sheet?, #status, #url, #virtual?

Constructor Details

#initialize(parent, start_time) ⇒ ArchiveMonthTreePage

Returns a new instance of ArchiveMonthTreePage.



96
97
98
99
# File 'lib/archive_page_tree_structure.rb', line 96

def initialize(parent, start_time)
  @parent = parent
  @start_time = start_time
end

Instance Method Details



106
107
108
# File 'lib/archive_page_tree_structure.rb', line 106

def breadcrumb
  title
end

#idObject



100
101
102
# File 'lib/archive_page_tree_structure.rb', line 100

def id
  @start_time.strftime("#{@parent.id}_%Y_%m")
end

#titleObject



103
104
105
# File 'lib/archive_page_tree_structure.rb', line 103

def title
  I18n.l @start_time, :format => "%B"
end

#tree_childrenObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/archive_page_tree_structure.rb', line 109

def tree_children
  end_time = @start_time.next_month.beginning_of_month
  condition_string = 'virtual = ? and (published_at >= ? and published_at < ? or (published_at is null and ('
  condition_string += 'updated_at is null or ' if Time.now.utc.beginning_of_month == @start_time.beginning_of_month
  condition_string += '(updated_at >= ? and updated_at < ?))))'
  @parent.children.find(:all, 
    :conditions => [
      condition_string, 
      false,
      @start_time, 
      end_time,
      @start_time, 
      end_time,
      ],
    :order => 'published_at desc, updated_at desc'
  )
end