2022-03-08 08:55:33 +00:00
|
|
|
class EventNewsModsController < ApplicationController
|
2020-07-22 02:23:36 +00:00
|
|
|
include EventNewsHelper
|
2024-07-18 12:59:34 +00:00
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
@app_title = 'event_news_mod'
|
|
|
|
#self.request = OrbitHelper.request
|
|
|
|
end
|
2020-07-22 02:23:36 +00:00
|
|
|
def index
|
|
|
|
EventNews.remove_expired_status
|
|
|
|
sorted,total_pages = get_sorted_event_news
|
|
|
|
event_news = sorted.collect do |a|
|
|
|
|
if a["source-site"].blank?
|
|
|
|
statuses = a.statuses_with_classname.collect do |status|
|
|
|
|
{
|
|
|
|
"status" => status["name"],
|
|
|
|
"status-class" => "status-#{status['classname']}"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
locale = OrbitHelper.get_site_locale.to_s
|
2021-09-16 09:16:20 +00:00
|
|
|
files = a.event_news_files.to_fronted(locale)
|
2020-07-22 02:23:36 +00:00
|
|
|
links = a.event_news_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
|
|
|
author = User.find(a.create_user_id).member_profile.name rescue ""
|
|
|
|
desc = a.image_description
|
2021-06-09 06:34:00 +00:00
|
|
|
desc = (desc.blank? ? "EventNews image" : desc)
|
2020-07-22 02:23:36 +00:00
|
|
|
link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)
|
|
|
|
target = a.is_external_link ? "_blank" : "_self"
|
2024-10-13 13:46:48 +00:00
|
|
|
title = a.title_plain_text
|
|
|
|
title = 'no content' if title.blank?
|
2022-01-21 02:09:31 +00:00
|
|
|
event_time = a.event_time_formated_for_frontend
|
2021-10-21 04:54:14 +00:00
|
|
|
event_time_formated = a.event_time_formated
|
2020-07-22 02:23:36 +00:00
|
|
|
{
|
|
|
|
"department" => author,
|
|
|
|
"event_news_links" => links,
|
|
|
|
"event_news_files" => files,
|
|
|
|
"title" => a.title,
|
|
|
|
"speaker" => a.speaker,
|
2021-08-24 15:09:19 +00:00
|
|
|
"speaker-css" => (a.speaker.blank? ? "display: none;" : ""),
|
2021-07-14 04:56:02 +00:00
|
|
|
"place" => a.place,
|
2021-10-21 04:14:15 +00:00
|
|
|
"place-css" => (a.place.blank? ? "display: none;" : ""),
|
2020-07-22 02:23:36 +00:00
|
|
|
"host" => a.host,
|
2021-08-24 15:09:19 +00:00
|
|
|
"host-css" => (a.host.blank? ? "display: none;" : ""),
|
2020-07-22 02:23:36 +00:00
|
|
|
"notes" => a.notes,
|
|
|
|
"source-site" => "",
|
|
|
|
"source-site-title" => "",
|
|
|
|
"source-site-link" => "",
|
|
|
|
"subtitle" => a.subtitle,
|
|
|
|
"statuses" => statuses,
|
2021-06-09 06:34:00 +00:00
|
|
|
"category" => (a.category.title rescue ""),
|
2021-08-09 02:45:06 +00:00
|
|
|
"postdate" => event_time,
|
2024-01-28 07:04:23 +00:00
|
|
|
"event_start_date" => a.event_date_frontend,
|
|
|
|
"event_end_date" => a.event_end_date_frontend,
|
2021-10-21 04:54:14 +00:00
|
|
|
"event-time-formated" => event_time_formated,
|
|
|
|
"event-time-css" => (event_time_formated.blank? ? "display: none;" : ""),
|
2020-07-22 02:23:36 +00:00
|
|
|
"author" => author,
|
|
|
|
"is_top" => (a.is_top? ? 1 : 0),
|
|
|
|
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
|
|
|
"target" => target,
|
2021-06-09 06:34:00 +00:00
|
|
|
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg",
|
2020-07-22 02:23:36 +00:00
|
|
|
"img_description" => desc,
|
2022-01-21 02:09:31 +00:00
|
|
|
"more" => t("event_news.more"),
|
2020-07-22 02:23:36 +00:00
|
|
|
"view_count" => a.view_count
|
|
|
|
}
|
|
|
|
else
|
|
|
|
a
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#If no data , hide title&table
|
|
|
|
if sorted.count == 0
|
|
|
|
display = "hide"
|
|
|
|
end
|
|
|
|
# event_news = event_news.concat(feeds_event_news)
|
|
|
|
# total_pages = event_news.total_pages
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
"event_news" => event_news,
|
|
|
|
"extras" => {
|
|
|
|
"widget-title" =>t('event_news.event_news'),
|
2024-01-28 07:04:23 +00:00
|
|
|
"category-head" => EventNewsCustomTitle.get_trans('category'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
|
|
|
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
|
|
|
"host-head" => EventNewsCustomTitle.get_trans('host'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2022-01-11 03:12:37 +00:00
|
|
|
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2024-01-28 07:04:23 +00:00
|
|
|
"event_start_date-head" => EventNewsCustomTitle.get_trans('start_date'),
|
|
|
|
"event_end_date-head" => EventNewsCustomTitle.get_trans('end_date'),
|
2020-07-22 02:23:36 +00:00
|
|
|
"status-head" => t('event_news.table.status'),
|
|
|
|
"author-head" => t('event_news.table.author'),
|
|
|
|
"subtitle-head" => t('event_news.table.sub_title'),
|
|
|
|
"link-head" => t('event_news.table.link'),
|
|
|
|
"file-head" => t('event_news.table.file'),
|
|
|
|
"view-count-head" => t('event_news.table.view_count'),
|
|
|
|
"display" => display,
|
|
|
|
"department-head" => t('event_news.table.department')
|
|
|
|
},
|
|
|
|
"total_pages" => total_pages
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def random_event_news_widget
|
|
|
|
pack_data(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def widget
|
|
|
|
pack_data()
|
|
|
|
end
|
|
|
|
|
|
|
|
def tag_cloud
|
2022-03-08 08:55:33 +00:00
|
|
|
ma = ModuleApp.where(:key => "event_news_mod").first
|
2020-07-22 02:23:36 +00:00
|
|
|
temp = []
|
|
|
|
ma.tags.each do |tag|
|
|
|
|
t1 = tag.taggings.collect{|t| t.taggable_id.to_s}
|
|
|
|
count = EventNews.where(:id.in => t1).can_display_and_sorted.count
|
|
|
|
temp << {
|
|
|
|
"tag-name" => tag.name,
|
|
|
|
"count" => count,
|
|
|
|
"tag-url" => OrbitHelper.widget_more_url + "?tags[]=" + tag.id.to_s
|
|
|
|
}
|
|
|
|
end
|
|
|
|
max = temp.max_by{|t| t["count"]}["count"]
|
|
|
|
tags = []
|
|
|
|
temp.each do |tag|
|
|
|
|
if tag["count"] > 0
|
|
|
|
percent = (tag["count"] * 100) / max
|
|
|
|
font_size = ((percent / 10).round) + 16
|
|
|
|
tag["font-size"] = font_size
|
|
|
|
tags << tag
|
|
|
|
end
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"tags" => tags,
|
|
|
|
"extras" => {}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
def pack_data(is_random=false)
|
|
|
|
cats = OrbitHelper.widget_categories || []
|
2021-06-09 06:34:00 +00:00
|
|
|
tags = OrbitHelper.widget_tags || []
|
2021-09-16 09:16:20 +00:00
|
|
|
tags = ['all'] if tags.blank?
|
2021-06-09 06:34:00 +00:00
|
|
|
subpart = OrbitHelper.get_current_widget
|
|
|
|
get_tabs_option
|
|
|
|
event_news = []
|
|
|
|
use_tag = false
|
2024-10-13 13:46:48 +00:00
|
|
|
tags = tags.collect{|tag| tag.to_s}
|
|
|
|
cats = cats.collect{|cat| cat.to_s}
|
2021-06-09 06:34:00 +00:00
|
|
|
if @tab_option == 0
|
|
|
|
event_news = get_event_news_for_pack_data(cats,tags,nil,is_random)
|
|
|
|
else
|
2021-09-15 14:02:59 +00:00
|
|
|
if cats.count != 1 || tags == ["all"]
|
2021-06-09 06:34:00 +00:00
|
|
|
cats.each do |cat|
|
2021-09-16 09:16:20 +00:00
|
|
|
event_news = event_news + get_event_news_for_pack_data([cat],tags,'',is_random)
|
2021-06-09 06:34:00 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
tags.each do |tag|
|
2021-09-16 09:16:20 +00:00
|
|
|
event_news = event_news + get_event_news_for_pack_data(cats,[tag],tag,is_random)
|
2021-06-09 06:34:00 +00:00
|
|
|
end
|
|
|
|
use_tag = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
mp = (event_news[0]["img_src"] rescue "")
|
|
|
|
mpd = (event_news[0]["img_description"] rescue "")
|
|
|
|
if @tab_option == 1
|
|
|
|
if use_tag
|
|
|
|
tags = ["all"] + tags
|
|
|
|
else
|
|
|
|
cats = ["all"] + cats
|
|
|
|
end
|
2024-10-13 13:46:48 +00:00
|
|
|
event_news = sort_event_news(event_news)
|
2021-06-09 06:34:00 +00:00
|
|
|
end
|
|
|
|
cats = cats.uniq
|
|
|
|
tags = tags.uniq
|
2024-10-13 13:46:48 +00:00
|
|
|
tags_translations = {'all' => I18n.t(:all)}
|
|
|
|
Tag.where(:id.in => tags).pluck(:id, :title).each{|id, title_translations|
|
|
|
|
tags_translations[id.to_s] = title_translations[I18n.locale]
|
|
|
|
}
|
|
|
|
cats_translations = {'all' => I18n.t(:all)}
|
|
|
|
Category.where(:id.in => cats).pluck(:id, :title).each{|id, title_translations|
|
|
|
|
cats_translations[id.to_s] = title_translations[I18n.locale]
|
|
|
|
}
|
2021-06-09 06:34:00 +00:00
|
|
|
cats_relations = cats_translations.map{|cat_id,t|
|
|
|
|
if cat_id == "all"
|
|
|
|
t = "all"
|
|
|
|
end
|
|
|
|
[cat_id,t]
|
|
|
|
}.to_h
|
2021-09-16 09:16:20 +00:00
|
|
|
home_page = Page.first
|
|
|
|
page = nil
|
|
|
|
locale = I18n.locale.to_s
|
|
|
|
if home_page.respond_to?(:find_page)
|
|
|
|
page = home_page.find_page(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil
|
2022-03-08 08:55:33 +00:00
|
|
|
page = home_page.find_page(:module=>"event_news_mod",:enabled_for=>locale).first rescue nil if page.nil?
|
2021-09-16 09:16:20 +00:00
|
|
|
else
|
|
|
|
page = Page.where(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil
|
2022-03-08 08:55:33 +00:00
|
|
|
page = Page.where(:module=>"event_news_mod",:enabled_for=>locale).first rescue nil if page.nil?
|
2021-09-16 09:16:20 +00:00
|
|
|
end
|
2021-06-09 06:34:00 +00:00
|
|
|
all_cats = cats.dup
|
|
|
|
all_cats.delete "all"
|
|
|
|
if all_cats.count == 0
|
|
|
|
all_cats = ["all"]
|
|
|
|
end
|
|
|
|
all_tags = tags.dup
|
|
|
|
all_tags.delete "all"
|
|
|
|
if all_tags.count == 0
|
|
|
|
all_tags = ["all"]
|
|
|
|
end
|
|
|
|
max_all_count = [OrbitHelper.widget_data_count,event_news.count].min
|
|
|
|
if @tab_option != 0
|
|
|
|
OrbitHelper.set_widget_title(OrbitHelper.widget_title +
|
|
|
|
"<div style=\"clear: both;\"></div>" +
|
|
|
|
"<ul class=\"nav_tabs_filter\">" +
|
|
|
|
(use_tag ? tags.map.with_index{|tag,i|
|
2021-09-16 09:16:20 +00:00
|
|
|
read_more_url = "/#{locale + page.url}" rescue ""
|
2021-06-09 06:34:00 +00:00
|
|
|
read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=>(tag == 'all' ? all_tags : [tag])}.to_param if read_more_url != ""
|
|
|
|
read_more_text = I18n.t("event_news.more")
|
|
|
|
if tag != "all"
|
|
|
|
begin
|
|
|
|
read_more_text = I18n.t("event_news.more_") + tags_translations[tag]
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" #{(tag == 'all' && @all_setting_option == 0) ? "data-count_limit=\"#{max_all_count}\"" : ''} data-read_more_text=\"#{read_more_text}\" data-read_more=\"#{read_more_url}\" data-tags=\"#{tag}\">#{tags_translations[tag]}</li>"
|
|
|
|
}.join("") : cats.map.with_index{|cat,i|
|
2021-09-16 09:16:20 +00:00
|
|
|
read_more_url = "/#{locale + page.url}" rescue ""
|
2021-06-09 06:34:00 +00:00
|
|
|
read_more_url = read_more_url + "?" + {"category"=>(cat == 'all' ? all_cats : cat)}.to_param if read_more_url != ""
|
|
|
|
read_more_text = I18n.t("event_news.more")
|
|
|
|
if cat != "all"
|
|
|
|
begin
|
|
|
|
read_more_text = I18n.t("event_news.more_") + cats_translations[cat]
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" #{(cat == 'all' && @all_setting_option == 0) ? "data-count_limit=\"#{max_all_count}\"" : ''} data-read_more_text=\"#{read_more_text}\" data-read_more=\"#{read_more_url}\" data-category=\"#{cats_relations[cat]}\">#{cats_translations[cat]}</li>"
|
|
|
|
}.join("")) +
|
|
|
|
"</ul>"
|
|
|
|
)
|
|
|
|
filter_attr = (use_tag ? 'data-tags' : 'data-category')
|
|
|
|
extra_html = '
|
|
|
|
<script>
|
|
|
|
if(typeof(wpexAnimsition) == "undefined"){
|
|
|
|
var wpexAnimsition = {
|
|
|
|
"loading":"1",
|
|
|
|
"inDuration":"400",
|
|
|
|
"outDuration":"400",
|
|
|
|
"inClass":"fade-in",
|
|
|
|
"outClass":"fade-out",
|
|
|
|
"need_fix_containers":".widget-event_news-4,.widget-event_news-15",
|
|
|
|
"linkElement": "[data-list=\"event_news\"] > *",
|
|
|
|
"children_text_block": ".w-annc__content-wrap",
|
|
|
|
"container_block": "[data-subpart-id=\"'+subpart.id.to_s+'\"] [data-list=\"event_news\"]:not(tbody)",
|
|
|
|
"parent_block": "[data-subpart-id=\"'+subpart.id.to_s+'\"]",
|
|
|
|
"filter_bar": ".nav_tabs_filter",
|
|
|
|
"filter_option": "li.filter_tab",
|
|
|
|
"filter_attr": "'+filter_attr+'",
|
|
|
|
"filter_target_attr": "class",
|
|
|
|
"use_attr_filter": true,
|
|
|
|
"equal_height": false
|
|
|
|
};
|
|
|
|
}else{
|
|
|
|
var filter_attr = "'+filter_attr+'";
|
|
|
|
wpexAnimsition.parent_block = wpexAnimsition.parent_block + ", [data-subpart-id=\"'+subpart.id.to_s+'\"]";
|
|
|
|
wpexAnimsition.container_block = wpexAnimsition.container_block + ", [data-subpart-id=\"'+subpart.id.to_s+'\"] [data-list=\"event_news\"]:not(tbody)";
|
|
|
|
if( wpexAnimsition.filter_attr.indexOf(filter_attr) == -1 ){
|
|
|
|
wpexAnimsition.filter_attr += ("," + filter_attr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var wpexLocalize = {
|
|
|
|
"lightboxType": "iLightbox",
|
|
|
|
"iLightbox": { "auto": false, "skin": "minimal", "path": "horizontal",
|
|
|
|
"infinite": false, "maxScale": 1, "minScale": 0, "width": 1400, "height": "",
|
|
|
|
"slideshow": { "pauseTime": 3000, "startPaused": true },
|
|
|
|
"effects": { "reposition": true, "repositionSpeed": 200, "switchSpeed": 300,
|
|
|
|
"loadedFadeSpeed": 50, "fadeSpeed": 500
|
|
|
|
},
|
|
|
|
"show": { "title": true, "speed": 200 },
|
|
|
|
"hide": { "speed": 200 },
|
|
|
|
"overlay": { "blur": true, "opacity": "0.9" },
|
|
|
|
"slideShow": "Slideshow", "next": "Next", "previous": "Previous" ,
|
|
|
|
"thumbnails": { "maxWidth": 120, "maxHeight": 80 }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$(document).ready(function(){
|
|
|
|
var first_filter_tab = $("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").eq(0);
|
|
|
|
var read_more_url = first_filter_tab.data("read_more");
|
|
|
|
if(read_more_url.length != 0){
|
2021-09-15 14:02:59 +00:00
|
|
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-event_news__more").attr("href",read_more_url);
|
|
|
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-event_news__more").text(first_filter_tab.data("read_more_text"));
|
2021-06-09 06:34:00 +00:00
|
|
|
}
|
|
|
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").click(function(){
|
|
|
|
var read_more_url = $(this).data("read_more");
|
|
|
|
if(read_more_url.length != 0){
|
2021-09-15 14:02:59 +00:00
|
|
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-event_news__more").attr("href",read_more_url);
|
|
|
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-event_news__more").text($(this).data("read_more_text"));
|
2021-06-09 06:34:00 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
<script src="/assets/event_news/wpex.min.js"></script>
|
|
|
|
<style>
|
|
|
|
[data-list="event_news"] {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
'
|
|
|
|
else
|
|
|
|
read_more_text = I18n.t("event_news.more")
|
|
|
|
if cats.count == 1 && cats[0] != "all"
|
|
|
|
begin
|
|
|
|
read_more_text = I18n.t("event_news.more_") + ((all_tags.count == 1 && all_tags[0] != 'all') ? tags_translations[tags[0]] : cats_translations[cats[0]])
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
extra_html = "
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
2021-09-15 14:02:59 +00:00
|
|
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-event_news__more\").text(\"#{read_more_text}\");
|
2021-06-09 06:34:00 +00:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
"
|
|
|
|
end
|
|
|
|
if (@read_more_option != 0 rescue false)
|
|
|
|
extra_html += "
|
|
|
|
<script>
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
var read_more_position = #{@read_more_option};
|
2021-09-15 14:02:59 +00:00
|
|
|
var read_more_block = $(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-event_news__more\");
|
2021-06-09 06:34:00 +00:00
|
|
|
if(read_more_position == 1 || read_more_position == 2){
|
|
|
|
read_more_block.addClass(\"pull-left\");
|
|
|
|
}else{
|
|
|
|
read_more_block.addClass(\"pull-right\");
|
|
|
|
}
|
|
|
|
if(read_more_position == 1 || read_more_position == 3){
|
|
|
|
var first_element = $(\"[data-subpart-id=\\\"#{subpart.id}\\\"] > *:eq(0)\");
|
|
|
|
var div_clearfix = $('<div class=\"clearfix\"></div>')
|
|
|
|
if(first_element.height() == 0){
|
|
|
|
read_more_block.appendTo(div_clearfix);
|
|
|
|
}else{
|
|
|
|
div_clearfix = read_more_block;
|
|
|
|
}
|
|
|
|
first_element.before(div_clearfix);
|
2021-09-16 09:16:20 +00:00
|
|
|
var annc_title = $(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-annc__widget-title\").eq(0);
|
|
|
|
if(annc_title.length != 0){
|
|
|
|
read_more_block.appendTo(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-annc__widget-title:eq(0)\");
|
|
|
|
}
|
2021-06-09 06:34:00 +00:00
|
|
|
}else{
|
|
|
|
var div_clearfix = $('<div class=\"clearfix\"></div>');
|
|
|
|
read_more_block.appendTo(div_clearfix);
|
|
|
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] > *:eq(-1)\").after(div_clearfix);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
"
|
|
|
|
end
|
|
|
|
extra_after_html = ""
|
|
|
|
if @all_setting_option == 0 && @tab_option == 1
|
|
|
|
extra_after_html = "
|
|
|
|
<script>
|
|
|
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] [data-list] [data-category]\").css(\"display\",\"none\");
|
|
|
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] [data-list] [data-category]:lt(#{max_all_count})\").css(\"display\",\"\");
|
|
|
|
</script>
|
|
|
|
"
|
|
|
|
end
|
|
|
|
if @tab_option == 0
|
2021-09-16 09:16:20 +00:00
|
|
|
read_more_url = "/#{locale + page.url}" rescue ""
|
2021-06-09 06:34:00 +00:00
|
|
|
read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=>all_tags}.to_param if read_more_url != ""
|
|
|
|
extra_after_html += "
|
|
|
|
<script>
|
2021-09-15 14:02:59 +00:00
|
|
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-event_news__more\").attr(\"href\",\"#{read_more_url}\");
|
2021-06-09 06:34:00 +00:00
|
|
|
</script>
|
|
|
|
"
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"event_news" => event_news,
|
|
|
|
"extras" => {
|
|
|
|
"more_url"=>OrbitHelper.widget_more_url,
|
|
|
|
"main_picture" => mp,
|
|
|
|
"main_picture_description" => mpd,
|
2024-01-28 07:04:23 +00:00
|
|
|
"category-head" => EventNewsCustomTitle.get_trans('category'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
|
|
|
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
|
|
|
"host-head" => EventNewsCustomTitle.get_trans('host'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2024-01-28 07:04:23 +00:00
|
|
|
"event_start_date-head" => EventNewsCustomTitle.get_trans('start_date'),
|
|
|
|
"event_end_date-head" => EventNewsCustomTitle.get_trans('end_date'),
|
2021-06-09 06:34:00 +00:00
|
|
|
"author-head" => t('event_news.table.author'),
|
|
|
|
"status-head" => t('event_news.table.status'),
|
|
|
|
"subtitle-head" => t('event_news.table.sub_title'),
|
|
|
|
"link-head" => t('event_news.table.link'),
|
|
|
|
"file-head" => t('event_news.table.file'),
|
|
|
|
"read_more" => read_more_url,
|
|
|
|
"read_more_text" => "read more",
|
|
|
|
"extra_brefore_html" => extra_html,
|
2021-09-06 05:44:20 +00:00
|
|
|
"extra_after_html" => extra_after_html,
|
|
|
|
"calendar_title" => get_calendar_title,
|
|
|
|
"widget_title" => subpart.title,
|
|
|
|
'widget_title_class' => subpart.title.blank? ? 'center' : '',
|
2021-06-09 06:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2021-09-16 09:16:20 +00:00
|
|
|
def get_tabs_option
|
|
|
|
subpart = OrbitHelper.get_current_widget
|
|
|
|
tab_options = ["not_enable_tabs","enable_tabs_with_categories_include_all","enable_tabs_with_categories"]
|
|
|
|
read_more_options = ['default','upper_left','lower_left','upper_right','lower_right']
|
|
|
|
all_setting_options = ['the_same_as_data_count','display_all_in_other_tabs']
|
|
|
|
@tab_option = 0
|
|
|
|
@read_more_option = 0
|
|
|
|
@all_setting_option = 0
|
2021-09-19 14:13:36 +00:00
|
|
|
@image_version = 'thumb'
|
|
|
|
@show_today_data_first = false
|
2024-10-13 13:46:48 +00:00
|
|
|
@show_options = nil
|
2021-09-16 09:16:20 +00:00
|
|
|
if subpart.methods.include? 'select_options'.to_sym
|
2024-10-13 13:46:48 +00:00
|
|
|
module_app = ModuleApp.where(key: 'event_news_mod').first
|
|
|
|
if module_app
|
|
|
|
@show_options = module_app.show_options
|
2021-09-16 09:16:20 +00:00
|
|
|
end
|
|
|
|
subpart.select_options.each do |select_option|
|
2021-09-19 14:13:36 +00:00
|
|
|
if !(@show_options.nil?)
|
2021-09-16 09:16:20 +00:00
|
|
|
value = YAML.load(select_option.value)
|
|
|
|
tmp = value[:en]
|
|
|
|
I18n.with_locale(:en) do
|
2021-09-19 14:13:36 +00:00
|
|
|
case select_option.field_name
|
|
|
|
when @show_options.keys[0].to_s
|
|
|
|
if tmp == t('event_news.small_size')
|
|
|
|
@image_version = 'thumb'
|
|
|
|
elsif tmp == t('event_news.medium_size')
|
|
|
|
@image_version = 'mobile'
|
|
|
|
elsif tmp == t('event_news.orignal_size')
|
|
|
|
@image_version = 'orignal'
|
2021-09-16 09:16:20 +00:00
|
|
|
end
|
2021-09-19 14:13:36 +00:00
|
|
|
when @show_options.keys[1].to_s
|
|
|
|
tab_options.each_with_index do |option,i|
|
|
|
|
if tmp == t("event_news.#{option}")
|
|
|
|
@tab_option = i
|
|
|
|
break
|
|
|
|
end
|
2021-09-16 09:16:20 +00:00
|
|
|
end
|
2021-09-19 14:13:36 +00:00
|
|
|
when @show_options.keys[2].to_s
|
|
|
|
read_more_options.each_with_index do |option,i|
|
|
|
|
if tmp == t("event_news.#{option}")
|
|
|
|
@read_more_option = i
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when @show_options.keys[3].to_s
|
|
|
|
all_setting_options.each_with_index do |option,i|
|
|
|
|
if tmp == t("event_news.#{option}")
|
|
|
|
@all_setting_option = i
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
when @show_options.keys[4].to_s
|
|
|
|
if tmp == t('no_')
|
|
|
|
@show_today_data_first = false
|
|
|
|
else
|
|
|
|
@show_today_data_first = true
|
2021-09-16 09:16:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-06-09 06:34:00 +00:00
|
|
|
def get_event_news_for_pack_data(cats,tags,set_tags=nil,is_random = false)
|
|
|
|
if tags.blank?
|
|
|
|
tags = ["all"]
|
|
|
|
end
|
2020-07-22 02:23:36 +00:00
|
|
|
subpart = OrbitHelper.get_current_widget
|
|
|
|
widget_data_count = OrbitHelper.widget_data_count
|
2021-06-09 06:34:00 +00:00
|
|
|
event_news_cache = EventNewsCache.where(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s)
|
2020-07-22 02:23:36 +00:00
|
|
|
devide_flag = (!(defined? SiteFeed).nil?)
|
2021-09-16 09:16:20 +00:00
|
|
|
event_news_cache.where(:invalid_date.lte => Time.now).destroy
|
|
|
|
count = event_news_cache.count
|
|
|
|
if count > 1
|
|
|
|
event_news_cache.limit(count-1).destroy
|
|
|
|
end
|
|
|
|
if event_news_cache.count == 0 || is_random
|
2020-07-22 02:23:36 +00:00
|
|
|
EventNews.remove_expired_status
|
2022-10-24 08:26:33 +00:00
|
|
|
uid = OrbitHelper.params[:uid].to_s rescue ""
|
2021-09-16 09:16:20 +00:00
|
|
|
event_news_for_locale = EventNews.where(:title.nin => ["",nil], :uid.ne => uid).is_approved_and_show.filter_cats_and_tags(cats,tags)
|
2021-09-19 14:13:36 +00:00
|
|
|
if @show_today_data_first
|
|
|
|
sorted_event_news = event_news_for_locale.can_display_and_sorted_according_today
|
|
|
|
else
|
|
|
|
sorted_event_news = event_news_for_locale.can_display_and_sorted
|
|
|
|
end
|
2020-07-22 02:23:36 +00:00
|
|
|
if !is_random
|
2021-09-19 14:13:36 +00:00
|
|
|
sorted_event_news = sorted_event_news.limit(widget_data_count).to_a
|
|
|
|
first_deadline = sorted_event_news.collect{|v| v[:deadline]}.compact.sort[0]
|
2021-09-16 09:16:20 +00:00
|
|
|
first_postdate = event_news_for_locale.open_in_future.limit(1).pluck(:postdate)[0]
|
2021-09-19 14:13:36 +00:00
|
|
|
if @show_today_data_first
|
|
|
|
sorted_event_news = sorted_event_news.reverse
|
2022-11-24 07:56:23 +00:00
|
|
|
invalid_date = [first_postdate,first_deadline, (Date.today + 1.day).to_time].compact.sort[0]
|
2021-09-19 14:13:36 +00:00
|
|
|
else
|
|
|
|
invalid_date = [first_postdate,first_deadline].compact.sort[0]
|
|
|
|
end
|
2020-07-22 02:23:36 +00:00
|
|
|
if devide_flag
|
2021-09-19 14:13:36 +00:00
|
|
|
top_event_news = sorted_event_news.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
|
|
|
not_top_event_news = sorted_event_news.select{|v| !v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
2021-09-16 09:16:20 +00:00
|
|
|
EventNewsCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: {top: top_event_news,not_top: not_top_event_news},invalid_date: invalid_date)
|
2020-07-22 02:23:36 +00:00
|
|
|
else
|
2021-06-09 06:34:00 +00:00
|
|
|
event_news = sorted_event_news.map{|v| data_to_human_type(v,set_tags)}
|
2021-09-16 09:16:20 +00:00
|
|
|
EventNewsCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: event_news,invalid_date: invalid_date)
|
2020-07-22 02:23:36 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if devide_flag
|
|
|
|
event_news = sorted_event_news.sample(widget_data_count)
|
2021-06-09 06:34:00 +00:00
|
|
|
top_event_news = event_news.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
|
|
|
not_top_event_news = event_news.select{|v| !v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
2020-07-22 02:23:36 +00:00
|
|
|
else
|
2021-06-09 06:34:00 +00:00
|
|
|
event_news = sorted_event_news.sample(widget_data_count).map{|v| data_to_human_type(v,set_tags)}
|
2020-07-22 02:23:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif devide_flag
|
|
|
|
now_event_news = event_news_cache.first.filter_result
|
|
|
|
top_event_news = now_event_news[:top]
|
|
|
|
not_top_event_news = now_event_news[:not_top]
|
|
|
|
else
|
|
|
|
event_news = event_news_cache.first.filter_result
|
|
|
|
end
|
|
|
|
if devide_flag
|
2024-10-13 13:46:48 +00:00
|
|
|
feeds_event_news, _ = get_feed_event_news("widget",nil,cats,widget_data_count - top_event_news.count)
|
|
|
|
top_event_news += feeds_event_news.select{|v| v['is_top'] == true}
|
|
|
|
top_event_news = sort_event_news(top_event_news)
|
2020-07-22 02:23:36 +00:00
|
|
|
rest_count = widget_data_count - top_event_news.count
|
|
|
|
if rest_count <= 0
|
2021-09-16 09:16:20 +00:00
|
|
|
event_news = top_event_news.take(widget_data_count)
|
2020-07-22 02:23:36 +00:00
|
|
|
else
|
|
|
|
rest_all_event_news = feeds_event_news.select{|v| v['is_top'] != true} + not_top_event_news.take(rest_count)
|
2024-10-13 13:46:48 +00:00
|
|
|
rest_event_news = sort_event_news(rest_all_event_news).take(rest_count)
|
2021-09-16 09:16:20 +00:00
|
|
|
event_news = top_event_news + rest_event_news
|
2020-07-22 02:23:36 +00:00
|
|
|
end
|
|
|
|
end
|
2021-06-09 06:34:00 +00:00
|
|
|
event_news
|
2020-07-22 02:23:36 +00:00
|
|
|
end
|
2021-09-16 09:16:20 +00:00
|
|
|
|
|
|
|
def get_file
|
|
|
|
@url = request.path
|
|
|
|
begin
|
|
|
|
if @url.match(/\/\.\./)
|
|
|
|
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
file = EventNewsFile.find(params[:id])
|
|
|
|
if File.basename(file.file.path) != URI.decode(params[:f_name])
|
|
|
|
render :file => "#{Rails.root}/app/views/errors/403.html", :layout => false, :status => :not_found, :content_type => 'text/html'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
@url = file.file.url
|
|
|
|
if file.can_access?(OrbitHelper.current_user)
|
|
|
|
@path = file.file.path rescue ""
|
|
|
|
@filename = @path.split("/").last
|
|
|
|
@ext = @path.split("/").last.to_s.split(".").last
|
|
|
|
if @ext == "png" || @ext == "jpg" || @ext == "bmp" || @ext == "pdf"
|
|
|
|
render "archives/download_file.html",:layout=>false
|
|
|
|
else
|
|
|
|
if (current_site.accessibility_mode rescue false)
|
|
|
|
render "archives/redirect_to_file.html",:layout=>false
|
|
|
|
return
|
|
|
|
else
|
|
|
|
send_file(@path)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
render :file => "#{Rails.root}/app/views/errors/403.html", :layout => false, :status => :not_found, :content_type => 'text/html'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-22 02:23:36 +00:00
|
|
|
def show_local_event_news(uid, is_preview)
|
|
|
|
locale = OrbitHelper.get_site_locale.to_s
|
|
|
|
if is_preview
|
|
|
|
event_news = EventNews.where(:uid => uid).first
|
|
|
|
else
|
|
|
|
event_news = EventNews.can_display_and_sorted.where(:uid => uid).first
|
|
|
|
end
|
|
|
|
event_news = EventNews.where(:uid => uid).first if event_news.nil?
|
2022-11-24 16:14:51 +00:00
|
|
|
return nil if event_news.nil?
|
2020-07-22 02:23:36 +00:00
|
|
|
url_to_edit = OrbitHelper.user_can_edit?(event_news) ? "/admin/event_news/#{event_news.id.to_s}/edit" : ""
|
|
|
|
|
|
|
|
access_level = OrbitHelper.user_access_level?
|
|
|
|
|
|
|
|
if !event_news.approved && (access_level != "manager" && access_level != "admin")
|
|
|
|
if EventNewsSetting.is_pro?
|
|
|
|
if !(access_level == "sub_manager" && EventNewsSetting.first.approvers.include?(OrbitHelper.current_user.id.to_s))
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
elsif access_level != "sub_manager"
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-09 06:34:00 +00:00
|
|
|
return {} if (event_news.category.disable rescue false)
|
2020-07-22 02:23:36 +00:00
|
|
|
|
|
|
|
tags = event_news.tags.map{|tag| {
|
|
|
|
"tag" => tag.name ,
|
|
|
|
"url" => OrbitHelper.page_for_tag(tag)
|
|
|
|
} } rescue []
|
2021-09-16 09:16:20 +00:00
|
|
|
files = event_news.event_news_files.to_fronted(locale)
|
2020-07-22 02:23:36 +00:00
|
|
|
links = event_news.event_news_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
|
|
|
update_user = event_news.update_user.member_profile.name rescue ""
|
|
|
|
desc = event_news.image_description
|
2021-06-09 06:34:00 +00:00
|
|
|
desc = (desc.nil? || desc == "" ? "EventNews image" : desc)
|
2020-07-22 02:23:36 +00:00
|
|
|
|
|
|
|
request = OrbitHelper.request
|
|
|
|
meta_desc = event_news.subtitle.nil? || event_news.subtitle == "" ? event_news.text[0..200] : event_news.subtitle
|
|
|
|
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => event_news.title},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => "#{request.base_url}#{event_news.image.url}"},{"property" => "og:type", "content" => "Article"}])
|
|
|
|
|
|
|
|
subtitle_ann = nil
|
|
|
|
img_src = nil
|
|
|
|
img_description = nil
|
|
|
|
subtitle_ann = event_news.subtitle if event_news.display_subtitle?
|
2021-06-09 06:34:00 +00:00
|
|
|
img_src = (event_news.image.thumb.url || "/assets/event_news-default.jpg") if event_news.display_img?
|
2020-07-22 02:23:36 +00:00
|
|
|
img_description = event_news.image_description if (event_news.image_description.present?) && (event_news.display_img?)
|
2021-08-09 02:45:06 +00:00
|
|
|
event_carousel_images = event_news.event_carousel_images.map{|image| {"src"=>image.file.url,"description"=>image.description.to_s,"description_text"=>image.description_text }}
|
|
|
|
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
|
|
|
|
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
|
|
|
|
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
|
|
|
|
next_btn_title = (I18n.locale.to_s =="zh_tw") ? "下一張" : "next"
|
2022-01-21 02:09:31 +00:00
|
|
|
begin
|
|
|
|
event_time = event_news.event_time_formated_for_frontend
|
|
|
|
rescue => e
|
|
|
|
puts e.to_s
|
|
|
|
event_time = ""
|
2021-08-09 02:45:06 +00:00
|
|
|
end
|
2020-07-22 02:23:36 +00:00
|
|
|
{
|
|
|
|
"tags" => tags,
|
|
|
|
"event_news_files" => files,
|
|
|
|
"event_news_links" => links,
|
2021-08-09 02:45:06 +00:00
|
|
|
"event_carousel_images" => event_carousel_images,
|
2021-08-24 15:43:30 +00:00
|
|
|
"data" => {
|
2022-01-21 02:09:31 +00:00
|
|
|
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
2021-08-24 15:43:30 +00:00
|
|
|
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
2021-08-24 15:43:30 +00:00
|
|
|
"host-head" => EventNewsCustomTitle.get_trans('host'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
|
|
|
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
|
|
|
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
|
|
|
"event-time-css" => (event_time.blank? ? "display: none;" : ""),
|
2021-08-24 15:43:30 +00:00
|
|
|
"speaker-css" => (event_news.speaker.blank? ? "display: none;" : ""),
|
|
|
|
"host-css" => (event_news.host.blank? ? "display: none;" : ""),
|
|
|
|
"speaker" => event_news.speaker,
|
|
|
|
"host" => event_news.host,
|
|
|
|
"notes" => event_news.notes,
|
|
|
|
"title" => event_news.title,
|
|
|
|
"subtitle_ann" => subtitle_ann,
|
|
|
|
"update_user" => update_user,
|
|
|
|
"updated_at" => event_time,
|
|
|
|
"body" =>event_news.text,
|
|
|
|
"image" => event_news.image.url,
|
|
|
|
"img_src" => img_src,
|
|
|
|
"img_description" => img_description,
|
|
|
|
"hide_class" => event_news.display_img? ? event_news.image_display_class : ' hide',
|
|
|
|
"alt_title" => desc,
|
|
|
|
"resume_btn_title" => resume_btn_title,
|
|
|
|
"pause_btn_title" => pause_btn_title,
|
|
|
|
"prev_btn_title" => prev_btn_title,
|
|
|
|
"next_btn_title" => next_btn_title,
|
|
|
|
"carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{event_news.carousel_image_width};margin: auto;"),
|
|
|
|
"carousel_count" => event_carousel_images.count,
|
2024-07-20 02:58:47 +00:00
|
|
|
"place_text" => (event_news.place.blank? ? "" : "#{EventNewsCustomTitle.get_trans("place")}: #{event_news.place}"),
|
|
|
|
"place-css" => (event_news.place.blank? ? "display: none;" : "")
|
2021-08-24 15:43:30 +00:00
|
|
|
},
|
2020-07-22 02:23:36 +00:00
|
|
|
"impressionist" => (event_news.is_preview ? nil : event_news),
|
|
|
|
"url_to_edit"=>url_to_edit
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_feed_event_news(uid)
|
|
|
|
event_news = OrbitHelper.get_from_feed(uid)
|
|
|
|
locale = OrbitHelper.get_site_locale.to_s
|
|
|
|
url_to_edit = "#"
|
2022-11-24 16:14:51 +00:00
|
|
|
return nil if event_news.blank?
|
2020-07-22 02:23:36 +00:00
|
|
|
tags = []
|
|
|
|
|
|
|
|
event_news["tags"].each{|tag|
|
|
|
|
t = Tag.where(:name => tag["name_translations"][locale]).first rescue nil
|
|
|
|
if t.nil?
|
|
|
|
I18n.locale = (locale == "en" ? :zh_tw : :en)
|
|
|
|
t = Tag.where(:name => tag["name_translations"][locale]).first rescue nil
|
|
|
|
I18n.locale = locale.to_sym
|
|
|
|
end
|
|
|
|
tags << {
|
|
|
|
"tag" => tag["name_translations"][locale],
|
|
|
|
"url" => (t.nil? ? "#" : OrbitHelper.page_for_tag(t))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-16 03:30:37 +00:00
|
|
|
files = event_news["event_news_files"].map{|file| { "file_url" => file["file_url"], "file_title" => file["file_title_translations"][locale] } } rescue []
|
2020-07-22 02:23:36 +00:00
|
|
|
|
|
|
|
files.each do |file|
|
|
|
|
if file["file_url"] =="" || file["file_url"] == nil
|
|
|
|
files.delete(file)
|
|
|
|
end
|
|
|
|
end
|
2024-09-16 03:30:37 +00:00
|
|
|
links = event_news["event_news_links"].map{|link| { "link_url" => link["link_url"], "link_title" => link["link_title_translations"][locale] } } rescue []
|
2020-07-22 02:23:36 +00:00
|
|
|
|
|
|
|
update_user = event_news["author"]
|
|
|
|
desc = event_news["image_description_translations"][locale] rescue ""
|
2021-06-09 06:34:00 +00:00
|
|
|
desc = (desc.nil? || desc == "" ? "EventNews image" : desc)
|
2021-08-09 02:45:06 +00:00
|
|
|
img_description = nil
|
|
|
|
img_description = event_news["image_description_translations"][I18n.locale] if event_news['display_img']
|
|
|
|
img_src = nil
|
|
|
|
img_src = (event_news['image']['original'] || "/assets/event_news-default.jpg") if event_news['display_img']
|
|
|
|
subtitle_ann = event_news['subtitle_ann']
|
2020-07-22 02:23:36 +00:00
|
|
|
request = OrbitHelper.request
|
|
|
|
if event_news["subtitle_translations"].present?
|
|
|
|
meta_desc = event_news["subtitle_translations"][locale] != "" ? event_news["subtitle_translations"][locale] : event_news["text_translations"][locale][0..200] rescue ""
|
|
|
|
else
|
|
|
|
meta_desc = ""
|
|
|
|
end
|
|
|
|
|
2024-09-16 03:30:37 +00:00
|
|
|
metas = [{"property" => "og:title", "content" => event_news["title_translations"][locale]},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url.split("?").first},{"property" => "og:description", "content" => meta_desc},{"property" => "og:type", "content" => "Article"}]
|
|
|
|
if event_news["image"]["original"].present?
|
|
|
|
image = event_news["image"]
|
|
|
|
metas << {"property" => "og:image", "content" => image["original"]}
|
|
|
|
if image["width"]
|
|
|
|
metas << {"property" => "og:image:width", "content" => image["width"].to_s}
|
|
|
|
end
|
|
|
|
if image["height"]
|
|
|
|
metas << {"property" => "og:image:height", "content" => image["height"].to_s}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
OrbitHelper.render_meta_tags(metas)
|
2020-07-22 02:23:36 +00:00
|
|
|
|
2021-08-09 02:45:06 +00:00
|
|
|
event_date = DateTime.parse(event_news["event_date"].to_s) rescue nil
|
|
|
|
event_end_date = DateTime.parse(event_news["event_end_date"].to_s) rescue nil
|
2024-09-16 03:30:37 +00:00
|
|
|
event_time = EventNewsSetting.event_time_formated_for_frontend(event_date, event_end_date)
|
2021-08-09 02:45:06 +00:00
|
|
|
event_carousel_images = Array(event_news["event_carousel_images"])
|
|
|
|
resume_btn_title = (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume"
|
|
|
|
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
|
|
|
|
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
|
|
|
|
next_btn_title = (I18n.locale.to_s =="zh_tw") ? "下一張" : "next"
|
2024-09-16 03:30:37 +00:00
|
|
|
speaker = event_news["speaker_translations"][locale]
|
|
|
|
host = event_news["host_translations"][locale]
|
2020-07-22 02:23:36 +00:00
|
|
|
{
|
|
|
|
"tags" => tags,
|
|
|
|
"event_news_files" => files,
|
|
|
|
"event_news_links" => links,
|
2021-08-09 02:45:06 +00:00
|
|
|
"event_carousel_images" => event_carousel_images,
|
2021-08-24 15:43:30 +00:00
|
|
|
"data" => {
|
|
|
|
"title" => event_news["title_translations"][locale],
|
|
|
|
"subtitle_ann" => subtitle_ann,
|
|
|
|
"update_user" => update_user,
|
|
|
|
"updated_at" => event_time,
|
|
|
|
"body" => event_news["text_translations"][locale],
|
2022-01-21 02:09:31 +00:00
|
|
|
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
2021-08-24 15:43:30 +00:00
|
|
|
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
2021-08-24 15:43:30 +00:00
|
|
|
"host-head" => EventNewsCustomTitle.get_trans('host'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
2021-08-24 15:43:30 +00:00
|
|
|
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
|
|
|
"event-time-css" => (event_time.blank? ? "display: none;" : ""),
|
2021-08-24 15:43:30 +00:00
|
|
|
"speaker-css" => (speaker.blank? ? "display: none;" : ""),
|
|
|
|
"host-css" => (host.blank? ? "display: none;" : ""),
|
|
|
|
"speaker" => speaker,
|
|
|
|
"host" => host,
|
|
|
|
"notes" => (event_news["notes_translations"][locale].to_s rescue ""),
|
|
|
|
"image" => event_news["image"]["original"],
|
|
|
|
"img_src" => img_src,
|
|
|
|
"img_description" => img_description,
|
|
|
|
"hide_class" => event_news["display_img"] ? '' : ' hide',
|
|
|
|
"alt_title" => desc,
|
|
|
|
"resume_btn_title" => resume_btn_title,
|
|
|
|
"pause_btn_title" => pause_btn_title,
|
|
|
|
"prev_btn_title" => prev_btn_title,
|
|
|
|
"next_btn_title" => next_btn_title,
|
|
|
|
"carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{EventNewsSetting.last.carousel_image_width};margin: auto;"),
|
|
|
|
"carousel_count" => event_carousel_images.count,
|
2024-07-20 02:58:47 +00:00
|
|
|
"place_text" => (event_news["place"].blank? ? "" : "#{I18n.t("event_news.place")}: #{event_news["place"]}"),
|
|
|
|
"place-css" => (event_news["place"].blank? ? "display: none;" : "")
|
2021-08-24 15:43:30 +00:00
|
|
|
},
|
2020-07-22 02:23:36 +00:00
|
|
|
"impressionist" => nil,
|
|
|
|
"url_to_edit" => url_to_edit
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
2022-10-24 08:26:33 +00:00
|
|
|
uid = params[:uid].to_s
|
2020-07-22 02:23:36 +00:00
|
|
|
if OrbitHelper.is_object_from_feed?(uid)
|
|
|
|
show_feed_event_news(uid)
|
|
|
|
else
|
|
|
|
show_local_event_news(uid, (params["preview"] == "true" ? true : false))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def show_widget
|
|
|
|
@type = "show_widget"
|
|
|
|
@show_page = params[:show_page]
|
|
|
|
if params[:tags].nil?
|
|
|
|
@tags = ['all']
|
|
|
|
else
|
|
|
|
@tags = params[:tags]
|
|
|
|
end
|
|
|
|
if params[:categories].nil?
|
|
|
|
@categories = ['all']
|
|
|
|
else
|
|
|
|
@categories = params[:categories]
|
|
|
|
end
|
2020-08-03 09:11:57 +00:00
|
|
|
OrbitHelper.set_site_locale(I18n.locale)
|
2022-03-08 08:55:33 +00:00
|
|
|
OrbitHelper.set_current_widget_module("event_news_mod")
|
2020-07-22 02:23:36 +00:00
|
|
|
OrbitHelper.set_params(params,current_user)
|
|
|
|
EventNews.remove_expired_status
|
|
|
|
OrbitHelper.set_page_number(params[:page_no].to_i)
|
|
|
|
OrbitHelper.set_page_data_count((params[:data_count].blank? ? 10 : params[:data_count].to_i))
|
|
|
|
sorted,total_pages = get_sorted_event_news
|
|
|
|
event_news = sorted.collect do |a|
|
|
|
|
if a["source-site"].blank?
|
|
|
|
statuses = a.statuses_with_classname.collect do |status|
|
|
|
|
{
|
|
|
|
"status" => status["name"],
|
|
|
|
"status-class" => "status-#{status['classname']}"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
locale = I18n.locale.to_s
|
2021-09-16 09:16:20 +00:00
|
|
|
files = a.event_news_files.to_fronted(locale)
|
2020-07-22 02:23:36 +00:00
|
|
|
links = a.event_news_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
|
|
|
author = User.find(a.create_user_id).member_profile.name rescue ""
|
|
|
|
desc = a.image_description
|
2021-06-09 06:34:00 +00:00
|
|
|
desc = (desc.blank? ? "EventNews image" : desc)
|
2020-07-22 02:23:36 +00:00
|
|
|
link_to_show = (a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)) rescue ""
|
|
|
|
target = a.is_external_link ? "_blank" : "_self"
|
2024-10-13 13:46:48 +00:00
|
|
|
title = a.title_plain_text
|
|
|
|
title = 'no content' if title.blank?
|
2022-01-21 02:09:31 +00:00
|
|
|
event_time = a.event_time_formated_for_frontend
|
2021-10-21 04:54:14 +00:00
|
|
|
event_time_formated = a.event_time_formated
|
2020-07-22 02:23:36 +00:00
|
|
|
{
|
|
|
|
"department" => author,
|
|
|
|
"event_news_links" => links,
|
|
|
|
"event_news_files" => files,
|
|
|
|
"title" => a.title,
|
2021-08-24 15:16:42 +00:00
|
|
|
"speaker-css" => (a.speaker.blank? ? "display: none;" : ""),
|
|
|
|
"host-css" => (a.host.blank? ? "display: none;" : ""),
|
2021-10-21 04:14:15 +00:00
|
|
|
"place-css" => (a.place.blank? ? "display: none;" : ""),
|
2021-10-21 04:54:14 +00:00
|
|
|
"event-time-formated" => event_time_formated,
|
|
|
|
"event-time-css" => (event_time_formated.blank? ? "display: none;" : ""),
|
2020-07-22 02:23:36 +00:00
|
|
|
"speaker" => a.speaker,
|
2021-07-14 04:56:02 +00:00
|
|
|
"place" => a.place,
|
2020-07-22 02:23:36 +00:00
|
|
|
"host" => a.host,
|
|
|
|
"notes" => a.notes,
|
|
|
|
"source-site" => "",
|
|
|
|
"source-site-title" => "",
|
|
|
|
"source-site-link" => "",
|
|
|
|
"subtitle" => a.subtitle,
|
|
|
|
"statuses" => statuses,
|
2021-06-09 06:34:00 +00:00
|
|
|
"category" => (a.category.title rescue ""),
|
2021-08-09 02:45:06 +00:00
|
|
|
"postdate" => event_time,
|
2024-01-28 07:04:23 +00:00
|
|
|
"event_start_date" => a.event_date_frontend,
|
|
|
|
"event_end_date" => a.event_end_date_frontend,
|
2020-07-22 02:23:36 +00:00
|
|
|
"author" => author,
|
|
|
|
"is_top" => (a.is_top? ? 1 : 0),
|
|
|
|
"link_to_show" => link_to_show+"\" title=\"#{title}\"",
|
|
|
|
"target" => target,
|
2021-06-09 06:34:00 +00:00
|
|
|
"img_src" => a.image.thumb.url || "/assets/event_news-default.jpg",
|
2020-07-22 02:23:36 +00:00
|
|
|
"img_description" => desc,
|
2022-01-21 02:09:31 +00:00
|
|
|
"more" => t("event_news.more"),
|
2020-07-22 02:23:36 +00:00
|
|
|
"view_count" => a.view_count
|
|
|
|
}
|
|
|
|
else
|
|
|
|
a
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#If no data , hide title&table
|
|
|
|
if sorted.count == 0
|
|
|
|
display = "hide"
|
|
|
|
end
|
|
|
|
# event_news = event_news.concat(feeds_event_news)
|
|
|
|
# total_pages = event_news.total_pages
|
|
|
|
|
|
|
|
|
|
|
|
@data = {
|
|
|
|
"event_news" => event_news,
|
|
|
|
"extras" => {
|
|
|
|
"widget-title" =>t('event_news.event_news'),
|
2024-01-28 07:04:23 +00:00
|
|
|
"category-head" => EventNewsCustomTitle.get_trans('category'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"place-head" => EventNewsCustomTitle.get_trans('place'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"host-head" => EventNewsCustomTitle.get_trans('host'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"notes-head" => EventNewsCustomTitle.get_trans('notes'),
|
2021-08-23 11:44:45 +00:00
|
|
|
"event_date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2022-01-21 02:09:31 +00:00
|
|
|
"date-head" => EventNewsCustomTitle.get_trans('event_date'),
|
2024-01-28 07:04:23 +00:00
|
|
|
"event_start_date-head" => EventNewsCustomTitle.get_trans('start_date'),
|
|
|
|
"event_end_date-head" => EventNewsCustomTitle.get_trans('end_date'),
|
2020-07-22 02:23:36 +00:00
|
|
|
"status-head" => t('event_news.table.status'),
|
|
|
|
"author-head" => t('event_news.table.author'),
|
|
|
|
"subtitle-head" => t('event_news.table.sub_title'),
|
|
|
|
"link-head" => t('event_news.table.link'),
|
|
|
|
"file-head" => t('event_news.table.file'),
|
|
|
|
"view-count-head" => t('event_news.table.view_count'),
|
|
|
|
"display" => display,
|
|
|
|
"department-head" => t('event_news.table.department')
|
|
|
|
},
|
|
|
|
"total_pages" => total_pages
|
|
|
|
}
|
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
2021-09-05 10:56:57 +00:00
|
|
|
def agenda
|
|
|
|
I18n.with_locale(params[:locale]||I18n.locale) do
|
|
|
|
if !params[:subpart_id].nil?
|
|
|
|
subpartid = params[:subpart_id]
|
|
|
|
subpart = SubPart.find(subpartid)
|
|
|
|
all_cats = subpart.categories
|
|
|
|
all_cats = ['all'] if all_cats.length==0
|
|
|
|
all_tags = subpart.tags
|
|
|
|
all_tags = ['all'] if all_tags.length==0
|
|
|
|
page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil
|
2022-03-08 08:55:33 +00:00
|
|
|
page = Page.where(:module => "event_news_mod").first rescue nil if page.nil?
|
2021-09-06 05:44:20 +00:00
|
|
|
read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue ""
|
|
|
|
read_more_url = read_more_url_root + "?" + {"category"=>all_cats,"tags"=> all_tags}.to_param if read_more_url != ""
|
|
|
|
else
|
2022-03-08 08:55:33 +00:00
|
|
|
page = Page.where(:module => "event_news_mod").first
|
2021-09-06 05:44:20 +00:00
|
|
|
read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue ""
|
2021-09-05 10:56:57 +00:00
|
|
|
end
|
|
|
|
if params[:unix_start].present? && params[:unix_end].present?
|
|
|
|
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
|
|
|
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
2021-09-06 05:44:20 +00:00
|
|
|
events = EventNews.agenda_events(agenda_start,agenda_end,read_more_url_root)
|
2021-09-05 10:56:57 +00:00
|
|
|
end
|
|
|
|
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_calendar_title(now_date=nil)
|
|
|
|
now_date = Time.now.utc if now_date.nil?
|
|
|
|
month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("event_news.month_name.#{now_date.month}")
|
|
|
|
I18n.t("event_news.calendar_title",year: now_date.year,month: month_name)
|
|
|
|
end
|
2020-07-22 02:23:36 +00:00
|
|
|
end
|