class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController def initialize super @app_title = 'web_resource' end # GET /web_links # GET /web_links.xml def index @part = PagePart.find(params[:part_id]) if @part.widget_data_count @page_num = @part.widget_data_count else @page_num = 4 end if @part.widget_field @widget_fields = @part.widget_field else @widget_fields = [] end @widget_style = @part.widget_style @category_id = @part.category date_now = Time.now if !params[:category_id].blank? @web_links = WebLink.all.can_display.available_for_lang(I18n.locale).any_in(:web_link_category => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :postdate ).page( params[:page_main] ).per(@page_num) @web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) elsif !params[:tag_id].blank? @web_links = WebLink.all.can_display.available_for_lang(I18n.locale).any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :postdate ).page( params[:page_main] ).per(@page_num) get_categorys else @web_links = WebLink.all.can_display.available_for_lang(I18n.locale).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :postdate ).page( params[:page_main] ).per(@page_num) get_categorys end end def home_list @title = params[:part_title] # deadline # @web_link = WebLink.where( :is_hidden => false ).desc(:is_top, :title).first @web_links = WebLink.widget_datas.available_for_lang(I18n.locale).page(params[:page]).per(5) # get_categorys module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) @tags = module_app.tags end def reload_web_links @web_links = WebLink.widget_datas.available_for_lang(I18n.locale).page(params[:page]).per(5) end protected def get_categorys @web_link_categorys = WebLinkCategory.all end def get_tags module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) @tags = module_app.tags end end