| 
									
										
										
										
											2011-05-25 06:50:56 +00:00
										 |  |  | class Admin::PagePartsController < ApplicationController | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-05 01:54:41 +00:00
										 |  |  |   layout "site_editor" | 
					
						
							| 
									
										
										
										
											2011-05-25 06:50:56 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   before_filter :authenticate_user! | 
					
						
							|  |  |  |   before_filter :is_admin? | 
					
						
							|  |  |  |   before_filter :set_current_item | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def show | 
					
						
							|  |  |  |     @part = PagePart.find(params[:id]) | 
					
						
							|  |  |  |     respond_to do |format| | 
					
						
							|  |  |  |       format.html {  | 
					
						
							|  |  |  |         render 'admin/items/index'  | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       format.js  {} | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def new | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def edit | 
					
						
							|  |  |  |     @part = PagePart.find(params[:id]) | 
					
						
							| 
									
										
										
										
											2011-05-27 03:27:54 +00:00
										 |  |  |     case @part.kind | 
					
						
							|  |  |  |       when 'text' | 
					
						
							|  |  |  |         @i18n_variable = @part.i18n_variable | 
					
						
							|  |  |  |         @partial = 'edit_text' | 
					
						
							|  |  |  |         @part_locale = params[:part_locale] || I18n.locale.to_s | 
					
						
							|  |  |  |       when 'module' | 
					
						
							| 
									
										
										
										
											2012-01-10 10:29:11 +00:00
										 |  |  |         @plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/new_blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/new_blog/widget_index"}]}] | 
					
						
							| 
									
										
										
										
											2011-05-27 03:27:54 +00:00
										 |  |  |       when 'snippet' | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2011-05-25 06:50:56 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def create | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def update | 
					
						
							|  |  |  |     @part = PagePart.find(params[:id]) | 
					
						
							| 
									
										
										
										
											2011-05-25 08:27:17 +00:00
										 |  |  |     if @part.update_attributes(params[:page_part]) | 
					
						
							|  |  |  |       flash.now[:notice] = t('admin.update_success_content') | 
					
						
							| 
									
										
										
										
											2011-06-01 02:24:14 +00:00
										 |  |  |       @part.build_content(@site_valid_locales) | 
					
						
							|  |  |  |       @part.save | 
					
						
							| 
									
										
										
										
											2011-05-25 08:27:17 +00:00
										 |  |  |       respond_to do |format| | 
					
						
							|  |  |  |         format.html {  | 
					
						
							|  |  |  |           redirect_to admin_page_url( @part.page ) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         format.js  { | 
					
						
							|  |  |  |           @item = @part.page | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2011-05-25 06:50:56 +00:00
										 |  |  |     else | 
					
						
							|  |  |  |       render :action => "edit" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def destroy | 
					
						
							|  |  |  |     @item = Page.find(params[:id]) | 
					
						
							|  |  |  |     @item.destroy | 
					
						
							|  |  |  |     @item.destroy_i18n_variable | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     redirect_to admin_items_url( :parent_id => @item.parent_id ) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | end |