diff --git a/vendor/plugins/design/lib/design/editor.rb b/vendor/plugins/design/lib/design/editor.rb index ea6d4a6..da9f6e0 100644 --- a/vendor/plugins/design/lib/design/editor.rb +++ b/vendor/plugins/design/lib/design/editor.rb @@ -28,40 +28,17 @@ module Design end end - private - - # Set to the owner the template choosed - def design_editor_set_template - if exists_template?(params[:template]) - design.template = params[:template] - end - end - - # Set to the owner the theme choosed - def design_editor_set_theme - if exists_theme?(params[:theme]) - design.theme = params[:theme] - end - end - - # Set to the owner the icon_theme choosed - def design_editor_set_icon_theme - if request.post? && exists_icon_theme?(params[:icon_theme]) - design.icon_theme = params[:icon_theme] - end - end - # TODO: see below here - def flexible_template_set_sort_mode + def design_editor_set_sort_mode box = design.boxes.find(params[:box_id]) render :update do |page| page.replace_html "box_#{box.number}", edit_blocks(box) - page.sortable "sort_#{box.number}", :url => {:action => 'flexible_template_sort_box', :box_number => box.number} + page.sortable "sort_#{box.number}", :url => {:action => 'design_editor_sort_box', :box_number => box.number} end end - def flexible_template_sort_box + def design_editor_sort_box box_number = params[:box_number] pos = 0 params["sort_#{box_number}"].each do |block_id| @@ -75,7 +52,7 @@ module Design # This method changes a block content to a different box place and # updates all boxes at the ends - def flexible_template_change_box + def design_editor_change_box #TODO fix it i tried the source code comment but i have no success #b = design.blocks.detect{|b| b.id.to_s == params[:block].to_s } b = Block.find(params[:block]) @@ -88,14 +65,14 @@ module Design end end - def flexible_template_new_block + def design_editor_new_block box = design.boxes.find(params[:box_id]) render :update do |page| - page.replace_html "box_#{box.number}", new_block_form(box) + page.replace_html "box_#{box.number}", design_editor_new_block_form(box) end end - def flexible_template_create_block + def design_editor_create_block block = Block.new(params[:block]) block.box = nil if !@ft_config[:boxes].include? block.box block.position = block.box.blocks.count + 1 if !block.box.nil? @@ -105,12 +82,12 @@ module Design end else render :update do |page| - page.replace_html "flexible_template_edit_mode", _('Block cannot be saved') + page.replace_html "design_editor_edit_mode", _('Block cannot be saved') end end end - def flexible_template_destroy_block + def design_editor_destroy_block block = Block.find(params[:block_id]) box = block.box #TO check if the block is of the owner @@ -161,7 +138,9 @@ module Design flash[:notice] = _("The file #{@ft_config[:template]}.yml it's not a valid template filename") if number_of_boxes.nil? number_of_boxes end - + + private + def exists_template?(template) Design.available_templates.include?(template) end @@ -173,12 +152,29 @@ module Design def exists_icon_theme?(icon_theme) Design.available_icon_themes.include?(icon_theme) end - - def parse_path(files_path = [], remove_until = 'public') - remove_until = remove_until.gsub(/\//, '\/') - files_path.map{|f| f.gsub(/.*#{remove_until}/, '')} + + # Set to the owner the template choosed + def design_editor_set_template + if exists_template?(params[:template]) + design.template = params[:template] + end + end + + # Set to the owner the theme choosed + def design_editor_set_theme + if exists_theme?(params[:theme]) + design.theme = params[:theme] + end + end + + # Set to the owner the icon_theme choosed + def design_editor_set_icon_theme + if request.post? && exists_icon_theme?(params[:icon_theme]) + design.icon_theme = params[:icon_theme] + end end + end end diff --git a/vendor/plugins/design/lib/design/editor/helper.rb b/vendor/plugins/design/lib/design/editor/helper.rb index 2aceab5..d11f769 100644 --- a/vendor/plugins/design/lib/design/editor/helper.rb +++ b/vendor/plugins/design/lib/design/editor/helper.rb @@ -35,19 +35,19 @@ module Design content_tag(:div, edit_blocks(box, content) , :id=>"box_#{box.number}") }].join("\n") - content = content_tag(:div, content, :id => 'flexible_template_edit_mode') + content = content_tag(:div, content, :id => 'design_editor_edit_mode') end # Symbol dictionary used on select when we add or edit a block. This # method has the responsability of translate a Block class in a humam # name By default the class "MainBlock" has the human name "Main Block". # Other classes defined by user are not going to display in a human name - # format until de method flexible_template_block_dict be redefined in a + # format until de method design_editor_block_dict be redefined in a # controller by user # #TODO define the method - # flexible_template_block_dict if not defined by helper - # if !self.public_instance_methods.include? "flexible_template_block_dict" - # define_method('flexible_template_block_dict') do |str| + # design_editor_block_dict if not defined by helper + # if !self.public_instance_methods.include? "design_editor_block_dict" + # define_method('design_editor_block_dict') do |str| # { # 'MainBlock' => _("Main Block") # }[str] || str @@ -56,7 +56,7 @@ module Design # FIXME: WTF? - def flexible_template_block_helper_dict(str) + def design_editor_block_helper_dict(str) { 'plain_content' => _('Plain Content') , 'list_content' => _('List Content') @@ -158,19 +158,19 @@ module Design def link_to_active_sort(box) link_to_remote(_('Sort'), - {:update => "sort_#{box.number}", :url => {:action => 'flexible_template_set_sort_mode', :box_id => box.id }}, + {:update => "sort_#{box.number}", :url => {:action => 'design_editor_set_sort_mode', :box_id => box.id }}, :class => 'sort_button') end def link_to_add_block(box) link_to_remote(_('Add Block'), - {:update => "sort_#{box.number}", :url => {:action => 'flexible_template_new_block', :box_id => box.id }}, + {:update => "sort_#{box.number}", :url => {:action => 'design_editor_new_block', :box_id => box.id }}, :class => 'add_block_button') end def link_to_destroy_block(block) link_to_remote(_('Remove'), - {:update => "sort_#{block.box.number}", :url => {:action => 'flexible_template_destroy_block', :block_id => block.id }}, + {:update => "sort_#{block.box.number}", :url => {:action => 'design_editor_destroy_block', :block_id => block.id }}, :class => 'destroy_block_button') end @@ -178,7 +178,7 @@ module Design # Allows the biven box to have sortable elements def sortable_block(box_number) sortable_element "sort_#{box_number}", - :url => {:action => 'flexible_template_sort_box', :box_number => box_number }, + :url => {:action => 'design_editor_sort_box', :box_number => box_number }, :complete => visual_effect(:highlight, "sort_#{box_number}") end @@ -198,7 +198,7 @@ module Design :before => "$('spinner').show();", :hoverclass => 'hover', :with => "'block=' + encodeURIComponent(element.id.split('_').last())", - :url => {:action=>:flexible_template_change_box, :box_id => box.id}) + :url => {:action=>:design_editor_change_box, :box_id => box.id}) }.to_s end @@ -223,7 +223,7 @@ module Design h end - def new_block_form(box) + def design_editor_new_block_form(box) type_block_options = options_for_select(available_blocks.collect{|k,v| [v,k] }) type_block_helper_options = options_for_select(block_helpers.collect{|k,v| [v,k] }) @block = Block.new @@ -231,7 +231,7 @@ module Design _("Adding block on %s") % box.name + [ - form_remote_tag(:url => {:action => 'flexible_template_create_block'}, :update => "sort_#{box.number}"), + form_remote_tag(:url => {:action => 'design_editor_create_block'}, :update => "sort_#{box.number}"), hidden_field('block', 'box_id'), content_tag( :p, -- libgit2 0.21.2