Class: CamaleonCms::PostDefault
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CamaleonCms::PostDefault
- Includes:
- CustomFieldsRead, Metas
- Defined in:
- app/models/camaleon_cms/post_default.rb
Overview
Camaleon CMS is a content management system
Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
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.
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.
See the GNU Affero General Public License (GPLv3) for more details.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#draft_id ⇒ Object
Returns the value of attribute draft_id.
Class Method Summary collapse
-
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language).
Instance Method Summary collapse
-
#author ⇒ Object
return the author of this Content.
-
#in_nav_menu_items ⇒ Object
return all menu items in which this post was assigned.
-
#parent ⇒ Object
return the parent of a post (support for sub contents or tree of posts).
-
#set_meta_from_form(data_metas) ⇒ Object
save meta values passed from form.
-
#set_params(meta, field_options, post_data_keywords) ⇒ Object
Set the meta, field values and the post keywords here.
Methods included from CustomFieldsRead
#add_custom_field_group, #add_custom_field_to_default_group, #get_field!, #get_field_groups, #get_field_object, #get_field_value, #get_field_values, #get_field_values_hash, #get_fields_object, #get_user_field_groups, #save_field_value, #set_field_values, #update_field_value
Methods included from Metas
#delete_meta, #delete_option, #fix_save_metas_options_no_changed, #get_meta, #get_option, #options, #save_metas_options, #save_metas_options_skip, #set_meta, #set_multiple_options, #set_option
Instance Attribute Details
#draft_id ⇒ Object
Returns the value of attribute draft_id.
15 16 17 |
# File 'app/models/camaleon_cms/post_default.rb', line 15 def draft_id @draft_id end |
Class Method Details
.find_by_slug(slug) ⇒ Object
find a content by slug (support multi language)
32 33 34 35 36 37 38 39 |
# File 'app/models/camaleon_cms/post_default.rb', line 32 def self.find_by_slug(slug) if current_site.present? && current_site.("languages_site", []).count <= 1 res = self.where(slug: slug) else res = self.where("#{CamaleonCms::Post.table_name}.slug = ? OR #{CamaleonCms::Post.table_name}.slug LIKE ? ", slug, "%-->#{slug}<!--%") end res.reorder("").first end |
Instance Method Details
#author ⇒ Object
return the author of this Content
47 48 49 50 51 52 53 |
# File 'app/models/camaleon_cms/post_default.rb', line 47 def begin CamaleonCms::User.find(self.user_id) rescue CamaleonCms::User.admin_scope.first end end |
#in_nav_menu_items ⇒ Object
return all menu items in which this post was assigned
63 64 65 |
# File 'app/models/camaleon_cms/post_default.rb', line 63 def CamaleonCms::NavMenuItem.joins(:metas).where("value LIKE ?","%\"object_id\":\"#{self.id}\"%").where("value LIKE ?","%\"type\":\"post\"%").readonly(false) end |
#parent ⇒ Object
return the parent of a post (support for sub contents or tree of posts)
42 43 44 |
# File 'app/models/camaleon_cms/post_default.rb', line 42 def parent CamaleonCms::Post.where(id: self.post_parent).first end |
#set_meta_from_form(data_metas) ⇒ Object
save meta values passed from form
56 57 58 59 60 |
# File 'app/models/camaleon_cms/post_default.rb', line 56 def () .each do |key, value| self.(key, value) end end |
#set_params(meta, field_options, post_data_keywords) ⇒ Object
Set the meta, field values and the post keywords here
68 69 70 71 72 |
# File 'app/models/camaleon_cms/post_default.rb', line 68 def set_params(, , post_data_keywords) self.() self.set_field_values() self.set_option("keywords", post_data_keywords) end |