Commit f1ae8d3af8d7c18dc1256e1d762518e646c3f9b2
1 parent
32dfc0b8
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
comment_paragraph: add plugin config page
Showing
4 changed files
with
65 additions
and
1 deletions
Show diff stats
plugins/comment_paragraph/controllers/comment_paragraph_plugin_admin_controller.rb
0 → 100644
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +class CommentParagraphPluginAdminController < AdminController | ||
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../views') | ||
3 | + | ||
4 | + def index | ||
5 | + @settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin, params[:settings]) | ||
6 | + @article_types = [] | ||
7 | + available_article_types.each do |type| | ||
8 | + @article_types.push({ | ||
9 | + :class_name => type.name, | ||
10 | + :short_description => type.short_description, | ||
11 | + :description => type.description | ||
12 | + }) | ||
13 | + end | ||
14 | + | ||
15 | + if request.post? | ||
16 | + @settings.save! | ||
17 | + redirect_to :controller => 'plugins', :action => 'index' | ||
18 | + end | ||
19 | + end | ||
20 | + | ||
21 | + protected | ||
22 | + | ||
23 | + def available_article_types | ||
24 | + articles = [TinyMceArticle, TextileArticle] + @plugins.dispatch(:content_types) | ||
25 | + articles | ||
26 | + end | ||
27 | + | ||
28 | +end |
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
@@ -42,7 +42,10 @@ class CommentParagraphPlugin < Noosfero::Plugin | @@ -42,7 +42,10 @@ class CommentParagraphPlugin < Noosfero::Plugin | ||
42 | def cms_controller_filters | 42 | def cms_controller_filters |
43 | block = proc do | 43 | block = proc do |
44 | if params['commit'] == 'Save' | 44 | if params['commit'] == 'Save' |
45 | - unless @article.id.blank? | 45 | + |
46 | + settings = Noosfero::Plugin::Settings.new(environment, CommentParagraphPlugin, params[:settings]) | ||
47 | + | ||
48 | + if !@article.id.blank? && CommentParagraphPlugin::CommentParagraphHelper.auto_marking_enabled?(settings, @article.class.name) | ||
46 | 49 | ||
47 | parsed_paragraphs = [] | 50 | parsed_paragraphs = [] |
48 | paragraph_id = 0 | 51 | paragraph_id = 0 |
plugins/comment_paragraph/lib/comment_paragraph_plugin/comment_paragraph_helper.rb
0 → 100644
@@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
1 | +module CommentParagraphPlugin::CommentParagraphHelper | ||
2 | + | ||
3 | + def self.auto_marking_enabled?(plugin_settings, article_type) | ||
4 | + auto_marking_setting = plugin_settings.get_setting('article_types_with_auto_marking') | ||
5 | + auto_marking_setting.include?(article_type) ? true : false | ||
6 | + end | ||
7 | + | ||
8 | +end |
plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb
0 → 100644
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +<h1><%= _("Comment paragraph plugin settings") %></h1> | ||
2 | + | ||
3 | +<%= form_for(:settings) do |f| %> | ||
4 | + | ||
5 | +<table> | ||
6 | + <tr> | ||
7 | + <th> </th> | ||
8 | + <th align="left"><%= _('Article type') %></th> | ||
9 | + <th align="left"><%= _('Article type description') %></th> | ||
10 | + </tr> | ||
11 | + <% @article_types.each do |type| %> | ||
12 | + <tr> | ||
13 | + <td><%= check_box_tag 'settings[article_types_with_auto_marking][]', type[:class_name], CommentParagraphPlugin::CommentParagraphHelper.auto_marking_enabled?(@settings, type[:class_name]) %></td> | ||
14 | + <td><%= _(type[:class_name]) %></td> | ||
15 | + <td><%= _(type[:short_description]) %></td> | ||
16 | + </tr> | ||
17 | + <% end %> | ||
18 | +</table> | ||
19 | + | ||
20 | + | ||
21 | + <% button_bar do %> | ||
22 | + <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> | ||
23 | + <% end %> | ||
24 | + | ||
25 | +<% end %> |