Dotnetnuke's skin. VB Code Flow Analysis

Source: Internet
Author: User
Tags dotnetnuke

From: http://www.apsky.cn/article.asp? Id = 353

This article describes how to use skin. the Analysis of VB may be relatively simple, but I should have written the specific process. For its specific function, I still need the code in the analysis. After all, I did my own research, there are also more or less mistakes in some places.

1. Obtain the httpcontext entry settings of the current request.
Dim _ portalsettings as portalsettings = ctype (httpcontext. Current. Items ("portalsettings"), portalsettings)
2. Obtain the module title: the ID of site settings (Stored Procedure getsitemode (), and then obtain the dnn container Based on the ID

3. traverse the Server Control (Me. controls, annotation: defines the attributes, methods, and events shared by all Asp.net server controls. If its type is htmlcontrol (typeof ctlcontrol is htmlcontrol) (annotation: common methods, attributes, and events of the HTML Server Control), convert them, and determine whether they contain the "runation = server" attribute values and corresponding values, only in the panes period table of _ portalsettings
For each ctlcontrol in me. Controls
'Load the skin panes
'Load skin container
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
'Window location
_ Portalsettings. panes. Add (ctlcontrol. ID)
End select
End if
End if
Next
4. determine whether it is a Management Control Based on URL parameters. If yes, repeat the admin. ascx control and process panes.
Panes: If we log in as an administrator, and this position can display the border (authorizedroles =-1 in the position) and name, for example, the default home location is used, its authorizedroles = "-1; 0" shows the border and the panen name (leftpane, rightpane, contextpane)
If (portalsecurity. isinrole (_ portalsettings. administratorroleid. tostring) = true or portalsecurity. isinroles (_ portalsettings. activetab. administratorroles. tostring) = true) and blnpreview = false then
'Is to manage login, and it can display the border (-1) and pane name, such as home, skin location, etc.
If isadmintab (_ portalsettings. activetab. Tabid, _ portalsettings. activetab. parentid) = false then
Blnlayoutmode = true
End if
End if
Display border and name
If blnlayoutmode then '??? Management, and whether it is independent
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
'Display the pane border
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
'Display the pane name, such as leftpane, contentpane, and rightpane.
Dim ctllabel as new label
Ctllabel. Text = "<center>" & strpane & "</center> <br>"
Ctllabel. cssclass = "Subhead"
Ctlpane. Controls. addat (0, ctllabel)
Next
End If click tour: http://www.cnblogs.com/images/cnblogs_com/zc_net/dnn_17.gif

5. Obtain information about all modules not in the current position from the database (dnn_modules) (/dotnetnuke/default. aspx? Tabid = 1), according to the position (panename) of each module, load it to the corresponding position (panename) 'inject the module into the skin
Brief process of injectmodule (parent, _ modulesettings, _ portalsettings) injectmodule event:
Step 1: load the container first (~ /Portal/_ default/containers/_ default/Default. ascx) ctlcontainer = loadcontainer ("~ "& Modulesettings. containerpath. remove (0, Len (Global. applicationpath) & modulesettings. containersrc, objpane) Step 2: Obtain the window table (PANE) and load the module in the table
'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
'Module user control processing
If not objportalmodulecontrol is nothing then

'Inject the module into the panel
'Objpanel = module container
Objpanel. Controls. Add (objportalmodulecontrol)

End if

'Inject the panel into the container pane
'Insert the injection panel into the container window
Objcell. Controls. Add (objpanel)
Step 3: load the created table at the specified location (leftpane, contentpane, rightpane)
'Inject the container into the page pane-This triggers the pre_init () event for the user control

Objpane. Controls. Add (ctlcontainer)

6. Analyze the URL address, analyze the corresponding modules and descriptions from the table in the database, and then perform the preceding steps (5 ).
Dim moduleid as integer =-1
Dim key as string = ""

'Get moduleid (obtain the module ID)
If not isnothing (request. querystring ("mid") then
Moduleid = int32.parse (request. querystring ("mid "))
End if

'Get key' to dynamically load controls
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
...... Run the Stored Procedure getmodulecontrolsbykey and return the list (module information)

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.