camaleon_cms 2.1.2.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -4
  3. data/app/apps/plugins/attack/attack_helper.rb +3 -0
  4. data/app/apps/plugins/attack/config/custom_models.rb +4 -2
  5. data/app/apps/plugins/attack/config/locales/translation.yml +19 -0
  6. data/app/apps/plugins/attack/models/attack.rb +1 -1
  7. data/app/apps/plugins/front_cache/config/initializer.rb +4 -2
  8. data/app/apps/plugins/front_cache/config/locales/translation.yml +19 -0
  9. data/app/apps/themes/camaleon_first/main_helper.rb +1 -3
  10. data/app/apps/themes/default/views/admin/settings.html.erb +0 -1
  11. data/app/apps/themes/default/views/layouts/index.html.erb +5 -5
  12. data/app/apps/themes/new/assets/css/main.css +1 -1
  13. data/app/apps/themes/new/assets/js/main.js +1 -1
  14. data/app/apps/themes/new/views/admin/settings.html.erb +1 -1
  15. data/app/assets/images/camaleon_cms/language/{pt_br.png → pt-BR.png} +0 -0
  16. data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +105 -51
  17. data/app/assets/javascripts/camaleon_cms/admin/_libraries.js +4 -2
  18. data/app/assets/javascripts/camaleon_cms/admin/_translator.js +2 -2
  19. data/app/assets/javascripts/camaleon_cms/admin/custom_fields_form.js +9 -7
  20. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/{pt_br.js → pt-BR.js} +0 -0
  21. data/app/assets/javascripts/camaleon_cms/admin/momentjs/{pt_br.js → pt-BR.js} +1 -1
  22. data/app/assets/javascripts/camaleon_cms/admin/nav_menu.js.coffee +15 -1
  23. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/{pt_br.js → pt-BR.js} +1 -1
  24. data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +24 -12
  25. data/app/assets/stylesheets/camaleon_cms/admin/_custom_admin.css.scss +9 -0
  26. data/app/assets/stylesheets/camaleon_cms/admin/lte/_admin.css.scss +1 -1
  27. data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +13 -6
  28. data/app/controllers/camaleon_cms/admin/appearances/themes_controller.rb +1 -1
  29. data/app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb +1 -1
  30. data/app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb +1 -1
  31. data/app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb +1 -1
  32. data/app/controllers/camaleon_cms/admin/comments_controller.rb +1 -1
  33. data/app/controllers/camaleon_cms/admin/media_controller.rb +15 -5
  34. data/app/controllers/camaleon_cms/admin/plugins_controller.rb +1 -1
  35. data/app/controllers/camaleon_cms/admin/settings/custom_fields_controller.rb +14 -8
  36. data/app/controllers/camaleon_cms/admin/settings_controller.rb +22 -7
  37. data/app/controllers/camaleon_cms/admin/user_roles_controller.rb +1 -1
  38. data/app/controllers/camaleon_cms/admin/users_controller.rb +1 -1
  39. data/app/controllers/camaleon_cms/apps/plugins_admin_controller.rb +4 -1
  40. data/app/controllers/camaleon_cms/apps/plugins_front_controller.rb +5 -10
  41. data/app/controllers/camaleon_cms/apps/themes_front_controller.rb +1 -4
  42. data/app/controllers/camaleon_cms/camaleon_controller.rb +4 -13
  43. data/app/controllers/camaleon_cms/frontend_controller.rb +15 -9
  44. data/app/controllers/concerns/camaleon_cms/frontend_concern.rb +17 -8
  45. data/app/decorators/camaleon_cms/application_decorator.rb +3 -3
  46. data/app/decorators/camaleon_cms/custom_fields_concern.rb +21 -6
  47. data/app/decorators/camaleon_cms/post_comment_decorator.rb +21 -0
  48. data/app/decorators/camaleon_cms/site_decorator.rb +5 -5
  49. data/app/decorators/camaleon_cms/theme_decorator.rb +10 -0
  50. data/app/decorators/camaleon_cms/user_decorator.rb +2 -2
  51. data/app/helpers/camaleon_cms/admin/custom_fields_helper.rb +24 -2
  52. data/app/helpers/camaleon_cms/admin/menus_helper.rb +13 -12
  53. data/app/helpers/camaleon_cms/frontend/application_helper.rb +1 -1
  54. data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +7 -6
  55. data/app/helpers/camaleon_cms/plugins_helper.rb +20 -18
  56. data/app/helpers/camaleon_cms/site_helper.rb +1 -20
  57. data/app/helpers/camaleon_cms/theme_helper.rb +1 -1
  58. data/app/helpers/camaleon_cms/uploader_helper.rb +25 -20
  59. data/app/helpers/camaleon_cms/user_roles_helper.rb +6 -1
  60. data/app/mailers/camaleon_cms/html_mailer.rb +2 -1
  61. data/app/models/camaleon_cms/ability.rb +3 -26
  62. data/app/models/camaleon_cms/custom_field.rb +2 -1
  63. data/app/models/camaleon_cms/custom_field_group.rb +23 -22
  64. data/app/models/camaleon_cms/custom_fields_relationship.rb +1 -1
  65. data/app/models/camaleon_cms/nav_menu.rb +1 -1
  66. data/app/models/camaleon_cms/nav_menu_item.rb +12 -19
  67. data/app/models/camaleon_cms/post.rb +1 -1
  68. data/app/models/camaleon_cms/post_comment.rb +3 -1
  69. data/app/models/camaleon_cms/post_default.rb +1 -1
  70. data/app/models/camaleon_cms/post_type.rb +5 -4
  71. data/app/models/camaleon_cms/site.rb +12 -0
  72. data/app/models/camaleon_cms/term_taxonomy.rb +1 -1
  73. data/app/models/camaleon_cms/user_role.rb +5 -1
  74. data/app/models/concerns/camaleon_cms/custom_fields_read.rb +99 -49
  75. data/app/uploaders/camaleon_cms_aws_uploader.rb +1 -1
  76. data/app/uploaders/camaleon_cms_local_uploader.rb +19 -3
  77. data/app/uploaders/camaleon_cms_uploader.rb +13 -6
  78. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_menus.html.erb +9 -2
  79. data/app/views/camaleon_cms/admin/appearances/nav_menus/_form.html.erb +1 -1
  80. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items.html.erb +2 -2
  81. data/app/views/camaleon_cms/admin/appearances/themes/index.html.erb +1 -3
  82. data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +1 -0
  83. data/app/views/camaleon_cms/admin/media/index.html.erb +3 -3
  84. data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +1 -1
  85. data/app/views/camaleon_cms/admin/posts/form.html.erb +1 -1
  86. data/app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb +4 -0
  87. data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +6 -6
  88. data/app/views/camaleon_cms/admin/settings/custom_fields/_meta_data.html.erb +0 -9
  89. data/app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb +39 -55
  90. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_audio.html.erb +1 -1
  91. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkbox.html.erb +2 -2
  92. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkboxes.html.erb +3 -3
  93. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_colorpicker.html.erb +3 -3
  94. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_date.html.erb +3 -3
  95. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_editor.html.erb +2 -2
  96. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_email.html.erb +1 -1
  97. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_field_attrs.html.erb +3 -3
  98. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_file.html.erb +1 -1
  99. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_image.html.erb +2 -2
  100. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_numeric.html.erb +1 -1
  101. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_phone.html.erb +1 -1
  102. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_posts.html.erb +3 -3
  103. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_private_file.html.erb +4 -0
  104. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_radio.html.erb +3 -3
  105. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_select.html.erb +3 -3
  106. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_select_eval.html.erb +1 -1
  107. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_text_area.html.erb +2 -2
  108. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_text_box.html.erb +2 -2
  109. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_url.html.erb +1 -1
  110. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_users.html.erb +1 -1
  111. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_video.html.erb +1 -1
  112. data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +8 -0
  113. data/app/views/camaleon_cms/admin/settings/site.html.erb +1 -20
  114. data/app/views/camaleon_cms/admin/settings/theme.html.erb +20 -0
  115. data/app/views/camaleon_cms/admin/user_roles/form.html.erb +2 -2
  116. data/app/views/camaleon_cms/default_theme/admin/settings.html.erb +0 -1
  117. data/app/views/camaleon_cms/default_theme/partials/_comments.html.erb +0 -2
  118. data/app/views/camaleon_cms/default_theme/partials/_search_form.html.erb +1 -1
  119. data/app/views/camaleon_cms/default_theme/partials/_sidebar.html.erb +3 -3
  120. data/app/views/layouts/camaleon_cms/admin/_footer.html.erb +1 -1
  121. data/config/initializers/action_view.rb +12 -7
  122. data/config/initializers/custom_initializers.rb +6 -12
  123. data/config/locales/camaleon_cms/admin/en.yml +1 -0
  124. data/config/locales/camaleon_cms/admin/es.yml +4 -0
  125. data/config/locales/camaleon_cms/admin/it.yml +1 -24
  126. data/config/locales/camaleon_cms/admin/js.yml +41 -0
  127. data/config/locales/camaleon_cms/admin/{pt_br.yml → pt-BR.yml} +48 -18
  128. data/config/locales/camaleon_cms/common.yml +66 -0
  129. data/config/locales/camaleon_cms/languages.yml +13 -0
  130. data/config/locales/camaleon_cms/routes.yml +2 -2
  131. data/config/routes/admin.rb +3 -0
  132. data/config/system.json +3 -3
  133. data/db/migrate/20160606135421_improve_menus_structure.rb +7 -0
  134. data/db/migrate/20160609121449_add_group_to_custom_field_values.rb +5 -0
  135. data/lib/camaleon_cms/engine.rb +4 -3
  136. data/lib/camaleon_cms/version.rb +1 -1
  137. data/lib/ext/string.rb +20 -0
  138. data/lib/ext/translator.rb +2 -2
  139. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +1 -1
  140. data/lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json +1 -1
  141. data/lib/generators/camaleon_cms/install_generator.rb +1 -0
  142. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/main_helper.rb +1 -4
  143. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/index.html.erb +1 -25
  144. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/layouts/index.html.erb +17 -18
  145. data/lib/plugin_routes.rb +4 -4
  146. metadata +25 -48
  147. data/app/apps/plugins/contact_form/admin_forms_controller.rb +0 -85
  148. data/app/apps/plugins/contact_form/assets/css/admin/form-builder/formbuilder.css +0 -70
  149. data/app/apps/plugins/contact_form/assets/css/contact-form.css +0 -8
  150. data/app/apps/plugins/contact_form/assets/css/front/railsform.scss +0 -94
  151. data/app/apps/plugins/contact_form/assets/css/readme.txt +0 -1
  152. data/app/apps/plugins/contact_form/assets/js/contact_form.js +0 -2
  153. data/app/apps/plugins/contact_form/assets/js/form-builder/formbuilder.js +0 -1271
  154. data/app/apps/plugins/contact_form/assets/js/form-builder/vendor.js +0 -3072
  155. data/app/apps/plugins/contact_form/assets/js/readme.txt +0 -1
  156. data/app/apps/plugins/contact_form/config/config.json +0 -35
  157. data/app/apps/plugins/contact_form/config/custom_models.rb +0 -3
  158. data/app/apps/plugins/contact_form/config/locales/readme.txt +0 -1
  159. data/app/apps/plugins/contact_form/config/locales/translation.yml +0 -315
  160. data/app/apps/plugins/contact_form/config/routes_admin.txt +0 -4
  161. data/app/apps/plugins/contact_form/config/routes_front.txt +0 -2
  162. data/app/apps/plugins/contact_form/contact_form_helper.rb +0 -154
  163. data/app/apps/plugins/contact_form/contact_form_html_helper.rb +0 -140
  164. data/app/apps/plugins/contact_form/front_controller.rb +0 -50
  165. data/app/apps/plugins/contact_form/models/contact_form.rb +0 -26
  166. data/app/apps/plugins/contact_form/views/admin_forms/_form.html.erb +0 -33
  167. data/app/apps/plugins/contact_form/views/admin_forms/edit.html.erb +0 -338
  168. data/app/apps/plugins/contact_form/views/admin_forms/index.html.erb +0 -65
  169. data/app/apps/plugins/contact_form/views/admin_forms/responses.html.erb +0 -60
  170. data/app/apps/plugins/contact_form/views/contact_form/_email_content.html.erb +0 -26
  171. data/app/apps/plugins/contact_form/views/forms_shorcode.html.erb +0 -28
  172. data/app/apps/plugins/contact_form/views/front/index.html.erb +0 -3
  173. data/app/apps/themes/camaleon_first/views/admin/settings.html.erb +0 -4
  174. data/app/apps/themes/new/assets/css/bootstrap/bootstrap.min.css +0 -6735
  175. data/app/apps/themes/new/assets/js/plugins/bootstrap/bootstrap.min.js +0 -6
  176. data/app/apps/themes/new/assets/js/plugins/jquery/jquery.min.js +0 -4
  177. data/lib/generators/camaleon_cms/gem_theme_generator.rb +0 -97
  178. data/lib/generators/camaleon_cms/gem_theme_template/app/assets/images/themes/my_plugin/image.png +0 -0
  179. data/lib/generators/camaleon_cms/gem_theme_template/app/assets/javascripts/themes/my_plugin/main.js +0 -14
  180. data/lib/generators/camaleon_cms/gem_theme_template/app/assets/stylesheets/themes/my_plugin/main.css +0 -13
  181. data/lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb +0 -26
  182. data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/admin/settings.html.erb +0 -4
  183. data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/index.html.erb +0 -25
  184. data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/layouts/index.html.erb +0 -70
  185. data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/partials/readme.txt +0 -1
  186. data/lib/generators/camaleon_cms/gem_theme_template/config/camaleon_theme.json +0 -14
