camaleon_cms 2.1.1 → 2.1.1.4

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 (180) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -1
  3. data/app/apps/plugins/attack/config/locales/translation.yml +20 -1
  4. data/app/apps/plugins/contact_form/config/locales/translation.yml +106 -1
  5. data/app/apps/plugins/contact_form/contact_form_helper.rb +44 -27
  6. data/app/apps/plugins/front_cache/config/locales/translation.yml +21 -1
  7. data/app/apps/plugins/front_cache/front_cache_helper.rb +1 -1
  8. data/app/apps/plugins/visibility_post/assets/js/form.js +1 -3
  9. data/app/apps/plugins/visibility_post/visibility_post_helper.rb +2 -4
  10. data/app/assets/images/camaleon_cms/language/de.png +0 -0
  11. data/app/assets/images/camaleon_cms/language/en.png +0 -0
  12. data/app/assets/images/camaleon_cms/language/es.png +0 -0
  13. data/app/assets/images/camaleon_cms/language/fr.png +0 -0
  14. data/app/assets/images/camaleon_cms/language/it.png +0 -0
  15. data/app/assets/images/camaleon_cms/language/nl.png +0 -0
  16. data/app/assets/images/camaleon_cms/language/pl.png +0 -0
  17. data/app/assets/images/camaleon_cms/language/pt.png +0 -0
  18. data/app/assets/images/camaleon_cms/language/pt_br.png +0 -0
  19. data/app/assets/images/camaleon_cms/language/ru.png +0 -0
  20. data/app/assets/images/camaleon_cms/language/zh.png +0 -0
  21. data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +3 -11
  22. data/app/assets/javascripts/camaleon_cms/admin/_data.js +2 -6
  23. data/app/assets/javascripts/camaleon_cms/admin/_libraries.js +11 -229
  24. data/app/assets/javascripts/camaleon_cms/admin/_modal.js +11 -37
  25. data/app/assets/javascripts/camaleon_cms/admin/_post.js +27 -22
  26. data/app/assets/javascripts/camaleon_cms/admin/_translator.js +2 -1
  27. data/app/assets/javascripts/camaleon_cms/admin/admin-manifest.js +6 -2
  28. data/app/assets/javascripts/camaleon_cms/admin/bootstrap-datepicker.js +2557 -1689
  29. data/app/assets/javascripts/camaleon_cms/admin/jquery.validate.js +119 -1361
  30. data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/nl.js +33 -0
  31. data/app/assets/javascripts/camaleon_cms/admin/momentjs/_moment.js +3606 -0
  32. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ar.js +136 -0
  33. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ca.js +79 -0
  34. data/app/assets/javascripts/camaleon_cms/admin/momentjs/de.js +76 -0
  35. data/app/assets/javascripts/camaleon_cms/admin/momentjs/es.js +79 -0
  36. data/app/assets/javascripts/camaleon_cms/admin/momentjs/fr.js +62 -0
  37. data/app/assets/javascripts/camaleon_cms/admin/momentjs/it.js +70 -0
  38. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ja.js +65 -0
  39. data/app/assets/javascripts/camaleon_cms/admin/momentjs/nl.js +71 -0
  40. data/app/assets/javascripts/camaleon_cms/admin/momentjs/pl.js +105 -0
  41. data/app/assets/javascripts/camaleon_cms/admin/momentjs/pt.js +64 -0
  42. data/app/assets/javascripts/camaleon_cms/admin/momentjs/pt_br.js +60 -0
  43. data/app/assets/javascripts/camaleon_cms/admin/momentjs/ru.js +166 -0
  44. data/app/assets/javascripts/camaleon_cms/admin/momentjs/zh.js +127 -0
  45. data/app/assets/javascripts/camaleon_cms/admin/nav-menu.js +15 -25
  46. data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/nl.js +219 -0
  47. data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +82 -19
  48. data/app/assets/javascripts/camaleon_cms/admin/user_profile.js +8 -8
  49. data/app/assets/stylesheets/camaleon_cms/admin/_custom_admin.css.scss +19 -2
  50. data/app/assets/stylesheets/camaleon_cms/admin/admin-manifest.css +0 -4
  51. data/app/assets/stylesheets/camaleon_cms/admin/bootstrap-datepicker.css.scss +315 -414
  52. data/app/assets/stylesheets/camaleon_cms/admin/uploader/_uploadfile.css.scss +7 -3
  53. data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +9 -5
  54. data/app/controllers/camaleon_cms/admin/categories_controller.rb +5 -0
  55. data/app/controllers/camaleon_cms/admin/media_controller.rb +27 -10
  56. data/app/controllers/camaleon_cms/admin/posts_controller.rb +9 -19
  57. data/app/controllers/camaleon_cms/admin/sessions_controller.rb +3 -10
  58. data/app/controllers/camaleon_cms/admin/settings/custom_fields_controller.rb +0 -1
  59. data/app/controllers/camaleon_cms/admin/settings/sites_controller.rb +6 -1
  60. data/app/controllers/camaleon_cms/admin/users_controller.rb +1 -8
  61. data/app/controllers/camaleon_cms/admin_controller.rb +5 -4
  62. data/app/controllers/camaleon_cms/apps/plugins_front_controller.rb +0 -8
  63. data/app/controllers/camaleon_cms/camaleon_controller.rb +6 -1
  64. data/app/controllers/camaleon_cms/frontend_controller.rb +11 -8
  65. data/app/decorators/camaleon_cms/category_decorator.rb +2 -1
  66. data/app/decorators/camaleon_cms/post_decorator.rb +28 -1
  67. data/app/decorators/camaleon_cms/post_tag_decorator.rb +1 -0
  68. data/app/decorators/camaleon_cms/post_type_decorator.rb +17 -0
  69. data/app/decorators/camaleon_cms/site_decorator.rb +22 -7
  70. data/app/decorators/camaleon_cms/user_decorator.rb +1 -0
  71. data/app/helpers/camaleon_cms/admin/application_helper.rb +3 -2
  72. data/app/helpers/camaleon_cms/admin/custom_fields_helper.rb +13 -25
  73. data/app/helpers/camaleon_cms/admin/post_type_helper.rb +27 -2
  74. data/app/helpers/camaleon_cms/camaleon_helper.rb +0 -16
  75. data/app/helpers/camaleon_cms/captcha_helper.rb +9 -3
  76. data/app/helpers/camaleon_cms/email_helper.rb +27 -8
  77. data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +21 -17
  78. data/app/helpers/camaleon_cms/frontend/seo_helper.rb +5 -3
  79. data/app/helpers/camaleon_cms/html_helper.rb +2 -2
  80. data/app/helpers/camaleon_cms/site_helper.rb +10 -14
  81. data/app/helpers/camaleon_cms/uploader_helper.rb +119 -31
  82. data/app/mailers/camaleon_cms/html_mailer.rb +26 -20
  83. data/app/models/camaleon_cms/custom_field.rb +1 -0
  84. data/app/models/camaleon_cms/custom_field_group.rb +2 -1
  85. data/app/models/camaleon_cms/nav_menu.rb +6 -7
  86. data/app/models/camaleon_cms/nav_menu_item.rb +2 -1
  87. data/app/models/camaleon_cms/post.rb +29 -2
  88. data/app/models/camaleon_cms/post_type.rb +20 -1
  89. data/app/models/camaleon_cms/site.rb +19 -19
  90. data/app/models/camaleon_cms/term_taxonomy.rb +1 -1
  91. data/app/models/concerns/camaleon_cms/custom_fields_read.rb +6 -4
  92. data/app/models/concerns/camaleon_cms/metas.rb +5 -4
  93. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_fields.html.erb +4 -2
  94. data/app/views/camaleon_cms/admin/appearances/nav_menus/_external_menu.html.erb +1 -1
  95. data/app/views/camaleon_cms/admin/appearances/nav_menus/index.html.erb +3 -6
  96. data/app/views/camaleon_cms/admin/categories/index.html.erb +1 -0
  97. data/app/views/camaleon_cms/admin/media/_files_list.html.erb +3 -3
  98. data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +3 -2
  99. data/app/views/camaleon_cms/admin/media/index.html.erb +31 -4
  100. data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +10 -1
  101. data/app/views/camaleon_cms/admin/posts/form.html.erb +6 -2
  102. data/app/views/camaleon_cms/admin/posts/index.html.erb +4 -4
  103. data/app/views/camaleon_cms/admin/search.html.erb +5 -3
  104. data/app/views/camaleon_cms/admin/settings/_file_system_settings.html.erb +5 -5
  105. data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +2 -1
  106. data/app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb +1 -1
  107. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_date.html.erb +3 -4
  108. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_image.html.erb +1 -1
  109. data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +2 -2
  110. data/app/views/camaleon_cms/admin/settings/post_types/_form.html.erb +11 -1
  111. data/app/views/camaleon_cms/admin/settings/post_types/index.html.erb +1 -0
  112. data/app/views/camaleon_cms/admin/users/form.html.erb +30 -55
  113. data/app/views/camaleon_cms/html_mailer/mailer.html.erb +1 -1
  114. data/app/views/camaleon_cms/html_mailer/password_reset.html.erb +3 -0
  115. data/app/views/layouts/camaleon_cms/admin.html.erb +4 -1
  116. data/app/views/layouts/camaleon_cms/admin/_ajax.html.erb +3 -1
  117. data/app/views/layouts/camaleon_cms/admin/_footer.html.erb +1 -1
  118. data/app/views/layouts/camaleon_cms/admin/_header.html.erb +1 -1
  119. data/config/initializers/assets.rb +4 -2
  120. data/config/initializers/model_alias.rb +11 -0
  121. data/config/locales/camaleon_cms/admin/en.yml +2 -0
  122. data/config/locales/camaleon_cms/admin/es.yml +2 -1
  123. data/config/locales/camaleon_cms/admin/it.yml +1 -0
  124. data/config/locales/camaleon_cms/admin/js.yml +42 -1
  125. data/config/locales/camaleon_cms/admin/nl.yml +659 -0
  126. data/config/locales/camaleon_cms/admin/pt_br.yml +1 -0
  127. data/config/locales/camaleon_cms/admin/ru.yml +659 -0
  128. data/config/locales/camaleon_cms/common.yml +127 -0
  129. data/config/locales/camaleon_cms/languages.yml +16 -0
  130. data/config/locales/camaleon_cms/routes.yml +8 -0
  131. data/config/locales/nl.yml +209 -0
  132. data/config/routes.rb +1 -1
  133. data/config/routes/admin.rb +5 -4
  134. data/config/routes/frontend.rb +16 -3
  135. data/config/system.json +2 -3
  136. data/lib/camaleon_cms/engine.rb +5 -1
  137. data/lib/camaleon_cms/version.rb +1 -1
  138. data/lib/ext/array.rb +5 -0
  139. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +1 -1
  140. data/lib/generators/camaleon_cms/gem_plugin_template/app/models/plugins/my_plugin/my_plugin.rb +1 -2
  141. data/lib/generators/camaleon_cms/gem_plugin_template/config/{custom_models.rb → initializers/custom_models.rb} +0 -0
  142. data/lib/plugin_routes.rb +38 -63
  143. data/lib/tasks/camaleon_cms/camaleon_tasks.rake +18 -0
  144. data/lib/tasks/camaleon_cms/rspec_test.rake +7 -4
  145. metadata +43 -54
  146. data/app/assets/javascripts/camaleon_cms/admin/bootstrap-datetimepicker.min.js +0 -26
  147. data/app/assets/javascripts/camaleon_cms/admin/plugins.js +0 -637
  148. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-cool.gif +0 -0
  149. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-cry.gif +0 -0
  150. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  151. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  152. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-frown.gif +0 -0
  153. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-innocent.gif +0 -0
  154. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-kiss.gif +0 -0
  155. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-laughing.gif +0 -0
  156. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  157. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-sealed.gif +0 -0
  158. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-smile.gif +0 -0
  159. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-surprised.gif +0 -0
  160. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  161. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-undecided.gif +0 -0
  162. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-wink.gif +0 -0
  163. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/emoticons/img/smiley-yell.gif +0 -0
  164. data/app/assets/javascripts/camaleon_cms/admin/tinymce/plugins/visualblocks/css/visualblocks.css +0 -135
  165. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/content.min.css.scss +0 -4
  166. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce-small.eot +0 -0
  167. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce-small.svg +0 -62
  168. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  169. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce-small.woff +0 -0
  170. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce.eot +0 -0
  171. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce.svg +0 -83
  172. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce.ttf +0 -0
  173. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/fonts/tinymce.woff +0 -0
  174. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/img/anchor.gif +0 -0
  175. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/img/loader.gif +0 -0
  176. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/img/object.gif +0 -0
  177. data/app/assets/javascripts/camaleon_cms/admin/tinymce/skins/lightgray/img/trans.gif +0 -0
  178. data/app/assets/javascripts/camaleon_cms/admin/tinymce/themes/modern/theme.min.js +0 -1
  179. data/app/assets/javascripts/camaleon_cms/admin/tinymce/tinymce.min.js +0 -11
  180. data/app/assets/stylesheets/camaleon_cms/admin/bootstrap-datetimepicker.css.scss +0 -339
