Class | PortalController
In: | app/controllers/portal_controller.rb
Parent: | ApplicationController

ポータルを制御する。

### Methods

config index pane portlet_config portlettable_members update_pattern update_portlets

### Classes and Modules

Class PortalController::DuplicatePortlet
Class PortalController::UnknownUser

### Public Instance methods

config()

ポータルの設定画面を表示する。

[Source]

        # File app/controllers/portal_controller.rb, line 19
    19:   def config
    20:     setup_portal
    21:     @screen = @portal.screen
    22:     @current_panes = @screen.panes
    23:     @groups = PortlettableGroup.find(:all)
    24:     @current_view = "view_m"
    25:   end

index()

ポータルレイアウトで表示する。

[Source]

        # File app/controllers/portal_controller.rb, line 11
    11:   def index
    12:     setup_portal
    13:     @screen = @portal.screen
    14:     @panes = @screen.panes
    15:     @current_view = "view_m"
    16:   end

pane()

ポータルのレイアウトのペインを表示する。

[Source]

        # File app/controllers/portal_controller.rb, line 57
    57:   def pane
    58:     unless params[:pane]
    59:       render :nothing => true
    60:       return
    61:     end
    62:     pane = params[:pane].upcase.to_sym
    63:     setup_portal
    64:     @screen = @portal.screen
    65:     @current_panes = @screen.panes
    66:     @groups = PortlettableGroup.find(:all)
    67:     render :partial => "pane", :locals => {:pane => pane}
    68:   end

portlet_config()

ポートレットの設定画面を表示する。

[Source]

        # File app/controllers/portal_controller.rb, line 28
    28:   def portlet_config
    29:     setup_portal
    30:     @portlet = Portlet.find(params[:portlet_id])
    31:     @parent_view = "view_m"
    32:     @current_view = "view_pconfig"
    33:   end

portlettable_members()

グループごとのポートレッタブルの一覧を表示する。

[Source]

        # File app/controllers/portal_controller.rb, line 36
    36:   def portlettable_members
    37:     setup_portal
    38:     unless params[:group_id]
    39:       render :nothing => true
    40:       return
    41:     end
    42:     @group = PortlettableGroup.find(params[:group_id])
    43:     @members = @group.portlettable_members.reject {|m| @portal.portlets.map(&:portlettable).include?(m.portlettable)}
    44:     render :partial => "portlettable_members"
    45:   end

update_pattern()

ポータルのレイアウトのパターンを設定する。

[Source]

        # File app/controllers/portal_controller.rb, line 48
    48:   def update_pattern
    49:     if params[:pattern]
    50:       setup_portal
    51:       @portal.update_pattern params[:pattern]
    52:     end
    53:     render :nothing => true
    54:   end

update_portlets()

ペイン内のポートレットを配置する。

[Source]

         # File app/controllers/portal_controller.rb, line 71
     71:   def update_portlets
     72:     return render(:nothing => true) unless params[:pane] =~ /\A[aAbBcC]\z/
     73:
     74:     kept, newbie = [], []
     75:     key = "portlets_#{params[:pane].downcase}".to_sym
     76:     if params[key]
     77:       params[key].each_with_index do |x, i|
     78:         case x
     79:         when /\Aportlet_([0-9]+)\z/
     80:           kept[$+.to_i] = i + 1
     81:         when /\Aportlettable_member_([0-9]+)\z/
     82:           newbie << [$+.to_i, i + 1]
     83:         else
     84:           # nothing to do
     85:         end
     86:       end
     87:     end
     88:
     89:     setup_portal
     90:     Portal.transaction do
     91:       pane = @portal.pane(params[:pane])
     92:       # arrange or remove current portlets
     93:       @portal.portlets.each do |portlet|
     94:         if position = kept[portlet.id]
     95:           portlet.position = position
     96:           portlet.save
     97:         elsif portlet.pane == pane
     98:           portlet.destroy
     99:         end
    100:       end
    101:       # add new portlets
    102:       newbie.each do |member_id, position|
    103:         member = PortlettableMember.find(member_id)
    104:         begin
    105:           Portlet.create!(:portal_id => @portal.id,
    106:                           :pane_id => pane.id,
    107:                           :position => position,
    108:                           :portlettable_id => member.portlettable_id,
    109:                           :portlettable_type => member.portlettable_type)
    110:         rescue ActiveRecord::ActiveRecordError
    111:           flash[:warning] = s_("flash|notice|It is impossible to add a duplicate portlet in your portal.")
    112:           raise DuplicatePortlet, ""
    113:         end
    114:       end
    115:     end
    116:     render :nothing => true
    117:   end

[Validate]