'
- case part.kind
- when 'text'
- ret << part.i18n_variable[I18n.locale] rescue ''
- when 'module_widget'
- if part[:category]
- ret << ""
- else
- ret << ""
- end
- when 'public_r_tag'
- ret << ""
- else
- ''
+ case part.kind
+ when 'text'
+ ret << part.i18n_variable[I18n.locale] rescue ''
+ when 'module_widget'
+ if part[:category]
+ ret << ""
+ else
+ ret << ""
end
- ret << '
'
+ when 'public_r_tag'
+ ret << ""
+ public_r_tags << part.public_r_tag
+ else
+ ''
end
end
- c.define_tag 'link' do |tag|
- item = Item.first(:conditions => { :full_name => tag.attr['name'] })
- ret = ''
- ret << ""
- ret << item.i18n_variable[I18n.locale]
- ret << ""
- end
- c.define_tag 'menu' do |tag|
- home = get_homepage
- menu = page.design.layout.menu
- menu_level(home, 0, menu, true)
+ scope = "<#{content.name}"
+ content.attributes.each_pair do |key, value|
+ scope << " #{key}='#{value}'"
end
+ scope << ">#{ret}#{content.name}>"
+ fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
+ content.swap(fragment)
end
+ public_r_tags.uniq
end
-
+
+
def self.included(base)
- base.send :helper_method, :parse_page_edit if base.respond_to? :helper_method
+ base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method
end
end
diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb
index 8d43c070..96cbb4b9 100644
--- a/lib/parsers/parser_common.rb
+++ b/lib/parsers/parser_common.rb
@@ -44,4 +44,56 @@ module ParserCommon
res << ""
end
+ # ad_banners
+ def parse_ad_banners(body = nil, page = nil, id = nil)
+ body.css('ad_banner').each do |banner|
+ res = ''
+ ad_banner = AdBanner.find(banner["id"]) rescue nil
+ if ad_banner && ad_banner.display?
+ res << ""
+ res << "
"
+ ad_banner.ad_images.each do |ad_image|
+ res << ""
+ end
+ res << "
"
+ end
+ fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
+ banner.swap(fragment)
+ end
+ end
+
+ # page_images
+ def parse_images(body, page)
+ body.css('.page_image').each do |page_image|
+ # image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
+ # image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
+ image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image
+ if image
+ res = "'
+ end
+ fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
+ page_image.swap(fragment)
+ end
+ end
+
+ # page_menu
+ def parse_menu(body, page, edit=nil)
+ page_menu = body.css('.page_menu').first
+ home = get_homepage
+ menu = page.design.layout.menu
+ fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu, true))
+ page_menu.swap(fragment)
+ end
+
end
diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb
index 99353cc1..c3ca1787 100644
--- a/lib/parsers/parser_front_end.rb
+++ b/lib/parsers/parser_front_end.rb
@@ -1,180 +1,77 @@
module ParserFrontEnd
- require 'radius'
include ParserCommon
+ # c.define_tag 'language_bar' do
+ # @site.in_use_locales.map{ |locale|
+ # lang = I18nVariable.first(:conditions => {:key => locale})[locale]
+ # if I18n.locale.to_s.eql?(locale)
+ # lang
+ # else
+ # "#{lang}"
+ # end
+ # }.join(' | ')
+ # end
+ # c.define_tag 'link' do |tag|
+ # item = Item.first(:conditions => { :full_name => tag.attr['name'] })
+ # ret = ''
+ # ret << ""
+ # ret << item.i18n_variable[I18n.locale]
+ # ret << ''
+ # end
+ # end
- def parser_context(page, attributes = {}, id = nil)
- Radius::Context.new do |c|
- c.define_tag 'snippet' do |tag|
- snippet = Snippet.first(:conditions => {:name => tag.attr['name']})
- if snippet
- snippet.content
- else
- t('nothing')
- end
- end
- c.define_tag 'language_bar' do
- @site.in_use_locales.map{ |locale|
- lang = I18nVariable.first(:conditions => {:key => locale})[locale]
- if I18n.locale.to_s.eql?(locale)
- lang
- else
- "#{lang}"
- end
- }.join(' | ')
- end
- c.define_tag 'locale' do |tag|
- case attributes[:locale]
- when 'create'
- var = I18nVariable.new(:key => (tag.attr['name'] rescue nil), :document_class => 'Text')
- @site.valid_locales.each do |locale|
- var[locale] = tag.attr[locale] rescue nil
- end
- var.save!
- res = ''
- res << "'
- when 'show'
- var = I18nVariable.find(tag.attr['id'])
- res = ''
- res << "'
- when 'destroy'
- var = I18nVariable.find(tag.attr['id'])
- var.destroy
- end
- end
- c.define_tag 'css' do |tag|
- assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip))
- res = ''
- assets.each do |asset|
- res << " " if asset.data.file.content_type.eql?('text/css')
- end
- res
- end
- c.define_tag 'stylesheets' do |tag|
- res = ''
- res << ""
- res << ""
- res << ""
- res << "" if page.design.reset_css
- res << " " if page.design.default_css
- theme = page.design.themes.detect{ |d| d.id == page.theme_id }
- res << "" if theme
- res
- end
- c.define_tag 'javascripts' do |tag|
- res = ''
- res << ""
- res << ""
- res << ""
- res << ""
- res << ""
- res << ""
- res << ""
- res << ""
- res << ""
- page.design.javascripts.each do |js|
- # res << ""
- end
- res
- end
- c.define_tag 'ad_banner' do |tag|
- res = ''
- ad_banner = AdBanner.find(tag.attr["id"]) rescue nil
- if ad_banner && ad_banner.display?
- res << ""
- res << "
"
- ad_banner.ad_images.each do |ad_image|
- res << ""
- end
- res << "
"
- end
- res
- end
- c.define_tag 'image' do |tag|
- # image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
- # image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
- image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
- if image
- res = "'
- end
- end
- c.define_tag 'layout_part' do |tag|
- part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
- part.content
- end
- c.define_tag 'content' do |tag|
- ret = ''
- if (tag.attributes["main"] == "true" && !page.module_app.nil?)
- ret << ""
- else
- part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
- case part.kind
- when 'text'
- ret << part.i18n_variable[I18n.locale] rescue ''
- when 'module_widget'
- if part[:category]
- ret << ""
- else
- ret << ""
- end
- when 'public_r_tag'
- ret << ""
- else
- ''
- end
- end
- ret
- end
- c.define_tag 'link' do |tag|
- item = Item.first(:conditions => { :full_name => tag.attr['name'] })
- ret = ''
- ret << ""
- ret << item.i18n_variable[I18n.locale]
- ret << ''
- end
- c.define_tag 'menu' do |tag|
- home = get_homepage
- menu = page.design.layout.menu
- menu_level(home, 0, menu)
- end
+ require 'nokogiri'
+
+ def parse_page_noko(page, id = nil)
+ body = Nokogiri::HTML(page.design.layout.body)
+ parse_menu(body, page)
+ public_r_tags = parse_contents(body, page, id)
+ parse_images(body, page)
+
+ public_r_tags.each do |tag|
+ send("parse_#{tag}s", body, page,id)
end
+
+ body.to_html
end
-
- def parse_page(page, id = nil)
- if page._type == 'Page'
- layout_content = page.design.layout.content.force_encoding('UTF-8') rescue ''
- context = parser_context(page, {}, id)
- parser = Radius::Parser.new(context, :tag_prefix => 'r')
- parser.parse(parser.parse(layout_content))
+
+ # page_contents
+ def parse_contents(body, page, id)
+ public_r_tags = []
+ body.css('.page_content').each do |content|
+ ret = ''
+ if (content["main"] == "true" && !page.module_app.nil?)
+ ret << ""
+ else
+ part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
+ case part.kind
+ when 'text'
+ ret << part.i18n_variable[I18n.locale] rescue ''
+ when 'module_widget'
+ if part[:category]
+ ret << ""
+ else
+ ret << ""
+ end
+ when 'public_r_tag'
+ ret << ""
+ public_r_tags << part.public_r_tag
+ else
+ ''
+ end
+ end
+ scope = "<#{content.name}"
+ content.attributes.each_pair do |key, value|
+ scope << " #{key}='#{value}'"
+ end
+ scope << ">#{ret}#{content.name}>"
+ fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
+ content.swap(fragment)
end
- end
-
- def self.included(base)
- base.send :helper_method, :parse_page if base.respond_to? :helper_method
+ public_r_tags.uniq
end
end
diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb
index 4a0232c6..01d681ef 100644
--- a/lib/parsers/parser_layout.rb
+++ b/lib/parsers/parser_layout.rb
@@ -1,39 +1,27 @@
module ParserLayout
- require 'radius'
- include ParserCommon
+ require 'nokogiri'
- def parse_layout_contents(layout)
- content = layout.content.force_encoding('UTF-8')
- context = parser_layout_contents(layout)
- parser = Radius::Parser.new(context, :tag_prefix => 'r')
- parser.parse(content)
- end
+ def parse_body(layout)
+ body = Nokogiri::HTML(layout.body)
- def parser_layout_contents(layout)
- Radius::Context.new do |c|
- c.define_tag 'javascripts' do |tag|
- end
- c.define_tag 'stylesheets' do |tag|
- end
- c.define_tag 'ad_banner' do |tag|
- end
- c.define_tag 'menu' do |tag|
- layout.build_menu(:levels => 0, :values => {}) unless layout.menu
- layout.menu.levels = i = tag.attr['level'].to_i
- layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1
- layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']})
- tag.expand
- end
- c.define_tag 'content' do |tag|
- layout.layout_parts.new(:name => tag.attr['name'])
- end
- c.define_tag 'image' do |tag|
- image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) }
- image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image
- end
+ body.css('.page_content').each do |content|
+ layout.layout_parts.build(:name => content['name'])
end
+
+ body.css('.page_image').each do |image|
+ image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(image.to_html)) }
+ image.update_attributes(:name => image['name'], :html_id => image['id'], :html_class => image['class']) if image
+ end
+
+ body.css('.page_menu').each do |menu|
+ layout.build_menu(:levels => 0, :values => {}) unless layout.menu
+ layout.menu.levels = i = menu['level'].to_i
+ layout.menu.values.merge!({'home' => menu['home']}) if i == 1
+ layout.menu.values.merge!({"id_#{i}" => menu['id'], "class_#{i}" => menu['class'], "li_class_#{i}" => menu['li_class'], "li_incremental_#{i}" => menu['li_incremental']})
+ end
+
end
-
+
def parse_html_image(html)
html.scan(/(?<=\)/){
$1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){
@@ -41,4 +29,6 @@ module ParserLayout
}
}
end
+
+
end
diff --git a/lib/tasks/noko.rake b/lib/tasks/noko.rake
new file mode 100644
index 00000000..b411fa30
--- /dev/null
+++ b/lib/tasks/noko.rake
@@ -0,0 +1,13 @@
+# encoding: utf-8
+
+namespace :nokogiri do
+ task :layout => :environment do
+ l = Design.first(:conditions => {:title => 'CCU'}).layout
+ l.layout_parts.destroy rescue nil
+ l.menu.destroy rescue nil
+ l.design.save
+ l = Design.first(:conditions => {:title => 'CCU'}).layout
+ l.file = File.open("#{Rails.root}/lib/noko/layout.html")
+ l.design.save
+ end
+end
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
index f55ad6e3..0e3894b9 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb
@@ -1,6 +1,4 @@
-class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationController
-
- layout 'new_admin'
+class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
def index
@bulletin_categorys = BulletinCategory.all
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
index 22df7fd6..a5c3cdcf 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb
@@ -1,5 +1,4 @@
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
- layout 'new_admin'
before_filter :authenticate_user!
before_filter :is_admin?
@@ -159,12 +158,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def file_quick_add
- # debugger
+ # debugger
@bulletin_file = BulletinFile.new
- @file_url = panel_announcement_back_end_bulletins_path
+ @file_url = panel_announcement_back_end_bulletins_path
- @bulletin_file.bulletin_id = params[:bulletin_id]
+ @bulletin_file.bulletin_id = params[:bulletin_id]
respond_to do |format|
format.js
@@ -173,75 +172,73 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def file_quick_edit
- # debugger
+ # debugger
@bulletin_file = BulletinFile.find(params[:bulletin_id])
- @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
+ @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format|
format.js
end
-
end
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
- if params[:bulletin_link]
-
- @bulletin_link = BulletinLink.find(params[:id])
-
- @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
+ if params[:bulletin_link]
+
+ @bulletin_link = BulletinLink.find(params[:id])
+
+ @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
- respond_to do |format|
- if @bulletin_link.update_attributes(params[:bulletin_link])
- # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
- format.js { render 'update_bulletin_link' }
- end
- end
-
- elsif params[:bulletin_file]
-
- @bulletin_file = BulletinFile.find(params[:id])
-
- @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
+ respond_to do |format|
+ if @bulletin_link.update_attributes(params[:bulletin_link])
+ # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
+ format.js { render 'update_bulletin_link' }
+ end
+ end
+
+ elsif params[:bulletin_file]
+
+ @bulletin_file = BulletinFile.find(params[:id])
+
+ @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
- respond_to do |format|
- if @bulletin_file.update_attributes(params[:bulletin_file])
- # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
- format.js { render 'update_bulletin_file' }
- end
- end
-
- else
-
- @bulletin = Bulletin.find(params[:id])
-
- @bulletin.update_user_id = current_user.id
-
- # @bulletin.image.clear if params[:bulletin][:image_del] == '1'
- # if params[:bulletin][:image_del] == '1'
- # @bulletin.remove_image!
- # @bulletin.image_del = nil
- # params[:bulletin][:image_del] = nil
- # end
+ respond_to do |format|
+ if @bulletin_file.update_attributes(params[:bulletin_file])
+ # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
+ format.js { render 'update_bulletin_file' }
+ end
+ end
+
+ else
+
+ @bulletin = Bulletin.find(params[:id])
+
+ @bulletin.update_user_id = current_user.id
+
+ # @bulletin.image.clear if params[:bulletin][:image_del] == '1'
+ # if params[:bulletin][:image_del] == '1'
+ # @bulletin.remove_image!
+ # @bulletin.image_del = nil
+ # params[:bulletin][:image_del] = nil
+ # end
- respond_to do |format|
- if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
- # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
- format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
- format.js { render 'toggle_enable' }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
- end
- end
+ respond_to do |format|
+ if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
+ # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
+ format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
+ format.js { render 'toggle_enable' }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
+ end
+ end
end
-
end
# DELETE /bulletins/1
@@ -268,6 +265,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# end
+
+ def load_quick_edit
+ @bulletin = Bulletin.find(params[:id])
+ @type = params[:type]
+ @bulletin_categories = BulletinCategory.all
+ get_tags
+ end
+
protected
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb
index c47e91fb..606225e9 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb
@@ -2,7 +2,6 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll
before_filter :authenticate_user!
include AdminHelper
# layout 'admin'
- layout 'new_admin'
def setting
@bulletin_categorys = BulletinCategory.all
@@ -18,7 +17,7 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll
else
first_category = @bulletin_categorys.first
end
- preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check')
+ preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check')
@users_array = preload_object_auth.first.privilege_users rescue []
respond_to do |format|
format.html
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
index ff3cbdc9..3ba0e666 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
@@ -2,7 +2,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def initialize
super
- @app_title = NewBlog::MOUDLEAPP_TITLE
+ @app_title = 'announcement'
end
# GET /bulletins
@@ -12,9 +12,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
date_now = Time.now
if params[:category_id]
- @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
+ @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
else
- @bulletins = Bulletin.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
+ @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
end
get_categorys
@@ -23,7 +23,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
end
def show
- @bulletin = Bulletin.find(params[:id])
+ @bulletin = Bulletin.can_display.where.where(_id: params[:id])
get_categorys
end
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb
index 60aad3d9..96277c5e 100644
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb
@@ -2,7 +2,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def initialize
super
- @app_title = NewBlog::MOUDLEAPP_TITLE
+ @app_title = 'announcement'
end
# GET /bulletins
@@ -14,9 +14,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
# @bulletin_categorys = BulletinCategory.first;
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
if params[:category_id]
- @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
+ @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
else
- @bulletins = Bulletin.widget_datas.limit(9)
+ @bulletins = Bulletin.can_display.widget_datas.limit(9)
end
get_categorys
@@ -26,14 +26,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def bulletins_and_web_links
@tags = AnnouncementTag.all
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
- @bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
+ @bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end
def reload_bulletins
@selected_tag = AnnouncementTag.find(params[:tag_id])
- @bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
+ @bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
end
def reload_web_links
diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb
index d1b7f3c5..e24f7f21 100644
--- a/vendor/built_in_modules/announcement/app/models/bulletin.rb
+++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb
@@ -19,12 +19,14 @@ class Bulletin
field :is_top, :type => Boolean, :default => false
field :is_hot, :type => Boolean, :default => false
field :is_hidden, :type => Boolean, :default => false
- field :is_checked, :type => Boolean, :default => false
+ field :is_checked, :type => Boolean, :default => nil
field :not_checked_reason
field :public, :type => Boolean, :default => true
+ scope :can_display,where(is_checked: true)
+
mount_uploader :image, ImageUploader
belongs_to :bulletin_category
@@ -47,28 +49,17 @@ class Bulletin
def self.search( search = nil, category_id = nil )
-
- if category_id.to_s.size > 0 and search.to_s.size > 0
-
+ if category_id.to_s.size > 0 and search.to_s.size > 0
key = /#{search}/
-
- find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
-
- elsif category_id.to_s.size > 0 and search.to_s.size < 1
-
- find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
-
- elsif search.to_s.size > 0 and category_id.to_s.size < 1
-
+ find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate )
+ elsif category_id.to_s.size > 0 and search.to_s.size < 1
+ find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate )
+ elsif search.to_s.size > 0 and category_id.to_s.size < 1
key = /#{search}/
-
- find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
- else
-
- find(:all).desc( :is_top, :postdate)
-
- end
-
+ find(:all, :conditions => {title: key}).desc( :is_top, :postdate )
+ else
+ find(:all).desc( :is_top, :postdate)
+ end
end
@@ -87,7 +78,11 @@ class Bulletin
end
end
-
+
+ def is_expired?
+ Date.today > self.deadline ? true : false rescue false
+ #some dates might sat as nil so rescue false
+ end
def is_top?
self.is_top
@@ -101,6 +96,15 @@ class Bulletin
self.is_hidden
end
+ def is_checked?
+ self.is_checked
+ end
+
+ def is_check_rejected?
+ self.is_checked == false
+ end
+
+
def save_bulletin_links
self.bulletin_links.each do |t|
if t.should_destroy
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
index e12af233..62b28c0c 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb
@@ -10,40 +10,45 @@
<% if bulletin.is_hidden? %>
<%= t(:hidden) %>
<% end %>
+
+
-
-<%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %>
-
-<% content_for :page_specific_javascript do %>
-
-<% end %>
\ No newline at end of file
+