Class: Ecm::CmsCore::Template

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/ecm/cms_core/template.rb

Defined Under Namespace

Classes: Resolver

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.partialsObject



55
56
57
# File 'app/models/ecm/cms_core/template.rb', line 55

def self.partials
  where("partial = ?", true)
end

.templatesObject



59
60
61
# File 'app/models/ecm/cms_core/template.rb', line 59

def self.templates
  where("partial = ?", false)
end

Instance Method Details

#available_localeObject



21
22
23
# File 'app/models/ecm/cms_core/template.rb', line 21

def available_locale
  I18n.available_locales.map(&:to_s).include?(self.locale)
end

#filenameObject



63
64
65
66
67
68
69
# File 'app/models/ecm/cms_core/template.rb', line 63

def filename
  if format.blank?
  "#{basename}.#{locale}.#{handler}"
  else    
    "#{basename}.#{locale}.#{format}.#{handler}"
  end
end

#formatted_partial_flagObject



71
72
73
# File 'app/models/ecm/cms_core/template.rb', line 71

def formatted_partial_flag
  ::I18n.t(self.partial.to_s)
end

#normalize_localeObject



25
26
27
# File 'app/models/ecm/cms_core/template.rb', line 25

def normalize_locale
  self.locale = self.locale.to_s
end

#set_defaultsObject



29
30
31
32
33
34
35
# File 'app/models/ecm/cms_core/template.rb', line 29

def set_defaults
  if self.new_record?
    self.locale  ||= I18n.default_locale
    # self.format  ||= 'html'
    self.handler ||= 'texterb'
  end
end

#to_sObject



75
76
77
# File 'app/models/ecm/cms_core/template.rb', line 75

def to_s
  "#{self.pathname}#{self.basename}"
end

#update_pathnameObject



37
38
39
40
41
42
43
44
# File 'app/models/ecm/cms_core/template.rb', line 37

def update_pathname
  self.pathname = self.folder.fullname unless self.folder.blank?
#        if self.folder.blank?
#          self.pathname = "/"
#        else
#          self.pathname = self.folder.fullname 
#        end  
end

#update_pathname!Object



46
47
48
49
# File 'app/models/ecm/cms_core/template.rb', line 46

def update_pathname!
  self.update_pathname
  self.save!
end