Sha256: 26b00d5a8aeb1b3a238b5200528c887537fb74829efd16923255a130dfd7a60b

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

module Optimacms
  class TemplateTranslation < ActiveRecord::Base
    self.table_name = 'cms_templates_translation'

    belongs_to :template, :foreign_key => 'item_id', :class_name => 'Template'

    delegate :basename, :basedirpath, :tpl_format, :is_type_partial?, to: :template

    ### content

    def content
      filename =  fullpath
      return nil if filename.nil?
      return '' if !File.exists? filename
      File.read(filename)
    end

    def content=(v)
      File.open(self.fullpath, "w+") do |f|
        f.write(v)
      end
    end


    ### path

    # base filename depending on  type
    # for page = name
    # for partial = _name
    def filename_base
      return '_'+basename if is_type_partial?
      basename
    end


    def path
      return nil if basename.nil?
      basedirpath + filename_base + Template.filename_lang_postfix(lang) + Template.filename_ext_with_dot(self.tpl_format)
    end

    def fullpath
      f = path
      return nil if f.nil?
      Template.base_dir + f
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
optimacms-0.1.61 app/models/optimacms/template_translation.rb
optimacms-0.3.9 app/models/optimacms/template_translation.rb
optimacms-0.3.8 app/models/optimacms/template_translation.rb
optimacms-0.3.7 app/models/optimacms/template_translation.rb
optimacms-0.3.6 app/models/optimacms/template_translation.rb
optimacms-0.3.5 app/models/optimacms/template_translation.rb
optimacms-0.3.2 app/models/optimacms/template_translation.rb
optimacms-0.3.1 app/models/optimacms/template_translation.rb
optimacms-0.2.23 app/models/optimacms/template_translation.rb
optimacms-0.2.22 app/models/optimacms/template_translation.rb
optimacms-0.2.19 app/models/optimacms/template_translation.rb
optimacms-0.2.18 app/models/optimacms/template_translation.rb
optimacms-0.2.17 app/models/optimacms/template_translation.rb
optimacms-0.2.8 app/models/optimacms/template_translation.rb
optimacms-0.2.7 app/models/optimacms/template_translation.rb
optimacms-0.2.6 app/models/optimacms/template_translation.rb
optimacms-0.2.5 app/models/optimacms/template_translation.rb