default widgets and sidebar.

This commit is contained in:
Matthew K. Fu JuYuan committed 2012-12-24 16:38:35 +08:00
1 parent 6995bb1622
commit 5f712622ad
28 files changed
+344 -162

No files matched your search

@@ -1,5 +1,5 @@
class Admin::ObjectAuthsController < ApplicationController
include OrbitCoreLib::PermissionUnility
include OrbitCoreLib::PermissionUtility
layout "new_admin"
before_filter :force_order
# before_filter :is_admin? ,:only => :index
@@ -1,5 +1,5 @@
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
include OrbitCoreLib::PermissionUnility
include OrbitCoreLib::PermissionUtility
before_filter :force_order
def set_module_app
+24 -21
View File
@@ -28,27 +28,29 @@ class Admin::PagePartsController < ApplicationController
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
@tag_objects = @r_tag.classify.constantize.all rescue nil
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
@widget_style = @module_app.get_widget_style[@widget_path][:style] unless @widget_path.nil?
@categories = @module_app.get_registration.get_categories
@tags = @module_app.get_registration.get_tags
# if @module_app.widgets.any?{|b| b.class == Array}
# @widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
# end
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
when 'archive'
@categories = ArchiveFileCategory.all
@tags = ArchiveTag.all
end
# case @module_app.key
# when 'announcement'
# @categories = BulletinCategory.all
# @tags = AnnouncementTag.all
# when 'news'
# @categories = NewsBulletinCategory.all
# @tags = NewsTag.all
# when 'web_resource'
# @categories = WebLinkCategory.all
# @tags = WebResourceTag.all
# when 'archive'
# @categories = ArchiveFileCategory.all
# @tags = ArchiveTag.all
# end
end
def create
@@ -60,7 +62,7 @@ class Admin::PagePartsController < ApplicationController
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type] ) if params[:page_part][:widget_field]
params[:page_part][:widget_field_type] = nil
if @part.update_attributes(params[:page_part])
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
flash.now[:notice] = t('update.success.content')
@@ -95,7 +97,7 @@ class Admin::PagePartsController < ApplicationController
@widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? )
@widget_style = @module_app.widgets[@widget_path] if ( !@widget_path.blank? )
@widget_style = @module_app.get_widget_style[@widget_path][:style] unless @widget_path.nil?
case @module_app.key
when 'announcement'
@@ -119,8 +121,9 @@ class Admin::PagePartsController < ApplicationController
def reload_widget_styles
@module_app = ModuleApp.find(params[:module_app_id])
@widget_style = @module_app.widgets[params[:id]]
style_ary = @module_app.get_widget_style[params[:id]]
@widget_style = style_ary[:style] unless style_ary.nil?
respond_to do |format|
format.js {}
end
@@ -0,0 +1,43 @@
class DefaultWidgetController< OrbitWidgetController
def front_end_available(var)
@page_part = PagePart.find params[:part_id]
@page_part.module_app.enable_frontend?
end
def default_widget
@tag_class = nil
@default_widget = @page_part.module_app.get_default_widget
@widget_image_field = @default_widget[:image]
data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
@data = eval(@default_widget[:query]).limit(data_limit).includes(@widget_image_field)
@fields = @page_part.widget_field
case params[:type]
when "typeA"
@tag_class = 'defulat_widget_typeA'
render "typeA"
when /typeB_/
@tag_class = "defulat_widget_#{params[:type]}"
render "typeB"
when "typeC"
@tag_class = 'defulat_widget_typeC'
render "typeC"
end
# {"inner"=>"true",
# "category_id"=>"false",
# "tag_id"=>"",
# "page"=>"",
# "search_query"=>"",
# "part_title"=>"",
# "part_id"=>"50ac426f83e75219d20000a7",
# "controller"=>"default_widget",
# "action"=>"default_widget",
# "type"=>"typeA"}
end
end
+2 -32
View File
@@ -1,41 +1,11 @@
class OrbitBackendController < ApplicationController
#before_filter :setup_vars
#before_filter :set_current_user
# before_filter {|c| c.front_end_available(@app_title)}
# before_filter :check_user_can_use
include OrbitCoreLib::PermissionUnility
include OrbitCoreLib::AppBackendUtility
include OrbitCoreLib::PermissionUtility
include AdminHelper
include ApplicationHelper
layout 'new_admin'
def setup_vars
@app_title ||= controller_path.split('/')[1].singularize
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
end
private
def force_order_for_visitor
setup_vars
set_current_user
end
def force_order_for_user
setup_vars
set_current_user
authenticate_user!
check_user_can_use
end
def check_user_can_use
unless check_permission
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
redirect_to root_url
end
end
def get_sorted_and_filtered(object_class, query=nil)
objects = get_objects(object_class, query)
@@ -1,3 +1,4 @@
class OrbitFrontendController< OrbitFrontendComponentController
end
@@ -1,3 +1,4 @@
class OrbitWidgetController< OrbitFrontendComponentController
end