module OrbitHelper
def self.set_params(params)
@params = params
end
def self.set_page_categories(categories)
@categories = categories;
end
def self.set_page_data_count(data_count)
@data_count = data_count
end
def self.page_data_count
@data_count
end
def self.page_categories
@categories
end
def self.this_module_app
@module_app
end
def self.set_this_module_app(module_app)
@module_app = ModuleApp.where(:key=>module_app).first
end
def self.params
@params
end
def self.url_to_show(slug)
if @params[:url]
"/#{@site_locale}#{@params[:url]}/#{slug}"
else
page = Page.where(:module => self.current_widget_module).first
"/#{@site_locale}#{page.url}/#{slug}"
end
end
def page_url(url)
"#{request.host_with_port}/#{locale}#{url}"
end
def self.set_site_locale(locale)
@site_locale = locale
end
def self.get_site_locale
@site_locale
end
def self.current_widget_module
@controller_name
end
def self.set_current_widget_module(name)
@controller_name = name
end
def get_item_module_infos(page)
if page.parent_page_id.nil?
["Home","icons-house"]
else
module_app = ModuleApp.where(:key => page.module).first
unless module_app.nil?
[module_app.title, module_app.get_registration.icon_class]
else
if page.module.eql? "sitemap"
["sitemap", "icons-directions"]
else
["", "icon-minus-sign"]
end
end
end
end
def self.orbit_impressionist(object)
impressionist(object)
end
# ===============================================================
# Breadcrumbs
# ===============================================================
def back_end_breadcrumb
res = ''
divider = "/"
res << "
#{t(:dashboard_)}#{divider}"
case controller.controller_name
when 'authorizations'
res << "#{@module_app.title}#{divider}"
case params[:type]
when 'approval'
res << "#{t(:approval_)}"
when 'category'
res << "#{t(:category_auth)}"
when nil
res << "#{t(:module_authorization)}"
else
res << "#{params[:type].underscore.humanize.capitalize} #{t(:authorization_)}"
end
when 'categories'
if @module_app.key!='category'
res << "#{@module_app.title}#{divider}"
res << "#{t(:categories)}"
else
res << "#{@module_app.title}"
end
when 'tags'
if @module_app.key!='tag'
res << "#{@module_app.title}#{divider}"
res << "#{t(:tags)}"
else
res << "#{@module_app.title}"
end
else
if params[:action].eql?('index')
res << "#{@module_app.title}"
else
res << "#{@module_app.title}#{divider}"
res << "#{t(params[:action], scope: 'restful_actions')}"
end
end
res.html_safe
end
def site_breadcrumb
res = ''
divider = "/"
res << "#{t(:settings)}#{divider}"
site = Site.first
case controller.controller_name
when 'sites'
case controller.action_name
when 'sitemap'
res << "#{t(:sitemap)}"
when 'responsive_setting'
res << "#{t(:mobile_settings)}"
when 'mail_setting'
res << "#{t(:mail_setting)}"
when 'preference'
res << "#{t(:preference)}"
when 'search_engine'
res << "#{t(:search_engine)}"
when 'site_info'
res << "#{t(:site_info)}"
when 'update_manager'
res << "#{t(:update_manager)}"
when 'system_info'
res << "#{t("site.system_preference")}"
end
when 'items'
res << "#{t(:structure)}"
when 'module_store'
res << "#{t(:modules)}"
when 'designs'
res << "#{t(:templates)}"
end
res.html_safe
end
def active_when_current_locale_eq(locale)
locale.to_sym == I18n.locale ? 'active in': ''
end
end