@@ -148,11 +148,15 @@ margin: 5px 10px 5px 0px;
148
148
  .file_item, .folder_item{
149
149
  position: relative;
150
150
  cursor: pointer;
151
- width: 150px;
151
+ width: 157px;
152
152
  float: left;
153
- margin: 5px;
154
- height: 152px;
153
+ margin: 0px;
154
+ height: 157px;
155
155
  overflow: hidden;
156
+ border: 5px solid transparent;
157
+ &.selected{
158
+ border-color: #3c8dbc;
159
+ }
156
160
  .actions{
157
161
  position: absolute;
158
162
  top: 0;
@@ -76,7 +76,11 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
76
76
  # show external menu form
77
77
  def form
78
78
  if params[:custom_fields].present?
79
- @nav_menu = current_site.nav_menus.find_by_id(params[:menu_id])
79
+ if params[:item_id] == 'undefined'
80
+ @nav_menu = current_site.nav_menus.find_by_id(params[:menu_id])
81
+ else
82
+ @nav_menu = current_site.nav_menu_items.find_by_id(params[:item_id])
83
+ end
80
84
  render "_custom_fields", layout: "camaleon_cms/admin/_ajax"
81
85
  else
82
86
  render "_external_menu", layout: false, locals: {submit: true}
@@ -87,11 +91,10 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
87
91
 
88
92
  def get_nav_items(menu_items, parent_id = 0)
89
93
  items = []
90
- # menu_items.eager_load(:metas, :field_values).each do |nav_item| # changed for "DEPRECATION WARNING: The association scope 'field_values' is instance dependent"
91
94
  menu_items.eager_load(:metas).each do |nav_item|
92
95
  object = _get_object_nav_menu(nav_item)
93
96
  if object.present?
94
- items << {id: nav_item.id, label: object[:name], link: nav_item.options[:object_id], url_edit: object[:url_edit], type: nav_item.options[:type], parent: parent_id.to_i, fields: "#{nav_item.get_field_values_hash.to_json}"}
97
+ items << {id: nav_item.id, label: object[:name], link: nav_item.options[:object_id], url_edit: object[:url_edit], type: nav_item.options[:type], parent: parent_id.to_i, fields: "#{nav_item.get_field_values_hash(true).to_json}"}
95
98
  items += get_nav_items(nav_item.children, nav_item.id)
96
99
  end
97
100
  end
@@ -115,11 +118,12 @@ class CamaleonCms::Admin::Appearances::NavMenusController < CamaleonCms::AdminCo
115
118
  post_type = CamaleonCms::PostType.find(nav_menu_item.get_option('object_id')).decorate
116
119
  {link: post_type.the_url, name: post_type.the_title, url_edit: post_type.the_edit_url}
117
120
  when 'external'
118
- {link: nav_menu_item.get_option('object_id'), name: nav_menu_item.name.to_s.translate}
121
+ {link: nav_menu_item.get_option('object_id'), name: nav_menu_item.name.to_s}
119
122
  else
120
123
  false
121
124
  end
122
- rescue
125
+ rescue => e
126
+ puts "@@@@@@@@@@@@@@@@@@@@@@@@@ Skipped menu for: #{e.message} (#{nav_menu_item})"
123
127
  false
124
128
  end
125
129
  end
@@ -48,6 +48,11 @@ class CamaleonCms::Admin::CategoriesController < CamaleonCms::AdminController
48
48
  end
49
49
  end
50
50
 
51
+ # return html category list used to reload categories list in post editor form
52
+ def list
53
+ render inline: post_type_html_inputs(@post_type, "categories", "categories" , "checkbox" , params[:categories] || [], "categorychecklist", true )
54
+ end
55
+
51
56
  def destroy
52
57
  flash[:notice] = t('camaleon_cms.admin.post_type.message.deleted') if @category.destroy
53
58
 
@@ -8,7 +8,7 @@
8
8
  =end
9
9
  class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
10
10
  skip_before_filter :cama_authenticate, only: :img
11
- skip_before_filter :admin_logged_actions, except: :index
11
+ skip_before_filter :admin_logged_actions, except: [:index, :search]
12
12
  skip_before_filter :verify_authenticity_token, only: :upload
13
13
  before_action :init_media_vars
14
14
 
@@ -19,6 +19,15 @@ class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
19
19
  add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.media")
20
20
  end
21
21
 
22
+ def search
23
+ authorize! :manager, :media
24
+ @tree = { files: cama_media_search_file(params[:q]), folders: [] }
25
+ @search = params[:q]
26
+ add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.media")
27
+ add_breadcrumb params[:q]
28
+ render 'index'
29
+ end
30
+
22
31
  # crop a image to save as a new file
23
32
  def crop
24
33
  path_image = Rails.root.join("tmp", File.basename(params[:cp_img_path])).to_s
@@ -37,7 +46,9 @@ class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
37
46
 
38
47
  # render media for modal content
39
48
  def ajax
40
- render partial: "files_list" if params[:partial].present?
49
+ if params[:partial].present?
50
+ render partial: "files_list", locals: { files: @tree[:files], folders: @tree[:folders] }
51
+ end
41
52
  render "index", layout: false unless params[:partial].present?
42
53
  end
43
54
 
@@ -55,21 +66,27 @@ class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
55
66
  when "del_file"
56
67
  cama_uploader_destroy_file(params[:folder].gsub("//", "/"))
57
68
  render inline: ""
69
+ when 'crop_url'
70
+ params[:url] = Rails.public_path.join(params[:url].sub(current_site.the_url, '')).to_s if params[:url].include?(current_site.the_url) # local file
71
+ r = cama_tmp_upload(params[:url], formats: params[:formats])
72
+ unless r[:error].present?
73
+ params[:file_upload] = r[:file_path]
74
+ upload({remove_source: true})
75
+ else
76
+ render inline: r[:error]
77
+ end
58
78
  end
59
79
  end
60
80
 
61
81
  # upload files from media uploader
62
- def upload
82
+ def upload(settings = {})
63
83
  f = {error: "File not found."}
64
84
  if params[:file_upload].present?
65
- f = upload_file(params[:file_upload], {folder: params[:folder]})
85
+ f = upload_file(params[:file_upload], {folder: params[:folder], dimension: params['dimension'], formats: params[:formats]}.merge(settings))
66
86
  end
67
87
 
68
- unless f[:error].present?
69
- render partial: "render_file_item", locals:{ file: f }
70
- else
71
- render inlien: f[:error]
72
- end
88
+ render(partial: "render_file_item", locals:{ file: f }) unless f[:error].present?
89
+ render inline: f[:error] if f[:error].present?
73
90
  end
74
91
 
75
92
  private
@@ -78,7 +95,7 @@ class CamaleonCms::Admin::MediaController < CamaleonCms::AdminController
78
95
  @media_formats = (params[:media_formats] || "").sub("media", ",video,audio").sub("all", "").split(",")
79
96
  @folder = params[:folder] || "/"
80
97
  @tree = cama_media_find_folder(@folder)
81
- @show_file_actions ||= params[:actions].to_s == true
98
+ @show_file_actions ||= params[:actions].to_s == 'true'
82
99
  end
83
100
 
84
101
  end
@@ -15,6 +15,7 @@ class CamaleonCms::Admin::PostsController < CamaleonCms::AdminController
15
15
 
16
16
  def index
17
17
  authorize! :posts, @post_type
18
+ per_page = current_site.admin_per_page
18
19
  posts_all = @post_type.posts.eager_load(:parent, :post_type)
19
20
  if params[:taxonomy].present? && params[:taxonomy_id].present?
20
21
  if params[:taxonomy] == "category"
@@ -33,7 +34,8 @@ class CamaleonCms::Admin::PostsController < CamaleonCms::AdminController
33
34
  end
34
35
 
35
36
  if params[:q].present?
36
- posts_all = posts_all.where(params[:q].split(" ").map{|text| "#{CamaleonCms::Post.table_name}.title LIKE '%#{text}%'" }.join(" OR "))
37
+ params[:q] = (params[:q] || '').downcase
38
+ posts_all = posts_all.where("LOWER(#{CamaleonCms::Post.table_name}.title) LIKE ?", "%#{params[:q]}%")
37
39
  end
38
40
 
39
41
  @posts = posts_all
@@ -49,9 +51,10 @@ class CamaleonCms::Admin::PostsController < CamaleonCms::AdminController
49
51
  end
50
52
 
51
53
  @btns = {published: "#{t('camaleon_cms.admin.post_type.published')} (#{posts_all.where(status: "published").size})", all: "#{t('camaleon_cms.admin.post_type.all')} (#{posts_all.no_trash.size})", pending: "#{t('camaleon_cms.admin.post_type.pending')} (#{posts_all.where(status: "pending").size})", draft: "#{t('camaleon_cms.admin.post_type.draft')} (#{posts_all.where(status: "draft").size})", trash: "#{t('camaleon_cms.admin.post_type.trash')} (#{posts_all.where(status: "trash").size})"}
52
- r = {posts: @posts, post_type: @post_type, btns: @btns, all_posts: posts_all, render: 'index' }
54
+ r = {posts: @posts, post_type: @post_type, btns: @btns, all_posts: posts_all, render: 'index', per_page: per_page }
53
55
  hooks_run("list_post", r)
54
- @posts = r[:posts].paginate(:page => params[:page], :per_page => current_site.admin_per_page)
56
+ per_page = 9999999 if @post_type.manage_hierarchy?
57
+ @posts = r[:posts].paginate(:page => params[:page], :per_page => r[:per_page])
55
58
  render r[:render]
56
59
  end
57
60
 
@@ -118,7 +121,7 @@ class CamaleonCms::Admin::PostsController < CamaleonCms::AdminController
118
121
  @post = @post_type.posts.find(params[:post_id])
119
122
  authorize! :destroy, @post
120
123
  @post.set_option('status_default', @post.status)
121
- @post.children.destroy_all unless @post.draft?
124
+ # @post.children.destroy_all unless @post.draft? TODO: why delete children?
122
125
  @post.update_column('status', 'trash')
123
126
  @post.update_extra_data
124
127
  flash[:notice] = t('camaleon_cms.admin.post.message.trash', post_type: @post_type.decorate.the_title)
@@ -153,15 +156,8 @@ class CamaleonCms::Admin::PostsController < CamaleonCms::AdminController
153
156
  json = {error: 'Not Found'}
154
157
  case params[:method]
155
158
  when 'exist_slug'
156
- slug_orig = params[:slug].to_s
157
- slug = slug_orig
158
- post_id = params[:post_id].present? ? params[:post_id] : 0
159
- i = 0
160
- while _exist_slug?(slug, post_id) do
161
- i +=1
162
- slug = "#{slug_orig}-#{i}"
163
- end
164
- json = {slug: slug, index: i}
159
+ slug = current_site.get_valid_post_slug(params[:slug].to_s, params[:post_id])
160
+ json = {slug: slug, index: 1}
165
161
  end
166
162
  render json: json
167
163
  end
@@ -193,16 +189,10 @@ class CamaleonCms::Admin::PostsController < CamaleonCms::AdminController
193
189
  # is_create: indicate if this info is for create a new post
194
190
  def get_post_data(is_create = false)
195
191
  post_data = params[:post]
196
- post_data[:post_parent] = nil
197
192
  post_data[:user_id] = cama_current_user.id if is_create
198
193
  post_data[:status] == 'pending' if post_data[:status] == 'published' && cannot?(:publish_post, @post_type)
199
194
  post_data[:data_tags] = params[:tags].to_s
200
195
  post_data[:data_categories] = params[:categories] || []
201
196
  post_data
202
197
  end
203
-
204
- # valid slug post
205
- def _exist_slug?(slug, post_id)
206
- current_site.posts.where("#{CamaleonCms::Post.table_name}.slug LIKE ? OR #{CamaleonCms::Post.table_name}.slug = ?", "%-->#{slug}<!--%", slug).where("#{CamaleonCms::Post.table_name}.status != 'draft'").where(post_parent: nil).where.not(id: post_id).present?
207
- end
208
198
  end
@@ -95,15 +95,7 @@ class CamaleonCms::Admin::SessionsController < CamaleonCms::CamaleonController
95
95
  data_user = params[:user]
96
96
  @user = current_site.users.find_by_email(data_user[:email])
97
97
  if @user.present?
98
- @user.send_password_reset
99
-
100
- reset_url = cama_admin_forgot_url({h: @user.password_reset_token})
101
-
102
- html = "<p>#{t('camaleon_cms.admin.login.message.hello')}, <b>#{@user.fullname}</b></p>
103
- <p>#{t('camaleon_cms.admin.login.message.reset_url')}:</p>
104
- <p><a href='#{reset_url}'><b>#{reset_url}</b></a></p> "
105
- sendmail(@user.email, t('camaleon_cms.admin.login.message.subject_email'), html)
106
-
98
+ send_password_reset_email(@user)
107
99
  flash[:notice] = t('camaleon_cms.admin.login.message.send_mail_succes')
108
100
  redirect_to cama_admin_login_path
109
101
  return
@@ -162,7 +154,8 @@ class CamaleonCms::Admin::SessionsController < CamaleonCms::CamaleonController
162
154
  private
163
155
 
164
156
  def before_hook_session
165
- I18n.locale = params[:locale] || current_site.get_languages.first
157
+ session[:cama_current_language] = params[:cama_set_language].to_sym if params[:cama_set_language].present?
158
+ I18n.locale = params[:locale] || session[:cama_current_language] || current_site.get_languages.first
166
159
  hooks_run("session_before_load")
167
160
  end
168
161
 
@@ -7,7 +7,6 @@
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
9
  class CamaleonCms::Admin::Settings::CustomFieldsController < CamaleonCms::Admin::SettingsController
10
- include CamaleonCms::Admin::CustomFieldsHelper
11
10
  add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.custom_fields"), :cama_admin_settings_custom_fields_path
12
11
  before_action :set_custom_field_group, only: [:show,:edit,:update,:destroy]
13
12
  before_action :set_post_data, only: [:create, :update]
@@ -28,10 +28,15 @@ class CamaleonCms::Admin::Settings::SitesController < CamaleonCms::Admin::Settin
28
28
  end
29
29
 
30
30
  def update
31
+ tmp = @site.slug
31
32
  if @site.update(params[:site])
32
33
  save_metas(@site)
33
34
  flash[:notice] = t('camaleon_cms.admin.sites.message.updated')
34
- redirect_to action: :index
35
+ if @site.id == Cama::Site.main_site.id && tmp != @site.slug
36
+ redirect_to @site.the_admin_url
37
+ else
38
+ redirect_to action: :index
39
+ end
35
40
  else
36
41
  edit
37
42
  end
@@ -52,14 +52,7 @@ class CamaleonCms::Admin::UsersController < CamaleonCms::AdminController
52
52
  # update som ajax requests from profile or user form
53
53
  def updated_ajax
54
54
  @user = current_site.users.find(params[:user_id])
55
- # update password
56
- if params[:password]
57
- if @user.authenticate(params[:password][:password_old])
58
- render inline: @user.update(params[:password]) ? "" : @user.errors.full_messages.join(', ')
59
- else
60
- render inline: t('camaleon_cms.admin.users.message.incorrect_old_password')
61
- end
62
- end
55
+ render inline: @user.update(params[:password]) ? "" : @user.errors.full_messages.join(', ')
63
56
  end
64
57
 
65
58
  def edit
@@ -19,7 +19,7 @@ class CamaleonCms::AdminController < CamaleonCms::CamaleonController
19
19
  before_action :admin_before_hooks
20
20
  after_action :admin_after_hooks
21
21
  layout Proc.new { |controller| params[:cama_ajax_request].present? ? "camaleon_cms/admin/_ajax" : 'camaleon_cms/admin' }
22
- add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.dashboard"), :cama_admin_path
22
+ add_breadcrumb I18n.t("camaleon_cms.admin.sidebar.dashboard", default: 'Dashboard'), :cama_admin_path
23
23
 
24
24
  # render admin dashboard
25
25
  def index
@@ -50,13 +50,14 @@ class CamaleonCms::AdminController < CamaleonCms::CamaleonController
50
50
  def search
51
51
  add_breadcrumb I18n.t("camaleon_cms.admin.button.search")
52
52
  params[:kind] = "content" unless params[:kind].present?
53
+ params[:q] = (params[:q] || '').downcase
53
54
  case params[:kind]
54
55
  when "category"
55
- @items = current_site.full_categories.where("#{CamaleonCms::Category.table_name}.name LIKE ?", "%#{params[:q]}%")
56
+ @items = current_site.full_categories.where("LOWER(#{CamaleonCms::Category.table_name}.name) LIKE ?", "%#{params[:q]}%")
56
57
  when "tag"
57
- @items = current_site.post_tags.where("#{CamaleonCms::PostTag.table_name}.name LIKE ?", "%#{params[:q]}%")
58
+ @items = current_site.post_tags.where("LOWER(#{CamaleonCms::PostTag.table_name}.name) LIKE ?", "%#{params[:q]}%")
58
59
  else
59
- @items = current_site.posts.where("#{CamaleonCms::Post.table_name}.title LIKE ?", "%#{params[:q]}%")
60
+ @items = current_site.posts.where("LOWER(#{CamaleonCms::Post.table_name}.title) LIKE ?", "%#{params[:q]}%")
60
61
  end
61
62
  @items = @items.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
62
63
  end
@@ -26,13 +26,5 @@ class CamaleonCms::Apps::PluginsFrontController < CamaleonCms::FrontendControlle
26
26
  return
27
27
  end
28
28
  lookup_context.prefixes.prepend(params[:controller].sub("plugins/#{plugin_name}", "#{plugin_name}/views")) if !@plugin.settings["gem_mode"].present?
29
-
30
- views_dir = "app/apps/"
31
- self.prepend_view_path(File.join($camaleon_engine_dir, views_dir).to_s)
32
- self.prepend_view_path(Rails.root.join(views_dir).to_s)
33
- # lookup_context.prefixes.prepend("camaleon_cms/default_theme")
34
- # lookup_context.prefixes.prepend("themes/#{current_theme.slug}") if current_theme.settings["gem_mode"]
35
- # lookup_context.prefixes.prepend("themes/#{current_theme.slug}/views") unless current_theme.settings["gem_mode"]
36
- # lookup_context.prefixes.prepend("themes/#{current_site.id}/views")
37
29
  end
38
30
  end
@@ -37,7 +37,7 @@ class CamaleonCms::CamaleonController < ApplicationController
37
37
 
38
38
  # show page error
39
39
  def render_error(status = 404, exception = nil, message = "")
40
- Rails.logger.info "========#{exception.message if exception.present?}====#{params[:error_msg]}========#{caller.inspect}"
40
+ Rails.logger.info "======url: #{request.original_url rescue nil}======message: #{exception.message if exception.present?}====#{params[:error_msg]}========#{caller.inspect}"
41
41
  @message = "#{message} #{params[:error_msg] || (exception.present? ? "#{exception.message}<br><br>#{caller.inspect}" : "")}"
42
42
  @message = "" if Rails.env == "production"
43
43
  render "camaleon_cms/#{status}", :status => status
@@ -69,9 +69,14 @@ class CamaleonCms::CamaleonController < ApplicationController
69
69
 
70
70
  request.env.except!('HTTP_X_FORWARDED_HOST') if request.env['HTTP_X_FORWARDED_HOST'] # just drop the variable
71
71
 
72
+ views_dir = "app/apps/"
73
+ self.prepend_view_path(File.join($camaleon_engine_dir, views_dir).to_s)
74
+ self.prepend_view_path(Rails.root.join(views_dir).to_s)
75
+
72
76
  # past plugins version support
73
77
  self.prepend_view_path(File.join($camaleon_engine_dir, "app", "apps", "plugins"))
74
78
  self.prepend_view_path(Rails.root.join("app", "apps", 'plugins'))
79
+
75
80
  CamaleonCms::PostDefault.current_user = cama_current_user
76
81
  CamaleonCms::PostDefault.current_site = current_site
77
82
  end
@@ -86,7 +86,8 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
86
86
  @param_search = params[:q]
87
87
  layout_ = lookup_context.template_exists?("layouts/search") ? "search" : (self.send :_layout)
88
88
  r = {layout: layout_, render: "search", posts: nil}; hooks_run("on_render_search", r)
89
- @posts = r[:posts] != nil ? r[:posts] : current_site.the_posts.where("title LIKE ? OR content_filtered LIKE ?", "%#{params[:q]}%", "%#{params[:q]}%")
89
+ params[:q] = (params[:q] || '').downcase
90
+ @posts = r[:posts] != nil ? r[:posts] : current_site.the_posts.where("LOWER(title) LIKE ? OR LOWER(content_filtered) LIKE ?", "%#{params[:q]}%", "%#{params[:q]}%")
90
91
  @posts_size = @posts.size
91
92
  @posts = @posts.paginate(:page => params[:page], :per_page => current_site.front_per_page)
92
93
  render r[:render], layout: r[:layout]
@@ -109,7 +110,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
109
110
  if params[:draft_id].present?
110
111
  draft_render
111
112
  else
112
- render_post(@post || params[:slug].to_s, true)
113
+ render_post(@post || params[:slug].to_s.split("/").last, true)
113
114
  end
114
115
  end
115
116
 
@@ -150,7 +151,11 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
150
151
  end
151
152
 
152
153
  unless @post.present?
153
- page_not_found()
154
+ if params[:format] == 'html' || !params[:format].present?
155
+ page_not_found()
156
+ else
157
+ render nothing: true, status: 404
158
+ end
154
159
  else
155
160
  @post = @post.decorate
156
161
  @cama_visited_post = @post
@@ -203,13 +208,10 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
203
208
  end
204
209
 
205
210
  @_site_options = current_site.options
206
- I18n.locale = params[:locale] || current_site.get_languages.first
211
+ session[:cama_current_language] = params[:cama_set_language].to_sym if params[:cama_set_language].present?
212
+ I18n.locale = params[:locale] || session[:cama_current_language] || current_site.get_languages.first
207
213
  return page_not_found unless current_site.get_languages.include?(I18n.locale.to_sym) # verify if this locale is available for this site
208
214
 
209
- views_dir = "app/apps/"
210
- self.prepend_view_path(File.join($camaleon_engine_dir, views_dir).to_s)
211
- self.prepend_view_path(Rails.root.join(views_dir).to_s)
212
-
213
215
  # define render paths
214
216
  lookup_context.prefixes.delete("frontend")
215
217
  lookup_context.prefixes.delete("application")
@@ -222,6 +224,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
222
224
  lookup_context.prefixes.prepend("themes/#{current_theme.slug}/views") unless current_theme.settings["gem_mode"]
223
225
  lookup_context.prefixes.prepend("themes/#{current_site.id}/views")
224
226
  end
227
+ lookup_context.prefixes = lookup_context.prefixes.uniq
225
228
  theme_init()
226
229
  end
227
230
 
@@ -13,7 +13,8 @@ class CamaleonCms::CategoryDecorator < CamaleonCms::TermTaxonomyDecorator
13
13
  def the_url(*args)
14
14
  args = args.extract_options!
15
15
  args[:category_id] = the_id
16
- args[:title] = the_title.parameterize
16
+ args[:title] = the_title.parameterize || the_slug
17
+ args[:title] = the_slug unless args[:title].present?
17
18
  args[:locale] = @_deco_locale unless args.include?(:locale)
18
19
  args[:format] = "html"
19
20
  as_path = args.delete(:as_path)
@@ -71,32 +71,46 @@ class CamaleonCms::PostDecorator < CamaleonCms::ApplicationDecorator
71
71
  l = _calc_locale(args[:locale])
72
72
  ptype = object.post_type.decorate
73
73
  p_url_format = ptype.contents_route_format
74
+ p_url_format = "hierarchy_post" if ptype.manage_hierarchy?
74
75
  case p_url_format
75
76
  when "post_of_post_type"
76
77
  args[:post_type_id] = ptype.id
77
78
  args[:title] = ptype.the_title(args[:locale]).parameterize
79
+ args[:title] = ptype.the_slug unless args[:title].present?
78
80
  when "post_of_category"
79
81
  if ptype.manage_categories?
80
82
  cat = object.categories.first.decorate rescue ptype.default_category.decorate
81
83
  args[:category_id] = cat.id
82
84
  args[:title] = cat.the_title(args[:locale]).parameterize
85
+ args[:title] = cat.the_slug unless args[:title].present?
83
86
  else
84
87
  p_url_format = "post"
85
88
  l = ""
86
89
  end
87
90
  when "post_of_posttype"
88
91
  args[:post_type_title] = ptype.the_title(args[:locale]).parameterize
92
+ args[:post_type_title] = ptype.the_slug unless args[:post_type_title].present?
89
93
  l = ""
90
94
  when "post_of_category_post_type"
91
95
  if ptype.manage_categories?
92
96
  cat = object.categories.first.decorate rescue ptype.default_category.decorate
93
97
  args[:post_type_title] = ptype.the_title(args[:locale]).parameterize
98
+ args[:post_type_title] = ptype.the_slug unless args[:post_type_title].present?
94
99
  args[:category_id] = cat.id
95
100
  args[:title] = cat.the_title(args[:locale]).parameterize
101
+ args[:title] = cat.the_slug unless args[:title].present?
96
102
  else
97
103
  p_url_format = "post"
98
104
  l = ""
99
105
  end
106
+ when 'hierarchy_post'
107
+ l = ""
108
+ if object.post_parent.present?
109
+ slugs = ([args[:slug]]+object.parents.map{|parent| parent.decorate.the_slug(args[:locale]) }).reverse
110
+ args[:slug], args[:parent_title] = slugs.slice(1..-1).join("/"), slugs.first
111
+ else
112
+ p_url_format = "post"
113
+ end
100
114
  else
101
115
  l = ""
102
116
  end
@@ -195,12 +209,14 @@ class CamaleonCms::PostDecorator < CamaleonCms::ApplicationDecorator
195
209
  # children: true/false (show/hide last item link)
196
210
  # show_categories: true/false, true: add categories tree to the breadcrumb
197
211
  def generate_breadcrumb(show_categories = true, add_post_type = true)
212
+ p_type = object.post_type
198
213
  f_cat = object.categories.first
199
214
  if f_cat.present? && show_categories
200
215
  f_cat.decorate.generate_breadcrumb(add_post_type, true)
201
216
  else
202
- object.post_type.decorate.generate_breadcrumb(add_post_type, true)
217
+ p_type.decorate.generate_breadcrumb(add_post_type, true)
203
218
  end
219
+ object.parents.reverse.each{|p| p=p.decorate; h.breadcrumb_add(p.the_title, p.published? ? p.the_url : nil) } if object.post_parent.present? && p_type.manage_hierarchy?
204
220
  h.breadcrumb_add(self.the_title)
205
221
  end
206
222
 
@@ -209,4 +225,15 @@ class CamaleonCms::PostDecorator < CamaleonCms::ApplicationDecorator
209
225
  object.post_type.decorate
210
226
  end
211
227
 
228
+ # return the title with hierarchy prefixed
229
+ # sample: title paren 1 - title parent 2 -.. -...
230
+ # if add_parent_title: true will add parent title like: —— item 1.1.1 | item 1.1
231
+ def the_hierarchy_title
232
+ return the_title unless object.post_parent.present?
233
+ res = '&#8212;' * object.parents.count
234
+ res << " " + the_title
235
+ res << " | #{object.parent.decorate.the_title}" if object.show_title_with_parent
236
+ res.html_safe
237
+ end
238
+
212
239
  end