Merge for new timeline updates and font updates
This commit is contained in:
commit
f635f642fc
604 files changed
+26660
-2980
No files matched your search
@@ -1,8 +1,14 @@
|
||||
class Admin::AdBannersController < ApplicationController
|
||||
class Admin::AdBannersController < OrbitBackendController
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview]
|
||||
before_filter :for_app_sub_manager
|
||||
|
||||
def rename
|
||||
@ad_banner = AdBanner.find(params[:id])
|
||||
@ad_banner.title = params[:body]
|
||||
render :json => {:success =>@ad_banner.save!}
|
||||
end
|
||||
def destroy
|
||||
@ad_banner = AdBanner.find(params[:id])
|
||||
@ad_banner.destroy
|
||||
@@ -22,9 +28,14 @@ class Admin::AdBannersController < ApplicationController
|
||||
|
||||
def create
|
||||
@ad_banner = AdBanner.new(params[:ad_banner])
|
||||
@ad_banner.save
|
||||
redirect_to admin_ad_banners_url
|
||||
|
||||
if @ad_banner.save
|
||||
@active = @ad_banner
|
||||
respond_to do |format|
|
||||
format.js {render 'new_created_node'}
|
||||
end
|
||||
else
|
||||
render 'create_error_msg'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -39,13 +50,14 @@ class Admin::AdBannersController < ApplicationController
|
||||
redirect_to admin_ad_banners_url
|
||||
end
|
||||
|
||||
def destroy_ad_image
|
||||
|
||||
def realtime_preview
|
||||
@ad_banner = AdBanner.find( params[:id] ).preview_clone
|
||||
@ad_banner.update_attributes(params[:ad_banner])#.update_attributes(params[:ad_images])
|
||||
end
|
||||
|
||||
def index
|
||||
@ad_banners = AdBanner.all
|
||||
@active = @ad_banners.first
|
||||
@active = @ad_banners.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,8 +1,8 @@
|
||||
class Admin::AdImagesController < ApplicationController
|
||||
class Admin::AdImagesController < OrbitBackendController
|
||||
layout 'new_admin'
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
before_filter :for_app_sub_manager
|
||||
|
||||
def edit
|
||||
@ad_banner = AdBanner.find params[:ad_banner_id]
|
||||
@ad_image = @ad_banner.ad_images.find params[:id]
|
||||
@@ -18,7 +18,10 @@ class Admin::AdImagesController < ApplicationController
|
||||
end
|
||||
|
||||
def new
|
||||
@ad_image =AdImage.new
|
||||
ad_banner = AdBanner.find params[:ad_banner_id]
|
||||
@ad_image =ad_banner.ad_images.build
|
||||
@ad_image.post_date = Date.today
|
||||
@ad_image.unpost_date = Date.today + 30
|
||||
#render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil}
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
class Admin::AssetCategoriesController < OrbitBackendController
|
||||
|
||||
def index
|
||||
@asset_categories = AssetCategory.all
|
||||
@asset_category = AssetCategory.new
|
||||
@url = admin_asset_categories_path
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@asset_category = AssetCategory.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@asset_category = AssetCategory.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@asset_category = AssetCategory.find(params[:id])
|
||||
@url = admin_asset_categories_path(@asset_category)
|
||||
end
|
||||
|
||||
def create
|
||||
@asset_category = AssetCategory.new(params[:asset_category])
|
||||
|
||||
respond_to do |format|
|
||||
if @asset_category.save
|
||||
format.html { redirect_to(admin_asset_categories_url, :notice => t('announcement.create_asset_category_success')) }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.js { render action: "new" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@asset_category = AssetCategory.find(params[:id])
|
||||
|
||||
@url = admin_asset_categories_path(@asset_category)
|
||||
|
||||
respond_to do |format|
|
||||
if @asset_category.update_attributes(params[:asset_category])
|
||||
# format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('asset_category.update_asset_category_success')) }
|
||||
# format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('asset_category.update_asset_category_success')) }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.js { render :action => "edit" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@asset_category = AssetCategory.find(params[:id])
|
||||
@asset_category.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_asset_categories_url) }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class Admin::AssetTagsController < Admin::TagsController
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'asset'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,11 +1,7 @@
|
||||
class Admin::AssetsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
class Admin::AssetsController < OrbitBackendController
|
||||
|
||||
def index
|
||||
@assets = Asset.all.entries
|
||||
@assets = (params[:sort] || @filter) ? get_sorted_and_filtered("asset") : Asset.all.page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -14,6 +10,8 @@ class Admin::AssetsController < ApplicationController
|
||||
|
||||
def new
|
||||
@asset = Asset.new
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/new'} }
|
||||
@@ -22,6 +20,8 @@ class Admin::AssetsController < ApplicationController
|
||||
|
||||
def edit
|
||||
@asset = Asset.find(params[:id])
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/edit'} }
|
||||
@@ -30,15 +30,29 @@ class Admin::AssetsController < ApplicationController
|
||||
|
||||
def create
|
||||
@asset = Asset.new(params[:asset])
|
||||
if @asset.save
|
||||
@asset.filename = @asset.title[I18n.locale] rescue nil
|
||||
if @asset.filename && @asset.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to admin_assets_url }
|
||||
format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'append', :id => 'asset_tbody', :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} }
|
||||
format.js {
|
||||
if params[:uploader]
|
||||
render 'create'
|
||||
else
|
||||
render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil}
|
||||
end
|
||||
}
|
||||
end
|
||||
else
|
||||
flash[:error] = t(:create_fail)
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
respond_to do |format|
|
||||
format.html { render :action => :new }
|
||||
format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}} }
|
||||
format.js {
|
||||
if params[:uploader]
|
||||
render 'file_upload'
|
||||
else
|
||||
render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}}
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -51,6 +65,9 @@ class Admin::AssetsController < ApplicationController
|
||||
format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} }
|
||||
end
|
||||
else
|
||||
flash[:error] = t(:update_fail)
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
respond_to do |format|
|
||||
format.html { render :action => :edit }
|
||||
format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} }
|
||||
@@ -66,5 +83,24 @@ class Admin::AssetsController < ApplicationController
|
||||
format.js { render 'js/remove_element', :locals => {:id => "asset_#{@asset.id}"} }
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
if params[:to_delete]
|
||||
asset = Asset.any_in(:_id => params[:to_delete]).delete_all
|
||||
end
|
||||
redirect_to assets_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
|
||||
end
|
||||
|
||||
def file_upload
|
||||
@asset = Asset.new
|
||||
@asset_categories = AssetCategory.all
|
||||
@tags = AssetTag.all
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def file_select
|
||||
@assets = Asset.all
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,9 +2,52 @@ class Admin::DashboardsController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
# before_filter :is_admin?
|
||||
|
||||
def index
|
||||
@module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'news_bulletin', 'page_context', 'web_link')
|
||||
@recent_updated = get_recently_updated('bulletin', 'news_bulletin', 'page_context', 'web_link')
|
||||
@most_visited = get_most_visited('bulletin', 'news_bulletin', 'page_context')
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_module_app_count(*args)
|
||||
a = {}
|
||||
total = 0
|
||||
args.each do |module_app|
|
||||
module_app_class = module_app.classify.constantize
|
||||
count = module_app_class.count
|
||||
a.merge!(module_app => count)
|
||||
total += count
|
||||
end
|
||||
[a.sort {|a,b| b[1]<=>a[1]}, total]
|
||||
end
|
||||
|
||||
def get_recently_updated(*args)
|
||||
a = {}
|
||||
args.each do |module_app|
|
||||
module_app_class = module_app.classify.constantize
|
||||
objects = module_app_class.order_by(:updated_at, :desc).limit(10)
|
||||
objects.each do |object|
|
||||
a.merge!(object => object.updated_at) unless (object.archived rescue nil)
|
||||
end
|
||||
end
|
||||
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
|
||||
sorted_objects[0..9]
|
||||
end
|
||||
|
||||
def get_most_visited(*args)
|
||||
a = {}
|
||||
args.each do |module_app|
|
||||
module_app_class = module_app.classify.constantize
|
||||
objects = module_app_class.order_by(:view_count, :desc).limit(10)
|
||||
objects.each do |object|
|
||||
a.merge!(object => object.view_count) if object.view_count > 0 && (!object.archived rescue true)
|
||||
end
|
||||
end
|
||||
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
|
||||
sorted_objects[0..9]
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,11 +1,12 @@
|
||||
class Admin::DesignsController < ApplicationController
|
||||
class Admin::DesignsController < OrbitBackendController
|
||||
require "net/http"
|
||||
require "uri"
|
||||
require 'zip/zip'
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :is_admin?
|
||||
before_filter :for_admin_only
|
||||
|
||||
def upload_package
|
||||
if !params[:design].nil?
|
||||
@@ -24,7 +25,7 @@ class Admin::DesignsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@designs = Design.all.entries
|
||||
@designs = params[:sort] ? get_sorted_and_filtered("designs") : Design.all
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -83,6 +84,13 @@ class Admin::DesignsController < ApplicationController
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
if params[:to_delete]
|
||||
designs = Design.any_in(:_id => params[:to_delete]).delete_all
|
||||
end
|
||||
redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ class Admin::InfosController < ApplicationController
|
||||
|
||||
def edit
|
||||
@attribute = Info.find(params[:id])
|
||||
@i18n_variable = @attribute.i18n_variable
|
||||
render :template => 'admin/attributes/edit'
|
||||
end
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@ class Admin::ItemsController < ApplicationController
|
||||
@item = get_homepage
|
||||
end
|
||||
end
|
||||
|
||||
def update_position
|
||||
item = Item.find(params[:id])
|
||||
item.shift_to(params[:parent_id], params[:position])
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
||||
@@ -65,9 +65,11 @@ class Admin::LinksController < ApplicationController
|
||||
end
|
||||
|
||||
def delete
|
||||
@item = Link.find(params[:id])
|
||||
@item.destroy
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { destroy }
|
||||
format.js { @item = @item.parent }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ]
|
||||
before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ]
|
||||
|
||||
layout "admin"
|
||||
layout "new_admin"
|
||||
|
||||
def index
|
||||
@module_apps = ModuleApp.all.entries
|
||||
@@ -11,12 +11,26 @@ class Admin::ModuleAppsController < ApplicationController
|
||||
|
||||
def reload_frontend_pages
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
@categories = @module_app.key.eql?('announcement') ? BulletinCategory.all : nil
|
||||
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
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def module_auth_proc
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
end
|
||||
|
||||
def edit
|
||||
@module_app = ModuleApp.find(params[:id])
|
||||
end
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
class Admin::ModuleAppsNewInterfaceController < OrbitBackendController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
include AdminHelper
|
||||
|
||||
layout "new_admin"
|
||||
|
||||
def setting
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
@module_app = ModuleApp.find(params[:module_app_id])
|
||||
@options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] }
|
||||
# if params.has_key? :category
|
||||
# @bulletin_category = BulletinCategory.find params[:category][:id]
|
||||
# else
|
||||
# @bulletin_category = @bulletin_categorys.first
|
||||
# end
|
||||
@users_array = @module_app.managing_users rescue []
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update_setting
|
||||
module_app = update_setting_by_params
|
||||
if module_app.save!
|
||||
flash[:notice] = t("admin.object_auth.update_done")
|
||||
else
|
||||
flash[:notice] = t("admin.object_auth.update_failed")
|
||||
end
|
||||
end
|
||||
|
||||
def user_list
|
||||
@module_app = ModuleApp.find params[:module_app][:id]
|
||||
end
|
||||
|
||||
protected
|
||||
def update_setting_by_params
|
||||
user_sat = []
|
||||
ma = ModuleApp.find params[:module_app][:id]
|
||||
user_sat = User.find params[:users].keys if params.has_key? :users
|
||||
users_to_new = user_sat - ma.managing_users
|
||||
users_to_remove = ma.managing_users - user_sat
|
||||
|
||||
users_to_new.each do |new_user|
|
||||
ma.assign_manager(new_user,current_user)
|
||||
end
|
||||
|
||||
users_to_remove.each do |remove_user|
|
||||
ma.remove_manager(remove_user)
|
||||
end
|
||||
ma
|
||||
end
|
||||
|
||||
def get_categorys(id = nil)
|
||||
@bulletin_categorys = []
|
||||
if(is_manager? || is_admin?)
|
||||
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
||||
elsif is_sub_manager?
|
||||
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Admin::ObjectAuthsController < ApplicationController
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
layout "admin"
|
||||
layout "new_admin"
|
||||
before_filter :force_order
|
||||
# before_filter :is_admin? ,:only => :index
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
before_filter :force_order
|
||||
|
||||
|
||||
def setting
|
||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar)
|
||||
@ob_auth = ObjectAuth.find params[:object_auth_id]
|
||||
@options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] }
|
||||
@users_array = @ob_auth.privilege_users rescue []
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update_setting
|
||||
ob_auth = update_setting_by_params
|
||||
if ob_auth.save!
|
||||
flash[:notice] = t("admin.object_auth.update_done")
|
||||
else
|
||||
flash[:notice] = t("admin.object_auth.update_failed")
|
||||
end
|
||||
end
|
||||
|
||||
def user_list
|
||||
@ob_auth = ObjectAuth.find params[:ob_auth][:id]
|
||||
end
|
||||
|
||||
protected
|
||||
def update_setting_by_params
|
||||
user_sat = []
|
||||
oa = ObjectAuth.find params[:ob_auth][:id]
|
||||
user_sat += User.find params[:users].keys if params.has_key? :users
|
||||
users_to_new = user_sat - oa.auth_users
|
||||
users_to_remove = oa.auth_users - user_sat
|
||||
|
||||
users_to_new.each do |new_user|
|
||||
oa.add_user_to_privilege_list(new_user)
|
||||
end
|
||||
|
||||
users_to_remove.each do |remove_user|
|
||||
oa.remove_user_from_privilege_list(remove_user)
|
||||
end
|
||||
oa
|
||||
end
|
||||
|
||||
# def get_categorys(id = nil)
|
||||
# @bulletin_categorys = []
|
||||
# if(is_manager? || is_admin?)
|
||||
# @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
|
||||
# elsif is_sub_manager?
|
||||
# @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
|
||||
# end
|
||||
# end
|
||||
|
||||
def force_order
|
||||
authenticate_user!
|
||||
check_if_user_can_do_object_auth
|
||||
end
|
||||
|
||||
def check_if_user_can_do_object_auth
|
||||
unless check_permission(:manager)
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -22,15 +22,20 @@ class Admin::PagePartsController < ApplicationController
|
||||
|
||||
def edit
|
||||
@part = PagePart.find(params[:id])
|
||||
@module_apps = ModuleApp.all(:conditions => {:enable_frontend => true})
|
||||
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
|
||||
@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
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
case @module_app.key
|
||||
when 'bulletin'
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,8 +46,8 @@ class Admin::PagePartsController < ApplicationController
|
||||
def update
|
||||
@part = PagePart.find(params[:id])
|
||||
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('admin.update_success_content')
|
||||
@part.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to admin_page_url( @part.page )
|
||||
@@ -67,12 +72,34 @@ class Admin::PagePartsController < ApplicationController
|
||||
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
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
def reload_r_tag_options
|
||||
@r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id]
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_children_sub_menu(part)
|
||||
part.page.children.each do |child|
|
||||
child_part = child.page_parts.detect{ |x| x.name.eql?(part.name) } rescue nil
|
||||
child_part.update_attributes(:kind => part.kind, :public_r_tag => part.public_r_tag, :public_r_tag_object_id => part.public_r_tag_object_id) rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -20,24 +20,38 @@ class Admin::PagesController < ApplicationController
|
||||
def new
|
||||
@item = Page.new
|
||||
@item.parent = Item.find(params[:parent_id]) rescue nil
|
||||
@apps = ModuleApp.all
|
||||
@apps = ModuleApp.excludes(app_pages: nil).entries
|
||||
@designs = Design.all.entries
|
||||
@design = Design.first
|
||||
end
|
||||
|
||||
def edit
|
||||
@item = Page.find(params[:id])
|
||||
@apps = ModuleApp.all
|
||||
@apps = ModuleApp.excludes(app_pages: nil).entries
|
||||
@designs = Design.all.entries
|
||||
@design = @item.design ? @item.design : @designs.first
|
||||
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
|
||||
@categories = BulletinCategory.all if @item.module_app && @item.module_app.key.eql?('announcement')
|
||||
if @item.module_app
|
||||
case @item.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
|
||||
end
|
||||
else
|
||||
@categories = nil
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@item = Page.new(params[:page])
|
||||
|
||||
if @item.module_app.key == 'page_content'
|
||||
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
|
||||
|
||||
@@ -85,14 +99,16 @@ class Admin::PagesController < ApplicationController
|
||||
format.html {
|
||||
redirect_to admin_items_url( :parent_id => @item.parent_id )
|
||||
}
|
||||
format.js {}
|
||||
format.js { redirect_to admin_items_url }
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
@item = Page.find(params[:id])
|
||||
@item.destroy
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.js { destroy }
|
||||
format.js { @item = @item.parent }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ class Admin::RolesController < ApplicationController
|
||||
|
||||
def edit
|
||||
@attribute = Role.find(params[:id])
|
||||
@i18n_variable = @attribute.i18n_variable
|
||||
render :template => 'admin/attributes/edit'
|
||||
end
|
||||
|
||||
|
||||
@@ -1,16 +1,48 @@
|
||||
class Admin::SitesController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :get_site
|
||||
|
||||
def index
|
||||
@site = Site.first
|
||||
redirect_to :action => :new unless @site
|
||||
# def index
|
||||
# @site = Site.first
|
||||
# # redirect_to :action => :new unless @site
|
||||
# end
|
||||
|
||||
# def new
|
||||
# @site = Site.new
|
||||
# end
|
||||
|
||||
def update
|
||||
@site.update_attributes(params[:site])
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
def new
|
||||
@site = Site.new
|
||||
|
||||
def site_info
|
||||
|
||||
end
|
||||
|
||||
def system_info
|
||||
|
||||
end
|
||||
|
||||
def language
|
||||
|
||||
end
|
||||
|
||||
def mail_setting
|
||||
|
||||
end
|
||||
|
||||
def ui_theme
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_site
|
||||
@site ||= Site.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -8,6 +8,10 @@ class ApplicationController < ActionController::Base
|
||||
helper :all
|
||||
before_filter :set_locale, :set_site
|
||||
|
||||
def set_current_user
|
||||
User.current = current_user
|
||||
end
|
||||
|
||||
def front_end_available(module_app_title='')
|
||||
app_controller = ModuleApp.first(conditions: {:key => module_app_title} )
|
||||
unless app_controller.enable_frontend?
|
||||
@@ -39,15 +43,65 @@ class ApplicationController < ActionController::Base
|
||||
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
|
||||
end
|
||||
|
||||
def auth_failed_in_backend
|
||||
#redirect_to admin_dashboards_url
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
# Check if the current_user is admin
|
||||
def is_admin?
|
||||
redirect_to root_url unless current_user.admin?
|
||||
current_user.admin? ? true : auth_failed_in_backend
|
||||
end
|
||||
|
||||
def is_manager?
|
||||
@module_app.managing_users.include?(current_user) || is_admin?
|
||||
end
|
||||
|
||||
def for_admin_only
|
||||
if is_admin?
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.not_admin")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_manager
|
||||
if is_manager?
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_manager")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_sub_manager
|
||||
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_sub_manager")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_user
|
||||
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
|
||||
true
|
||||
else
|
||||
flash[:error] = t("admin.access.denied.app.not_authed_user")
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def check_object_premission(obj,title)
|
||||
flash[:error] = t("admin.access.denied.object")
|
||||
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
|
||||
end
|
||||
|
||||
# Render the page
|
||||
def render_page(id = nil)
|
||||
def render_page
|
||||
if @item
|
||||
render :text => process_page(@item, id), :layout => 'page_layout'
|
||||
render :text => parse_page_noko(@item), :layout => 'page_layout'
|
||||
else
|
||||
render :text => '404 Not Found'
|
||||
end
|
||||
@@ -78,8 +132,8 @@ class ApplicationController < ActionController::Base
|
||||
# set site if exist or create site
|
||||
@site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []})
|
||||
session[:site] = @site.id
|
||||
@site_in_use_locales = @site.in_use_locales
|
||||
@site_valid_locales = @site.valid_locales
|
||||
@site_in_use_locales = site_locales_default_head(@site.in_use_locales)
|
||||
@site_valid_locales = site_locales_default_head(@site.valid_locales)
|
||||
end
|
||||
|
||||
def set_current_item
|
||||
@@ -103,7 +157,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def get_homepage
|
||||
Item.first(:conditions => {:parent_id => nil})
|
||||
Page.root
|
||||
end
|
||||
|
||||
def layout_by_resource
|
||||
@@ -114,4 +168,14 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def site_locales_default_head(locales)
|
||||
if locales[0].eql? I18n.locale.to_s
|
||||
locales
|
||||
else
|
||||
a = Array.new(locales)
|
||||
shift_out = a.delete(I18n.locale.to_s)
|
||||
[shift_out] + a
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -7,12 +7,43 @@ class DesktopOrbitController< ApplicationController
|
||||
def getevents
|
||||
@event = params["event"]
|
||||
@data = Array.new
|
||||
@fromdate = params["from"]
|
||||
case @event
|
||||
when "papers"
|
||||
@journals = current_user.journals
|
||||
@journals.each do |journal|
|
||||
@data << {"title"=> journal.title,"papers"=> journal.papers}
|
||||
@data = current_user.papers.where(:created_at.gt => Date.new(Integer(@fromdate[0]),Integer(@fromdate[1])-1),:created_at.lt => Date.new(Integer(@fromdate[0]),Integer(@fromdate[1])+1)).desc(:created_at)
|
||||
end
|
||||
render :json=>@data.to_json
|
||||
end
|
||||
|
||||
def eventajaxload
|
||||
@limit = 15
|
||||
@fromdate = params["from"]
|
||||
@fromdate[0] = Integer(@fromdate[0])
|
||||
@fromdate[1] = Integer(@fromdate[1])
|
||||
@totalpapers = 0
|
||||
@lastpaper = current_user.papers.all.desc(:created_at).last
|
||||
@date = Date.new(Integer(@lastpaper.created_at.strftime("%Y")),Integer(@lastpaper.created_at.strftime("%m")))
|
||||
@data = Array.new
|
||||
while @totalpapers < @limit
|
||||
if Date.new(@date.year,@date.month-1) > Date.new(@fromdate[0],@fromdate[1])
|
||||
break
|
||||
end
|
||||
if(@fromdate[1] == 12)
|
||||
@papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0]+1,1)).desc(:created_at)
|
||||
else
|
||||
@papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0],@fromdate[1]+1)).desc(:created_at)
|
||||
end
|
||||
if(@papers.length > 0)
|
||||
@data << {"papers" => @papers}
|
||||
end
|
||||
@totalpapers = @totalpapers + @papers.length
|
||||
|
||||
@fromdate[1] = @fromdate[1]-1
|
||||
if(@fromdate[1] == 0)
|
||||
@fromdate[1] = 12
|
||||
@fromdate[0] = @fromdate[0] - 1
|
||||
end
|
||||
|
||||
end
|
||||
render :json=>@data.to_json
|
||||
end
|
||||
|
||||
@@ -1,50 +1,61 @@
|
||||
class DesktopPublicationsController< ApplicationController
|
||||
def journal_p
|
||||
render "desktop/journal_p", :layout => false
|
||||
end
|
||||
|
||||
def journal_p_list
|
||||
render "desktop/journal_pages/list", :layout => false
|
||||
end
|
||||
|
||||
def journal_p_add
|
||||
render "desktop/journal_pages/add", :layout => false
|
||||
end
|
||||
|
||||
def books
|
||||
render "desktop/books", :layout => false
|
||||
end
|
||||
|
||||
def books_list
|
||||
render "desktop/books/list", :layout => false
|
||||
end
|
||||
|
||||
def books_add
|
||||
render "desktop/books/add", :layout => false
|
||||
end
|
||||
|
||||
def create_journal
|
||||
Journal.create(user_id: current_user.id, title: "Google")
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def getjournals
|
||||
@journals = current_user.journals
|
||||
data = Array.new
|
||||
@journals.each do |journal|
|
||||
@papers = journal.papers.all
|
||||
data << {"title" => journal.title, "papers" => @papers}
|
||||
end
|
||||
render :json=>data.to_json
|
||||
end
|
||||
|
||||
def delete_journal
|
||||
@journals = Journal.find("")
|
||||
@journals.delete
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
end
|
||||
class DesktopPublicationsController< ApplicationController
|
||||
def journal_p
|
||||
render "desktop/journal_p", :layout => false
|
||||
end
|
||||
|
||||
def journal_p_list
|
||||
render "desktop/journal_pages/list", :layout => false
|
||||
end
|
||||
|
||||
def journal_p_add
|
||||
render "desktop/journal_pages/add", :layout => false
|
||||
end
|
||||
|
||||
def books
|
||||
render "desktop/books", :layout => false
|
||||
end
|
||||
|
||||
def books_list
|
||||
render "desktop/books/list", :layout => false
|
||||
end
|
||||
|
||||
def books_add
|
||||
render "desktop/books/add", :layout => false
|
||||
end
|
||||
|
||||
def create_journal
|
||||
Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich")
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def getjournals
|
||||
@journals = current_user.journals
|
||||
data = Array.new
|
||||
@journals.each do |journal|
|
||||
@papers = journal.papers.all
|
||||
data << {"title" => journal.title, "papers" => @papers}
|
||||
end
|
||||
render :json=>data.to_json
|
||||
end
|
||||
|
||||
def delete_journal
|
||||
@journals = Journal.find("")
|
||||
@journals.delete
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
|
||||
def update_journal
|
||||
@journal = Journal.find("4ff2d6ebbd98eb02b9000017")
|
||||
@papers = @journal.papers
|
||||
@papers.each do |paper|
|
||||
paper.update_attributes(:user_id => current_user.id)
|
||||
end
|
||||
b = Array.new
|
||||
b << {"success"=>"true"}
|
||||
render :json=>b.to_json
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,8 @@
|
||||
class OrbitBackendController< ApplicationController
|
||||
before_filter :force_order,:except => [:public]
|
||||
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
|
||||
@@ -10,9 +12,11 @@ class OrbitBackendController< ApplicationController
|
||||
|
||||
def setup_vars
|
||||
@app_title = request.fullpath.split('/')[2]
|
||||
@app_title = request.fullpath.split('/')[1] if(@app_title == "back_end")
|
||||
@app_title.gsub!(/[?].*/,'')
|
||||
@module_app = ModuleApp.first(conditions: {:key => @app_title} )
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def force_order
|
||||
@@ -22,8 +26,164 @@ class OrbitBackendController< ApplicationController
|
||||
|
||||
def check_user_can_use
|
||||
unless check_permission
|
||||
redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
|
||||
#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)
|
||||
object_class = object_class.classify.constantize
|
||||
if !params[:sort].blank?
|
||||
options = params[:sort_options]
|
||||
options = [options] if !options.class.eql?(Array)
|
||||
options.each do |option|
|
||||
if object_class.fields.include?(option)
|
||||
case object_class.fields[option].type.to_s
|
||||
when 'BigDecimal', 'Boolean', 'Date', 'DateTime', 'Float', 'Integer', 'String', 'Symbol', 'Time'
|
||||
(objects = objects.order_by(option, params[:direction])) rescue nil
|
||||
when 'Object'
|
||||
objects = get_objects_from_referenced_objects(object_class.fields[option].options[:class_name].constantize, objects, option)
|
||||
end
|
||||
elsif object_class.relations.include?(option)
|
||||
case object_class.relations[option].macro
|
||||
when :references_one
|
||||
a = Array.new
|
||||
objects.each { |object| a << [get_string_value_from_object(object), object] }
|
||||
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
|
||||
objects = sorted.collect {|x| x[1] }
|
||||
when :references_many, :references_and_referenced_in_many
|
||||
objects = get_objects_from_self(object_class, objects, option)
|
||||
when :referenced_in
|
||||
objects = get_objects_from_referenced_objects(object_class.relations[option].class_name.constantize, objects, "#{option}_id")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if @filter
|
||||
@filter.each do |key, value|
|
||||
case key
|
||||
when 'status'
|
||||
a = Array.new
|
||||
objects.each do |object|
|
||||
value.each do |v|
|
||||
a << object if object[v]
|
||||
end
|
||||
end
|
||||
objects = a.uniq
|
||||
when 'categories'
|
||||
a = Array.new
|
||||
objects.each do |object|
|
||||
a << object if (value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s) rescue nil)
|
||||
end
|
||||
objects = a.uniq
|
||||
when 'tags'
|
||||
a = Array.new
|
||||
objects.each do |object|
|
||||
object.tags.each do |tag|
|
||||
a << object if value.include?(tag.id.to_s)
|
||||
end
|
||||
end
|
||||
objects = a.uniq
|
||||
end if value.size > 0
|
||||
end
|
||||
end
|
||||
Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def get_string_value_from_object(object)
|
||||
s = object[I18n.locale] rescue nil
|
||||
s = object.i18n_variable unless s rescue nil
|
||||
s = object.name unless s rescue nil
|
||||
s = object.title unless s rescue nil
|
||||
if s
|
||||
case s.class.to_s
|
||||
when "String"
|
||||
s.downcase rescue ''
|
||||
when "I18nVariable"
|
||||
s[I18n.locale].downcase rescue ''
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_objects_from_referenced_objects(object_class, objects, option)
|
||||
referer_ids = objects.distinct(option)
|
||||
referenced_objects = object_class.find(referer_ids) rescue nil
|
||||
if referenced_objects
|
||||
a = Array.new
|
||||
referenced_objects.each { |referer| a << [get_string_value_from_object(referer), referer.id] }
|
||||
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
|
||||
sorted_objects = sorted.collect {|x| objects.where(option => x[1]).entries }
|
||||
sorted_objects.flatten!
|
||||
sorted_objects.uniq!
|
||||
get_with_nil(objects, option, sorted_objects)
|
||||
else
|
||||
objects
|
||||
end
|
||||
end
|
||||
|
||||
def get_objects_from_self(object_class, objects, option)
|
||||
referenced_class = object_class.relations[option].class_name.constantize
|
||||
referenced_objects = referenced_class.all rescue nil
|
||||
if referenced_objects
|
||||
reverse_relation = nil
|
||||
referenced_class.relations.each { |relation| reverse_relation = relation[1].name.to_s if relation[1].class_name.eql?(object_class.to_s) }
|
||||
a = Array.new
|
||||
referenced_objects.each { |referenced_object| a << [get_string_value_from_object(referenced_object), referenced_object] }
|
||||
a.compact!
|
||||
sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse!
|
||||
sorted_objects = Array.new
|
||||
sorted.each {|x| sorted_objects << x[1].send(reverse_relation) }
|
||||
sorted_objects.flatten!
|
||||
sorted_objects.uniq!
|
||||
get_with_nil(objects, option, sorted_objects)
|
||||
else
|
||||
objects
|
||||
end
|
||||
end
|
||||
|
||||
def get_with_nil(objects, option, sorted_objects)
|
||||
tmp = Array.new
|
||||
objects.each { |object| tmp << [get_string_value_from_object(object), object] if (object.send(option).blank? || (object.send(option).size == 0 rescue nil)) }
|
||||
sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse!
|
||||
sorted_tmp = sorted.collect {|a| a[1] }
|
||||
a = params[:direction].eql?('asc') ? (sorted_tmp + sorted_objects) : (sorted_objects + sorted_tmp)
|
||||
a.flatten
|
||||
end
|
||||
|
||||
|
||||
def get_viewable(object_class)
|
||||
objects = get_objects(object_class).order_by(:created_at, :desc)
|
||||
Kaminari.paginate_array(objects).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
def get_objects(object_class, query=nil)
|
||||
object_class = object_class.classify.constantize
|
||||
if query
|
||||
objects = object_class.all.where(query)
|
||||
else
|
||||
objects = object_class.all
|
||||
end
|
||||
objects
|
||||
end
|
||||
|
||||
def filter_authorized_objects(objects)
|
||||
if(!is_admin? || !is_manager?)
|
||||
objects.delete_if{ |object|
|
||||
if object.is_pending == true
|
||||
if check_permission(:manager)
|
||||
object.create_user_id != current_user.id
|
||||
else
|
||||
!object.send("#{object.class.to_s.underscore}_category").authed_users('fact_check').include?(current_user) rescue false
|
||||
end
|
||||
else
|
||||
false
|
||||
end
|
||||
}
|
||||
end
|
||||
objects
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
class OrbitFrontendComponentController< ApplicationController
|
||||
before_filter :setup_vars
|
||||
before_filter {|c| c.front_end_available(@app_title)}
|
||||
layout :false
|
||||
layout "module_widget"
|
||||
|
||||
def setup_vars
|
||||
@app_title = request.fullpath.split('/')[2]
|
||||
|
||||
@@ -7,6 +7,7 @@ class PagesController < ApplicationController
|
||||
def index
|
||||
@item = Page.find_by_name('home')
|
||||
if @item
|
||||
impressionist(@item)
|
||||
render_page
|
||||
else
|
||||
render :text => 'You need a home page'
|
||||
@@ -14,33 +15,38 @@ class PagesController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
#begin
|
||||
@item = Item.first(:conditions => {:full_name => params[:page_name]})
|
||||
if @item && @item.is_published
|
||||
case @item._type
|
||||
when 'Page'
|
||||
render_page(params[:id])
|
||||
when 'Link'
|
||||
redirect_to "http://#{@item[:url]}"
|
||||
end
|
||||
else
|
||||
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
end
|
||||
#begin
|
||||
@item = Item.first(:conditions => {:path => params[:page_name]})
|
||||
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
||||
impressionist(@item)
|
||||
case @item._type
|
||||
when 'Page'
|
||||
render_page
|
||||
when 'Link'
|
||||
redirect_to @item[:url]
|
||||
end
|
||||
else
|
||||
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
end
|
||||
#rescue
|
||||
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
#end
|
||||
end
|
||||
|
||||
def index_from_link
|
||||
if params[:page]
|
||||
redirect_to "/#{@item.full_name}?page=#{params[:page]}"
|
||||
else
|
||||
redirect_to "/#{@item.full_name}"
|
||||
end
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
redirect_to url + options
|
||||
end
|
||||
|
||||
def show_from_link
|
||||
redirect_to "/#{@item.full_name}?id=#{params[:id]}"
|
||||
url = "/#{@item.path}?id=#{params[:id]}"
|
||||
options = ''
|
||||
options << "&preview=#{params[:preview]}" unless params[:preview].blank?
|
||||
redirect_to url + options
|
||||
end
|
||||
|
||||
def load_orbit_bar
|
||||
@@ -51,11 +57,7 @@ class PagesController < ApplicationController
|
||||
|
||||
def get_item
|
||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||
if params[:category_id]
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]})
|
||||
else
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
|
||||
end
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user