Create page.

This commit is contained in:
chris2tof committed 2011-06-01 10:24:14 +08:00
1 parent 2522cde2f5
commit ddc7c74436
21 files changed
+163 -83

No files matched your search

+4
View File
@@ -7,4 +7,8 @@ class I18nVariable
field :document_class, :type => String
field :parent_id, :type => BSON::ObjectId, :index => true
def method_missing(field)
self[field]
end
end
+12 -1
View File
@@ -11,13 +11,24 @@ class Page < Item
referenced_in :layout
has_many :page_parts
def create_parts
page_layout = self.get_layout
page_layout.layout_parts.each do |p|
self.page_parts.create( :name => p.name, :i18n_variable_id => I18nVariable.create.id, :kind => 'text' )
end
end
def get_layout
Layout.find(layout_id)
end
protected
def setup_default_value
super
if self.layout_id
self.layout_name = Layout.find(layout_id).name
self.layout_name = get_layout.name
end
end
+13
View File
@@ -25,5 +25,18 @@ class PagePart
self.i18n_variable_id = var.id
end
end
# Build the content from the i18n_variable
def build_content(locales)
res = ''
res << "<r:multi_lang i18n_id='#{i18n_variable.id}'>"
locales.each do |locale|
res << "<r:lang name='#{locale.to_s}'>"
res << i18n_variable[locale.to_s]
res << "</r:lang>"
end
res << "</r:multi_lang>"
self.content = res
end
end