2014-10-31 05:36:38 +00:00
|
|
|
class AnnouncementLinkWidgetsController < ApplicationController
|
2014-11-03 12:29:21 +00:00
|
|
|
include PagesHelper
|
2014-11-03 12:22:04 +00:00
|
|
|
layout false
|
2014-10-31 05:36:38 +00:00
|
|
|
def widget
|
2014-11-03 12:22:04 +00:00
|
|
|
{
|
|
|
|
"extras" => {}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_content
|
2014-10-31 05:36:38 +00:00
|
|
|
announcement_app = ModuleApp.find_by_key("announcement")
|
|
|
|
link_app = ModuleApp.find_by_key("web_resource")
|
|
|
|
OrbitHelper.override_widget_module_app("announcement")
|
|
|
|
link_app_tags = link_app.tags
|
|
|
|
common_tags = []
|
|
|
|
an_tags = []
|
|
|
|
l_tags = []
|
|
|
|
announcement_app.tags.each do |tag|
|
|
|
|
if !tag.name.nil?
|
|
|
|
ct = link_app_tags.where(:name => tag.name).first rescue nil
|
|
|
|
if !ct.nil?
|
|
|
|
common_tags << ct
|
|
|
|
an_tags << tag
|
|
|
|
l_tags << ct
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
common_tags_frontend = common_tags.collect do |ct|
|
|
|
|
{
|
|
|
|
"tag-name" => ct.name,
|
|
|
|
"tag-id" => ct.name.downcase.gsub(" ", "_"),
|
|
|
|
"announcements" => [],
|
|
|
|
"links" => []
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if common_tags_frontend.size > 0
|
|
|
|
Bulletin.all.each do |ann|
|
|
|
|
intersection = ann.tags & an_tags
|
|
|
|
if intersection.size > 0
|
|
|
|
intersection.each do |t|
|
|
|
|
name = t.name.downcase.gsub(" ", "_")
|
|
|
|
index = common_tags_frontend.index{|t| t["tag-id"] == name}
|
|
|
|
ctf = common_tags_frontend[index]
|
|
|
|
ctf["announcements"] << {"title" => ann.title,"link"=>OrbitHelper.widget_item_url(ann.to_param)}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
WebLink.all.each do |wl|
|
|
|
|
intersection = wl.tags & l_tags
|
|
|
|
# debugger
|
|
|
|
if intersection.size > 0
|
|
|
|
intersection.each do |t|
|
|
|
|
name = t.name.downcase.gsub(" ", "_")
|
|
|
|
index = common_tags_frontend.index{|t| t["tag-id"] == name}
|
|
|
|
ctf = common_tags_frontend[index]
|
|
|
|
ctf["links"] << {"title" => wl.title,"url" => wl.url}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# debugger
|
|
|
|
end
|
|
|
|
|
|
|
|
{
|
|
|
|
"tags" => common_tags_frontend,
|
|
|
|
"extras" => {
|
|
|
|
"heading-announcements" => "Announcements",
|
|
|
|
"heading-links" => "Links"
|
|
|
|
}
|
|
|
|
}
|
2014-11-03 12:22:04 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def content
|
2014-11-03 13:03:29 +00:00
|
|
|
OrbitHelper.set_site_locale I18n.locale
|
2014-11-03 12:22:04 +00:00
|
|
|
OrbitHelper.register_subpart(params["sub_part_id"])
|
|
|
|
html = render_widget_for_frontend("announcement_link_widget","render_content","content")
|
|
|
|
render :html => html.html_safe
|
2014-10-31 05:36:38 +00:00
|
|
|
end
|
|
|
|
end
|