page_content_marker.rb 711 Bytes
module Kanjai
  class PageContentMarker < ActiveRecord::Base
    belongs_to :page_content

    belongs_to :reference, polymorphic: true


    def get_file_path
      "page-content-marker/#{self.id}/"
    end




    def get_marker_type(type_content)
      page_content = self.page_content
      template = page_content.page.page_template
      subpart = template.template_parts.find_by_code(type_content)
      obj = subpart.field_options.select{|item| item[:name] == self.marker }.first
      if obj
        obj[:attributes]['type']
      else
        return nil
      end

    end

    def self.image?(url)
      ext = File.extname(url)
      ['.jpg', '.gif', '.jpeg', '.png'].include?(ext)
    end

  end
end