Fix album widget options

This commit is contained in:
chris 2013-01-07 00:40:43 +08:00
parent be00cec4d7
commit c6111460f5
7 changed files with 18 additions and 28 deletions

View File

@ -39,9 +39,8 @@ class Admin::PagePartsController < ApplicationController
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'gallery'
@albums = GalleryAlbum.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
@ -102,9 +101,8 @@ class Admin::PagePartsController < ApplicationController
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'gallery'
@albums = GalleryAlbum.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all

View File

@ -1,10 +1,3 @@
class OrbitWidgetController< OrbitFrontendComponentController
before_filter :get_wiget_options
def get_wiget_options
@wiget_options = {}
if params[:widget_options]
@wiget_options = (eval('{'+ params[:widget_options] +'}') rescue {})
end
end
end

View File

@ -23,10 +23,6 @@ class PagePart
before_save :delete_empty_widget_field
after_save :update_parent
def widget_options_uri
self.widget_options.map{|t| "#{t[0]}: #{t[1]}"}.join(',') rescue ''
end
protected

View File

@ -1,5 +1,9 @@
<% if (@module_app && @module_app.widget_options) %>
<%= label_tag('widget_options') %>
<% if @module_app.key.eql?('gallery') %>
<%= t('gallery.gallery') %>
<%= select_tag "page_part[widget_options][album_id]", options_from_collection_for_select(@albums, :id, :name, :selected => (@part.widget_options[key] rescue nil)) %>
<% end %>
<% if @module_app.widget_options.has_key? @part.widget_path%>
<% @module_app.widget_options[@part.widget_path].each do |key,options| %>
<%= label_tag(t(@module_app.widget_options_fields_i18n[@part.widget_path][key]))%>

View File

@ -210,7 +210,7 @@ module ParserCommon
when 'default_widget'
"/panel/orbit_app/widget/#{part.widget_style}?inner=true"
else
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&widget_options=#{part.widget_options_uri}"
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
end
options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"

View File

@ -114,7 +114,7 @@ module ParserFrontEnd
when 'default_widget'
"/panel/orbit_app/widget/\#{part.widget_style}?inner=true"
else
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true&widget_options=\#{part.widget_options_uri}"
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
end
options = "&part_id=\#{part.id}&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}"
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"

View File

@ -1,11 +1,13 @@
class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
def widget1
vertical = 2
horizontal = 6
@part = PagePart.find(params[:part_id])
vertical = @wiget_options[:vertical] if (@wiget_options.has_key?(:vertical) && @wiget_options[:vertical] < vertical)
horizontal = @wiget_options[:horizontal] if (@wiget_options.has_key?(:horizontal) && @wiget_options[:horizontal] < horizontal)
vertical = @part.widget_options['vertical'].to_i rescue 0
horizontal = @part.widget_options['horizontal'].to_i rescue 0
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
@album_images = @album.gallery_images if @album
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
@class = "c" + @settings["horizontal"].to_s
@ -13,15 +15,12 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
@rnd = Random.new
@images = []
for i in 0..@total-1
@sn = @rnd.rand(0...GalleryImage.count)
if @sn < 0
@sn = @sn * -1
end
image = GalleryImage.skip(@sn).limit(1).first
image = @album_images[@rnd.rand(0...@album_images.count)]
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
end
def widget2
end