Sha256: 7d8b8719753cac1356b605ce0577ea2d01fb2a5a82f918598a538389b0389b92

Contents?: true

Size: 1.94 KB

Versions: 7

Compression:

Stored size: 1.94 KB

Contents

module Alchemy
  module Admin
    class ContentsController < Alchemy::Admin::BaseController

      def new
        @element = Element.find(params[:element_id])
        @contents = @element.available_contents
        @content = @element.contents.build
        render :layout => false
      end

      def create
        @element = Element.find(params[:content][:element_id])
        @content = Content.create_from_scratch(@element, params[:content])
        @options = params[:options] || {}
        @html_options = params[:html_options] || {}
        if @options.is_a?(String)
          @options = JSON.parse(@options)
        end
        if @content.essence_type == "Alchemy::EssencePicture"
          @content_dom_id = "#add_content_#{@element.id}"
          @content.essence.picture_id = params[:picture_id]
          @content.essence.save
          @contents_of_this_type = @element.contents.find_all_by_essence_type('Alchemy::EssencePicture')
          @dragable = @contents_of_this_type.length > 1
          @options = @options.merge(:dragable => @dragable)
        else
          @content_dom_id = "#add_content_for_element_#{@element.id}"
        end
        @locals = {
          :content => @content,
          :options => @options.symbolize_keys,
          :html_options => @html_options.symbolize_keys
        }
      end

      def update
        content = Content.find(params[:id])
        content.essence.update_attributes(params[:content])
      end

      def order
        params[:content_ids].each do |id|
          content = Content.find(id)
          content.move_to_bottom
        end
        @notice = t("Successfully saved content position")
      end

      def destroy
        @content = Content.find(params[:id])
        @content_dup = @content.clone
        element = @content.element
        content_name = @content.name
        @notice = t("Successfully deleted content", :content => content_name)
        @content.destroy
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alchemy_cms-2.2.4 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.2.3.2 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.2.3.1 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.2.2 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.2.1 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.2.0 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.2.rc15 app/controllers/alchemy/admin/contents_controller.rb