zoukankan      html  css  js  c++  java
  • DotNetNuke的Skin.vb代码流程分析

    转自: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
  • 相关阅读:
    Django ORM 进行查询操作和性能优化
    Python PIL 长文本换行,二维码,图片合成
    python 常用的资料链接
    人生苦短,我用Python
    windows下搭建Python virtualenvvirtualenvwrapper虚拟环境。
    Python 文件上传base64图片
    python实现中文转换url编码的方法
    同时装了Python3和Python2,怎么用pip?
    统计当天下单量
    Django ORM 级联删除
  • 原文地址:https://www.cnblogs.com/shiningrise/p/849633.html
Copyright © 2011-2022 走看看