轉自:http://www.apsky.cn/article.asp?id=353
這篇隨筆對SKIN.VB的分析可能比較簡單,但具體的流程我應該是寫出來了,對於它的具體作用還是需要大家自己的分析裡面的代碼,畢竟我也是自己研究,對一些地方的看法也有或多或少存在錯誤。
一,擷取當前請求的httpcontext的入口設定
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
二,擷取模組標題為:Site Settings 的ID(預存程序GetSiteMode()),然後根據該ID擷取DNN的容器
三,遍曆HTML表單的伺服器控制項(Me.Controls,注釋:定義所有asp.net伺服器控制項共用的屬性,方法和事件)如果它的類型是HTMLCONTROL(TypeOf ctlControl Is HtmlControl)(注釋:HTML伺服器控制項的所通用的方法,屬性和事件),進行轉換,並斷定它是否包含“runation=server“的屬性值及對應值,只在到_portalSettings的Panes哈期表中
For Each ctlControl In Me.Controls
' load the skin panes
'載入皮膚容器
If TypeOf ctlControl Is HtmlControl Then
objHtmlControl = CType(ctlControl, HtmlControl)
If Not objHtmlControl.ID Is Nothing Then
Select Case objHtmlControl.TagName.ToUpper 'leftpane,contentpane,rightpane
Case "TD", "DIV", "SPAN", "P"
' content pane
'窗器位置
_portalSettings.Panes.Add(ctlControl.ID)
End Select
End If
End If
Next
四,根據URL的參數判斷是否是管理控制,如果是,重申admin.ascx控制項,並處理panes
panes:如果當我們以管理員登陸,並且這個位置是可以顯示邊框(位置的AuthorizedRoles=-1)及名稱的,比如預設有Home位置,它的AuthorizedRoles=”-1;0”,就相應的顯示邊框,並顯示panen名稱(leftpane,rightpane,contextpane)
If (PortalSecurity.IsInRole(_portalSettings.AdministratorRoleId.ToString) = True Or PortalSecurity.IsInRoles(_portalSettings.ActiveTab.AdministratorRoles.ToString) = True) And blnPreview = False Then
'是以管理登陸,並且它是可以顯示邊框(-1) 及pane名稱的,比如home,skin位置等
If IsAdminTab(_portalSettings.ActiveTab.TabId, _portalSettings.ActiveTab.ParentId) = False Then
blnLayoutMode = True
End If
End If
顯示邊框及名稱
If blnLayoutMode Then '???管理,並且它是否是獨立
Dim ctlPane As Control
Dim strPane As String
For Each strPane In _portalSettings.Panes '_portalSettings.Panes=rightpant,contentpant,rightpane
ctlPane = Me.FindControl(strPane)
ctlPane.Visible = True
' display pane border
'顯示pane的邊框
If TypeOf ctlPane Is HtmlTableCell Then
CType(ctlPane, HtmlTableCell).Style("border-top") = "1px #CCCCCC dotted"
CType(ctlPane, HtmlTableCell).Style("border-bottom") = "1px #CCCCCC dotted"
CType(ctlPane, HtmlTableCell).Style("border-right") = "1px #CCCCCC dotted"
CType(ctlPane, HtmlTableCell).Style("border-left") = "1px #CCCCCC dotted"
End If
' display pane name
'顯示pane的名稱,如leftpane,contentpane,rightpane
Dim ctlLabel As New Label
ctlLabel.Text = "<center>" & strPane & "</center><br>"
ctlLabel.CssClass = "SubHead"
ctlPane.Controls.AddAt(0, ctlLabel)
Next
End If點擊遊覽:http://www.cnblogs.com/images/cnblogs_com/zc_net/dnn_17.gif
五,從資料庫中(DNN_Modules)擷取不當前位置的所有模組資訊(/dotnetnuke/default.aspx?tabid=1),根據每個模組的的位置(panename),載入到相應的位置當中(panename) ' inject the module into the skin
InjectModule(parent, _moduleSettings, _portalSettings) InjectModule事件的簡要的流程:
第一步:先載入容器(~/portal/_default/containers/_default/default.ascx) ctlContainer = LoadContainer("~" & ModuleSettings.ContainerPath.Remove(0, Len(Global.ApplicationPath)) & ModuleSettings.ContainerSrc, objPane)第二步:擷取視窗的表格(pane),然後在表格中載入模組
' get container pane
Dim objCell As Control = ctlContainer.FindControl(glbDefaultPane) 'glbDefaultPane="contentpane"
' create a wrapper panel control for the module content min/max
Dim objPanel As New Panel
objPanel.ID = "ModuleContent"
' module user control processing
'模組使用者控制處理
If Not objPortalModuleControl Is Nothing Then
' inject the module into the panel
'objPanel=模組容器
objPanel.Controls.Add(objPortalModuleControl)
End If
' inject the panel into the container pane
'注入面板插入到容器窗框中
objCell.Controls.Add(objPanel)
第三步:在指定位置(leftpane,contentpane,rightpane)載入建立的表格
' inject the container into the page pane - this triggers the Pre_Init() event for the user control
objPane.Controls.Add(ctlContainer)
六:分析URL的地址,從資料庫中的表中分析相應模組及說明,然後又執行上面的(五)步驟
Dim ModuleId As Integer = -1
Dim Key As String = ""
' get ModuleId(擷取模組ID)
If Not IsNothing(Request.QueryString("mid")) Then
ModuleId = Int32.Parse(Request.QueryString("mid"))
End If
' get Key(獲得關鍵字),動態進行裝載控制項
If Not IsNothing(Request.QueryString("def")) Then
Key = Request.QueryString("def") ' old syntax
End If
If Not IsNothing(Request.QueryString("ctl")) Then
Key = Request.QueryString("ctl") ' new syntax
End If
Dim arrModuleControls As ArrayList = objModuleControls.GetModuleControlsByKey(Key, _moduleSettings.ModuleDefId)
For intCounter = 0 To arrModuleControls.Count - 1
……這裡執行預存程序GetModuleControlsByKey,返回列表(也就是模組資訊)
next
If blnAuthorized Then
' inject the module
InjectModule(parent, _moduleSettings, _portalSettings)
Else
Skin.AddPageMessage(Me, "", "Either you are not currently logged in, or you do not have the rights to access this module within the portal.", Skins.ModuleMessage.ModuleMessageType.YellowWarning)
End If