diff --git a/plugins/comment_paragraph/controllers/comment_paragraph_plugin_admin_controller.rb b/plugins/comment_paragraph/controllers/comment_paragraph_plugin_admin_controller.rb new file mode 100644 index 0000000..d768af6 --- /dev/null +++ b/plugins/comment_paragraph/controllers/comment_paragraph_plugin_admin_controller.rb @@ -0,0 +1,28 @@ +class CommentParagraphPluginAdminController < AdminController + append_view_path File.join(File.dirname(__FILE__) + '/../views') + + def index + @settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin, params[:settings]) + @article_types = [] + available_article_types.each do |type| + @article_types.push({ + :class_name => type.name, + :short_description => type.short_description, + :description => type.description + }) + end + + if request.post? + @settings.save! + redirect_to :controller => 'plugins', :action => 'index' + end + end + + protected + + def available_article_types + articles = [TinyMceArticle, TextileArticle] + @plugins.dispatch(:content_types) + articles + end + +end diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb index 252debc..0c927ba 100644 --- a/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin.rb @@ -42,7 +42,10 @@ class CommentParagraphPlugin < Noosfero::Plugin def cms_controller_filters block = proc do if params['commit'] == 'Save' - unless @article.id.blank? + + settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin, params[:settings]) + + if !@article.id.blank? && CommentParagraphPlugin::CommentParagraphHelper.auto_marking_enabled?(settings, @article.class.name) parsed_paragraphs = [] paragraph_id = 0 diff --git a/plugins/comment_paragraph/lib/comment_paragraph_plugin/comment_paragraph_helper.rb b/plugins/comment_paragraph/lib/comment_paragraph_plugin/comment_paragraph_helper.rb new file mode 100644 index 0000000..7fce74e --- /dev/null +++ b/plugins/comment_paragraph/lib/comment_paragraph_plugin/comment_paragraph_helper.rb @@ -0,0 +1,8 @@ +module CommentParagraphPlugin::CommentParagraphHelper + + def self.auto_marking_enabled?(plugin_settings, article_type) + auto_marking_setting = plugin_settings.get_setting('article_types_with_auto_marking') + auto_marking_setting.include?(article_type) ? true : false + end + +end diff --git a/plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb b/plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb new file mode 100644 index 0000000..30f3300 --- /dev/null +++ b/plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb @@ -0,0 +1,25 @@ +

<%= _("Comment paragraph plugin settings") %>

+ +<%= form_for(:settings) do |f| %> + + + + + + + + <% @article_types.each do |type| %> + + + + + + <% end %> +
 <%= _('Article type') %><%= _('Article type description') %>
<%= check_box_tag 'settings[article_types_with_auto_marking][]', type[:class_name], CommentParagraphPlugin::CommentParagraphHelper.auto_marking_enabled?(@settings, type[:class_name]) %><%= _(type[:class_name]) %><%= _(type[:short_description]) %>
+ + + <% button_bar do %> + <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> + <% end %> + +<% end %> -- libgit2 0.21.2