Module: CamaleonCms::Admin::PostTypeHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/camaleon_cms/admin/post_type_helper.rb

Overview

encoding: utf-8

Instance Method Summary collapse

Instance Method Details

#cama_hierarchy_post_list(posts_list, parent_id = nil, skip_non_parent_posts = false) ⇒ Object

sort array of posts to build post’s tree skip_non_parent_posts: don’t include post’s where root post doesn’t exist internal control for recursive items



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 37

def cama_hierarchy_post_list(posts_list, parent_id = nil, skip_non_parent_posts = false)
  res = []
  @_cama_hierarchy_post_list_no_parent ||= posts_list.clone
  posts_list.each do |element|
    if element.post_parent.to_s == parent_id.to_s
      res << element
      @_cama_hierarchy_post_list_no_parent.delete_item(element)
      res += cama_hierarchy_post_list(posts_list, element.id)
    end
  end

  if !parent_id.present? && !skip_non_parent_posts
    @_cama_hierarchy_post_list_no_parent.each do |element|
      element.show_title_with_parent = true
      res << element
      res += cama_hierarchy_post_list(posts_list, element.id)
    end
  end
  res
end

#post_type_html_inputs(post_type, taxonomy = "categories", name = "categories", type = "checkbox", values = [], class_cat = "categorychecklist", required = false) ⇒ Object

taxonomy -> (categories || post_tags)



13
14
15
16
17
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 13

def post_type_html_inputs(post_type, taxonomy="categories", name ="categories", type="checkbox", values=[], class_cat="categorychecklist" , required = false)
  categories = post_type.send(taxonomy)
  categories = categories.eager_load(:children, :post_type_parent, :parent) if taxonomy == "categories" || taxonomy == "children"
  post_type_taxonomy_html_(categories,taxonomy, name, type, values, class_cat, required)
end

#post_type_list_taxonomy(taxonomies, color = "primary") ⇒ Object

taxonomies -> (categories || post_tags)



25
26
27
28
29
30
31
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 25

def post_type_list_taxonomy(taxonomies, color="primary")
  html = ""
  taxonomies.decorate.each do |f|
    html += "<a class='cama_ajax_request' href='#{cama_admin_post_type_taxonomy_posts_path(@post_type.id, f.taxonomy, f.id)}'><span class='label label-#{color} label-form'>#{f.the_title}</span></a> "
  end
  return html
end

#post_type_status(status, color = "default") ⇒ Object



19
20
21
22
# File 'app/helpers/camaleon_cms/admin/post_type_helper.rb', line 19

def post_type_status(status, color="default")
  html = "<span class='label label-#{color} label-form'>#{status}</span>"

end