diff --git a/plugins/video/lib/ext/article.rb b/plugins/video/lib/ext/article.rb index a870126..8e97c3b 100644 --- a/plugins/video/lib/ext/article.rb +++ b/plugins/video/lib/ext/article.rb @@ -2,8 +2,8 @@ require_dependency 'article' class Article - scope :video_gallery, :conditions => ["articles.type == 'VideoGallery'"] - + scope :video_gallery, :conditions => ["articles.type = 'VideoPlugin::VideoGallery'"] + #FIXME This should be done via hotspot def self.folder_types_with_video self.folder_types_without_video << 'VideoPlugin::VideoGallery' @@ -13,31 +13,15 @@ class Article class << self alias_method_chain :folder_types, :video end - - -# def self.articles_columns -# Article.column_names.map {|c| "articles.#{c}"} .join(",") -# end -# -# def self.most_accessed(owner, limit = nil) -# conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id] -# result = Article.relevant_content.find( -# :all, -# :order => 'hits desc', -# :limit => limit, -# :conditions => conditions) -# result.paginate({:page => 1, :per_page => limit}) -# end - - def self.can_be_listed - conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id] + + def self.owner_video_galleries(owner) + conditions = owner.kind_of?(Environment) ? [] : ["profile_id = ?", owner.id] result = Article.video_gallery.find( :all, - :order => 'hits desc', + :order => 'created_at desc', :conditions => conditions) end - - + end diff --git a/plugins/video/lib/video_plugin/video_gallery_block.rb b/plugins/video/lib/video_plugin/video_gallery_block.rb new file mode 100644 index 0000000..60a21ab --- /dev/null +++ b/plugins/video/lib/video_plugin/video_gallery_block.rb @@ -0,0 +1,31 @@ +class VideoPlugin::VideoGalleryBlock < Block + + settings_items :video_gallery_id, :type => :integer + attr_accessible :video_gallery_id + + include ActionView::Helpers + include Rails.application.routes.url_helpers + + def self.description + _('Display a Video Gallery') + end + + def help + _('This block presents a video gallery') + end + + def content(args={}) + block = self + if video_gallery_id.present? + video_gallery = VideoPlugin::VideoGallery.find(video_gallery_id) + proc do + render :partial => 'content_viewer/video_plugin/video_gallery', :locals => {:video_gallery => video_gallery} + end + end + end + + def list_my_galleries + Article.owner_video_galleries(owner) + end + +end diff --git a/plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb b/plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb new file mode 100644 index 0000000..dfe6449 --- /dev/null +++ b/plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb @@ -0,0 +1,3 @@ +