Cấu trúc Cổng thông tin Viện Đại Học Mở Hà Nội 2.1 Cấu trúc cổng

Một phần của tài liệu Phân tích hệ thống Cổng thông tin Viện Đại Học Mở Hà Nội (Trang 111 - 115)

2.1 Cấu trúc cổng

Cổng thông tin Viện Đại Học Mở được cấu trúc dưới dạng Tab. Tất cả các thông tin sẽ được trình bày trên 1 trang duy nhất (default.aspx)

Hình 63 : Cấu trúc Cổng Thơng Tin Viện Đại Học Mở Hà Nội

Các Module chương trình sẽ được trình bày trên các Tab. Khi mỗi Tab được chọn, nội dung của Tab đó sẽ được hiển thị.

Hình 64: Cấu trúc một Tab

Portal Default .aspx

Tab1

Header …

Nội dung

Tab3

Tab2 ……

Nội dung trái Nội dung giữa Nội dung phải

Footer …

Module 1 Module 2 Module 3 …

2.2 Ý nghĩa của Tab trong hệ thống

Trong Cổng thơng tin Viện Đại Học Mở Hà Nội, có 3 file quan trọng nhất đó là : Configuration.vb , DesktopControls.vb , PortalCfg.xml

PortalCfg.xml : chứa cấu trúc của portal dạng xml

Configuration.vb : là file quan trọng nhất , chứa lõi của portal .

DesktopControls.vb : chứa định nghĩa PortalModuleControl , là baseclass của các module

trong Portal .

Khi Click vào 1 Tab sẽ xuất hiện đường dẫn như sau:

http://localhost/HouPortal/DesktopDefault.aspx?tabindex=0&tabid=1

trong đó :

tabindex : thứ tự của tab hiện thời. tabid : id của tab hiện thời

Như vậy đường dẫn trên có ý nghĩa : tab hiện thời có id là 1 và có thứ tự trong listtab là 0 . Như thế phần nội dung phía dưới sẽ hiển thị nội dung của tab có id là 1 và sẽ tơ trắng tab có thứ tự là 0 trong listtab (chính là phần tử có id = 1). Trong hệ thống đây chính là “trang chủ”

Trong file Global.asax, mỗi lần có yêu cầu (request) (mỗi lần hiển thị trang) các tham số tabindex và tabid sẽ được nhận và từ đó sẽ lấy ra PortalSettings cần thiết . Cùng với SiteSettings , 2 đối tượng này sẽ được cho vào Context (đối tượng tồn tại suốt trong thời gian chạy Portal) . Đoạn mã sau nằm trong file Global.asax thực thi việc này.

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

Dim tabIndex As Integer = 0 Dim tabId As Integer = 1 ' Lay tabindex tu querystring

If Not (Request.Params("tabindex") Is Nothing) Then tabIndex = CInt(Request.Params("tabindex")) End If

' lay TabID tu querystring

If Not (Request.Params("tabid") Is Nothing) Then tabId = CInt(Request.Params("tabid"))

End If

' Add doi tuong PortalSettings vao context Context.Items.Add("PortalSettings", New PortalSettings(tabIndex, tabId))

' Doc thong tin cau hinh tu file XML và add vao context Dim config As Configuration = New Configuration

Context.Items.Add("SiteSettings", config.GetSiteSettings()) Try

If Not (Request.UserLanguages Is Nothing) Then Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0)) Else Thread.CurrentThread.CurrentCulture = New CultureInfo("en-us") End If Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture Catch ex As Exception

Thread.CurrentThread.CurrentCulture = New CultureInfo("en- us")

End Try

End Sub

----------------------------------------------------------------------------------------------------------- Như vậy nhiệm vụ còn lại của DestopDefault.aspx chỉ là sử dụng 2 đối tượng này (tabindex, tabid) và hiển thị các Module. Đoạn mã sau nằm trong file DestopDefault.aspx.vb thực thi công việc này.

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

InitializeComponent()

If Request.Params("tabindex") Is Nothing Or Request.Params("tabid") Is Nothing Then

Response.Redirect("DesktopDefault.aspx? tabindex=0&tabid=1")

Return End If

' Lay PortalSettings tu` Current Context Dim _portalSettings As PortalSettings =

CType(HttpContext.Current.Items("PortalSettings"), PortalSettings) 'Kiem tra quyen`

If

PortalSecurity.IsInRoles(_portalSettings.ActiveTab.AuthorizedRoles) = False Then

Response.Redirect("~/Admin/AccessDenied.aspx") End If

' Tu dong chen` cac module vao` trang .

If _portalSettings.ActiveTab.Modules.Count > 0 Then ' Lap qua cac Configuration

Dim _moduleSettings As ModuleSettings For Each _moduleSettings In

Dim parent As Control = Page.FindControl(_moduleSettings.PaneName)

If _moduleSettings.CacheTime = 0 Then

Dim portalModule As PortalModuleControl =

CType(Page.LoadControl(_moduleSettings.DesktopSrc), PortalModuleControl) portalModule.PortalId = _portalSettings.PortalId portalModule.ModuleConfiguration = _moduleSettings parent.Controls.Add(portalModule)

Else

Dim portalModule As New CachedPortalModuleControl portalModule.PortalId = _portalSettings.PortalId portalModule.ModuleConfiguration = _moduleSettings parent.Controls.Add(portalModule)

End If

' moi module duoc cach nhau boi <br> (xuong dong`) parent.Controls.Add(New LiteralControl("<" + "br" + ">")) parent.Visible = True Next _moduleSettings End If End Sub

Một phần của tài liệu Phân tích hệ thống Cổng thông tin Viện Đại Học Mở Hà Nội (Trang 111 - 115)