Skip to content

Commit

Permalink
Merge commit 'origin/site_template_changes' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Jul 25, 2010
2 parents 85b45ba + af7023a commit 66ac7bb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
4 changes: 4 additions & 0 deletions app/controllers/edit_controller.rb
Expand Up @@ -553,15 +553,19 @@ def page_variables
get_container
# output the page, go through each block, and get the variables
edit_page_info(@container_type,@container_id,params[:path][2],false)
logger.error @revision.variables.inspect

variable_names = []
@output.html do |blk|
if blk.is_a?(Hash) && blk[:variable]
variable_names << blk[:variable]
end
end


@options = DefaultsHashObject.new(@revision.variables || {})

logger.error @revision.variables.inspect
@variables = (@site_template.options[:options] || []).find_all do |opt|
variable_names.include?(opt[0]) ? true : false
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/templates_controller.rb
Expand Up @@ -159,13 +159,14 @@ def update
@selected_language = params[:selected_language].to_s
@site_template = SiteTemplate.find(params[:path][0])

@site_template.set_localization(params[:localize_values],params[:translate],params[:translation])

@site_template.attributes = params[:site_template]
@site_template.modified_at= Time.now
@site_template.modified_by=myself.id

@parsing_errors = @site_template.update_zones_and_options
@site_template.update_option_values(params[:options])
@site_template.set_localization(params[:localize_values],params[:translate],params[:translation])

if(@site_template.parent_template)
@site_template.save
Expand All @@ -174,7 +175,6 @@ def update
parent.update_zones_and_options
parent.save
else
@site_template.update_option_values(params[:options])
@site_template.save

@site_template.update_feature_options
Expand Down
5 changes: 5 additions & 0 deletions app/models/page_revision.rb
Expand Up @@ -40,6 +40,11 @@ def self.activate_page_revision(page,revision_id)

end

def display_variables
return @display_variables if @display_variables
@display_variables = (self.variables || {}).clone
end

def self.deactivate_page_revision(page,revision_id)

active_rev = page.page_revisions.find_by_id(revision_id)
Expand Down
3 changes: 1 addition & 2 deletions app/models/site_node_modifier.rb
Expand Up @@ -233,9 +233,8 @@ def apply_modifier_framework!(engine,page_information)

# Use this as the revision, unless we have a one already
engine.revision = rev unless engine.revision
engine.revision.variables ||= {}
(rev.variables||{}).each do |var,value|
engine.revision.variables[var] = value if engine.revision.variables[var].blank?
engine.revision.display_variables[var] = value if engine.revision.display_variables[var].blank?
end

# Go through the paragraphs in reverse order (as each is added to the beginning of the list)
Expand Down
31 changes: 18 additions & 13 deletions app/models/site_template.rb
Expand Up @@ -139,13 +139,13 @@ def update_zones_and_options
parsing_errors << ('Error Parsing Design Styles of %s:' / self.name) + err.to_s.t
end

# self.site_features.each do |feature|
# begin
# template_parser.parse(feature.body)
# rescue Exception => err
# parsing_errors << ('Error Parsing Feature %s:' / feature.name) + err.to_s.t
# end
# end
self.site_features.each do |feature|
begin
template_parser.parse(feature.body)
rescue Exception => err
parsing_errors << ('Error Parsing Feature %s:' / feature.name) + err.to_s.t
end
end

begin
template_parser.parse(self.template_html)
Expand Down Expand Up @@ -252,10 +252,16 @@ def update_option_values(values)
saved_values = {}
self.options[:options].each do |opt|
var_name = opt[0]
if values && values[var_name]
if values && !values[var_name].blank?
saved_values[var_name] = values[var_name]
elsif opt[6]
saved_values[var_name] = opt[6]
if opt[2] == 'image'
parent = self.domain_file
img = DomainFile.find_by_file_path(parent.file_path + "/" + opt[6]) if parent
saved_values[var_name] = img.id if img
else
saved_values[var_name] = opt[6]
end
end
end
self.options[:values] = saved_values
Expand Down Expand Up @@ -423,13 +429,12 @@ def render_variable(variable,value,language)
value
when 'image':
img = DomainFile.find_by_id(value)
img ? img.url : '/images/spacer.gif'
img ? img.image_tag : '/images/spacer.gif'
when 'src':
img = DomainFile.find_by_id(value)
img ? img.url : ''
when 'node':
nd = SiteNode.find_by_id(value)
nd ? nd.node_path : ''
when 'url':
value
else
value
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/templates/_custom_field.rhtml
Expand Up @@ -14,8 +14,8 @@
<%= f.filemanager_image opt[0].to_sym, :label => opt[1] %>
<% when "src": -%>
<%= f.filemanager_file opt[0].to_sym, :label => opt[1] %>
<% when "node": -%>
<%= f.select opt[0].to_sym, [['--Select Page--'.t,'']] + SiteNode.page_options.collect { |elem| [ elem[0],elem[1].to_s ] }, :label => opt[1] %>
<% when "url": -%>
<%= f.select opt[0].to_sym, [['--Select Page--'.t,'']] + SiteNode.page_url_options, :label => opt[1] %>
<% when "color": -%>
<%= f.color_field opt[0].to_sym, :label => opt[1] %>
<% else -%>
Expand Down
3 changes: 2 additions & 1 deletion lib/site_node_engine.rb
Expand Up @@ -961,7 +961,8 @@ def compile_page_information(user)
# content and paragraph attribute hashes
def render_page_elements()
@active_template = SiteTemplate.find(@page_information.site_template_id) unless @active_template
variables = @revision.variables || {}

variables = (@revision.display_variables || {}).clone

# Generate an array of strings (for static content),
# and hashs (for zones with paragraphs)
Expand Down

0 comments on commit 66ac7bb

Please sign in to comment.