Sha256: aad1e8caf278950e3bdff615abf31c9178d7fbd7c81069abe5ca94f3a417391a

Contents?: true

Size: 1.59 KB

Versions: 8

Compression:

Stored size: 1.59 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]
				# If options params come from Flash uploader then we have to parse them as hash.
				if @options.is_a?(String)
					@options = Rack::Utils.parse_query(@options)
				end
				if @content.essence_type == "Alchemy::EssencePicture"
					@content.essence.picture = Picture.find(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
					) if @options
				end
			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])
				element = content.element
				content_name = content.name
				@content_dom_id = "#{content.essence_type.underscore}_#{content.id}"
				@notice = t("Successfully deleted content", :content => content_name)
				content.destroy
			end
  
		end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alchemy_cms-2.1.1 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1.rc6 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1.rc5 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1.rc4 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1.rc3 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1.rc2 app/controllers/alchemy/admin/contents_controller.rb
alchemy_cms-2.1.beta6 app/controllers/alchemy/admin/contents_controller.rb