diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 29c001d..81c1b60 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -149,7 +149,6 @@ class CmsController < MyProfileController @uploaded_files = [] @article = @parent = check_parent(params[:parent_id]) @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier - @folders = Folder.find(:all, :conditions => { :profile_id => profile }) if @article record_coming end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e5324e0..5108850 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -664,19 +664,6 @@ module ApplicationHelper content_tag('div', result) end - def select_folder(label, object, method, collection, html_options = {}, js_options = {}) - root = profile ? profile.identifier : _("root") - labelled_form_field(label, select(object, method, - collection.map {|f| [ root + '/' + f.full_name, f.id ]}, - {:include_blank => root}, html_options.merge(js_options))) - end - - def select_profile_folder(label, object, method, profile, html_options = {}, js_options = {}) - labelled_form_field(label, select(object, method, - profile.folders.map {|f| [ profile.identifier + '/' + f.full_name, f.id ]}, - {:include_blank => profile.identifier}, html_options.merge(js_options))) - end - def theme_option(opt = nil) conf = RAILS_ROOT.to_s() + '/public' + theme_path + diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index 3f7724c..2c53a03 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -123,6 +123,38 @@ module FormsHelper options_for_select.join("\n") end + def select_folder(label_text, field_id, collection, default_value=nil, html_options = {}, js_options = {}) + root = profile ? profile.identifier : _("root") + labelled_form_field( + label_text, + select_tag( + field_id, + options_for_select( + [[root, '']] + + collection.collect {|f| [ root + '/' + f.full_name, f.id ] }, + default_value + ), + html_options.merge(js_options) + ) + ) + end + + def select_profile_folder(label_text, field_id, profile, default_value='', html_options = {}, js_options = {}) + result = labelled_form_field( + label_text, + select_tag( + field_id, + options_for_select( + [[profile.identifier, '']] + + profile.folders.collect {|f| [ profile.identifier + '/' + f.full_name, f.id ] }, + default_value + ), + html_options.merge(js_options) + ) + ) + return result + end + protected def self.next_id_number if defined? @@id_num diff --git a/app/views/cms/_general_fields.html.erb b/app/views/cms/_general_fields.html.erb index 3644994..95212d4 100644 --- a/app/views/cms/_general_fields.html.erb +++ b/app/views/cms/_general_fields.html.erb @@ -1 +1,2 @@ +<%= select_profile_folder(_('Parent folder:'), 'article[parent_id]', profile, @article.parent_id) %> <%= labelled_form_field(_('License'), select(:article, :license_id, options_for_select_with_title([[_('None'), nil]] + profile.environment.licenses.map {|license| [license.name, license.id]}, @article.license ? @article.license.id : nil))) %> diff --git a/app/views/cms/_text_editor_sidebar.rhtml b/app/views/cms/_text_editor_sidebar.rhtml index f04d727..e67dc5a 100644 --- a/app/views/cms/_text_editor_sidebar.rhtml +++ b/app/views/cms/_text_editor_sidebar.rhtml @@ -9,8 +9,7 @@
<%= file_field_tag('file1') %>
<%= file_field_tag('file2') %>
diff --git a/app/views/cms/_upload_file_form.rhtml b/app/views/cms/_upload_file_form.rhtml index c5033c1..0786dc4 100644 --- a/app/views/cms/_upload_file_form.rhtml +++ b/app/views/cms/_upload_file_form.rhtml @@ -1,7 +1,7 @@ <% if @parent %> <%= hidden_field_tag('parent_id', @parent.id) %> <% else %> - <%= labelled_form_field(_('Choose folder to upload files:'), select_tag('parent_id', options_for_select([[profile.identifier, '']] + @folders.collect {|f| [ profile.identifier + '/' + f.full_name, f.id ] }))) %> + <%= select_profile_folder(_('Choose folder to upload files:'), :parent_id, profile) %> <% end %>