@@ -1,140 +0,0 @@
1
- =begin
2
- Camaleon CMS is a content management system
3
- Copyright (C) 2015 by Owen Peredo Diaz
4
- Email: owenperedo@gmail.com
5
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
- See the GNU Affero General Public License (GPLv3) for more details.
8
- =end
9
- module Plugins::ContactForm::ContactFormHtmlHelper
10
-
11
- # This allows calls to methods plugin from html views
12
- def self.included(klass)
13
- klass.helper_method [:form_element_object, :form_element_bootstrap_object, :form_shortcode, :get_forms, :form_value_rescue] rescue ""
14
- end
15
-
16
- # This returns the format of the plugin shortcode.
17
- def form_shortcode(slug)
18
- "[forms slug=#{slug}]"
19
- end
20
-
21
- # This returns all the answers on a form made from the frontend.
22
- def get_forms(id)
23
- current_site.contact_forms.where({parent_id: id})
24
- end
25
-
26
- def form_value_rescue(form)
27
- JSON.parse(form.settings).to_sym rescue form.value
28
- end
29
-
30
- # form contact with css bootstrap
31
- def form_element_bootstrap_object(form, object, values)
32
- html = ""
33
-
34
- object.each do |ob|
35
- temp = "<div class='form-group'>
36
- <label>[label ci]</span></label>
37
- #{'<p>[descr ci]</p>' if ob[:field_options][:description].present?}
38
- <div>[ci]</div>
39
- </div>"
40
-
41
- r = {field: ob, form: form, template: temp, custom_class: "form-control #{ob[:field_options][:field_class]}", custom_attrs: {id: ob[:cid] } }
42
- hooks_run("contact_form_item_render", r)
43
- ob = r[:field]
44
- ob[:custom_class] = r[:custom_class]
45
- ob[:custom_attrs] = r[:custom_attrs]
46
- field_options = ob[:field_options]
47
- for_name = ob[:label].to_s
48
- f_name = "fields[#{ob[:cid]}]"
49
- cid = ob[:cid].to_sym
50
-
51
- temp2 = ""
52
-
53
- case ob[:field_type].to_s
54
- when 'paragraph','textarea'
55
- temp2 = "<textarea #{ob[:custom_attrs].to_attr_format} name=\"#{f_name}\" maxlength=\"#{field_options[:maxlength] || 500 }\" class=\"#{ob[:custom_class]} \">#{values[cid]}</textarea>"
56
- when 'radio'
57
- temp2= form_select_multiple_bootstrap(ob, ob[:label], ob[:field_type],values)
58
- when 'checkboxes'
59
- temp2= form_select_multiple_bootstrap(ob, ob[:label], "checkbox",values)
60
- when 'text', 'website', 'email'
61
- class_type = ""
62
- class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="website"
63
- class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="email"
64
- temp2 = "<input #{ob[:custom_attrs].to_attr_format} type=\"#{ob[:field_type]}\" value=\"#{values[cid]}\" name=\"#{f_name}\" class=\"#{ob[:custom_class]} #{class_type}\">"
65
- when 'captcha'
66
- temp2 = cama_captcha_tag(5, {}, {class: "#{ob[:custom_class]} field-captcha required"}.merge(ob[:custom_attrs]))
67
- when 'file'
68
- class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="website"
69
- temp2 = "<input multiple=\"multiple\" type=\"file\" value=\"\" name=\"#{f_name}\" #{ob[:custom_attrs].to_attr_format} class=\"#{class_type} #{ob[:custom_class]}\">"
70
- when 'dropdown'
71
- temp2 = form_select_multiple_bootstrap(ob, ob[:label], "select",values)
72
- else
73
- end
74
- r[:template] = r[:template].sub('[label ci]', for_name).sub('[ci]', temp2)
75
- r[:template] = r[:template].sub('[descr ci]', field_options[:description] || "")
76
- html += r[:template]
77
- end
78
- html
79
- end
80
-
81
- def form_select_multiple_bootstrap(ob, title, type, values)
82
- options = ob[:field_options][:options]
83
- include_other_option = ob[:field_options][:include_other_option]
84
- other_input = ""
85
-
86
- f_name = "fields[#{ob[:cid]}]"
87
- f_label = ""
88
- cid = ob[:cid].to_sym
89
- html = ""
90
-
91
- if type == "radio" || type == "checkbox"
92
-
93
- other_input = (include_other_option)? "<div class=\"#{type} #{ob[:custom_class]}\"> <label for=\"#{ob[:cid]}\"><input id=\"#{ob[:cid]}-other\" type=\"#{type}\" name=\"#{title.downcase}[]\" class=\"\">Other <input type=\"text\" /></label></div>" : " "
94
-
95
- else
96
- html = "<select #{ob[:custom_attrs].to_attr_format} name=\"#{f_name}\" class=\"#{ob[:custom_class]}\">"
97
- end
98
-
99
- options.each do |op|
100
- if type == "radio" || type == "checkbox"
101
- html += "<div class=\"#{type} #{ob[:custom_class]}\">
102
- <label for=\"#{ob[:cid]}\">
103
- <input #{ob[:custom_attrs].to_attr_format} type=\"#{type}\" name=\"#{f_name}[]\" class=\"\" value=\"#{op[:label].downcase}\">
104
- #{op[:label]}
105
- </label>
106
- </div>"
107
- else
108
- html += "<option value=\"#{op[:label].downcase.gsub(" ", "_")}\" #{"selected" if "#{op[:label].downcase.gsub(" ", "_")}" == values[cid]} >#{op[:label]}</option>"
109
- end
110
- end
111
-
112
- if type == "radio" || type == "checkbox"
113
- html += other_input
114
- else
115
- html += " </select>"
116
- end
117
- end
118
-
119
- def convert_form_values(op_fields, fields)
120
- values = {}
121
-
122
- op_fields.each do |field|
123
- cid = field[:cid].to_sym
124
- label = field[:label]
125
-
126
- values[label] = []
127
-
128
- if field[:field_type] == 'file'
129
- values[label] << fields[cid].original_filename if fields[cid].present?
130
- elsif field[:field_type] == 'captcha'
131
- values[label] << '--'
132
- elsif field[:field_type] == 'radio' || field[:field_type] == 'checkboxes'
133
- values[label] << fields[cid].join(',') if fields[cid].present?
134
- else
135
- values[label] << fields[cid] if fields[cid].present?
136
- end
137
- end
138
- return values
139
- end
140
- end
@@ -1,50 +0,0 @@
1
- =begin
2
- Camaleon CMS is a content management system
3
- Copyright (C) 2015 by Owen Peredo Diaz
4
- Email: owenperedo@gmail.com
5
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
- See the GNU Affero General Public License (GPLv3) for more details.
8
- =end
9
- class Plugins::ContactForm::FrontController < CamaleonCms::Apps::PluginsFrontController
10
- before_filter :append_view_paths
11
-
12
- def index
13
- # here your actions for frontend module
14
- end
15
-
16
- # here add your custom functions
17
- def save_form
18
- @form = current_site.contact_forms.find_by_id(params[:id])
19
- values = JSON.parse(@form.value).to_sym
20
- settings = JSON.parse(@form.settings).to_sym
21
- fields = params[:fields]
22
- errors = []
23
- success = []
24
-
25
- perform_save_form(@form, values, fields, settings, success, errors)
26
- if success.present?
27
- flash[:notice] = success.join('<br>')
28
- else
29
- flash[:error] = errors.join('<br>')
30
- flash[:values] = fields
31
- end
32
-
33
- redirect_to :back
34
- end
35
-
36
- private
37
-
38
- def append_view_paths
39
- append_view_path File.join($camaleon_engine_dir, 'app', 'apps', 'plugins', self_plugin_key, 'views')
40
- end
41
-
42
- def fix_meta_value(value)
43
- if value.is_a?(Array) || value.is_a?(Hash)
44
- value = value.to_json
45
- elsif value.is_a?(String)
46
- value = value.to_var
47
- end
48
- value
49
- end
50
- end
@@ -1,26 +0,0 @@
1
- =begin
2
- Camaleon CMS is a content management system
3
- Copyright (C) 2015 by Owen Peredo Diaz
4
- Email: owenperedo@gmail.com
5
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
- See the GNU Affero General Public License (GPLv3) for more details.
8
- =end
9
- class Plugins::ContactForm::Models::ContactForm < ActiveRecord::Base
10
- attr_accessible :site_id, :name, :description, :count, :slug, :value, :settings, :parent_id
11
-
12
- belongs_to :site, class_name: "Site", foreign_key: :site_id
13
- belongs_to :post, class_name: "Post", foreign_key: :parent_id
14
- has_many :responses, :class_name => "Plugins::ContactForm::Models::ContactForm", :foreign_key => :parent_id, dependent: :destroy
15
- validates :name, presence: true
16
- validates_uniqueness_of :slug, scope: :site_id
17
-
18
- before_validation :before_validating
19
-
20
- private
21
- def before_validating
22
- slug = self.slug
23
- slug = self.name if slug.blank?
24
- self.slug = slug.to_s.parameterize
25
- end
26
- end
@@ -1,33 +0,0 @@
1
- <%
2
- if @form.nil?
3
- @form = current_site.contact_forms.new
4
- end
5
- %>
6
- <%= form_for @form, url:{action: @form.new_record? ? :create : :update}, html:{class: 'validate-forms cama_ajax_request'} do |f| %>
7
- <input id="plugins_contact_form_models_contact_form_site_id" type="hidden" name="plugins_contact_form_models_contact_form[site_id]" value="<%= current_site.id %>" />
8
-
9
- <%= f.hidden_field :id %>
10
- <div class="panel-body">
11
- <%#= render partial: 'layouts/camaleon_cms/admin/form_error', locals: {data: @form} %>
12
- <div class="form-group">
13
- <%= f.label t('camaleon_cms.admin.table.name') %><br>
14
- <%= f.text_field :name, :class => "form-control required" %>
15
- </div>
16
- <div class="form-group">
17
- <%= f.label t('camaleon_cms.admin.table.slug') %><br>
18
- <%= f.text_field :slug, :class => "form-control slug", "data-parent" => "plugins_contact_form_models_contact_form_name" %>
19
- </div>
20
-
21
- <div class="form-group">
22
- <%= f.label t('camaleon_cms.admin.table.description') %><br>
23
- <%= f.text_area :description, :class => "form-control", :rows => 4 %>
24
- </div>
25
-
26
- </div>
27
-
28
- <div class="panel-footer">
29
- <a class="btn btn-default" href="<%= url_for action: :index %>" role="back" ><%= t('plugin.contact_form.button.back') %></a>
30
- <button class="btn btn-primary pull-right" type="submit"><%= t('plugin.contact_form.button.submit') %></button>
31
- </div>
32
- <% end %>
33
-
@@ -1,338 +0,0 @@
1
- <% @form = current_site.contact_forms.new if @form.nil? %>
2
- <div class="page-title">
3
- <h2><span class="fa fa-folder"></span> <%= t('plugin.contact_form.contact_form') %> - <%= @form.name %></h2>
4
- </div>
5
- <div class="page-content-wrap">
6
-
7
- <div class="row">
8
- <div class="col-md-12">
9
- <div class="panel panel-default">
10
-
11
- <%= form_for @form, url:{action: @form.new_record? ? :create : :update} , role: 'form', html: { id: "contact_form_editor", class: "validate" } do |f| %>
12
- <%= f.hidden_field :site_id %>
13
- <%= f.hidden_field :id %>
14
- <input id="meta_forms" type="hidden" name="meta" />
15
-
16
- <div class="panel-heading">
17
- <div class="row">
18
- <div class="col-md-6">
19
- <br>
20
- <label><%= t('plugin.contact_form.copy_shortcode_post')%> </label>
21
- <%= raw cama_shortcode_print(form_shortcode(@form.slug)) %>
22
-
23
- </div>
24
- <div class="col-md-6 text-right">
25
- <a class="btn btn-default" href="<%= url_for action: :index %>"><%= t('plugin.contact_form.button.back') %></a>
26
- <button class="btn btn-primary" type="submit"><%= t('plugin.contact_form.button.submit') %></button>
27
- </div>
28
- </div>
29
- </div>
30
-
31
- <div class="panel-body">
32
- <%= render partial: 'layouts/camaleon_cms/admin/form_error', locals: {data: @form} %>
33
- <div class="row">
34
- <div class="code hidden"></div>
35
- </div>
36
- <div class="row">
37
- <div class="col-md-4" style="overflow: hidden">
38
-
39
- <div class="panel panel-default">
40
- <div class="panel-heading">
41
- <h3 class="panel-title"><%= t('plugin.contact_form.title_panel.form_details') %></h3>
42
- <ul class="panel-controls">
43
- <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
44
- </ul>
45
- </div>
46
- <div class="panel-body">
47
- <div class="row">
48
- <div class="form-group">
49
- <%= f.label nil, "#{t('camaleon_cms.admin.table.name')} <abbr title='required'>*</abbr>".html_safe, :class => "" %><br>
50
- <%= f.text_field :name, :class => "form-control required", style: "" %>
51
- </div>
52
-
53
- <div class="form-group">
54
- <%= f.label nil, "#{t('camaleon_cms.admin.table.slug')} <abbr title=\"required\">*</abbr>".html_safe, :class => "" %>
55
- <%= f.text_field :slug, :class => "form-control slug required", "data-parent" => "plugins_contact_form_models_contact_form_name", style: "" %>
56
- </div>
57
- </div>
58
- </div>
59
- </div>
60
-
61
- <div class="panel panel-default">
62
- <div class="panel-heading">
63
- <h3 class="panel-title"><%= t('plugin.contact_form.form_settings_email') %></h3>
64
- <ul class="panel-controls">
65
- <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
66
- </ul>
67
- </div>
68
- <div class="panel-body">
69
- <div class="row">
70
- <div class="form-group">
71
- <label for="railscf_mail_to"><%= t('plugin.contact_form.to') %> <abbr title="required">*</abbr>:</label><br>
72
- <input id="railscf_mail_to" class="form-control required" type="text" value="" name="railscf_mail[to]" />
73
- </div>
74
-
75
- <div class="form-group">
76
- <label for="railscf_mail_subject"><%= t('plugin.contact_form.subject') %> <abbr title="required">*</abbr>:</label><br>
77
- <input id="railscf_mail_subject" class="form-control required" type="text" name="railscf_mail[subject]" />
78
- </div>
79
-
80
- <div class="form-group">
81
- <label for="railscf_mail_body"><%= t('plugin.contact_form.body') %>:</label><br>
82
- <textarea rows="4" cols="5" id="railscf_mail_body" class="form-control" name="railscf_mail[body]"><%= t('plugin.contact_form.body_value') %></textarea>
83
- </div>
84
- </div>
85
- </div>
86
- </div>
87
-
88
- <div class="panel panel-default panel-toggled">
89
- <div class="panel-heading">
90
- <h3 class="panel-title"><%= t('plugin.contact_form.form_settings_messages') %></h3>
91
- <ul class="panel-controls">
92
- <li><a href="#" class="panel-collapse"><span class="fa fa-angle-up"></span></a></li>
93
- </ul>
94
- </div>
95
- <div class="panel-body">
96
- <div class="row">
97
- <div class="form-group">
98
- <p class="description"><label for="railscf_message_mail-sent-ok"><%= t('plugin.contact_form.lbl_message_has_been_success') %></label></p>
99
- <input type="text" class="form-control" name="railscf_message[mail_sent_ok]" id="railscf_message_mail_sent_ok" value="<%= t('plugin.contact_form.msg_message_has_been_sent_success_tank_you') %>" />
100
-
101
- </div>
102
- <div class="form-group">
103
- <p class="description"><label for="railscf_message_mail-sent-ng"><%= t('plugin.contact_form.lbl_failed_sending_message') %></label></p>
104
- <input type="text" class="form-control" name="railscf_message[mail_sent_ng]" id="railscf_message_mail_sent_ng" value="<%= t('plugin.contact_form.msg_failed_sending_message_please_contact_admin') %>" />
105
- </div>
106
- <div class="form-group">
107
- <p class="description"><label for="railscf_message_validation-error"><%= t('plugin.contact_form.lbl_there_was_validation_error') %></label></p>
108
- <input type="text" class="form-control" name="railscf_message[validation_error]" id="railscf_message_validation_error" value="<%= t('plugin.contact_form.msg_there_was_validation_error_please_confirm_submit_form') %>"/>
109
-
110
- </div>
111
- <div class="form-group">
112
- <p class="description"><label for="railscf_message_spam"><%= t('plugin.contact_form.lbl_shipment_considered_spam') %></label></p>
113
- <input type="text" class="form-control" name="railscf_message[spam]" id="railscf_message_spam" value="<%= t('plugin.contact_form.msg_falied_sending_message_please_contact_admin') %>"/>
114
-
115
- </div>
116
- <div class="form-group">
117
- <p class="description"><label for="railscf_message_accept-terms"><%= t('plugin.contact_form.lbl_you_must_accept_all_terms') %></label></p>
118
- <input type="text" class="form-control" name="railscf_message[accept_terms]" id="railscf_message_accept_terms" value="<%= t('plugin.contact_form.msg_please_accept_terms_conditions_contiue')%>"/>
119
-
120
- </div>
121
- <div class="form-group">
122
- <p class="description"><label for="railscf_message_invalid-required"><%= t('plugin.contact_form.lbl_you_must_complete_all_fields') %></label></p>
123
- <input type="text" class="form-control" name="railscf_message[invalid_required]" id="railscf_message_invalid_required" value="<%= t('plugin.contact_form.msg_please_fill_the_required_field')%>" />
124
-
125
- </div>
126
- <div class="form-group">
127
- <p class="description"><label for="railscf_message_invalid-too-long"><%= t('plugin.contact_form.lbl_there_field_user_input_longer_maximum_allowed_length')%></label></p>
128
- <input type="text" class="form-control" name="railscf_message[invalid_too_long]" id="railscf_message_invalid_too_long" value="<%= t('plugin.contact_form.mgs_this_input_too_long') %>" />
129
-
130
- </div>
131
- <div class="form-group">
132
- <p class="description"><label for="railscf_message_invalid-too-short"><%= t('plugin.contact_form.lbl_there_field_user_input_shorter_minimum_allowed_length')%></label></p>
133
- <input type="text" class="form-control" name="railscf_message[invalid_too_short]" id="railscf_message_invalid_too_short" value="<%= t('plugin.contact_form.mgs_this_input_too_short') %>"/>
134
-
135
- </div>
136
- <div class="form-group">
137
- <p class="description"><label for="railscf_message_captcha-not-match"><%= t('plugin.contact_form.lbl_the_code_entered_did_not_match_the_captcha') %></label></p>
138
- <input type="text" class="form-control" name="railscf_message[captcha_not_match]" id="railscf_message_captcha_not_match" value="<%= t('plugin.contact_form.msg_the_entered_code_incorrect') %>"/>
139
-
140
- </div>
141
- <div class="form-group">
142
- <p class="description"><label for="railscf_message_invalid-number"><%= t('plugin.contact_form.lbl_the_entered_number_format_invalid') %></label></p>
143
- <input type="text" class="form-control" name="railscf_message[invalid_number]" id="railscf_message_invalid_number" value="<%= t('plugin.contact_form.msg_the_numeric_format_seems_invalid') %>"/>
144
-
145
- </div>
146
- <div class="form-group">
147
- <p class="description"><label for="railscf_message_number-too-small"><%= t('plugin.contact_form.lbl_the_number_entered_less_allowable_limit') %></label></p>
148
- <input type="text" class="form-control" name="railscf_message[number_too_small]" id="railscf_message_number_too_small" value="<%= t('plugin.contact_form.msg_number_too_samll') %>"/>
149
-
150
- </div>
151
- <div class="form-group">
152
- <p class="description"><label for="railscf_message_number-too-large"><%= t('plugin.contact_form.lbl_the_number_entered_greater_than_allowable_limit') %></label></p>
153
- <input type="text" class="form-control" name="railscf_message[number_too_large]" id="railscf_message_number_too_large" value="<%= t('plugin.contact_form.msg_number_too_large') %>"/>
154
-
155
- </div>
156
- <div class="form-group">
157
- <p class="description"><label for="railscf_message_invalid-email"><%= t('plugin.contact_form.lbl_the_email_is_invalid') %></label></p>
158
- <input type="text" class="form-control" name="railscf_message[invalid_email]" id="railscf_message_invalid_email" value="<%= t('plugin.contact_form.msg_the_email_address_appears_invalid') %>"/>
159
-
160
- </div>
161
- <div class="form-group">
162
- <p class="description"><label for="railscf_message_invalid-url"><%= t('plugin.contact_form.lbl_url_invalid') %></label></p>
163
- <input type="text" class="form-control" name="railscf_message[invalid_url]" id="railscf_message_invalid_url" value="<%= t('plugin.contact_form.msg_url_appearse_invalid') %>"/>
164
-
165
- </div>
166
- <div class="form-group">
167
- <p class="description"><label for="railscf_message_invalid-tel"><%= t('plugin.contact_form.lbl_phone_invalid') %></label></p>
168
- <input type="text" class="form-control" name="railscf_message[invalid_tel]" id="railscf_message_invalid_tel" value="<%= t('plugin.contact_form.msg_phone_appearse_invalid') %>"/>
169
-
170
- </div>
171
- <div class="form-group">
172
- <p class="description"><label for="railscf_message_quiz-answer-not-correct"><%= t('plugin.contact_form.lbl_have_not_correct_answer') %></label></p>
173
- <input type="text" class="form-control" name="railscf_message[quiz_answer_not_correct]" id="railscf_message_quiz_answer_not_correct" value="<%= t('plugin.contact_form.msg_answer_not_correct') %>" />
174
-
175
- </div>
176
- <div class="form-group">
177
- <p class="description"><label for="railscf_message_invalid-date"><%= t('plugin.contact_form.lbl_date_format_invalid') %></label></p>
178
- <input type="text" class="form-control" name="railscf_message[invalid_date]" id="railscf_message_invalid_date" value="<%= t('plugin.contact_form.msg_date_appears_invalid') %>"/>
179
-
180
- </div>
181
- <div class="form-group">
182
- <p class="description"><label for="railscf_message_date-too-early"><%= t('plugin.contact_form.lbl_date_is_earlier_allowable_limit') %></label></p>
183
- <input type="text" class="form-control" name="railscf_message[date_too_early]" id="railscf_message_date_too_early" value="<%= t('plugin.contact_form.msg_date_early') %>"/>
184
-
185
- </div>
186
- <div class="form-group">
187
- <p class="description"><label for="railscf_message_date-too-late"><%= t('plugin.contact_form.lbl_date_later_than_allowable_limit') %></label></p>
188
- <input type="text" class="form-control" name="railscf_message[date_too_late]" id="railscf_message_date_too_late" value="<%= t('plugin.contact_form.msg_date_too_late') %>"/>
189
-
190
- </div>
191
- <div class="form-group">
192
- <p class="description"><label for="railscf_message_upload-failed"><%= t('plugin.contact_form.lbl_file_upload_failed_some_reason') %></label></p>
193
- <input type="text" class="form-control" name="railscf_message[upload_failed]" id="railscf_message_upload_failed" value="<%= t('plugin.contact_form.msg_failed_upload_file') %>"/>
194
-
195
- </div>
196
- <div class="form-group">
197
- <p class="description"><label for="railscf_message_upload-file-type-invalid"><%= t('plugin.contact_form.lbl_upload_file_not_valid_format') %></label></p>
198
- <input type="text" class="form-control" name="railscf_message[upload_file_type_invalid]" id="railscf_message_upload_file_type_invalid" value="<%= t('plugin.contact_form.msg_invalid_file_format') %>"/>
199
-
200
- </div>
201
- <div class="form-group">
202
- <p class="description"><label for="railscf_message_upload-file-too-large"><%= t('plugin.contact_form.lbl_uploaded_file_too_large') %></label></p>
203
- <input type="text" class="form-control" name="railscf_message[upload_file_too_large]" id="railscf_message_upload_file_too_large" value="<%= t('plugin.contact_form.msg_file_too_large') %>" />
204
-
205
- </div>
206
- <div class="form-group">
207
- <p class="description"><label for="railscf_message_upload-failed-rails-error"><%= t('plugin.contact_form.lbl_file_upload_failed_rails_error') %></label></p>
208
- <input type="text" class="form-control" name="railscf_message[upload_failed]" id="railscf_message_upload_failed" value="<%= t('plugin.contact_form.msg_failed_upload_file_was_error') %>" />
209
-
210
- </div>
211
- </div>
212
- </div>
213
- </div>
214
- </div>
215
- <div class="col-md-8">
216
- <div class="fb-main"></div>
217
-
218
- <div class="row">
219
- <div class="col-md-7">
220
- <label><%= t('plugin.contact_form.name_button') %>:</label>
221
- <input id="name_button" class="form-control" type="text" name="railscf_form_button[name_button]" value="Send">
222
- </div>
223
- </div>
224
- </div>
225
- </div>
226
- </div>
227
- <% end %>
228
- </div>
229
- </div>
230
-
231
- </div>
232
- <!-- END PAGE CONTENT WRAPPER -->
233
- </div>
234
-
235
- <script>
236
- jQuery(function($){
237
- var options = <%= raw (@form.value ).to_sym %>;
238
- var settings = <%= raw (@form.settings ).to_sym %>;
239
-
240
- //set values fields
241
- $("#meta_forms").val(JSON.stringify(options));
242
-
243
- if($.isEmptyObject(settings)){
244
-
245
- }else{
246
- //set values mail
247
- $.each(settings.railscf_mail, function(i, value){
248
- if(i=="theme"){
249
- //set select theme
250
- $("#railscf_mail_theme").find('option').each(function(i,e){
251
- if($(e).val() == value){
252
- $('#railscf_mail_theme').prop('selectedIndex',i);
253
- }
254
- });
255
- }else{
256
- $("#railscf_mail_"+i).val(value);
257
- }
258
- });
259
-
260
- //set values messages
261
- $.each(settings.railscf_message, function(i, value){
262
- $("#railscf_message_"+i).val(value);
263
- });
264
-
265
- //set name button
266
- $("#name_button").val(settings.railscf_form_button.name_button);
267
- }
268
-
269
- var lang = {
270
- add_field: '<%= t('plugin.contact_form.add_field') %>',
271
- add_new_field: '<%= t('plugin.contact_form.add_new_field') %>',
272
- add_option: '<%= t('plugin.contact_form.add_option') %>',
273
- edit_field: '<%= t('plugin.contact_form.edit_field') %>',
274
- custom_class: '<%= t('plugin.contact_form.custom_class') %>',
275
- default: '<%= t('plugin.contact_form.default') %>',
276
- duplicate_field: '<%= t('plugin.contact_form.duplicate_field') %>',
277
- include_lank: '<%= t('plugin.contact_form.include_lank') %>',
278
- include_other: '<%= t('plugin.contact_form.include_other') %>',
279
- label: '<%= t('plugin.contact_form.label') %>',
280
- options: '<%= t('plugin.contact_form.options') %>',
281
- msg_add_longer_description_field: '<%= t('plugin.contact_form.msg_add_longer_description_field') %>',
282
- remove_field: '<%= t('plugin.contact_form.remove_field') %>',
283
- remove_option: '<%= t('plugin.contact_form.remove_option') %>',
284
- required: '<%= t('plugin.contact_form.required') %>',
285
- untitled: '<%= t('plugin.contact_form.untitled') %>',
286
- text_box: '<%= t('camaleon_cms.admin.custom_field.fields.text_box') %>',
287
- text_area: '<%= t('camaleon_cms.admin.custom_field.fields.text_area') %>',
288
- select: '<%= t('camaleon_cms.admin.custom_field.fields.select') %>',
289
- website: '<%= t('camaleon_cms.admin.custom_field.fields.website') %>',
290
- email: '<%= t('camaleon_cms.admin.custom_field.fields.email') %>',
291
- upload_file: '<%= t('camaleon_cms.admin.button.upload_file') %>',
292
- multiple_choice: '<%= t('camaleon_cms.admin.custom_field.fields.multiple_choice') %>'
293
-
294
- };
295
-
296
- fb = new Formbuilder({
297
- selector: '.fb-main',
298
- bootstrapData: options.fields,
299
- lang: lang
300
- });
301
-
302
- fb.on('save', function (payload) {
303
- $(".code").html(payload);
304
- $("#meta_forms").val(payload);
305
-
306
- });
307
-
308
- $('#addField a').each(function(){
309
-
310
- var txt = $.trim($(this).text());
311
- var span = $(this).find('span').html();
312
- switch ( txt ){
313
- case 'Text':
314
- $(this).html(span).append(' ').append(lang.text_box);
315
- break;
316
- case 'Dropdown':
317
- $(this).html(span).append(' ').append(lang.select);
318
- break;
319
- case 'Website':
320
- $(this).html(span).append(' ').append(lang.website);
321
- break;
322
- case 'Email':
323
- $(this).html(span).append(' ').append(lang.email);
324
- break;
325
- case 'Upload File':
326
- $(this).html(span).append(' ').append(lang.upload_file);
327
- break;
328
- case 'Multiple Choice':
329
- $(this).html(span).append(' ').append(lang.multiple_choice);
330
- break;
331
- default:
332
- //$(this).text();
333
- }
334
-
335
- });
336
-
337
- });
338
- </script>