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
@@ -12,7 +12,7 @@ class CamaleonCms::PostUniqValidator < ActiveModel::Validator
12
12
  slug_array = record.slug.to_s.translations_array
13
13
  ptype = record.post_type
14
14
  if ptype.present? # only for posts that belongs to a post type model
15
- posts = ptype.site.posts.where("(#{slug_array.map {|s| "#{CamaleonCms::Post.table_name}.slug LIKE '%-->#{s}<!--%'"}.join(" OR ")} ) OR #{CamaleonCms::Post.table_name}.slug = ?", record.slug).where("#{CamaleonCms::Post.table_name}.status != 'draft'").where(post_parent: nil).where.not(id: record.id)
15
+ posts = ptype.site.posts.where("(#{slug_array.map {|s| "#{CamaleonCms::Post.table_name}.slug LIKE '%-->#{s}<!--%'"}.join(" OR ")} ) OR #{CamaleonCms::Post.table_name}.slug = ?", record.slug).where("#{CamaleonCms::Post.table_name}.status != 'draft'").where.not(id: record.id)
16
16
  if posts.size > 0
17
17
  if slug_array.size > 1
18
18
  record.errors[:base] << "#{I18n.t('camaleon_cms.admin.post.message.requires_different_slug')}: #{posts.pluck(:slug).map{|slug| record.slug.to_s.translations.map{|lng, r_slug| "#{r_slug} (#{lng})" if slug.translations_array.include?(r_slug) }.join(",") }.join(",").split(",").uniq.clean_empty.join(", ")} "
@@ -20,6 +20,9 @@ class CamaleonCms::PostUniqValidator < ActiveModel::Validator
20
20
  record.errors[:base] << "#{I18n.t('camaleon_cms.admin.post.message.requires_different_slug')}: #{record.slug.to_s} "
21
21
  end
22
22
  end
23
+
24
+ # avoid recursive page parent
25
+ record.errors[:base] << I18n.t('camaleon_cms.admin.post.message.recursive_hierarchy', default: 'Parent Post Recursive') if record.post_parent.present? && ptype.manage_hierarchy? && record.parents.cama_pluck(:id).include?(record.id)
23
26
  else
24
27
  # validation for other classes
25
28
  end
@@ -29,7 +32,7 @@ end
29
32
 
30
33
  class CamaleonCms::Post < CamaleonCms::PostDefault
31
34
  include CamaleonCms::CategoriesTagsForPosts
32
- default_scope ->{ where(post_class: "Post").order(post_order: :asc) }
35
+ default_scope ->{ where(post_class: "Post").order(post_order: :asc, created_at: :desc) }
33
36
  has_many :metas, ->{ where(object_class: 'Post')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :destroy
34
37
 
35
38
  # DEPRECATED
@@ -54,11 +57,35 @@ class CamaleonCms::Post < CamaleonCms::PostDefault
54
57
  scope :trash, -> {where(status: 'trash')}
55
58
  scope :no_trash, -> {where.not(status: 'trash')}
56
59
  scope :published, -> {where(status: 'published')}
60
+ scope :root_posts, -> {where(post_parent: [nil, ''])}
57
61
  scope :drafts, -> {where(status: 'draft')}
58
62
  scope :pendings, -> {where(status: 'pending')}
59
63
  scope :latest, -> {reorder(created_at: :desc)}
60
64
 
61
65
  validates_with CamaleonCms::PostUniqValidator
66
+ attr_accessor :show_title_with_parent
67
+
68
+ # return all parents for current page hierarchy ordered bottom to top
69
+ def parents
70
+ cama_fetch_cache("parents_#{self.id}") do
71
+ res = []
72
+ p = self.parent
73
+ while p.present?
74
+ res << p
75
+ p = p.parent
76
+ end
77
+ res
78
+ end
79
+ end
80
+
81
+ # return all children elements for current post (page hierarchy)
82
+ def full_children
83
+ cama_fetch_cache("full_children_#{self.id}") do
84
+ res = self.children.to_a
85
+ res.each{|c| res += c.full_children }
86
+ res
87
+ end
88
+ end
62
89
 
63
90
  # return the post type of this post (DEPRECATED)
64
91
  def get_post_type_depre
@@ -22,6 +22,9 @@ class CamaleonCms::PostType < CamaleonCms::TermTaxonomy
22
22
  scope :hidden_menu, -> {where(term_group: -1)}
23
23
  before_destroy :destroy_field_groups
24
24
  after_create :set_default_site_user_roles
25
+ after_create :refresh_routes
26
+ after_destroy :refresh_routes
27
+ after_update :check_refresh_routes
25
28
  before_update :default_category
26
29
 
27
30
  # check if current post type manage categories
@@ -135,7 +138,8 @@ class CamaleonCms::PostType < CamaleonCms::TermTaxonomy
135
138
  "post_of_category" => "<code>/category/:category_id-:title/:slug</code><br> (Sample: http://localhost.com/category/17-services/myservice.html)",
136
139
  "post_of_category_post_type" => "<code>/:post_type_title/category/:category_id-:title/:slug</code><br> (Sample: http://localhost.com/services/category/17-services/myservice.html)",
137
140
  "post_of_posttype" => "<code>/:post_type_title/:slug</code><br> (Sample: http://localhost.com/services/myservice.html)",
138
- "post" => "<code>/:slug</code><br> (Sample: http://localhost.com/myservice.html)"
141
+ "post" => "<code>/:slug</code><br> (Sample: http://localhost.com/myservice.html)",
142
+ "hierarchy_post" => "<code>/:parent1_slug/:parent2_slug/.../:slug</code><br> (Sample: http://localhost.com/item-1/item-1-1/item-111.html)"
139
143
  }
140
144
  end
141
145
 
@@ -144,6 +148,11 @@ class CamaleonCms::PostType < CamaleonCms::TermTaxonomy
144
148
  get_option("contents_route_format", "post")
145
149
  end
146
150
 
151
+ # verify if this post_type support for page hierarchy (parents)
152
+ def manage_hierarchy?
153
+ get_option('has_parent_structure', false)
154
+ end
155
+
147
156
  private
148
157
  # skip save_metas_options callback after save changes (inherit from taxonomy) to call from here manually
149
158
  def save_metas_options_skip
@@ -168,4 +177,14 @@ class CamaleonCms::PostType < CamaleonCms::TermTaxonomy
168
177
  self.get_field_groups.destroy_all
169
178
  end
170
179
 
180
+ # reload routes to enable this post type url, like: http://localhost/my-slug
181
+ def refresh_routes
182
+ PluginRoutes.reload
183
+ end
184
+
185
+ # check if slug was changed
186
+ def check_refresh_routes
187
+ refresh_routes if self.slug_changed?
188
+ end
189
+
171
190
  end
@@ -33,7 +33,7 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
33
33
  # all user roles for this site
34
34
  def user_roles
35
35
  if PluginRoutes.system_info["users_share_sites"]
36
- CamaleonCms::Site.first.user_roles_rel
36
+ CamaleonCms::Site.main_site.user_roles_rel
37
37
  else
38
38
  user_roles_rel
39
39
  end
@@ -134,16 +134,15 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
134
134
  if user_role.valid?
135
135
  d = {}
136
136
  if post_type.present?
137
- d = user_role.get_meta("_post_type", {})
137
+ d = user_role.get_meta("_post_type_#{self.id}", {})
138
138
  CamaleonCms::UserRole::ROLES[:post_type].each { |value|
139
- value_old = d[value[:key]] || []
140
- d[value[:key]] = value_old + [post_type.id]
139
+ value_old = d[value[:key].to_sym] || []
140
+ d[value[:key].to_sym] = value_old + [post_type.id]
141
141
  }
142
142
  else
143
143
  pts = self.post_types.all.pluck(:id)
144
144
  CamaleonCms::UserRole::ROLES[:post_type].each { |value| d[value[:key]] = pts }
145
145
  end
146
-
147
146
  user_role.set_meta("_post_type_#{self.id}", d || {})
148
147
  end
149
148
 
@@ -151,16 +150,15 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
151
150
  if user_role.valid?
152
151
  d = {}
153
152
  if post_type.present?
154
- d = user_role.get_meta("_post_type", {})
153
+ d = user_role.get_meta("_post_type_#{self.id}", {})
155
154
  CamaleonCms::UserRole::ROLES[:post_type].each { |value|
156
- value_old = d[value[:key]] || []
157
- d[value[:key]] = value_old + [post_type.id] if value[:key].to_s == 'edit'
155
+ value_old = d[value[:key].to_sym] || []
156
+ d[value[:key].to_sym] = value_old + [post_type.id] if value[:key].to_s == 'edit'
158
157
  }
159
158
  else
160
159
  pts = self.post_types.all.pluck(:id)
161
160
  CamaleonCms::UserRole::ROLES[:post_type].each { |value| d[value[:key]] = pts if value[:key].to_s == 'edit' }
162
161
  end
163
-
164
162
  user_role.set_meta("_post_type_#{self.id}", d || {})
165
163
  end
166
164
 
@@ -176,13 +174,13 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
176
174
 
177
175
  # return main site
178
176
  def self.main_site
179
- CamaleonCms::Site.first
177
+ @main_site ||= CamaleonCms::Site.reorder(id: :ASC).first
180
178
  end
181
179
 
182
180
  # check if this site is the main site
183
181
  # main site is a site that doesn't have slug
184
182
  def main_site?
185
- @_is_default_site ||= (CamaleonCms::Site.first.id == self.id)
183
+ self.class.main_site == self
186
184
  end
187
185
 
188
186
  alias_method :is_default?, :main_site?
@@ -217,9 +215,10 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
217
215
 
218
216
  # return an available slug for a new post
219
217
  # slug: (String) possible slug value
218
+ # post_id: (integer, optional) current post id
220
219
  # sample: ("<!--:es-->features-1<!--:--><!--:en-->caract-1<!--:-->") | ("features")
221
220
  # return: (String) available slugs
222
- def get_valid_post_slug(slug)
221
+ def get_valid_post_slug(slug, post_id=nil)
223
222
  slugs = slug.translations
224
223
  if slugs.present?
225
224
  slugs.each do |k, v|
@@ -229,7 +228,8 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
229
228
  else
230
229
  res = slug
231
230
  (1..9999).each do |i|
232
- break unless self.posts.find_by_slug(res)
231
+ p = self.posts.find_by_slug(res)
232
+ break if !p.present? || (p.present? && p.id == post_id)
233
233
  res = "#{slug}-#{i}"
234
234
  end
235
235
  res
@@ -287,13 +287,13 @@ class CamaleonCms::Site < CamaleonCms::TermTaxonomy
287
287
  # update all routes of the system
288
288
  # reload system routes for this site
289
289
  def update_routes
290
- if self.id == CamaleonCms::Site.first.id
291
- set_option("base_domain", self.slug, "main_settings") if self.slug.present?
292
- end
293
- PluginRoutes.reload
290
+ PluginRoutes.reload if self.slug_changed?
294
291
  end
295
292
 
296
293
  def before_validating
297
- #overwriting/skipping term_taxonomy validations
294
+ slug = self.slug
295
+ slug = self.name if slug.blank?
296
+ self.name = slug unless self.name.present?
297
+ self.slug = slug.to_s.try(:downcase)
298
298
  end
299
- end
299
+ end
@@ -67,7 +67,7 @@ class CamaleonCms::TermTaxonomy < ActiveRecord::Base
67
67
  slug = self.slug
68
68
  slug = self.name if slug.blank?
69
69
  self.name = slug unless self.name.present?
70
- self.slug = slug.to_s.parameterize
70
+ self.slug = slug.to_s.parameterize.try(:downcase)
71
71
  end
72
72
 
73
73
  # destroy all dependencies
@@ -97,13 +97,15 @@ module CamaleonCms::CustomFieldsRead extend ActiveSupport::Concern
97
97
 
98
98
 
99
99
  # return all values
100
- # {key1: value3, key2: [value1, value2], key3: value4}
101
- def get_field_values_hash
100
+ # {key1: "single value", key2: [multiple, values], key3: value4} if include_options = false
101
+ # {key1: {values: "single value", options: {a:1, b: 4}}, key2: {values: [multiple, values], options: {a=1, b=2} }} if include_options = true
102
+ def get_field_values_hash(include_options = false)
102
103
  fields = {}
103
104
  self.field_values.to_a.uniq.each do |field_value|
104
105
  custom_field = field_value.custom_fields
105
106
  values = custom_field.values.where(objectid: self.id).pluck(:value)
106
- fields[field_value.custom_field_slug] = custom_field.options[:multiple].to_s.to_bool ? values : values.first
107
+ fields[field_value.custom_field_slug] = custom_field.options[:multiple].to_s.to_bool ? values : values.first unless include_options
108
+ fields[field_value.custom_field_slug] = {values: custom_field.options[:multiple].to_s.to_bool ? values : values.first, options: custom_field.options, id: custom_field.id} if include_options
107
109
  end
108
110
  fields.to_sym
109
111
  end
@@ -219,7 +221,7 @@ module CamaleonCms::CustomFieldsRead extend ActiveSupport::Concern
219
221
  end
220
222
 
221
223
  def _destroy_custom_field_groups
222
- class_name = self.class.to_s.gsub("Decorator","")
224
+ class_name = self.class.to_s.parseCamaClass
223
225
  if ['Category','Post','PostTag'].include?(class_name)
224
226
  CamaleonCms::CustomFieldGroup.where(objectid: self.id, object_class: class_name).destroy_all
225
227
  elsif ['PostType'].include?(class_name)
@@ -28,14 +28,15 @@ module CamaleonCms::Metas extend ActiveSupport::Concern
28
28
  # if meta not exist, return default
29
29
  # return default if meta value == ""
30
30
  def get_meta(key, default = nil)
31
- cama_fetch_cache("meta_#{key}") do
32
- option = metas.where(key: key).first
33
- res = ""
31
+ key_str = key.is_a?(Symbol) ? key.to_s : key
32
+ cama_fetch_cache("meta_#{key_str}") do
33
+ option = metas.select { |m| m.key.eql?(key_str) }.first
34
+ res = ''
34
35
  if option.present?
35
36
  value = JSON.parse(option.value) rescue option.value
36
37
  res = (value.is_a?(Hash) ? value.to_sym : value) rescue option.value
37
38
  end
38
- res == "" ? default : res
39
+ res == '' ? default : res
39
40
  end
40
41
  end
41
42
 
@@ -1,6 +1,8 @@
1
1
  <form class="menus_field_form required">
2
- <%= render partial: "camaleon_cms/camaleon_cms/admin/settings/custom_fields/render", locals: {record: @nav_menu, field_groups: @nav_menu.get_field_groups()} %>
2
+ <% if @nav_menu.present? %>
3
+ <%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @nav_menu, field_groups: @nav_menu.get_field_groups()} %>
4
+ <% end %>
3
5
  <div class="text-right">
4
6
  <button class="btn btn-primary" type="submit"><%= t("camaleon_cms.admin.button.submit") %> <i class="fa fa-arrow-right"></i></button>
5
7
  </div>
6
- </form>
8
+ </form>
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  <div class="form-group">
8
8
  <label><%= t('camaleon_cms.admin.menus.link_url')%></label>
9
- <input id="external_url" class="form-control" name="external_url" />
9
+ <input id="external_url" class="form-control translatable" name="external_url" />
10
10
  </div>
11
11
  <div class="text-right">
12
12
  <button type="submit" id="add_external_link" class="btn btn-primary"><%= t('camaleon_cms.admin.button.add_menu')%> <i class="fa fa-arrow-right"></i></button>
@@ -43,13 +43,11 @@
43
43
  <div class=" tab-content">
44
44
  <div class="tab-pane active class_type" id="tab-<%= pt.slug %>-posts" data-type="post" data-post_type="<%= pt.slug %>">
45
45
  <ul class="categorychecklist">
46
- <% pt.posts.eager_load(:post_type).published.each do |p|
47
- p = p.decorate
48
- %>
46
+ <% (pt.manage_hierarchy? ? cama_hierarchy_post_list(pt.posts.eager_load(:post_type).published.decorate.to_a) : pt.posts.eager_load(:post_type).published.decorate).each do |p| %>
49
47
  <li>
50
48
  <label class="class_slug" data-post_link_edit="<%= p.the_edit_url %>">
51
49
  <input type="checkbox" value="<%= p.id %>">
52
- <%= p.the_title %>
50
+ <%= p.the_hierarchy_title %>
53
51
  </label>
54
52
  </li>
55
53
  <% end %>
@@ -99,9 +97,8 @@
99
97
  </div>
100
98
  <!-- END PAGE CONTENT WRAPPER -->
101
99
  </div>
102
-
103
100
  <script>
104
- var RENDER_FORM = '<%= cama_admin_appearances_nav_menus_form_path(menu_id: @nav_menu.id) %>';
101
+ var RENDER_FORM = '<%= cama_admin_appearances_nav_menus_form_path(menu_id: @nav_menu.id, cama_skip_breadcrumb: true, item_id: '-9999') %>';
105
102
  var main_menus_panel;
106
103
  jQuery(function(){
107
104
  main_menus_panel = $("#menu_content");
@@ -41,6 +41,7 @@
41
41
  <%= link_to raw('<i class="fa fa-list"></i>'), cama_admin_post_type_taxonomy_posts_path(@post_type.id, "category", item.id), class: "btn btn-default btn-xs cama_ajax_request", title: "#{@post_type.decorate.the_title.pluralize} - #{item.the_title.to_s.titleize}" if @post_type.present? && (can? :posts, @post_type) %>
42
42
  <%= link_to raw('<i class="fa fa-pencil"></i>'), {action: :edit, id: item.id }, class: "btn btn-default btn-xs cama_ajax_request", title: "#{t('camaleon_cms.admin.button.edit')}" %>
43
43
  <%= link_to raw('<i class="fa fa-times"></i>'), { action: :destroy, id: item.id },method: :delete, data: { confirm: t('camaleon_cms.admin.message.delete') }, class: "btn btn-danger btn-xs cama_ajax_request", title: "#{t('camaleon_cms.admin.button.delete')}" unless item.get_option('not_deleted', false) %>
44
+ <%= link_to raw('<i class="fa fa-eye"></i>'), item.the_url, class: "btn btn-info btn-xs", title: "#{t('camaleon_cms.common.visit')}" %>
44
45
  </td>
45
46
  </tr>
46
47
  <%
@@ -1,7 +1,7 @@
1
- <% @tree[:files].each do |file| next if @media_formats.present? && !@media_formats.include?(file["format"]) %>
1
+ <% files.each do |file| next if @media_formats.present? && !@media_formats.include?(file["format"]) && !@media_formats.include?(file["url"].split('.').last) %>
2
2
  <%= render "render_file_item", file: file %>
3
3
  <% end %>
4
4
 
5
- <% @tree[:folders].each do |fname, folder| %>
5
+ <% folders.each do |fname, folder| %>
6
6
  <%= render "render_folder_item", fname: fname, folder: folder %>
7
- <% end %>
7
+ <% end %>
@@ -10,8 +10,9 @@
10
10
  <% when "compress" %>
11
11
  <i class="fa fa-file-archive-o"></i>
12
12
  <% when "doc" %>
13
+ <% when "document" %>
13
14
  <i class="fa fa-file-text-o"></i>
14
- <% when "else" %>
15
+ <% else %>
15
16
  <i class="fa fa-file-o"></i>
16
17
  <% end %>
17
18
  </div>
@@ -21,7 +22,7 @@
21
22
  <textarea class="hidden data_value"><%= raw file.to_json %></textarea>
22
23
  <% if @show_file_actions %>
23
24
  <div class="actions">
24
- <a href="#" class="del_item"><i class="fa fa-trash"></i></a>
25
+ <a href="#" class="del_item btn btn-danger btn-xs"><i class="fa fa-trash"></i></a>
25
26
  </div>
26
27
  <% end %>
27
28
  </div>
@@ -1,4 +1,19 @@
1
- <div id="cama_media_gallery" data-url_actions="<%= actions_cama_admin_media_path(actions: @show_file_actions) %>" data-formats="<%= @media_formats.join(",") %>" data-folder="<%= @folder %>" data-url="<%= ajax_cama_admin_media_path(actions: @show_file_actions) %>">
1
+ <div class="row">
2
+ <div class="col-md-3 col-md-offset-9">
3
+ <%= form_tag search_cama_admin_media_path, method: 'get' do %>
4
+ <div class="input-group">
5
+ <%= text_field_tag :q, @search, class: 'form-control' %>
6
+ <span class="input-group-btn">
7
+ <%= submit_tag t('camaleon_cms.admin.button.search'), class: 'btn btn-default' %>
8
+ </span>
9
+ </div>
10
+ <% end %>
11
+ </div>
12
+ </div>
13
+
14
+ <br/>
15
+
16
+ <div id="cama_media_gallery" data-url_actions="<%= actions_cama_admin_media_path(actions: @show_file_actions, dimension: params[:dimension]) %>" data-formats="<%= @media_formats.join(",") %>" data-folder="<%= @folder %>" data-url="<%= ajax_cama_admin_media_path(actions: @show_file_actions) %>" data-dimension="<%= params[:dimension] %>">
2
17
  <div class="panel panel-default">
3
18
  <div class="panel-heading">
4
19
  <div class="row">
@@ -16,7 +31,7 @@
16
31
  <div class="panel-body">
17
32
  <div class="row" style="margin-bottom: 16px">
18
33
  <div class="col-md-9 media_browser_list">
19
- <%= render "files_list" %>
34
+ <%= render "files_list", files: @tree[:files], folders: @tree[:folders] %>
20
35
  </div>
21
36
 
22
37
  <div class="col-md-3 media_file_info_col">
@@ -26,7 +41,19 @@
26
41
  </ul>
27
42
  <div class="tab-content">
28
43
  <div role="tabpanel" class="tab-pane active" id="cama_media_upload">
29
- <div class="cama_media_fileuploader" data-url="<%= upload_cama_admin_media_path(actions: @show_file_actions) %>"><%= t("camaleon_cms.admin.button.upload_file") %></div>
44
+ <div class="cama_media_fileuploader" data-url="<%= upload_cama_admin_media_path(actions: @show_file_actions, dimension: params[:dimension]) %>" data-dragDropStr="<%= t("camaleon_cms.admin.button.drag_drop") %>" data-uploadStr="<%= t("camaleon_cms.admin.button.upload_file") %>"><%= t("camaleon_cms.admin.button.upload_file") %></div>
45
+ <hr/>
46
+ <form id="cama_media_external">
47
+ <fieldset>
48
+ <legend><%= t("camaleon_cms.admin.media.external", default: 'From URL') %></legend>
49
+ <div class="form-group">
50
+ <input type="text" class="form-control" placeholder="http://..." class="required">
51
+ </div>
52
+ <div class="form-group">
53
+ <button type="submit" class="btn btn-primary"><%= t("camaleon_cms.admin.button.submit") %></button>
54
+ </div>
55
+ </fieldset>
56
+ </form>
30
57
  </div>
31
58
  <div role="tabpanel" class="tab-pane" id="cama_media_info">
32
59
  <div class="media_file_info"></div>
@@ -39,4 +66,4 @@
39
66
  </div>
40
67
  <script>jQuery(function () {
41
68
  cama_init_media($("#cama_media_gallery"));
42
- });</script>
69
+ });</script>
@@ -1,4 +1,4 @@
1
- <div class="content-frame-right col-md-3">
1
+ <div class="col-md-3" id="post_right_bar">
2
2
 
3
3
  <div id="post-actions" class="panel panel-default panel-lite">
4
4
  <div class="panel-body ">
@@ -65,6 +65,14 @@
65
65
  </div>
66
66
  <% end %>
67
67
 
68
+ <!-- page hierarchi -->
69
+ <% if @post_type.manage_hierarchy? %>
70
+ <div class="form-group">
71
+ <label class="control-label"><%= t('camaleon_cms.admin.post_type.post_parent', layout: 'Parent Page')%></label>
72
+ <%= f.select :post_parent, cama_hierarchy_post_list(@post_type.posts.published.decorate.to_a).map{|p| [p.the_hierarchy_title, p.id] }, { include_blank: true, selected: (params[:post][:post_parent] rescue false || @post.post_parent ), disabled: (@post.full_children.cama_pluck(:id) << @post.id) }, {class: 'form-control'} %>
73
+ </div>
74
+ <% end %>
75
+
68
76
  <!-- has comments? -->
69
77
  <% if @post.manage_comments?(@post_type) %>
70
78
  <div class="form-group">
@@ -80,6 +88,7 @@
80
88
  <div class="panel-heading">
81
89
  <h3 class="panel-title"><%= t('camaleon_cms.admin.post_type.categories')%> <em class="text-danger">*</em></h3>
82
90
  <ul class="panel-controls">
91
+ <li><a id="post_add_new_category" data-reload-url="<%= list_cama_admin_post_type_categories_path(@post_type.id) %>" href="<%= cama_admin_post_type_categories_path(@post_type.id, cama_body_class: true) %>" title="<%= t("camaleon_cms.admin.post.create_category", default: 'Create New Category') %>" class="panel-add-category"><span class="fa fa-plus"></span></a></li>
83
92
  <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
84
93
  </ul>
85
94
  </div>
@@ -27,7 +27,7 @@
27
27
  <%= hidden_field :meta, :slug %>
28
28
  <div class="form-group">
29
29
  <%= f.label t('camaleon_cms.admin.table.title') %> <em class="text-danger">*</em><br>
30
- <%= f.text_field :title, :class => "form-control required translatable title-post" %>
30
+ <%= f.text_field :title, :class => "form-control required translatable required_all_langs title-post" %>
31
31
  </div>
32
32
  <% if @post.manage_content?(@post_type) %>
33
33
  <div class="form-group">
@@ -51,7 +51,11 @@
51
51
  </div>
52
52
 
53
53
  <!-- render all custom fields assigned to this post -->
54
- <%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @post, field_groups: @post.get_field_groups({kind: "Post", include_parent: true}), show_shortcode: true} %>
54
+ <%
55
+ r = {render: 'camaleon_cms/admin/settings/custom_fields/render', record: @post, field_groups: @post.get_field_groups({kind: 'Post', include_parent: true}), show_shortcode: true}
56
+ hooks_run('posts_form_custom_fields_render', r)
57
+ %>
58
+ <%= render partial: r[:render], locals: {record: r[:record], field_groups: r[:field_groups], show_shortcode: r[:show_shortcode]} %>
55
59
 
56
60
  <% unless @post.draft? || @post.new_record? %>
57
61
  <% if @post.manage_comments?(@post_type) %>