Changeset 3428
- Timestamp:
- 05/14/07 19:18:49 (3 years ago)
- Files:
-
- components/bbs/trunk/bbs/_install/component_info.rb (modified) (1 diff)
- components/bbs/trunk/bbs/_install/db/001_bbs_schema_001.rb (modified) (3 diffs)
- components/bbs/trunk/bbs/_install/stylesheets/style.css (modified) (1 diff)
- components/bbs/trunk/bbs/admin (added)
- components/bbs/trunk/bbs/admin/main.rhtml (added)
- components/bbs/trunk/bbs/admin_controller.rb (added)
- components/bbs/trunk/bbs/bbs/forum_detail.rhtml (modified) (2 diffs)
- components/bbs/trunk/bbs/bbs/latest_block.rhtml (added)
- components/bbs/trunk/bbs/bbs/main.rhtml (modified) (1 diff)
- components/bbs/trunk/bbs/bbs/topic_detail.rhtml (modified) (3 diffs)
- components/bbs/trunk/bbs/bbs_config.rb (added)
- components/bbs/trunk/bbs/bbs_controller.rb (modified) (2 diffs)
- components/bbs/trunk/bbs/bbs_message.rb (modified) (3 diffs)
- components/bbs/trunk/bbs/bbs_topic.rb (modified) (2 diffs)
- components/bbs/trunk/bbs/bbs_topic_controller.rb (modified) (4 diffs)
- components/bbs/trunk/bbs/languages/english.rb (modified) (1 diff)
- components/bbs/trunk/bbs/languages/japanese.rb (modified) (1 diff)
- components/bbs/trunk/bbs/rubricks_search.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
components/bbs/trunk/bbs/_install/component_info.rb
r2419 r3428 22 22 :function => 'admin', 23 23 :description => '[_Bbs_Menu_DescAdminGroup]' 24 }, 25 { 26 :extend_page => 'admin', 27 :title => '[_Bbs_BbsConfig]', 28 :controller => '/bbs/admin', 29 :function => 'admin', 30 :description => '' 24 31 } 25 32 ] 26 @blocks = [] 33 @blocks = [ 34 { 35 :title => '[_Bbs_LatestPosts]', 36 :controller => '/bbs/bbs', 37 :action => 'latest_block', 38 :function => 'access', 39 :description => 'bbs latest block', 40 :widget => { 41 :default_height => '240', 42 :default_width => '400', 43 :visible => true 44 } 45 } 46 ] 27 47 end 28 48 end components/bbs/trunk/bbs/_install/db/001_bbs_schema_001.rb
r3331 r3428 4 4 # Schema 5 5 #################################################################################################################### 6 create_table :bbs_configs, :force => true do |t| 7 t.column :latest_block_size, :integer, :default => 0, :null => false 8 end 9 6 10 create_table :bbs_infos, :force => true do |t| 7 11 t.column :administrator_group_id, :integer, :default => 0, :null => false … … 44 48 t.column :topic_poster_id, :integer, :default => 0, :null => false 45 49 t.column :last_poster_name, :string, :limit => 96, :default => '', :null => false 46 t.column :topic_title, :string, :limit => 96, :default => '', :null => false47 t.column :topic_message, :text, :null => false48 t.column :topic_message_plain, :text, :null => false49 t.column :topic_poster_name, :string, :limit => 96, :default => '', :null => false50 50 t.column :last_posted, :datetime, :null => true 51 51 t.column :created_on, :datetime, :null => false … … 87 87 add_index(:bbs_authorized_groups, [:rubricks_group_id], {:name => 'bbs_authorized_groups_rubricks_group_id'}) 88 88 add_index(:bbs_authorized_groups, [:authorized_type], {:name => 'bbs_authorized_groups_authorized_type'}) 89 90 #################################################################################################################### 91 # Initial Data 92 #################################################################################################################### 93 Bbs::BbsConfig.create :latest_block_size => 10 89 94 end 90 95 91 96 def self.down 97 drop_table :bbs_configs 92 98 drop_table :bbs_authorized_groups 93 99 drop_table :bbs_messages components/bbs/trunk/bbs/_install/stylesheets/style.css
r2419 r3428 13 13 font-weight: bold; 14 14 } 15 16 .jump_bbs_icon { 17 float: right; 18 padding-top: 0px; 19 padding-bottom: 0px; 20 } components/bbs/trunk/bbs/bbs/forum_detail.rhtml
r3345 r3428 108 108 <thead> 109 109 <tr class="rubricks_general_table_title"> 110 <th class="rubricks_general_table_title" style="width: 60%;"><%= hl('[_Bbs_Topic]') %></th>111 <th class="rubricks_general_table_title" style="width: 1 3%;"><%= hl('[_Bbs_Post_Cnt]') %></th>110 <th class="rubricks_general_table_title" style="width: 54%;"><%= hl('[_Bbs_Topic]') %></th> 111 <th class="rubricks_general_table_title" style="width: 10%;"><%= hl('[_Bbs_Post_Cnt]') %></th> 112 112 <th class="rubricks_general_table_title" style="width: 16%;"><%= hl('[_Common_Creater]') %></th> 113 <th class="rubricks_general_table_title" style="width: 16%;"><%= hl('[_Bbs_Last_Poster]') %></th>113 <th class="rubricks_general_table_title" style="width: 20%;"><%= hl('[_Bbs_Last_Poster]') %></th> 114 114 </tr> 115 115 </thead> … … 423 423 var edit_forum_window = new Window('edit_forum_window', {width:750, height:440, closeButton:true, maxButton:false, minButton:true, resize:true, modal:true}); 424 424 open_edit_forum_window = function() { 425 $('forum_edit_form').reset(); 425 426 select_option('bbs_forum_category', '<%= @bbs_forum.bbs_category_id %>'); 426 427 if(!select_option('bbs_forum_moderator_groups', '<%= @bbs_forum.moderator_group_id %>')){ 427 428 $('bbs_forum_moderator_blank').selected = 'true'; 428 429 } 429 $('forum_edit_form').reset();430 430 ('<%= @bbs_forum.closed %>' == 'true')? $('bbs_forum_closed').checked = 'true' : $('bbs_forum_opened').checked = 'true'; 431 431 ('<%= @bbs_forum.locked %>' == 'true')? $('bbs_forum_locked').checked = 'true' : $('bbs_forum_unlocked').checked = 'true'; components/bbs/trunk/bbs/bbs/main.rhtml
r3149 r3428 5 5 treeview = new TreeView('bbs_tree', {move: false, enableUnselected: false}); 6 6 7 var bbs_tree_callback_function = function(element) { 7 var bbs_tree_callback_function = function(element) { 8 8 id = element.id.split('_'); 9 9 if(id[0] != 'tree'){ components/bbs/trunk/bbs/bbs/topic_detail.rhtml
r3345 r3428 21 21 <%= render_float_button_end('float_button_area_topic_edit') %> 22 22 <div style='float: left;width:100%'> 23 <div class="bbs_detail">24 <div style="margin-top: 10px;margin-bottom: 10px;" id="topic_message">25 <table style="width: 100%">26 <tr>27 <td style="width: 4%;" rowspan="2">28 <div class="switcher_state_open" onClick="bbs_toggle('0');" id='toggle_message0'></div>29 </td>30 <td style="width: 10%;font-weight: bold;"><%= hl('[_Bbs_Created_Name]') %>:</td>31 <td style="width: 86%" id="topic_detail_poster_name"><%= hl(@bbs_topic.topic_poster_name) %></td>32 </tr>33 < tr>34 <td style="width: 10%;font-weight: bold;"><%= hl('[_Bbs_Created_Date]') %>:</td>35 < td style="width: 86%"><%= hl(@bbs_topic.updated_on_to_s) %></td>36 </t r>37 <tr>38 <td style="width: 2%;"></td>39 <td colspan="4" id="toggle_content0">40 <div class="wysiwyg_content"><pre id="topic_detail_topic_message"><%= cs(@bbs_topic.topic_message, {:rule => :tiny_mce}) %></pre></div>41 </td>42 </tr>23 <table class="rubricks_general_table" id="topic_message_table"> 24 <tr class="bbs_detail"> 25 <td class="rubricks_general_table_cell_borderless" style="width: 16px;"> 26 <div class="switcher_state_open" onClick="bbs_toggle('0');" id='toggle_message0'></div> 27 </td> 28 <td class="rubricks_general_table_cell_borderless"> 29 [001] <span style="font-weight: bold;"><%= hl(@bbs_topic.topic_title) %></span> 30 </td> 31 <td class="rubricks_general_table_cell_borderless"> 32 (<span id="topic_detail_poster_name" class="<%= (@bbs_topic.topic_poster_id == RubricksUser::GUEST_USER_ID)? 'guest_postor' : 'logined_postor' %>"><%= hl(@bbs_topic.topic_poster_name) %></span>) 33 </td> 34 <td class="rubricks_general_table_cell_borderless" style="vertical-align: middle;"> 35 <span style="float: left;">[<%= hl(@bbs_topic.updated_on_to_s) %>]</span> 36 </td> 37 </tr> 38 <tr class="bbs_detail" style="height: 100px;" id="toggle_content0"> 39 <td class="rubricks_general_table_cell_dotted" style="vertical-align: top;" colspan=4> 40 <pre class="wysiwyg_content" id="topic_detail_topic_message"><%= cs(@bbs_topic.topic_message, {:rule => :tiny_mce}) %></pre> 41 </td> 42 </tr> 43 43 </table> 44 </div>45 </div>46 44 </div> 47 45 <hr/> … … 53 51 <% end %> 54 52 <%= render_float_button_end('float_button_area_create_message') %> 55 <% if @bbs_topic. bbs_messages.empty? %>53 <% if @bbs_topic.no_message? %> 56 54 <div id="not_register_message" style="padding-left:20px;"><%= hl('[_Bbs_Nothing_Post]') %></div> 57 55 <% else %> … … 79 77 </td> 80 78 <td class="rubricks_general_table_cell_borderless"> 81 [<%= sprintf("%03d", bbs_message.message_no)%>] <span style="font-weight: bold;" id="message_title<%= hl(bbs_message.id) %>"><%= hl(bbs_message.message_title) %></span>79 [<%= bbs_message.display_message_no %>] <span style="font-weight: bold;" id="message_title<%= hl(bbs_message.id) %>"><%= hl(bbs_message.message_title) %></span> 82 80 </td> 83 81 <td class="rubricks_general_table_cell_borderless"> components/bbs/trunk/bbs/bbs_controller.rb
r3055 r3428 3 3 uses_component_template_root 4 4 authorize :admin, :only => [:create_bbs, :edit_bbs, :delete_bbs] 5 authorize :access, :except => [:create_bbs, :edit_bbs, :delete_bbs ]5 authorize :access, :except => [:create_bbs, :edit_bbs, :delete_bbs, :latest_block] 6 6 7 7 def main … … 13 13 @detail = simple_render_component_as_string('/bbs/bbs', 'forum_tab', params) 14 14 end 15 end 16 17 def latest_block 18 offset = 0 19 @bbs_messages = [] 20 while @bbs_messages.size < Bbs::BbsConfig.latest_block_size do 21 messages = Bbs::BbsMessage.latest_messages(offset, Bbs::BbsConfig.latest_block_size - @bbs_messages.size) 22 break if messages.nil? 23 @bbs_messages.concat messages 24 offset += Bbs::BbsConfig.latest_block_size 25 end 15 26 end 16 27 components/bbs/trunk/bbs/bbs_message.rb
r3345 r3428 7 7 validates_not_nil_of :message 8 8 validates_length_of :poster_name, :in => 1..32 9 10 def self.latest_messages(offset, result_size) 11 result = Bbs::BbsMessage.find(:all, :include => :bbs_topic, :offset => offset, :limit => Bbs::BbsConfig.latest_block_size, :order => 'bbs_messages.created_on DESC') 12 return nil if result.empty? 13 bbs_messages = [] 14 result.each do |bbs_message| 15 bbs_forum = bbs_message.bbs_topic.bbs_forum 16 if bbs_forum.viewer? 17 bbs_messages << bbs_message 18 end 19 break if bbs_messages.size == result_size 20 end 21 return bbs_messages 22 end 9 23 10 24 def created_on_to_s … … 17 31 if self.updated_on 18 32 self.updated_on.strftime(RubricksLib.hl('[_Common_Date_HourMinSec_Format]')) 33 end 34 end 35 36 def created_on_block 37 if self.created_on 38 format = (self.created_on.to_date == Date.today) ? '[_Common_Time_Format]' : '%m/%d' 39 self.created_on.strftime(RubricksLib.hl(format)) 19 40 end 20 41 end … … 32 53 end 33 54 end 55 56 def display_message_no 57 return sprintf("%03d", self.message_no) 58 end 34 59 end components/bbs/trunk/bbs/bbs_topic.rb
r3345 r3428 1 1 class Bbs::BbsTopic < ActiveRecord::Base 2 acts_as_strippable :topic_message3 2 has_many :bbs_messages, :dependent => :destroy 4 3 belongs_to :bbs_forum 5 4 belongs_to :rubricks_user, :foreign_key => 'topic_poster_id' 6 5 validates_bool_of :locked 7 validates_length_of :topic_title, :in => 1..328 validates_length_of :topic_poster_name, :in => 1..329 validates_length_of :topic_message, :maximum => 2000010 validates_not_nil_of :topic_message11 6 12 def over_flow_message?13 return max_message_no>= self.bbs_forum.bbs_category.bbs_info.message_max_posts14 end7 def over_flow_message? 8 return max_message_no - 1 >= self.bbs_forum.bbs_category.bbs_info.message_max_posts 9 end 15 10 16 def max_message_no17 return Bbs::BbsMessage.maximum(:message_no, :conditions => ['bbs_topic_id = ?', self.id]) || 018 end11 def max_message_no 12 return Bbs::BbsMessage.maximum(:message_no, :conditions => ['bbs_topic_id = ?', self.id]) || 0 13 end 19 14 20 def last_message?(message_no)21 return message_no == self.max_message_no22 end15 def last_message?(message_no) 16 return message_no == self.max_message_no 17 end 23 18 24 def new_message_no25 return max_message_no + 126 end19 def new_message_no 20 return max_message_no + 1 21 end 27 22 28 23 def last_posted_to_s … … 55 50 return Bbs::BbsMessage.count(:conditions => ['bbs_topic_id = ?', self.id]) 56 51 end 52 53 def no_message? 54 return message_count <= 1 55 end 56 57 def message 58 unless @message 59 @message = Bbs::BbsMessage.find(:first, :include => :rubricks_user, :conditions => ['message_no = 1 and bbs_topic_id = ?', self.id]) 60 end 61 return @message 62 end 63 64 def message_id 65 return message.id 66 end 67 68 def topic_message 69 return message.message 70 end 71 72 def topic_title 73 return message.message_title 74 end 75 76 def topic_poster_name 77 return message.poster_name 78 end 57 79 end components/bbs/trunk/bbs/bbs_topic_controller.rb
r3055 r3428 23 23 if @per_page == -1 24 24 @bbs_messages = Bbs::BbsMessage.find(:all, :include => :rubricks_user, 25 :conditions => ['bbs_topic_id = ? ' , @bbs_topic.id], :order => 'bbs_messages.message_no desc')25 :conditions => ['bbs_topic_id = ? and message_no <> 1' , @bbs_topic.id], :order => 'bbs_messages.message_no desc') 26 26 else 27 27 if params[:message_id] … … 35 35 36 36 @pages, @bbs_messages = paginate(:"#{Bbs::BbsMessage.to_s}", :per_page => @per_page, :include => :rubricks_user, 37 :conditions => ['bbs_topic_id = ? ', @bbs_topic.id], :order => 'bbs_messages.message_no desc')37 :conditions => ['bbs_topic_id = ? and message_no <> 1', @bbs_topic.id], :order => 'bbs_messages.message_no desc') 38 38 end 39 40 39 if @bbs_topic.over_flow_message? 41 40 flash[:bbs_message] = '[_Bbs_Max_Posts_Msg]' … … 51 50 ActiveRecord::Base.transaction do 52 51 authorize_topic_poster(params[:create_topic][:forum_id]) 53 bt.topic_title = params[:create_topic][:topic_title] 52 bt.bbs_forum_id = params[:create_topic][:forum_id] 53 bt.topic_poster_id = current_user.id 54 bt.save! 55 56 bm = Bbs::BbsMessage.new 57 bm.message = params[:create_topic][:message] 58 bm.poster_id = current_user.id 59 bm.message_title = params[:create_topic][:topic_title] 54 60 if params[:create_topic][:topic_poster_name] 55 b t.topic_poster_name = params[:create_topic][:topic_poster_name]61 bm.poster_name = params[:create_topic][:topic_poster_name] 56 62 else 57 b t.topic_poster_name = current_user.name63 bm.poster_name = current_user.name 58 64 end 59 bt.bbs_forum_id = params[:create_topic][:forum_id] 60 bt.topic_message = params[:create_topic][:message] 61 bt.topic_poster_id = current_user.id 62 raise ::ActionController::ValidateException unless bt.valid? 63 bt.save 65 bm.message_no = bt.new_message_no 66 bm.bbs_topic_id = bt.id 67 bm.save! 68 69 bt.last_poster_name = bm.poster_name 70 bt.last_posted = bm.created_on 71 bt.save! 64 72 end 65 73 flash[:bbs_message] = '[_Bbs_Create_Topic_Success]' … … 73 81 bt = Bbs::BbsTopic.find(params[:edit_topic][:topic_id]) 74 82 authorize_moderator(bt.bbs_forum_id) 75 bt.topic_title = params[:edit_topic][:topic_title]76 83 bt.bbs_forum_id = params[:edit_topic][:forum_id] if params[:edit_topic][:forum_id] 77 bt.topic_poster_name = params[:edit_topic][:topic_poster_name] if params[:edit_topic][:topic_poster_name]78 84 bt.locked = params[:edit_topic][:locked] 79 bt.topic_message = params[:edit_topic][:topic_message] 80 raise ::ActionController::ValidateException unless bt.valid? 81 bt.save 85 bt.save! 86 87 bm = bt.message 88 bm.poster_name = params[:edit_topic][:topic_poster_name] if params[:edit_topic][:topic_poster_name] 89 bm.message_title = params[:edit_topic][:topic_title] 90 bm.message = params[:edit_topic][:topic_message] 91 bm.save! 82 92 end 83 93 flash[:bbs_message] = '[_Bbs_Update_Topic_Success]' components/bbs/trunk/bbs/languages/english.rb
r3055 r3428 86 86 @lang['_Bbs_Deleted_Forum'] = 'The forum may be deleted.' 87 87 @lang['_Bbs_Deleted_Topic'] = 'The topic may be deleted.' 88 @lang['_Bbs_BbsConfig'] = 'BBS Config' 89 @lang['_Bbs_BbsConfig_Update'] = 'The bbs setting was updated.' 90 @lang['_Bbs_BbsConfig_Update_Failed'] = 'The bbs setting updating was failure.' 91 @lang['_Bbs_LatestPosts'] = 'LatestãPosts' 92 @lang['_Bbs_LatestBlockSize'] = 'The number of messages in latest block' 93 @lang['_Bbs_LatestBlock_ConfirmMessage'] = 'This message will be displayed.Is it all right?' 88 94 end 89 95 end components/bbs/trunk/bbs/languages/japanese.rb
r3055 r3428 97 97 @lang['_Bbs_Deleted_Category'] = 'ã«ããŽãªãåé€ãããŠããå¯èœæ§ããããŸã' 98 98 @lang['_Bbs_Deleted_Forum'] = 'ãã©ãŒã©ã ãåé€ãããŠããå¯èœæ§ããããŸã' 99 @lang['_Bbs_Deleted_Topic'] = 'ãããã¯ãåé€ãããŠããå¯èœæ§ããããŸã' 99 @lang['_Bbs_Deleted_Topic'] = 'ãããã¯ãåé€ãããŠããå¯èœæ§ããããŸã' 100 @lang['_Bbs_BbsConfig'] = 'æ²ç€ºæ¿ç®¡ç' 101 @lang['_Bbs_BbsConfig_Update'] = 'æ²ç€ºæ¿èšå®ãæŽæ°ããŸããã' 102 @lang['_Bbs_BbsConfig_Update_Failed'] = 'æ²ç€ºæ¿èšå®ã®æŽæ°ã«å€±æããŸããã' 103 @lang['_Bbs_LatestPosts'] = 'ææ°æçš¿' 104 @lang['_Bbs_LatestBlockSize'] = 'ææ°æçš¿ãããã¯ã«è¡šç€ºããæå€§æçš¿ä»¶æ°' 105 @lang['_Bbs_LatestBlock_ConfirmMessage'] = 'æ²ç€ºæ¿ãžé·ç§»ããŸããããããã§ããïŒ' 100 106 end 101 107 end components/bbs/trunk/bbs/rubricks_search.rb
r3337 r3428 1 1 class Bbs::RubricksSearch 2 2 def search(query, offset, limit, snippet_size, ru, target_list = ['message_title', 'message_plain']) 3 result = []4 result.concat(search_topic(query, offset, limit, snippet_size, ru, target_list))5 result.concat(search_message(query, offset, limit, snippet_size, ru, target_list))6 7 return result8 end9 10 def search_topic(query, offset, limit, snippet_size, ru, target_list = ['message_title', 'message_plain'])11 result = []12 target_list_topic = topic_target_list(target_list)13 conditions = RubricksLib.query_to_conditions(query, target_list_topic)14 query = conditions.shift15 query = "(#{query})"16 conditions.unshift(query)17 18 bt_list = Bbs::BbsTopic.find(:all, :conditions => conditions, :include => [:rubricks_user, [:bbs_forum => [:bbs_category => :bbs_info ]]], :offset => offset, :limit => limit, :order => 'bbs_topics.created_on desc')19 bt_list.each do |bbs_topic|20 administrator = bbs_topic.bbs_forum.bbs_category.bbs_info.bbs_admin?21 bbs_forum = bbs_topic.bbs_forum22 if bbs_forum.viewer?23 result << {24 :url => {:controller => '/bbs/bbs', :action => 'main', :params => {:type => 'topic', :id => bbs_topic.id}},25 :permalink => {:controller => '/bbs/bbs', :main => '_main', :params => {:type => 'topic', :id => bbs_topic.id}},26 :title => "ã #{RubricksLib.hl('[_Bbs_Topic]')}ã #{bbs_topic.topic_title}",27 :author => bbs_topic.display_topic_poster_name,28 :date => bbs_topic.created_on,29 :snippet => bbs_topic.topic_message_plain30 }31 end32 end33 return result34 end35 36 def search_message(query, offset, limit, snippet_size, ru, target_list = ['message_title', 'message_plain'])37 3 result = [] 38 4 conditions = RubricksLib.query_to_conditions(query, target_list) … … 49 15 :url => {:controller => '/bbs/bbs', :action => 'main', :params => {:type => 'message', :id => bbs_message.id}}, 50 16 :permalink => {:controller => '/bbs/bbs', :main => '_main', :params => {:type => 'message', :id => bbs_message.id}}, 51 :title => "ã #{RubricksLib.hl('[_Common_Message]')}ã #{bbs_message.message_title}",17 :title => bbs_message.message_title, 52 18 :author => bbs_message.display_poster_name, 53 19 :date => bbs_message.created_on, … … 60 26 61 27 def count(query, ru, target_list = ['message_title', 'message_plain']) 62 count = count_topic(query, ru, target_list = ['rubricks_users.name','message_title', 'message_plain'])63 count += count_message(query, ru, target_list = ['rubricks_users.name','message_title', 'message_plain'])64 return count65 end66 67 def count_topic(query, ru, target_list = ['message_title', 'message_plain'])68 target_list_topic = topic_target_list(target_list)69 conditions = RubricksLib.query_to_conditions(query, target_list_topic)70 query = conditions.shift71 query = "(#{query})"72 conditions.unshift(query)73 count = Bbs::BbsTopic.count(:all, :include => :rubricks_user, :conditions => conditions)74 return count75 end76 77 def count_message(query, ru, target_list = ['message_title', 'message_plain'])78 28 conditions = RubricksLib.query_to_conditions(query, target_list) 79 29 query = conditions.shift … … 87 37 target = { 88 38 'message_title' => '[_Common_Title]', 89 'message_plain' => '[_Common_Message]'39 'message_plain' => '[_Common_Message]' 90 40 } 91 41 end 92 93 def topic_target_list(target_list)94 target_list_topic = []95 target_list.each do |target|96 case target97 when 'message_title'98 target_list_topic << 'topic_title'99 when 'message_plain'100 target_list_topic << 'topic_message'101 end102 end103 return target_list_topic104 end105 42 end
