/// <summary>
    /// PreInit event handler.
    /// </summary>
    protected void PreInit_Setting(object sender, EventArgs e)
    {
        mBodyClass = BrowserHelper.GetBrowserClass();

        // Initialize the control
        widgetProperties.AliasPath      = aliasPath;
        widgetProperties.CultureCode    = QueryHelper.GetString("culture", CMSContext.PreferredCultureCode);
        widgetProperties.PageTemplateId = templateId;
        widgetProperties.WidgetId       = QueryHelper.GetString("widgetid", "");
        widgetProperties.ZoneId         = QueryHelper.GetString("zoneid", "");
        widgetProperties.InstanceGUID   = QueryHelper.GetGuid("instanceguid", Guid.Empty);
        widgetProperties.IsNewWidget    = QueryHelper.GetBoolean("isnew", false);
        widgetProperties.IsNewVariant   = QueryHelper.GetBoolean("isnewvariant", false);
        widgetProperties.IsInline       = QueryHelper.GetBoolean("Inline", false);
        widgetProperties.VariantID      = QueryHelper.GetInteger("variantid", 0);
        widgetProperties.VariantMode    = VariantModeFunctions.GetVariantModeEnum(QueryHelper.GetString("variantmode", string.Empty));
        widgetProperties.ZoneType       = WidgetZoneTypeCode.ToEnum(QueryHelper.GetString("zonetype", ""));
        widgetProperties.IsLiveSite     = false;

        // Ensure the design mode for the dialog
        if (String.IsNullOrEmpty(aliasPath))
        {
            PortalContext.SetRequestViewMode(ViewModeEnum.Design);
        }

        widgetProperties.OnNotAllowed += widgetProperties_OnNotAllowed;
    }
Пример #2
0
    /// <summary>
    /// PreInit event handler.
    /// </summary>
    protected void PreInit_Setting(object sender, EventArgs e)
    {
        mBodyClass = BrowserHelper.GetBrowserClass();
        // Initialize the control
        string aliasPath = QueryHelper.GetString("aliaspath", "");

        widgetProperties.AliasPath      = aliasPath;
        widgetProperties.PageTemplateId = QueryHelper.GetInteger("templateid", 0);
        widgetProperties.WidgetId       = QueryHelper.GetString("widgetid", "");
        widgetProperties.ZoneId         = QueryHelper.GetString("zoneid", "");
        widgetProperties.InstanceGUID   = QueryHelper.GetGuid("instanceguid", Guid.Empty);
        widgetProperties.IsNewWidget    = QueryHelper.GetBoolean("isnew", false);
        widgetProperties.IsNewVariant   = QueryHelper.GetBoolean("isnewvariant", false);
        widgetProperties.IsInline       = QueryHelper.GetBoolean("Inline", false);
        widgetProperties.VariantID      = QueryHelper.GetInteger("variantid", 0);
        widgetProperties.ZoneType       = WidgetZoneTypeCode.ToEnum(QueryHelper.GetString("zonetype", ""));

        widgetProperties.IsLiveSite = true;

        widgetProperties.OnNotAllowed += new EventHandler(widgetProperties_OnNotAllowed);
    }
