class WebFooterCompaniesController < ApplicationController
  layout 'admin'
  menu_item :projects, :only => :projects
  menu_item :plugins, :only => :plugins
  menu_item :info, :only => :info
  before_filter :require_admin

  def index
    @companys = WebFooterCompany.all
  end

  def new
    @company ||= WebFooterCompany.new
  end

  def create
    @company = WebFooterCompany.new(params[:web_footer_company])
    if @company.save
      flash[:notice] = l(:notice_successful_create)
      redirect_to web_footer_companies_url
    else
      flash[:error] = "#{l :web_footer_company_create_fail}: #{@company.errors.full_messages[0]}"
      respond_to do |format|
        format.html {  render :action => 'new'}
        format.api  { render_validation_errors(@company) }
      end

    end
  end

  def destroy
    @company = WebFooterCompany.find(params[:id])
    @company.destroy
    redirect_to web_footer_companies_url
  end

  def edit
    @company = WebFooterCompany.find(params[:id])
  end

  def update
    @company = WebFooterCompany.find(params[:id])
    if @company.update_attributes(params[:web_footer_company])
      flash[:notice] = l(:notice_successful_update)
      redirect_to web_footer_companies_url
    else
      flash[:error] = "#{l :web_footer_company_update_fail}: #{@company.errors.full_messages[0]}"
      render :action => 'edit'
    end
  end

end
