2012-11-15 07:51:44 +00:00
|
|
|
class Admin::PagesController < Admin::ItemsController
|
2009-05-07 17:18:16 +00:00
|
|
|
|
2013-10-28 03:37:56 +00:00
|
|
|
def show
|
|
|
|
@item = Page.find(params[:id])
|
|
|
|
@no_orbit_bar = true
|
|
|
|
@edit = true
|
|
|
|
render :text => parse_page_content(@item), :layout => 'page_layout'
|
|
|
|
end
|
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
def create
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Page.new(params[:page])
|
2013-07-02 08:46:44 +00:00
|
|
|
if @item.module_app && @item.module_app.key == 'page_content'
|
|
|
|
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
|
|
|
end
|
2011-05-25 06:50:56 +00:00
|
|
|
if @item.save
|
2013-10-27 16:59:38 +00:00
|
|
|
render 'admin/items/reload_items'
|
2010-01-04 09:49:55 +00:00
|
|
|
else
|
2013-10-27 16:59:38 +00:00
|
|
|
@error = error_messages_for(@item)
|
|
|
|
render 'admin/items/form_error'
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2011-08-23 18:34:24 +00:00
|
|
|
@item = Page.find(params[:id])
|
2013-01-21 08:56:37 +00:00
|
|
|
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
|
|
|
|
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
|
|
|
|
end
|
2013-10-27 16:59:38 +00:00
|
|
|
if @item.update_attributes(params[:page])
|
|
|
|
render 'admin/items/reload_items'
|
|
|
|
else
|
2013-10-23 07:51:49 +00:00
|
|
|
@error = error_messages_for(@item)
|
2013-10-27 16:59:38 +00:00
|
|
|
render 'admin/items/form_error'
|
2013-10-23 07:51:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_display_style
|
2013-10-27 16:59:38 +00:00
|
|
|
@item = Page.find(params[:id]) rescue nil
|
|
|
|
@module_app = ModuleApp.find(params[:module_id]) rescue nil
|
|
|
|
if @module_app
|
|
|
|
if params[:val].eql?("default_widget")
|
|
|
|
@checked_style = @item.frontend_style.present? ? @item.frontend_style : nil if @item && @item.app_frontend_url.eql?("default_widget")
|
|
|
|
@enabled_styles = @module_app.get_default_widget["enabled_styles"]
|
|
|
|
@widget_fields = @module_app.widget_fields.collect do |widget_field|
|
|
|
|
label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}")
|
|
|
|
[label, widget_field[0], class: widget_field[2]]
|
|
|
|
end
|
|
|
|
@class_options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
|
|
|
|
@partial = 'default_front'
|
|
|
|
else
|
|
|
|
@frontend_styles = @module_app.app_pages[params[:val]]["style"] rescue nil
|
|
|
|
@partial = 'custom_front' if @frontend_styles.present?
|
|
|
|
end
|
|
|
|
end
|
2013-10-23 07:51:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_page_setting_json
|
|
|
|
begin
|
|
|
|
page = Page.find(params[:id])
|
|
|
|
design = {main: page.design_id.to_s, sub: page.theme_id.to_s}
|
|
|
|
m = {}
|
|
|
|
m["main"] = page.module_app_id.to_s
|
|
|
|
m["sub"] = page.app_frontend_url
|
|
|
|
m["category"] = page.category.present? ? [0, page.category.map{|c| c.to_s}] : [1]
|
|
|
|
m["tags"] = page.tag.present? ? [0, page.tag.map{|c| c.to_s}] : [1]
|
|
|
|
m["public"] = page.is_published ? 1 : 0
|
|
|
|
m["link"] = @site_valid_locales.inject([]) do |link, locale|
|
2013-10-29 06:39:23 +00:00
|
|
|
link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale].eql?('true')) ? 1 :0]
|
2011-08-23 18:34:24 +00:00
|
|
|
end
|
2013-10-23 07:51:49 +00:00
|
|
|
m["count"] = page.frontend_data_count
|
|
|
|
render json: JSON.pretty_generate({design: design, module: m})
|
|
|
|
rescue
|
2013-10-23 10:28:09 +00:00
|
|
|
render :json => {error: ''}, status: 422
|
2011-08-23 18:34:24 +00:00
|
|
|
end
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|