";
- dom.html(dhtml);
- if(typeof callbackFn=="function")
- callbackFn.call(this,dhtml);
- },
-makeDraggable : function(handler,dom){
- handler.css("position","absolute");
- dom.css("position","absolute");
- var puranix=0;
- var nayeex=0;
- var puraniy=0;
- var nayeey=0;
- var offset="";
- var zIndex=dom.css("z-index");
- handler.mousedown(function(e){
- puranix=e.clientX;
- puraniy=e.clientY;
- offset=dom.offset();
- $rss(this).mousemove(function(e){
- nayeex=e.clientX-puranix;
- nayeex+=offset.left;
- nayeey=e.clientY-puraniy;
- nayeey+=offset.top;
- dom.css({"left":nayeex+"px","top":nayeey+"px","z-index":"9999"});
- })
- }).mouseup(function(){
- $rss(this).unbind("mousemove");
- dom.css("z-index",zIndex);
- })
- },
-
-//automatically scrolls to the bottom of the div
-scrollToBottom : function(dom){
- var domId = dom.attr("id");
-// var domScrollHeight = document.getElementById(domId).scrollHeight;
- var obj = document.getElementById(domId);
-
- if((obj.scrollTop+100) >= (obj.scrollHeight - obj.offsetHeight))
- dom.scrollTop(obj.scrollHeight);
- },
-
-/*ajax loading of images... needs following settings
-dom:in which images ve to be loaded
-url:the server url for making ajax calls
-limit:how many images to load
-divClass:the class of div surrounding each image
-nameClass:class for span showing name
-fn:function to be called in on the server
-imageSrc:the image source of all the images.
-bindTo:to bind images to a onclick function or else will be binded to normal a tag.
-urlKey:to specify the key of the value.. if bindTo is used, this will be neglected..
-returns json;
-*/
-loadImages : function(settings,callbackFn){
-
- var dom = settings.dom;
- var domid= dom.attr("id");
- var temp_array=Array();
- var starting = $rss("#"+domid+" img:last").attr("id");
- if(typeof starting != 'undefined'){
- starting = starting.substr(4,starting.length-1);
- }else{starting = 0};
- var temp_var="";
- var json = "";
- var dhtml="";
- var extraparam="";
- if(typeof settings.extraParam != "undefined"){
- extraparam = settings.extraParam;
- }
- $rss.getJSON(settings.url,{fn:settings.fn,id:settings.whereId,limit:settings.limit,start:starting,extra:extraparam},function(images){
- json = eval(images);
- $rss.each(images,function(i,pic){
- var temp_array=Array();
- var a_var=Array();
- var name_var="";
- var title="";
- $rss.each(pic,function(i,value){
- temp_array.push(value);
- })
- if(temp_array.length>=4){
- name_var=""+temp_array[3]+""
- }
- if(temp_array[2]==null)
- title = "";
- else
- title = temp_array[2];
- if(typeof settings.bindTo!="undefined"){
- a_var[1]="onclick='"+settings.bindTo+"("+temp_array[0]+");return false;'";
- a_var[0]="";
- }else{a_var[0]='?'+settings.urlKey+'='+temp_array[0];a_var[1]="";}
- dhtml="
"+name_var;
- dom.delay(100).append(dhtml);
- $rss("#pic_"+pic.id).delay(100).fadeIn(200);
-
- })
- if(typeof callbackFn=="function")
- callbackFn.call(this,json);
- })
-
-
- },
-
-//function to get url variables...
-getUrlVars : function(){
- var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for(var i = 0; i < hashes.length; i++){
- hash = hashes[i].split('=');
- vars.push(hash[0]);
- vars[hash[0]] = hash[1];
- }
- return vars;
-},
-/*function to open a modalwindow on a page.. self reliant no images, no css needed.
-settings
-
-width:in percentage or pixcel
-height:in percentage or pixcel
-closeBtn:true or false
-envClose:closing through background click, true or flase
-loadDiv:load html from a div
-loadPage:load a page
-loadHtml: load html
-
-*/
-modalWindow : function(settings,callbackFn){
-
- var envClose = settings.envClose;
- var dhtml="";
- if(typeof envClose == "undefined")
- envClose = true;
- var closeBtn = settings.closeBtn;
- if(typeof closeBtn == "undefined")
- closeBtn = true;
-
- var rgmaskHeight = $rss(window).height();
- var rgmaskWidth = $rss(window).width();
- var tempheight = settings.height;
- var tempwidth = settings.width;
-
- if(typeof tempheight!="undefined"){
- if(tempheight.charAt(tempheight.length-1)=='%')
- tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100;
- }else{tempheight="auto";}
-
- if(typeof tempwidth!="undefined"){
- if(tempwidth.charAt(tempwidth.length-1)=='%')
- tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
- }else{tempwidth="auto";}
-
- $rss("body").append('');
- $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199});
- $rss("body").append('');
- $rss("#rgWindow").css({"position": "fixed", "z-index": "999", "background": "#fff", "border": "solid 3px #ccc", "padding": "20px", "overflow": "hidden", "border-radius": "12px", "-webkit-border-radius": "12px", "-moz-border-radius": "12px", "-ms-border-radius": "12px", "box-shadow": "0 0 20px rgba(0,0,0,0.9)","-webkit-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-moz-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-ms-box-shadow": "0 0 20px rgba(0,0,0,0.9)"});
- var rgWTop = (rgmaskHeight-20)/2;
- var rgWLeft = (rgmaskWidth-20)/2;
- $rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"});
- if(typeof settings.loadDiv!="undefined"){
- dhtml = $rss("#"+settings.loadDiv).html();
- $rss("#rgWindow").html(dhtml).hide();
- prepareWindow();
- }
- if(typeof settings.loadHtml!="undefined"){
- dhtml = settings.loadHtml;
- $rss("#rgWindow").html(dhtml).hide();
- prepareWindow();
- }
- if(typeof settings.loadPage!="undefined"){
- $rss("#rgWindow").load(settings.loadPage,function(){$rss(this).hide();dhtml=$rss(this).html();prepareWindow();});
- }
- function prepareWindow(){
- if(tempheight!="auto")
- rgWTop = (rgmaskHeight-tempheight)/2;
- else{
- tempheight=$rss("#rgWindow").height();
- rgWTop=(rgmaskHeight-tempheight)/2;
- }
- if(tempwidth!="auto")
- rgWLeft = (rgmaskWidth-tempwidth)/2;
- else{
- tempwidth=$rss("#rgWindow").width();
- rgWLeft=(rgmaskWidth-tempwidth)/2;
- }
- $rss("#rgWindow").empty().show();
- var closebtn = "";
- if(closeBtn)
- closebtn='X';
- $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"
"+dhtml+"
");
- $rss("#close_modal").mouseover(function(){$rss(this).css("color","#999");}).mouseout(function(){$rss(this).css("color","#666");})
- $rss("#close_modal").click(function(){
- $rss("#rgWindow").empty();
- var x = (rgmaskHeight-20)/2;
- var y = (rgmaskWidth-20)/2;
- $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});
- return false;
- })
- if(envClose)
- $rss("#rgsheath").click(function(){
- $rss("#rgWindow").empty();
- var x = (rgmaskHeight-20)/2;
- var y = (rgmaskWidth-20)/2;
- $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});})
-
- if(typeof callbackFn=="function")
- callbackFn.call(this,dhtml);
- });
- }
-},
-modalWindowClose : function(callbackFn){
- if($rss("#rgWindow").length>0){
- $rss("#rgWindow").empty();
- var rgmaskHeight = $rss(window).height();
- var rgmaskWidth = $rss(window).width();
- var x = (rgmaskHeight-20)/2;
- var y = (rgmaskWidth-20)/2
- $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();})
- }
- if(typeof callbackFn=="function")
- callbackFn.call(this,"harry");
-},
-bindDomToHead : function(dom){
- var gc = dom.css("background");
- var t = dom.offset();
- var gw = dom.width();
- $rss(window).scroll(function(){
- var wt = $rss(window).scrollTop();
- if ( wt > t.top ) {
- var cssObj = {
- 'position':'fixed',
- 'top':0,
- 'width':gw,
- 'background':gc,
- 'box-shadow':'0 1px 0 rgba(0,0,0,0.2)',
- 'z-index':99
- }
- dom.css(cssObj);
- } else {
- dom.attr('style',"");
- }
- });
-},
-progressBar : function(dom,settings){
- var domid = dom.prop("id");
- if($rss("#rss_progressbar_div_"+domid).length==0){
- if(typeof settings.top == "undefined")
- settings.value = 1;
- if(typeof settings.top == "undefined")
- settings.top = (dom.height()-12)/2;
- dom.append("
\ No newline at end of file
diff --git a/app/views/admin/designs/index.html.erb b/app/views/admin/designs/index.html.erb
index fa5748ef..6195afd5 100644
--- a/app/views/admin/designs/index.html.erb
+++ b/app/views/admin/designs/index.html.erb
@@ -18,7 +18,7 @@
\ No newline at end of file
diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb
index fcd76205..15948578 100644
--- a/app/views/layouts/_side_bar.html.erb
+++ b/app/views/layouts/_side_bar.html.erb
@@ -1,7 +1,33 @@
-
"
ad_banner.ad_images.each do |ad_image|
@@ -98,7 +99,9 @@ module ParserBackEnd
c.define_tag 'content' do |tag|
ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
- ret << ""
+ ret << ""
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
ret << "
"
@@ -109,7 +112,11 @@ module ParserBackEnd
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
- ret << ""
+ if part[:category]
+ ret << ""
+ else
+ ret << ""
+ end
when 'public_r_tag'
ret << ""
else
diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb
index 70006eb3..8d43c070 100644
--- a/lib/parsers/parser_common.rb
+++ b/lib/parsers/parser_common.rb
@@ -6,7 +6,7 @@ module ParserCommon
if current != 0
res << "
" + menu_level(child, current + 1, menu, edit) + "
"
end
@@ -39,7 +39,7 @@ module ParserCommon
if page.children.size > 0
res << menu_level(page, current + 1, menu, edit)
else
- res << "#{page.name}"
+ res << "#{page.i18n_variable[I18n.locale]}"
end
res << ""
end
diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb
index 44eb90ac..d1334b06 100644
--- a/lib/parsers/parser_front_end.rb
+++ b/lib/parsers/parser_front_end.rb
@@ -61,6 +61,8 @@ module ParserFrontEnd
end
c.define_tag 'stylesheets' do |tag|
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 }
@@ -72,7 +74,12 @@ module ParserFrontEnd
res << ""
res << ""
res << ""
+ res << ""
+ res << ""
+ res << ""
+ res << ""
res << ""
+ res << ""
page.design.javascripts.each do |js|
res << ""
end
@@ -83,7 +90,7 @@ module ParserFrontEnd
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|
@@ -119,14 +126,20 @@ module ParserFrontEnd
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
ret << ""
+ ret << "?inner=true&page_id=#{page.id}"
+ ret << "&bulletin_category_id=#{page.category}" if page[:category]
+ 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'
- ret << ""
+ if part[:category]
+ ret << ""
+ else
+ ret << ""
+ end
when 'public_r_tag'
ret << ""
else
diff --git a/lib/tasks/page_content.rake b/lib/tasks/page_content.rake
new file mode 100644
index 00000000..b1edeba9
--- /dev/null
+++ b/lib/tasks/page_content.rake
@@ -0,0 +1,11 @@
+# encoding: utf-8
+
+namespace :add_content do
+
+ task :build => :environment do
+
+ ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/page_content/page_content.json").read).save
+
+ end
+
+end
diff --git a/public/static/Other.xml b/public/static/Other.xml
new file mode 100644
index 00000000..22c41bbb
--- /dev/null
+++ b/public/static/Other.xml
@@ -0,0 +1,144 @@
+
+
+ 國立政治大學校園活動行事曆
+
+ 其他類別-最新活動
+ zh-tw
+
+ 國立政治大學101學年度碩士班暨碩士在職專班招生考試
+
+
+
+
+ 101/02/25-101/02/26 07:00-17:00
+
+
+ 國立中正大學101學年度碩士班招生考試
+
+
+
+
+ 101/03/10 07:00-17:00
+
+
+ 「樂活飲食•健康之鑰」系列活動--膳食纖維的功用及食物來源
+
+
+
+
+ 101/02/29 12:00-14:00
+
+
+ 「樂活飲食•健康之鑰」系列活動-美味的代價與健康問題之探討
+
+
+
+
+ 101/03/08 12:00-14:00
+
+
+ 「樂活飲食•健康之鑰」系列活動--代謝症候群與檢康飲食
+
+
+
+
+ 101/03/22 12:00-14:00
+
+
+ 「學生健康體位控制班」
+
+
+
+
+ 101/03/01-101/05/03 18:00-20:30
+
+
+ 學生大使志工團- 2012 Field Trip-Must Sea+ FUN舟趣
+
+
+
+
+ 101/03/17-101/03/18 08:00-20:00
+
+
+ 職場勞資關係講座-你知道自己的權益嗎?
+
+
+
+
+ 101/03/05 18:30-21:00
+
+
+ 職場「面面」觀 - 談職場趨勢與面試
+
+
+
+
+ 101/03/06 18:30-21:00
+
+
+ 「自」銷不要「滯」銷~一窺自我行銷術的秘密
+
+
+
+
+ 101/03/07 18:30-21:00
+
+
+ 職涯經驗談-開創職涯的一片天
+
+
+
+
+ 101/03/08 18:30-21:00
+
+
+ 2012徵政好企業說明會--花旗銀行
+
+
+
+
+ 101/03/05 12:15-14:00
+
+
+ 2012徵政好企業說明會--日商野村總合研究所
+
+
+
+
+ 101/03/09 12:15-14:00
+
+
+ 2012徵政好企業說明會--渣打銀行
+
+
+
+
+ 101/03/06 12:15-14:00
+
+
+ 2012徵政好企業說明會--台新金控
+
+
+
+
+ 101/03/07 12:15-14:00
+
+
+ 2012徵政好企業說明會--第一銀行
+
+
+
+
+ 101/03/08 12:15-14:00
+
+
+ 101年生命教育師資培訓課程研習會
+
+
+
+
+ 101/03/24-101/03/25 07:30-17:40
+
+
+
diff --git a/public/static/kernel.js b/public/static/kernel.js
index 13d6d3fe..c5b9a8a6 100644
--- a/public/static/kernel.js
+++ b/public/static/kernel.js
@@ -17,13 +17,12 @@ function ajax_load_proc(wapper,url){
wapper.html("Loading Failed");
});
}
-// Ad Banner FX code [start]
-function onAfter(e) {
- var parent = $(this).parent();
- var time_to_next = $(this).attr('time_to_next');
- parent.cycle('pause');
- setTimeout(function(){parent.cycle('resume')},time_to_next);
+
+// Ad Banner FX code [start]
+function getTimeout() {
+ return $(this).attr('time_to_next');
}
+
$(document).ready(function() {
$('.slideshow').children('img').click(function()
{
@@ -37,4 +36,4 @@ $(document).ready(function() {
}
})
});
-// Ad Banner FX code [end]
\ No newline at end of file
+// Ad Banner FX code [end]
diff --git a/vendor/built_in_modules/announcement/announcement.json b/vendor/built_in_modules/announcement/announcement.json
index 76516b50..0751a0e7 100644
--- a/vendor/built_in_modules/announcement/announcement.json
+++ b/vendor/built_in_modules/announcement/announcement.json
@@ -7,6 +7,6 @@
"update_info": "Some info",
"create_date": "11-11-2011",
"app_pages": ["bulletins"],
- "widgets": ["bulletins"],
+ "widgets": ["bulletins", "bulletins_and_web_links"],
"enable_frontend": true
}
diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js b/vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js
new file mode 100644
index 00000000..89a5e569
--- /dev/null
+++ b/vendor/built_in_modules/announcement/app/assets/javascripts/announcement_link.js
@@ -0,0 +1,45 @@
+$(document).ready(function(){
+ var topic1="0px";
+ var topic2="-948px";
+ var topic3="-1896px";
+ var topic_page=1;
+ $(".topic_prev").addClass("topic_prev_first");
+ $(document).on("click", ".topic_prev", function() {
+ if (topic_page !=1){
+ topic_page-=1;
+ }else{
+ }
+ if (topic_page == 1){
+ $("#topic_list").stop().animate({"left": topic1}, "slow");
+ $(".topic_prev").addClass("topic_prev_first");
+ }
+ if (topic_page == 2){
+ $("#topic_list").stop().animate({"left": topic2}, "slow");
+ $(".topic_prev").removeClass("topic_prev_first");
+ $(".topic_next").removeClass("topic_next_last");
+ }
+ if (topic_page == 3){
+ $("#topic_list").stop().animate({"left": topic3}, "slow");
+ $(".topic_prev").removeClass("topic_next_last");
+ }
+
+ });
+ $(document).on("click", ".topic_next", function() {
+ if (topic_page >=1 && topic_page <=2){
+ topic_page+=1;
+ }else{
+ }
+ if (topic_page == 1){
+ $("#topic_list").stop().animate({"left": topic1}, "slow");
+ $(".topic_prev").addClass("topic_prev_first");
+ }
+ if (topic_page == 2){
+ $("#topic_list").stop().animate({"left": topic2}, "slow");
+ $(".topic_prev").removeClass("topic_prev_first");
+ }
+ if (topic_page == 3){
+ $("#topic_list").stop().animate({"left": topic3}, "slow");
+ $(".topic_next").addClass("topic_next_last");
+ }
+ });
+});
diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js b/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js
new file mode 100644
index 00000000..9c429aac
--- /dev/null
+++ b/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require announcement_link
\ 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 3bb7d54b..92bf922f 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,6 @@
class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationController
- layout 'admin'
+ layout 'new_admin'
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 6fd4737d..48b9ac88 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
@@ -12,14 +12,17 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
# @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id]
- @bulletins = Bulletin.search(params[:search],params[:category_id])
+ # @bulletins = Bulletin.search(params[:search], params[:category_id])
+ # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
+ @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all
@bulletin_categories = BulletinCategory.all
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
- @tags = Tag.all(:conditions => {:module_app_id => module_app.id})
+ @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
respond_to do |format|
format.html # index.html.erb
+ format.js
format.xml { render :xml => @bulletins }
end
end
@@ -97,7 +100,6 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
if params[:bulletin][:image_del] == '1'
@bulletin.remove_image!
- @bulletin.image_filename = nil
# @bulletin.image_del = nil
params[:bulletin][:image_del] = nil
end
@@ -145,6 +147,50 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
def get_categorys(id = nil)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
end
+
+ def get_sorted_bulletins
+ bulletins = Bulletin.all
+ case params[:sort]
+ when 'postdate', 'deadline'
+ bulletins.order_by([params[:sort], params[:direction]])
+ when 'category'
+ category_ids = bulletins.distinct(:bulletin_category_id)
+ categories = BulletinCategory.find(category_ids) rescue nil
+ if categories
+ h = Hash.new
+ categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id }
+ sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
+ sorted_categorys = sorted.collect {|a| bulletins.where(:bulletin_category_id => a[1]).entries }
+ sorted_categorys.flatten
+ else
+ nil
+ end
+ when 'title'
+ h = Hash.new
+ bulletins.each { |bulletin| h[bulletin.title[I18n.locale]] = bulletin }
+ sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
+ sorted.collect {|a| a[1] }
+ when 'status'
+ bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction])
+ when 'update_user_id'
+ user_ids = bulletins.distinct(:update_user_id)
+ users = User.find(user_ids) rescue nil
+ if users
+ h = Hash.new
+ users.each { |user| h[user.name] = user.id }
+ sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse!
+ sorted_users = sorted.collect {|a| bulletins.where(:update_user_id => a[1]).entries }
+ sorted_users.flatten
+ else
+ nil
+ end
+ when 'tags'
+ a = Array.new
+ AnnouncementTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.bulletins }
+ a.flatten!
+ a.uniq
+ end
+ end
end
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 28a3ec5b..cf4e1801 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
@@ -10,9 +10,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController
def index
- date_now = Time.now
-
- @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(1)
+ date_now = Time.now
+ if params[:bulletin_category_id]
+ @bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_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)
+ end
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 41319bf1..6695156a 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
@@ -13,21 +13,31 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController
# deadline
# @bulletin_categorys = BulletinCategory.first;
# @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9)
- @bulletins = Bulletin.widget_datas.limit(9)
+ if params[:category_id]
+ @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9)
+ else
+ @bulletins = Bulletin.widget_datas.limit(9)
+ end
get_categorys
end
- def bulletins_list
+ 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
+ @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
+ end
- @bulletins = Bulletin.widget_datas.limit(5)
-
- # get_categorys
-
- module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
- @tags = Tag.all(:conditions => {:module_app_id => module_app.id})
-
+ def reload_bulletins
+ @selected_tag = AnnouncementTag.find(params[:tag_id])
+ @bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil
+ end
+
+ def reload_web_links
+ @selected_tag = AnnouncementTag.find(params[:tag_id])
+ @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
end
diff --git a/vendor/built_in_modules/announcement/app/models/announcement_tag.rb b/vendor/built_in_modules/announcement/app/models/announcement_tag.rb
index 2eac0102..9cb29038 100644
--- a/vendor/built_in_modules/announcement/app/models/announcement_tag.rb
+++ b/vendor/built_in_modules/announcement/app/models/announcement_tag.rb
@@ -2,4 +2,10 @@ class AnnouncementTag < Tag
has_and_belongs_to_many :bulletins
+
+ def get_visible_bulletins(sort = :name)
+ date_now = Time.now
+ self.bulletins.where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort)
+ end
+
end
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb
index d086d531..7c258f23 100644
--- a/vendor/built_in_modules/announcement/app/models/bulletin.rb
+++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb
@@ -106,6 +106,17 @@ class Bulletin
def text
@text ||= I18nVariable.first(:conditions => {:key => 'text', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
+
+ def self.filter(bulletins)
+ bulletins.each do |bulletin|
+ p "#{bulletin.id}/#{bulletin.is_top}/#{bulletin.is_hot}/#{bulletin.is_hidden}"
+ end
+ return nil
+ end
+
+ def sorted_tags
+ tags.order_by(I18n.locale, :asc)
+ end
protected
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 a9ab39ae..3f6f50e1 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
@@ -1,4 +1,4 @@
-
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb
new file mode 100644
index 00000000..3a6982dc
--- /dev/null
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb
@@ -0,0 +1,10 @@
+<% @web_links.each do |web_link| %>
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb
new file mode 100644
index 00000000..3e628120
--- /dev/null
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb
@@ -0,0 +1,19 @@
+
+
+
+<% content_for :page_specific_javascript do %>
+
+<% end %>
\ No newline at end of file
diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
new file mode 100644
index 00000000..c1d86fe1
--- /dev/null
+++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb
@@ -0,0 +1,10 @@
+
+
-
-<% end %>
diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb
new file mode 100644
index 00000000..a4577328
--- /dev/null
+++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb
@@ -0,0 +1 @@
+$('#web_links_links').html("<%= j render 'web_links' if @web_links %>")
\ No newline at end of file
diff --git a/vendor/built_in_modules/web_resource/config/routes.rb b/vendor/built_in_modules/web_resource/config/routes.rb
index fb2eed2d..6783cc99 100644
--- a/vendor/built_in_modules/web_resource/config/routes.rb
+++ b/vendor/built_in_modules/web_resource/config/routes.rb
@@ -16,6 +16,7 @@ Rails.application.routes.draw do
end
namespace :widget do
match "web_links" => "web_links#index"
+ match "reload_web_links" => "web_links#reload_web_links"
end
end
end