Пример #3
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!AuthenticationHelper.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        selectElem.AliasPath   = QueryHelper.GetString("aliaspath", String.Empty);
        selectElem.CultureCode = QueryHelper.GetString("culture", LocalizationContext.PreferredCultureCode);
        selectElem.ZoneId      = QueryHelper.GetString("zoneid", String.Empty);
        selectElem.ZoneType    = WidgetZoneTypeCode.ToEnum(QueryHelper.GetString("zonetype", ""));

        bool isInline = QueryHelper.GetBoolean("inline", false);

        selectElem.IsInline = isInline;

        // Base tag is added in master page
        AddBaseTag = false;

        // Proceeds the current item selection
        StringBuilder script = new StringBuilder();

        script.Append(@"
function SelectCurrentWidget() 
{");
        if (isInline)
        {
            // Skip initial configuration for inline widgets is not supported on the live site
            script.Append(@"
    selectedSkipDialog = false;");
        }
        script.Append(@"
    SelectWidget(selectedValue, selectedSkipDialog);
}

function SelectWidget(value, skipDialog)
{
    if ((value != null) && (value != ''))
    {");
        if (isInline)
        {
            script.Append(@"
        var editor = wopener.currentEditor || wopener.CMSPlugin.currentEditor;
        if (editor) {
            editor.getCommand('InsertWidget').open(value);
        }

        CloseDialog(false);");
        }
        else
        {
            script.Append(@"
	    if (wopener.OnSelectWidget)
        {                    
                wopener.OnSelectWidget(value, skipDialog);                      
        }
        CloseDialog();");
        }

        script.Append(@"
	}
	else
	{
        alert(document.getElementById('", hdnMessage.ClientID, @"').value);		    
	}                
} 
           
");

        ScriptHelper.RegisterStartupScript(this, typeof(string), "WidgetSelector", script.ToString(), true);
        selectElem.SelectFunction = "SelectWidget";
        selectElem.IsLiveSite     = true;

        // Set the title and icon
        PageTitle.TitleText = GetString("widgets.selectortitle");
        // Remove default css class
        if (CurrentMaster.PanelBody != null)
        {
            Panel pnl = CurrentMaster.PanelContent;
            if (pnl != null)
            {
                pnl.CssClass = String.Empty;
            }
        }
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!CMSContext.CurrentUser.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        string aliasPath = QueryHelper.GetString("aliaspath", "");

        selectElem.AliasPath = aliasPath;

        selectElem.PageTemplateId = QueryHelper.GetInteger("templateid", 0);
        selectElem.ZoneId         = QueryHelper.GetString("zoneid", "");
        selectElem.ZoneType       = WidgetZoneTypeCode.ToEnum(QueryHelper.GetString("zonetype", ""));

        // Ensure the design mode for the dialog
        if (String.IsNullOrEmpty(aliasPath))
        {
            PortalContext.SetRequestViewMode(ViewModeEnum.Design);
        }

        bool isInline = QueryHelper.GetBoolean("inline", false);

        selectElem.IsInline = isInline;

        ScriptHelper.RegisterWOpenerScript(this.Page);

        btnOk.OnClientClick = "SelectCurrentWidget(); return false;";

        // Base tag is added in master page
        base.AddBaseTag = false;

        // Proceeds the current item selection
        string javascript = @"
            function SelectCurrentWidget() 
            {                
                SelectWidget(selectedValue);
            }
            function SelectWidget(value)
            {
                if (value != null)
                {
                    window.close();";

        if (isInline)
        {
            javascript += @"
                    var editor = wopener.currentEditor || wopener.CMSPlugin.currentEditor;
                    if (editor) {
                        editor.getCommand('InsertWidget').open(value);
                    }";
        }
        else
        {
            javascript += @"
	                if (wopener.OnSelectWidget)
                    {                    
                          wopener.OnSelectWidget(value);                      
                    }	   ";
        }

        javascript += @"  
	            }
		        else
		        {
                    alert(document.getElementById('" + hdnMessage.ClientID + @"').value);		    
		        }                
            }            
            // Cancel action
            function Cancel()
            {
                window.close();
            } ";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "WidgetSelector", ScriptHelper.GetScript(javascript));
        selectElem.SelectFunction = "SelectWidget";
        selectElem.IsLiveSite     = false;

        // Set the title and icon
        this.CurrentMaster.Title.TitleText  = GetString("widgets.selectortitle");
        this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Widget/object.png");

        // Remove default css class
        if (this.CurrentMaster.PanelBody != null)
        {
            Panel pnl = this.CurrentMaster.PanelBody.FindControl("pnlContent") as Panel;
            if (pnl != null)
            {
                pnl.CssClass = String.Empty;
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            pi = CMSContext.CurrentPageInfo;
            if (pi != null)
            {
                CMSPagePlaceholder parentPlaceHolder = PortalHelper.FindParentPlaceholder(this);

                // Nothing to render, nothing to do
                if ((!DisplayAddButton && !DisplayResetButton) || ((parentPlaceHolder != null) && (parentPlaceHolder.UsingDefaultPage)))
                {
                    Visible = false;
                    return;
                }

                CurrentUserInfo currentUser = CMSContext.CurrentUser;
                zoneType = WidgetZoneTypeCode.ToEnum(WidgetZoneType);


                // Check security
                if (((zoneType == WidgetZoneTypeEnum.Group) && !currentUser.IsGroupAdministrator(pi.NodeGroupID)) ||
                    ((zoneType == WidgetZoneTypeEnum.User || zoneType == WidgetZoneTypeEnum.Dashboard) && !currentUser.IsAuthenticated()))
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // Displaying - Editor zone only in edit mode, User/Group zone only in Live site/Preview mode
                if (((zoneType == WidgetZoneTypeEnum.Editor) && ((CMSContext.ViewMode != ViewModeEnum.Edit) && (CMSContext.ViewMode != ViewModeEnum.EditLive))) ||
                    (((zoneType == WidgetZoneTypeEnum.User) || (zoneType == WidgetZoneTypeEnum.Group)) && ((CMSContext.ViewMode != ViewModeEnum.LiveSite) && (CMSContext.ViewMode != ViewModeEnum.Preview))) || ((zoneType == WidgetZoneTypeEnum.Dashboard) && ((CMSContext.ViewMode != ViewModeEnum.DashboardWidgets) || (String.IsNullOrEmpty(PortalContext.DashboardName)))))
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // Get current document
                TreeNode currentNode = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider);
                if (((zoneType == WidgetZoneTypeEnum.Editor) && (!currentUser.IsEditor || (currentUser.IsAuthorizedPerDocument(currentNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied))))
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // If use checkin checkout enabled, check if document is checkout by current user
                if (zoneType == WidgetZoneTypeEnum.Editor)
                {
                    if (currentNode != null)
                    {
                        WorkflowManager wm = WorkflowManager.GetInstance(TreeProvider);
                        // Get workflow info
                        WorkflowInfo wi = wm.GetNodeWorkflow(currentNode);

                        // Check if node is under workflow and if use checkin checkout enabled
                        if ((wi != null) && (wi.UseCheckInCheckOut(CMSContext.CurrentSiteName)))
                        {
                            int checkedOutBy = currentNode.DocumentCheckedOutByUserID;

                            // Check if document is checkout by current user
                            if (checkedOutBy != CMSContext.CurrentUser.UserID)
                            {
                                Visible      = false;
                                resetAllowed = false;
                                return;
                            }
                        }
                    }
                }

                // Find widget zone
                PageTemplateInfo pti = pi.UsedPageTemplateInfo;

                // ZodeID specified directly
                if (!String.IsNullOrEmpty(WidgetZoneID))
                {
                    zoneInstance = pti.GetZone(WidgetZoneID);
                }

                // Zone not find or specified zone is not of correct type
                if ((zoneInstance != null) && (zoneInstance.WidgetZoneType != zoneType))
                {
                    zoneInstance = null;
                }

                // For delete all variants all zones are necessary
                if (parentPlaceHolder != null)
                {
                    var zones = parentPlaceHolder.WebPartZones;
                    if (zones != null)
                    {
                        foreach (CMSWebPartZone zone in zones)
                        {
                            if ((zone.ZoneInstance != null) && (zone.ZoneInstance.WidgetZoneType == zoneType))
                            {
                                zoneInstances.Add(zone.ZoneInstance);
                                if (zoneInstance == null)
                                {
                                    zoneInstance = zone.ZoneInstance;
                                }
                            }
                        }
                    }
                }

                // No suitable zones on the page, nothing to do
                if (zoneInstance == null)
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // Adding is enabled
                if (DisplayAddButton)
                {
                    pnlAdd.Visible       = true;
                    lnkAddWidget.Visible = true;
                    lnkAddWidget.Text    = HTMLHelper.HTMLEncode(DataHelper.GetNotEmpty(AddButtonText, GetString("widgets.addwidget")));

                    int templateId = 0;
                    if (pi.UsedPageTemplateInfo != null)
                    {
                        templateId = pi.UsedPageTemplateInfo.PageTemplateId;
                    }

                    addScript = "NewWidget('" + HttpUtility.UrlEncode(zoneInstance.ZoneID) + "', '" + HttpUtility.UrlEncode(pi.NodeAliasPath) + "', '" + templateId + "'); return false;";
                    lnkAddWidget.Attributes.Add("onclick", addScript);
                }

                // Reset is enabled
                if (DisplayResetButton)
                {
                    pnlReset.Visible = true;
                    btnReset.Text    = HTMLHelper.HTMLEncode(DataHelper.GetNotEmpty(ResetButtonText, GetString("widgets.resettodefault")));
                    btnReset.Click  += new EventHandler(btnReset_Click);

                    // Add confirmation if required
                    if (ResetConfirmationRequired)
                    {
                        btnReset.Attributes.Add("onclick", "if (!confirm('" + GetString("widgets.resetzoneconfirmtext") + "')) return false;");
                    }
                }

                // Set the panel css clas with dependence on actions zone type
                switch (zoneType)
                {
                // Editor
                case WidgetZoneTypeEnum.Editor:
                    pnlWidgetActions.CssClass = "EditorWidgetActions";
                    break;

                // User
                case WidgetZoneTypeEnum.User:
                    pnlWidgetActions.CssClass = "UserWidgetActions";
                    break;

                // Group
                case WidgetZoneTypeEnum.Group:
                    pnlWidgetActions.CssClass = "GroupWidgetActions";
                    break;

                // Dashboard
                case WidgetZoneTypeEnum.Dashboard:
                {
                    if (pnlContextHelp.Controls.Count == 0)
                    {
                        // Load help control dynamically (due to faster start compilation)
                        var help = this.LoadUserControl("~/CMSAdminControls/UI/PageElements/Help.ascx") as HelpControl;
                        help.TopicName = "dashboard";
                    }
                }
                break;
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!CMSContext.CurrentUser.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        selectElem.AliasPath   = QueryHelper.GetString("aliaspath", String.Empty);
        selectElem.CultureCode = QueryHelper.GetString("culture", CMSContext.PreferredCultureCode);
        selectElem.ZoneId      = QueryHelper.GetString("zoneid", String.Empty);
        selectElem.ZoneType    = WidgetZoneTypeCode.ToEnum(QueryHelper.GetString("zonetype", ""));

        bool isInline = QueryHelper.GetBoolean("inline", false);

        selectElem.IsInline = isInline;

        // Base tag is added in master page
        AddBaseTag = false;

        // Proceeds the current item selection
        string javascript = @"
            function SelectCurrentWidget() 
            {                
                SelectWidget(selectedValue, selectedSkipDialog);
            }

            function SelectWidget(value, skipDialog)
            {
                if ((value != null) && (value != ''))
                {
                    ";

        if (isInline)
        {
            javascript += @"
                    var editor = wopener.currentEditor || wopener.CMSPlugin.currentEditor;
                    if (editor) {
                        editor.getCommand('InsertWidget').open(value);
                    }";
        }
        else
        {
            javascript += @"
	                if (wopener.OnSelectWidget)
                    {                    
                          wopener.OnSelectWidget(value, skipDialog);                      
                    }	   ";
        }

        javascript += @"CloseDialog();  
	            }
		        else
		        {
                    alert(document.getElementById('" + hdnMessage.ClientID + @"').value);		    
		        }                
            }            
            // Cancel action
            function Cancel()
            {
                CloseDialog();
            } ";


        ScriptHelper.RegisterStartupScript(this, typeof(string), "WidgetSelector", ScriptHelper.GetScript(javascript));
        selectElem.SelectFunction = "SelectWidget";
        selectElem.IsLiveSite     = true;

        // Set the title and icon
        CurrentMaster.Title.TitleText  = GetString("widgets.selectortitle");
        CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Widget/object.png");

        // Remove default css class
        if (CurrentMaster.PanelBody != null)
        {
            Panel pnl = CurrentMaster.PanelBody.FindControl("pnlContent") as Panel;
            if (pnl != null)
            {
                pnl.CssClass = String.Empty;
            }
        }
    }
Пример #7
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (CurrentPageInfo != null)
            {
                PageInfo pi = CurrentPageInfo;

                // Make visible, visibility according to the current state will be set later (solves issue with changing visibility during postbacks)
                Visible = true;

                CMSPagePlaceholder parentPlaceHolder = PortalHelper.FindParentPlaceholder(this);

                // Nothing to render, nothing to do
                if ((!DisplayAddButton && !DisplayResetButton) ||
                    ((parentPlaceHolder != null) && (parentPlaceHolder.UsingDefaultPage || (parentPlaceHolder.PageInfo.DocumentID != pi.DocumentID))))
                {
                    Visible = false;
                    return;
                }

                var currentUser = MembershipContext.AuthenticatedUser;
                zoneType = WidgetZoneTypeCode.ToEnum(WidgetZoneType);


                // Check security
                if (((zoneType == WidgetZoneTypeEnum.Group) && !currentUser.IsGroupAdministrator(pi.NodeGroupID)) ||
                    ((zoneType == WidgetZoneTypeEnum.User || zoneType == WidgetZoneTypeEnum.Dashboard) && !AuthenticationHelper.IsAuthenticated()))
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // Displaying - Editor zone only in edit mode, User/Group zone only in Live site/Preview mode
                if (((zoneType == WidgetZoneTypeEnum.Editor) && !PortalManager.ViewMode.IsOneOf(ViewModeEnum.Edit, ViewModeEnum.EditDisabled, ViewModeEnum.EditLive)) ||
                    (((zoneType == WidgetZoneTypeEnum.User) || (zoneType == WidgetZoneTypeEnum.Group)) && !PortalManager.ViewMode.IsOneOf(ViewModeEnum.LiveSite, ViewModeEnum.Preview)) ||
                    ((zoneType == WidgetZoneTypeEnum.Dashboard) && ((PortalManager.ViewMode != ViewModeEnum.DashboardWidgets) || (String.IsNullOrEmpty(PortalContext.DashboardName)))))
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // Get current document
                TreeNode currentNode = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider);
                if (((zoneType == WidgetZoneTypeEnum.Editor) && (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, SiteContext.CurrentSiteName) || (currentUser.IsAuthorizedPerDocument(currentNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied))))
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // If use checkin checkout enabled, check if document is checkout by current user
                if (zoneType == WidgetZoneTypeEnum.Editor)
                {
                    if (currentNode != null)
                    {
                        WorkflowManager wm = WorkflowManager.GetInstance(TreeProvider);
                        // Get workflow info
                        WorkflowInfo wi = wm.GetNodeWorkflow(currentNode);

                        // Check if node is under workflow and if use checkin checkout enabled
                        if ((wi != null) && (wi.UseCheckInCheckOut(SiteContext.CurrentSiteName)))
                        {
                            int checkedOutBy = currentNode.DocumentCheckedOutByUserID;

                            // Check if document is checkout by current user
                            if (checkedOutBy != MembershipContext.AuthenticatedUser.UserID)
                            {
                                Visible      = false;
                                resetAllowed = false;
                                return;
                            }
                        }
                    }
                }

                // Find widget zone
                PageTemplateInfo pti = pi.UsedPageTemplateInfo;

                // ZodeID specified directly
                if (!String.IsNullOrEmpty(WidgetZoneID))
                {
                    zoneInstance = pti.TemplateInstance.GetZone(WidgetZoneID);
                }

                // Zone not find or specified zone is not of correct type
                if ((zoneInstance != null) && (zoneInstance.WidgetZoneType != zoneType))
                {
                    zoneInstance = null;
                }

                // For delete all variants all zones are necessary
                if (parentPlaceHolder != null)
                {
                    var zones = parentPlaceHolder.WebPartZones;
                    if (zones != null)
                    {
                        foreach (CMSWebPartZone zone in zones)
                        {
                            if ((zone.ZoneInstance != null) && (zone.ZoneInstance.WidgetZoneType == zoneType))
                            {
                                zoneInstances.Add(zone.ZoneInstance);
                                if (zoneInstance == null)
                                {
                                    zoneInstance = zone.ZoneInstance;
                                }
                            }
                        }
                    }
                }

                // No suitable zones on the page, nothing to do
                if (zoneInstance == null)
                {
                    Visible      = false;
                    resetAllowed = false;
                    return;
                }

                // Adding is enabled
                if (DisplayAddButton)
                {
                    btnAddWidget.Visible = true;
                    btnAddWidget.Text    = GetAddWidgetButtonText();

                    int templateId = 0;
                    if (pi.UsedPageTemplateInfo != null)
                    {
                        templateId = pi.UsedPageTemplateInfo.PageTemplateId;
                    }

                    addScript = (PortalContext.ViewMode == ViewModeEnum.EditLive ? "OEDeactivateWebPartBorder({ webPartSpanId: $cmsj('.OnSiteMenuTable').parent().attr('id').replace('OE_OE_', 'OE_')}, null );" : String.Empty) + "NewWidget(new zoneProperties('" + zoneInstance.ZoneID + "', '" + pi.NodeAliasPath + "', '" + templateId + "')); return false;";
                    btnAddWidget.Attributes.Add("onclick", addScript);
                }

                // Reset is enabled
                if (DisplayResetButton)
                {
                    btnReset.Visible = true;
                    btnReset.Text    = GetResetButtonText();
                    btnReset.Click  += new EventHandler(btnReset_Click);

                    // Add confirmation if required
                    if (ResetConfirmationRequired)
                    {
                        btnReset.Attributes.Add("onclick", "if (!confirm(" + ScriptHelper.GetLocalizedString("widgets.resetzoneconfirmtext") + ")) return false;");
                    }
                }

                // Set the panel css clas with dependence on actions zone type
                switch (zoneType)
                {
                // Editor
                case WidgetZoneTypeEnum.Editor:
                    pnlWidgetActions.CssClass = "EditorWidgetActions";
                    break;

                // User
                case WidgetZoneTypeEnum.User:
                    pnlWidgetActions.CssClass = "UserWidgetActions";
                    break;

                // Group
                case WidgetZoneTypeEnum.Group:
                    pnlWidgetActions.CssClass = "GroupWidgetActions";
                    break;
                }
            }
        }
    }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!CMSContext.CurrentUser.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        string aliasPath = QueryHelper.GetString("aliaspath", "");

        selectElem.AliasPath      = aliasPath;
        selectElem.CultureCode    = QueryHelper.GetString("culture", CMSContext.PreferredCultureCode);
        selectElem.PageTemplateId = QueryHelper.GetInteger("templateid", 0);
        selectElem.ZoneId         = QueryHelper.GetString("zoneid", "");
        selectElem.ZoneType       = WidgetZoneTypeCode.ToEnum(QueryHelper.GetString("zonetype", ""));

        // Ensure the design mode for the dialog
        if (String.IsNullOrEmpty(aliasPath))
        {
            PortalContext.SetRequestViewMode(ViewModeEnum.Design);
        }

        bool isInline = QueryHelper.GetBoolean("inline", false);

        selectElem.IsInline = isInline;

        ScriptHelper.RegisterWOpenerScript(Page);

        btnOk.OnClientClick = "SelectCurrentWidget(); return false;";

        // Base tag is added in master page
        AddBaseTag = false;

        // Proceeds the current item selection
        string javascript = @"
function SelectCurrentWidget() 
{                
    SelectWidget(selectedValue, selectedSkipDialog);
}
function SelectWidget(value, skipDialog)
{
    if ((value != null) && (value != ''))
    {";

        if (isInline)
        {
            javascript += @"
        if (skipDialog) {
            AddInlineWidgetWithoutDialog(value);
        }
        else {
            var editor = wopener.currentEditor || wopener.CMSPlugin.currentEditor;
            if (editor) {
                editor.getCommand('InsertWidget').open(value);
            }

            CloseDialog();
        }";
        }
        else
        {
            javascript += @"
	    if (wopener.OnSelectWidget)
        {                    
            wopener.OnSelectWidget(value, skipDialog);                      
        }

        CloseDialog();";
        }

        javascript += @"  
	}
	else
	{
        alert(document.getElementById('" + hdnMessage.ClientID + @"').value);		    
	}                
}            
// Cancel action
function Cancel()
{
    CloseDialog();
} ";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "WidgetSelector", ScriptHelper.GetScript(javascript));
        selectElem.SelectFunction = "SelectWidget";
        selectElem.IsLiveSite     = false;

        // Set the title and icon
        CurrentMaster.Title.TitleText  = GetString("widgets.selectortitle");
        CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Widget/object.png");

        // Remove default css class
        if (CurrentMaster.PanelBody != null)
        {
            Panel pnl = CurrentMaster.PanelBody.FindControl("pnlContent") as Panel;
            if (pnl != null)
            {
                pnl.CssClass = String.Empty;
            }
        }

        // Register scripts for inline widgets with the property 'Skip initial configuration' set (insert widget without configuration dialog)
        string script = @"
// Inline widgets
function AddInlineWidgetWithoutDialog(widgetId) {
    " + Page.ClientScript.GetCallbackEventReference(this, "widgetId", "OnReceiveAddInlineWidgetScript", null) + @";
    }

function OnReceiveAddInlineWidgetScript(rvalue, context) {
    if ((rvalue != null) && (rvalue != '')) {
        setTimeout(rvalue, 1);
    }
}";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "inlinewidgets11", script, true);
    }