container_block.rb
874 Bytes
1
2
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
class ContainerBlock < Block
include Noosfero::Plugin::HotSpot
after_create :create_box
settings_items :container_box_id, :type => Integer, :default => nil
def self.description
_('Container')
end
def help
_('This block acts as a container for another blocks')
end
def create_box
box = Box.create!(:owner => self)
settings[:container_box_id] = box.id
save!
end
def container_box
Box.find(container_box_id)
end
def block_classes=(classes)
classes.each { |c| block = c.constantize.create!(:box => container_box) } if classes
end
def blocks
container_box.blocks
end
#FIXME needed?
def layout_template
'default2'
end
#FIXME controller test
def content(args={})
block = self
lambda do
render :file => 'blocks/container.rhtml', :locals => {:block => block}
end
end
end