Sha256: 13511cf6493ebe7a58ae828bce6f4bf622fdb7cbe6cf6426d78809444062be43

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

class Admin::LanguagesController < AlchemyController
  
  filter_resource_access
  before_filter :set_translation
  
  def index
    if !params[:query].blank?
      @languages = Language.where([
        "languages.name LIKE ? OR languages.code = ? OR languages.frontpage_name LIKE ?",
        "%#{params[:query]}%",
        "#{params[:query]}",
        "%#{params[:query]}%"
      ])
    else
      @languages = Language.all
    end
  end

  def new
    @language = Language.new
    render :layout => false
  end

  def edit
    render :layout => false
  end

  def create
    @language = Language.new(params[:language])
    @language.save
    render_errors_or_redirect(
      @language,
      admin_languages_path,
      ( _("Language '%{name}' created") % {:name => @language.name} ),
      "form#new_language button.button"
    )
  end

  def update
    @language.update_attributes(params[:language])
    render_errors_or_redirect(
      @language,
      admin_languages_path,
      ( _("Language '%{name}' updated") % {:name => @language.name} ),
      "form#edit_language_#{@language.id} button.button"
    )
  end

  def destroy
    name = @language.name
    if @language.destroy
      flash[:notice] = ( _("Language '%{name}' destroyed") % {:name => name} )
      set_language_to_default
    end
    render(:update) { |page| page.redirect_to(admin_languages_url) }
  rescue Exception => e
    render :update do |page|
      page << "confirm.close();"
      page.call('Alchemy.growl', e, :error)
    end
    logger.error("++++++++++++++ #{e}")
  end

private

  def find_language
    @language = Language.find(params[:id])
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
alchemy_cms-2.0.7 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.6.1 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.5 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.4 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.3.1 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.3 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.2 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.1 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.rc6 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.rc5 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.rc4 app/controllers/admin/languages_controller.rb
alchemy_cms-2.0.rc3 app/controllers/admin/languages_controller.rb