Module: ForumAdminUI

Defined in:
lib/forum_admin_ui.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/forum_admin_ui.rb', line 3

def self.included(base)
 base.class_eval do

    attr_accessor :forum, :topic, :post
    alias_method :forums, :forum
    alias_method :topics, :topic
    alias_method :posts, :post

    def load_forum_extension_regions
      @forum = load_default_forum_regions
      @topic = load_default_topic_regions
      @post = load_default_post_regions
    end

    def load_default_regions_with_forum
      load_default_regions_without_forum
      load_forum_extension_regions
    end
    alias_method_chain :load_default_regions, :forum

    protected

      def load_default_forum_regions
        OpenStruct.new.tap do |forum|
          forum.edit = Radiant::AdminUI::RegionSet.new do |edit|
            edit.main.concat %w{edit_header edit_form}
            edit.form.concat %w{edit_name edit_description edit_group}
            edit.form_bottom.concat %w{edit_buttons}
          end
          forum.index = Radiant::AdminUI::RegionSet.new do |index|
            index.thead.concat %w{title_header description_header latest_header modify_header}
            index.tbody.concat %w{title_cell description_cell latest_cell modify_cell}
            index.bottom.concat %w{buttons}
          end
          forum.remove = forum.index
          forum.new = forum.edit
        end
      end

      def load_default_topic_regions
        OpenStruct.new.tap do |topic|
          topic.edit = Radiant::AdminUI::RegionSet.new do |edit|
            edit.main.concat %w{edit_header edit_form}
            edit.form.concat %w{edit_name edit_body}
            edit.form_bottom.concat %w{edit_buttons}
          end
          topic.index = Radiant::AdminUI::RegionSet.new do |index|
            index.thead.concat %w{title_header date_header author_header body_header modify_header}
            index.tbody.concat %w{title_cell date_cell author_cell body_cell modify_cell}
            index.bottom.concat %w{buttons}
          end
          topic.remove = topic.index
          topic.new = topic.edit
        end
      end

      def load_default_post_regions
        OpenStruct.new.tap do |post|
          post.edit = Radiant::AdminUI::RegionSet.new do |edit|
            edit.main.concat %w{edit_header edit_form}
            edit.form.concat %w{show_name edit_body}
            edit.form_bottom.concat %w{edit_buttons}
          end
          post.index = Radiant::AdminUI::RegionSet.new do |index|
            index.thead.concat %w{body_header author_header topic_header modify_header}
            index.tbody.concat %w{body_cell author_cell topic_cell modify_cell}
            index.bottom.concat %w{buttons}
          end
          post.remove = post.index
          post.new = post.edit
        end
      end
    
  end
end