Sha256: 2fcf6e5c466f50e55470fb595522559c89751c0c35b10601d544a6d55282015e

Contents?: true

Size: 1.06 KB

Versions: 22

Compression:

Stored size: 1.06 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

22 entries across 22 versions & 1 rubygems

Version Path
optimacms-0.3.35 app/models/optimacms/template_translation.rb
optimacms-0.3.34 app/models/optimacms/template_translation.rb
optimacms-0.3.30 app/models/optimacms/template_translation.rb
optimacms-0.3.29 app/models/optimacms/template_translation.rb
optimacms-0.3.23 app/models/optimacms/template_translation.rb
optimacms-0.3.15 app/models/optimacms/template_translation.rb
optimacms-0.3.12 app/models/optimacms/template_translation.rb
optimacms-0.3.11 app/models/optimacms/template_translation.rb
optimacms-0.2.26 app/models/optimacms/template_translation.rb
optimacms-0.2.25 app/models/optimacms/template_translation.rb
optimacms-0.2.24 app/models/optimacms/template_translation.rb
optimacms-0.3.4 app/models/optimacms/template_translation.rb
optimacms-0.3.3 app/models/optimacms/template_translation.rb
optimacms-0.2.21 app/models/optimacms/template_translation.rb
optimacms-0.2.20 app/models/optimacms/template_translation.rb
optimacms-0.2.16 app/models/optimacms/template_translation.rb
optimacms-0.2.15 app/models/optimacms/template_translation.rb
optimacms-0.2.14 app/models/optimacms/template_translation.rb
optimacms-0.2.13 app/models/optimacms/template_translation.rb
optimacms-0.2.12 app/models/optimacms/template_translation.rb