Sha256: ad5a53818a0229bc081999e5cefd8043063953ad1ebcf3dc7c0676caef17859a

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

class Ckeditor::BaseController < ApplicationController
  respond_to :html, :json
  layout "ckeditor"
  
  before_filter :set_locale
  before_filter :find_asset, :only => [:destroy]
  before_filter :ckeditor_authenticate

  protected
    
    def set_locale
      if !params[:langCode].blank? && I18n.available_locales.include?(params[:langCode].to_sym)
        I18n.locale = params[:langCode]
      end
    end
    
    def respond_with_asset(asset)
      file = params[:CKEditor].blank? ? params[:qqfile] : params[:upload]
	    asset.data = Ckeditor::Http.normalize_param(file, request)
	    
	    callback = ckeditor_before_create_asset(asset)
	    
      if callback && asset.save
        body = params[:CKEditor].blank? ? asset.to_json(:only=>[:id, :type]) : %Q"<script type='text/javascript'>
          window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{Ckeditor::Utils.escape_single_quotes(asset.url_content)}');
        </script>"
        
        render :text => body
      else
        render :nothing => true
      end
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ckeditor-3.6.3 app/controllers/ckeditor/base_controller.rb
ckeditor-3.6.2 app/controllers/ckeditor/base_controller.rb
ckeditor-3.6.1 app/controllers/ckeditor/base_controller.rb
ckeditor-3.6.0 app/controllers/ckeditor/base_controller.rb
ckeditor-3.6.0.pre app/controllers/ckeditor/base_controller.rb