protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (PageTemplate == null)
        {
            return;
        }

        var deviceProfile = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId);

        if (deviceProfile == null)
        {
            return;
        }

        var currentDeviceProfile = HTMLHelper.HTMLEncode(deviceProfile.ProfileDisplayName);
        var aliasPath            = QueryHelper.GetString("aliaspath", null);
        var aliasPathParam       = string.IsNullOrEmpty(aliasPath) ? string.Empty : "&aliaspath=" + aliasPath;

        if (isDialog)
        {
            CurrentMaster.Title.TitleText  = GetString("objecttype.cms_templatedevicelayout");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_DeviceProfile/object.png");
        }
        else
        {
            var breadcrumbs = new string[2, 3];

            breadcrumbs[0, 0] = GetString("devicelayout.devicelayouts");
            breadcrumbs[0, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_DeviceLayouts.aspx?templateid=" + PageTemplateID + aliasPathParam);
            breadcrumbs[0, 2] = "_parent";

            breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(currentDeviceProfile);
            breadcrumbs[1, 1] = "";
            breadcrumbs[1, 2] = "";

            CurrentMaster.Title.Breadcrumbs = breadcrumbs;
        }

        CurrentMaster.Title.HelpTopicName = "page_template_device_layout";
        CurrentMaster.Title.HelpName      = "helpTopic";

        // Initialize menu
        var i = 0;

        // Layout tab
        var layoutUrl = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageLayouts/PageLayout_Edit.aspx?allowswitch=1&templateid=" + PageTemplateID + "&deviceprofileid=" + deviceProfileId + "&devicename=" + deviceProfile.ProfileName + "&DeviceObjectLifeTime=request" + aliasPathParam);

        layoutUrl = EnsureDialogModeUrlParameter(layoutUrl);
        SetTab(i++, GetString("Administration-PageTemplate_Header.Layouts"), layoutUrl, "SetHelpTopic('helpTopic', 'page_template_device_layout');");

        if (!isDialog)
        {
            // Design tab
            var designUrl = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Design.aspx?templateid=" + PageTemplateID + "&deviceprofileid=" + deviceProfileId + "&devicename=" + deviceProfile.ProfileName + "&DeviceObjectLifeTime=request" + aliasPathParam);
            SetTab(i++, GetString("edittabs.design"), designUrl, "SetHelpTopic('helpTopic', 'page_template_device_design');");
        }
    }
Пример #2
0
 protected void editForm_OnBeforeSave(object sender, EventArgs e)
 {
     // Initialize order for new profile
     if (editForm.Mode == FormModeEnum.Insert)
     {
         editForm.Data["ProfileOrder"] = DeviceProfileInfoProvider.GetLastProfileOrder() + 1;
     }
 }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        var deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0);

        if (deviceProfileId == 0)
        {
            var deviceLayoutId = QueryHelper.GetInteger("devicelayoutid", 0);
            var deviceLayout   = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(deviceLayoutId);
            if (deviceLayout != null)
            {
                deviceProfileId = deviceLayout.ProfileID;
            }
        }

        var deviceProfile = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId);

        if (deviceProfile != null)
        {
            deviceLayoutHeaderUrl  = string.Format(deviceLayoutHeaderUrl, PageTemplateID, deviceProfileId);
            deviceLayoutContentUrl = string.Format(deviceLayoutContentUrl, PageTemplateID, deviceProfileId, deviceProfile.ProfileName);
        }

        var editOnlyCode = QueryHelper.GetBoolean("editonlycode", false);

        if (editOnlyCode)
        {
            deviceLayoutHeaderUrl  = URLHelper.AddParameterToUrl(deviceLayoutHeaderUrl, "editonlycode", "1");
            deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "dialogmode", "1");
            deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "tabmode", "1");
        }

        var deviceActions = QueryHelper.GetBoolean("deviceactions", true);

        deviceLayoutHeaderUrl  = URLHelper.AddParameterToUrl(deviceLayoutHeaderUrl, "deviceactions", deviceActions ? "1" : "0");
        deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "deviceactions", deviceActions ? "1" : "0");

        // Include the AliasPath parameter to ensure path pre-selection in the preview control
        string aliasPath = QueryHelper.GetString("aliaspath", null);

        if (!string.IsNullOrEmpty(aliasPath))
        {
            deviceLayoutHeaderUrl  = URLHelper.AddParameterToUrl(deviceLayoutHeaderUrl, "aliaspath", aliasPath);
            deviceLayoutContentUrl = URLHelper.AddParameterToUrl(deviceLayoutContentUrl, "aliaspath", aliasPath);
        }

        string aliasPathParam = (string.IsNullOrEmpty(aliasPath) ? string.Empty : "&aliaspath=" + aliasPath);

        string script = @"
function RefreshAfterDelete() {
    location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_DeviceLayouts.aspx?templateid=" + PageTemplateID + aliasPathParam) + @"';
}";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "refreshGrid", script, true);
    }
    /// <summary>
    /// Groups created event handler.
    /// </summary>
    protected void ucUIToolbar_OnGroupsCreated(object sender, List <Group> groups)
    {
        if (!IsPageNotFound)
        {
            // Replace Culture button
            Group culture = groups.Find(g => g.CssClass.Contains("OnSiteCultures"));
            if (culture != null)
            {
                // Hide culture selector when there is only one culture for the current site
                InfoDataSet <CultureInfo> sites = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);
                if ((sites.Tables[0].Rows.Count < 2) ||
                    (IsPageNotFound && OnSiteEditHelper.PageInfoForPageNotFound.NodeID == 0))
                {
                    // Remove the culture button
                    groups.Remove(culture);
                }
                else
                {
                    culture.ControlPath = "~/CMSAdminControls/UI/UniMenu/OnSiteEdit/CultureMenu.ascx";
                }
            }

            // Replace Device profile button
            Group deviceProfile = groups.Find(g => g.CssClass.Contains("OnSiteDeviceProfile"));
            if (deviceProfile != null)
            {
                // Hide device profile selector when there is only one device defined or device profile module is disabled
                if (!DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName))
                {
                    // Remove the device profile button
                    groups.Remove(deviceProfile);
                }
                else
                {
                    deviceProfile.ControlPath = "~/CMSModules/DeviceProfile/Controls/ProfilesMenuControl.ascx";
                }
            }

            // Replace the Highlight and Hidden buttons
            Group otherGroup = groups.Find(g => g.CssClass.Contains("OnSiteOthers"));
            if (otherGroup != null)
            {
                otherGroup.ControlPath = "~/CMSAdminControls/UI/UniMenu/OnSiteEdit/OtherMenu.ascx";
            }

            // Use a specific css class for the large CMSDesk button
            if (largeCMSDeskButton)
            {
                Group adminsGroup = groups.Find(g => g.CssClass.Contains("OnSiteAdmins"));
                if (adminsGroup != null)
                {
                    adminsGroup.CssClass += " BigCMSDeskButton";
                }
            }
        }
    }
Пример #5
0
    void gridProfiles_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        case "moveup":
            DeviceProfileInfoProvider.MoveProfileUp(ValidationHelper.GetInteger(actionArgument, 0));
            break;

        case "movedown":
            DeviceProfileInfoProvider.MoveProfileDown(ValidationHelper.GetInteger(actionArgument, 0));
            break;
        }
    }
    /// <summary>
    /// Handles the PreRender event of the Page control.
    /// </summary>
    protected void Page_PreRender(object sender, EventArgs e)
    {
        DeviceProfileInfo oldDevice = (currentDevice != null ? currentDevice.Clone() : null);

        currentDevice = DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(SiteContext.CurrentSiteName, true);

        // Reload device menu if profile changed by postback. Apply this, only if no device was selected from outside environment via 'SelectedDevice' property.
        if ((SelectedDevice == null) && DeviceChanged(oldDevice, currentDevice))
        {
            buttons.Buttons.Clear();
            LoadDevicesMenu();
            buttons.ReloadButtons();
        }
    }
Пример #7
0
    /// <summary>
    /// Initialize device preview frame.
    /// </summary>
    private void InitializeDevicePreview()
    {
        // Get device ID from query string
        String deviceName = QueryHelper.GetString(DeviceProfileInfoProvider.DEVICENAME_QUERY_PARAM, String.Empty);

        // If device profile not set, use current device profile
        DeviceProfileInfo deviceProfile = DeviceContext.CurrentDeviceProfile;

        // Add hash control for X-Frame-Option
        if (deviceName != String.Empty)
        {
            ViewPage = URLHelper.UpdateParameterInUrl(ViewPage, DeviceProfileInfoProvider.DEVICENAME_QUERY_PARAM, deviceName);

            String query = URLHelper.GetQuery(ViewPage);
            string hash  = ValidationHelper.GetHashString(query, new HashSettings {
                UserSpecific = false
            });
            ViewPage += String.Format("&clickjackinghash={0}", hash);
        }

        // If device's boundaries are set, use iframe
        if ((deviceProfile != null) && (deviceProfile.ProfilePreviewWidth > 0) && (deviceProfile.ProfilePreviewHeight > 0))
        {
            // Remove frame scrolling
            mFramescroll = "no";

            // Register device css from site name folder or design folder
            DeviceProfileInfoProvider.RegisterDeviceProfileCss(Page, deviceProfile.ProfileName);

            pnlDevice.CssClass += " " + deviceProfile.ProfileName;

            string deviceScript = "CMSView.RotateCookieName = '" + CookieName.CurrentDeviceProfileRotate + "';";
            deviceScript += String.Format("CMSView.InitializeFrame({0}, {1}, {2}); CMSView.ResizeContentArea();",
                                          deviceProfile.ProfilePreviewWidth,
                                          deviceProfile.ProfilePreviewHeight,
                                          (RotateDevice ? "true" : "false"));

            ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeDeviceFrame", deviceScript, true);
        }
        else
        {
            // Hide all device frame divs
            pnlTop.Visible         = false;
            pnlBottom.Visible      = false;
            pnlLeft.Visible        = false;
            pnlRight.Visible       = false;
            pnlCenter.CssClass     = String.Empty;
            pnlCenterLine.CssClass = String.Empty;
        }
    }
    public override void OnInit()
    {
        Control.OnTabCreated += Control_OnTabCreated;

        var info = Control.UIContext.EditedObject as PageTemplateDeviceLayoutInfo;

        if (info != null)
        {
            DeviceProfileInfo dpi = DeviceProfileInfoProvider.GetDeviceProfileInfo(info.ProfileID);
            if (dpi != null)
            {
                deviceName = dpi.ProfileName;
            }
        }
    }
Пример #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        imgShow.ImageUrl       = GetImageUrl("CMSModules/CMS_Content/ContextMenu/refresh.png");
        imgShow.ToolTip        = GetString("general.refresh");
        ucPath.UseImageButtons = true;

        TrimPreviewValues();
        ProcessLanguageAndDeviceChange();
        pnlDevice.Visible = DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName);

        if (PreviewObjectName != String.Empty)
        {
            String script = "function ChangeLanguage(culture) {" + ControlsHelper.GetPostBackEventReference(btnLanguage, "#").Replace("'#'", "culture") + "}";
            script += "function ChangeDevice(device) {" + ControlsHelper.GetPostBackEventReference(btnDevice, "#").Replace("'#'", "device") + "}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "PostbackScript", ScriptHelper.GetScript(script));
        }
    }
Пример #10
0
    /// <summary>
    /// Init event handler.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        // Show devices selection button
        if (DeviceProfileInfoProvider.IsDeviceProfilesEnabled(SiteContext.CurrentSiteName) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.DeviceProfiles))
        {
            ucProfiles = LoadControl("~/CMSModules/DeviceProfile/Controls/ProfilesMenuControl.ascx") as InlineUserControl;
            if (ucProfiles != null)
            {
                ucProfiles.ID = "ucProfiles";
                ucProfiles.SetValue("UseSmallButton", true);
                ucProfiles.SetValue("DisplayRotateButtons", true);
                plcDevice.Controls.Add(ucProfiles);
                plcDevice.Visible = true;
            }
        }
        else
        {
            plcDevice.Visible = false;
        }

        base.OnInit(e);
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(SiteContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice);
        LoadDevicesMenu();

        if (UseSmallButton &&
            (currentDevice != null) &&
            ((PortalContext.ViewMode == ViewModeEnum.Preview) || DisplayRotateButtons)
            )
        {
            bool isHorizontalDevice      = (currentDevice.ProfilePreviewWidth > currentDevice.ProfilePreviewHeight);
            bool isHorizontalOrientation = isHorizontalDevice;

            // Define the rotation buttons
            CMSButtonGroupAction hButton = new CMSButtonGroupAction {
                UseIconButton = true, Name = LAYOUT_HORIZONTAL, OnClientClick = "return false;", IconCssClass = "icon-rectangle-o-h", ToolTip = GetString("device.landscape")
            };
            CMSButtonGroupAction vButton = new CMSButtonGroupAction {
                UseIconButton = true, Name = LAYOUT_VERTICAL, OnClientClick = "return false;", IconCssClass = "icon-rectangle-o-v", ToolTip = GetString("device.portrait")
            };

            // Append the rotation buttons
            rotationButtons.Actions.Add(hButton);
            rotationButtons.Actions.Add(vButton);
            rotationButtons.Visible = true;

            // Get the current device rotation state
            isRotated = ValidationHelper.GetBoolean(CookieHelper.GetValue(CookieName.CurrentDeviceProfileRotate), false);
            if (isRotated)
            {
                isHorizontalOrientation = !isHorizontalOrientation;
            }

            // Highlight the currently selected rotation button
            rotationButtons.SelectedActionName = (isHorizontalOrientation) ? LAYOUT_HORIZONTAL : LAYOUT_VERTICAL;

            StringBuilder sb = new StringBuilder();
            sb.Append(@"
var CMSDeviceProfile = {
    Rotated: ", isRotated.ToString().ToLower(), @",
    Initialized: false,
    OnRotationFunction: null,
    PreviewUrl: null,

    Init: function () {
        if (!this.Initialized) {
            this.Initialized = true;
            var rotateBtns = $cmsj('.device-rotation').find('button');
            var activeClass = '", activeButtonCssClass, @"';
            rotateBtns.bind('click', function () {
                var jThis = $cmsj(this);
                var selected = jThis.hasClass(activeClass);
                if (!selected) {
                    rotateBtns.removeClass(activeClass);
                    jThis.addClass(activeClass);
                    $cmsj.cookie('", CookieName.CurrentDeviceProfileRotate, @"', !CMSDeviceProfile.Rotated, { path: '/' } );

                    if (CMSDeviceProfile.OnRotationFunction != null) {
                        CMSDeviceProfile.OnRotationFunction(this, !CMSDeviceProfile.Rotated);
                    }
                }
            });
        }
    }
}

$cmsj(document).ready(function () {
    CMSDeviceProfile.Init();
});");

            ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "deviceProfileScript", sb.ToString(), true);
        }
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Setup the page variables
        templateId      = QueryHelper.GetInteger("templateid", 0);
        deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0);

        if (deviceProfileId > 0)
        {
            // Display device profile label
            showNewDeviceSelector = false;

            DeviceProfileInfo deviceLayout = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId);
            if (deviceLayout != null)
            {
                lblNewDevice.Text = GetString("devicelayout.createdevicelayout") + ": <strong>" + HTMLHelper.HTMLEncode(deviceLayout.ProfileDisplayName) + "</strong>";
            }
        }
        else
        {
            // Display device profile selector
            pnlNewDevice.Visible = true;
            lblNewDevice.Visible = false;
        }

        // Setup the page title
        PageTitle.TitleText = GetString("devicelayout.new");

        // Source device profile selector
        ucDeviceProfile.WhereCondition = "ProfileID IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE PageTemplateID = " + templateId + ")";
        ucDeviceProfile.SpecialFields.Add(new SpecialField {
            Text = GetString("devicelayout.defaultdeviceprofile"), Value = "0"
        });

        // New device profile selector
        // Do not display profiles which have layout already defined
        ucNewDeviceProfile.WhereCondition = "(ProfileEnabled = 1) AND (ProfileID NOT IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE (PageTemplateID = " + templateId + ")))";
        ucNewDeviceProfile.OrderBy        = "ProfileOrder";
        ucNewDeviceProfile.SpecialFields.Add(new SpecialField {
            Text = GetString("devicelayout.selectdeviceprofile"), Value = ""
        });
        ucNewDeviceProfile.OnBeforeClientChanged = "EnableSelection(value.length > 0);";

        // Javascript
        rbtnDevice.Attributes.Add("onclick", "EnableSelection(true)");
        rbtnLayout.Attributes.Add("onclick", "EnableSelection(true)");
        rbtnEmptyLayout.Attributes.Add("onclick", "EnableSelection(true)");

        if (!RequestHelper.IsPostBack())
        {
            rbtnDevice.Checked = true;
        }

        // Register the page javascript
        string script = @"

function EnableSelection(enabled) {
    var pnlContent = $cmsj('#" + pnlContent.ClientID + @" :input');
    if (enabled) {
        pnlContent.removeAttr('disabled');
        
        var rbtnDevice = $cmsj('#" + rbtnDevice.ClientID + @"');
        var rbtnLayout = $cmsj('#" + rbtnLayout.ClientID + @"');
        var pnlLayout = $cmsj('#" + pnlLayout.ClientID + @" :input');
        var pnlDevice = $cmsj('#" + pnlDevice.ClientID + @" :input');
        if (rbtnDevice.is(':checked')) {
            pnlLayout.attr('disabled', 'disabled');
        }
        else if (rbtnLayout.is(':checked')) {
            pnlDevice.attr('disabled', 'disabled');
        }
        else {
            pnlLayout.attr('disabled', 'disabled');
            pnlDevice.attr('disabled', 'disabled');
        }
    }
    else {
        pnlContent.attr('disabled', 'disabled');
    }

    $cmsj('#" + pnlNewDevice.ClientID + @" :input').removeAttr('disabled');
}

$cmsj(document).ready(function () {
    EnableSelection(" + (showNewDeviceSelector ? "false" : "true") + @");
});";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "layoutScript", script, true);
        ScriptHelper.RegisterJQuery(Page);

        Save += SaveAction;
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (PageTemplate != null)
        {
            // Initialize page title
            string title = GetString("Administration-PageTemplate_Header.TemplateProperties");

            // Check if the object exists - if not->redirect and inform the user
            EditedObject = PageTemplate;

            PageTemplateCategoryInfo categoryInfo = PageTemplateCategoryInfoProvider.GetPageTemplateCategoryInfo(PageTemplate.CategoryID);
            string currentPageTemplate            = HTMLHelper.HTMLEncode(PageTemplate.DisplayName);
            string[,] breadcrumbs;

            if (!isDialog)
            {
                breadcrumbs = new string[3, 4];

                breadcrumbs[0, 0] = GetString("development.pagetemplates");
                breadcrumbs[0, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx");
                breadcrumbs[0, 2] = "_parent";
                breadcrumbs[0, 3] = "if (parent.parent.frames['pt_tree']) { parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx") + "'; }";

                if (categoryInfo != null)
                {
                    breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(categoryInfo.DisplayName);
                    breadcrumbs[1, 1] = URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Category_Frameset.aspx?categoryid=" + PageTemplate.CategoryID);
                    breadcrumbs[1, 2] = "_parent";
                    breadcrumbs[1, 3] = "if (parent.parent.frames['pt_tree']) { parent.parent.frames['pt_tree'].location.href = '" + URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Tree.aspx?categoryid=" + PageTemplate.CategoryID) + "'; }";

                    breadcrumbs[2, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
                    breadcrumbs[2, 1] = "";
                    breadcrumbs[2, 2] = "";
                }
            }
            else
            {
                breadcrumbs = new string[2, 3];

                breadcrumbs[0, 0] = GetString("development.pagetemplates");
                breadcrumbs[0, 1] = "";
                breadcrumbs[0, 2] = "";

                breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(currentPageTemplate);
                breadcrumbs[1, 1] = "";
                breadcrumbs[1, 2] = "";

                if (PageTemplate.IsReusable)
                {
                    CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_PageTemplates/pagetemplate.png");
                }
                else
                {
                    CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_PageTemplates/adhoc.png");
                }
                CurrentMaster.Title.TitleText = title;
            }

            CurrentMaster.Title.Breadcrumbs   = breadcrumbs;
            CurrentMaster.Title.HelpTopicName = "general_tab12";
            CurrentMaster.Title.HelpName      = "helpTopic";

            // Initialize menu
            int    i = 0;
            string defaultDeviceProfileQuery = "&devicename=default&ObjectLifeTime=request";

            string dialog = String.Empty;
            if (isDialog)
            {
                dialog = "&dialog=1";
            }

            // General tab
            SetTab(i, GetString("general.general"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_General.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'general_tab12');");
            i++;

            bool showDesign = ((PageTemplate.PageTemplateType == PageTemplateTypeEnum.Portal) || (PageTemplate.PageTemplateType == PageTemplateTypeEnum.Dashboard));

            // Design tab
            if (!isDialog && showDesign)
            {
                SetTab(i, GetString("edittabs.design"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Design.aspx?templateid=" + PageTemplateID + defaultDeviceProfileQuery), "SetHelpTopic('helpTopic', 'design_tab2');");
                i++;
            }

            if (showDesign)
            {
                string aliasPath = QueryHelper.GetString("aliaspath", string.Empty);
                string query     = string.IsNullOrEmpty(aliasPath) ? "" : "&aliasPath=" + aliasPath;
                query += defaultDeviceProfileQuery;

                // Layouts tab
                SetTab(i, GetString("Administration-PageTemplate_Header.Layouts"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageLayouts/PageLayout_Edit.aspx?allowswitch=1&templateid=" + PageTemplateID + dialog + query), "SetHelpTopic('helpTopic', 'layout');");
                i++;

                // Show the Device layouts tab
                bool deviceProfilesEnabled = DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName);
                if (deviceProfilesEnabled && (PageTemplate.PageTemplateType == PageTemplateTypeEnum.Portal))
                {
                    // Device layouts tab
                    SetTab(i, "Device layouts", URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_DeviceLayouts.aspx?templateid=" + PageTemplateID + dialog + query), "SetHelpTopic('helpTopic', 'device_layouts');");
                    i++;
                }
            }

            CurrentUserInfo user = CMSContext.CurrentUser;
            if (!isDialog && (PageTemplate.IsReusable) && user.UserSiteManagerAdmin)
            {
                // Sites tab
                SetTab(i, GetString("general.sites"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Sites.aspx?templateid=" + PageTemplateID), "SetHelpTopic('helpTopic', 'sites_tab2');");
                i++;

                if (PageTemplate.PageTemplateType != PageTemplateTypeEnum.Dashboard)
                {
                    // Scopes tab
                    SetTab(i, GetString("pagetemplate.edit.scopes"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/Scopes/PageTemplateScopes_List.aspx?templateid=" + PageTemplateID), "SetHelpTopic('helpTopic', 'page_templates_scopes');");
                    i++;
                }
            }

            if (showDesign && PageTemplate.IsReusable && !StorageHelper.IsExternalStorage(PageTemplate.GetThemePath()) && user.UserSiteManagerAdmin)
            {
                // Theme tab
                SetTab(i, GetString("Stylesheet.Theme"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Theme.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'page_templates_theme');");
                i++;
            }

            // Show web part tab
            if (showDesign || (PageTemplate.PageTemplateType == PageTemplateTypeEnum.AspxPortal))
            {
                // Web parts tab
                if ((!isDialog || SettingsKeyProvider.DevelopmentMode) && CurrentUser.IsGlobalAdministrator)
                {
                    SetTab(i, GetString("Administration-PageTemplate_Header.WebParts"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_WebParts.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'web_parts');");
                    i++;

                    if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSShowTemplateASPXTab"], false))
                    {
                        // ASPX tab
                        SetTab(i, GetString("Administration-PageTemplate_Header.ASPX"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_ASPX.aspx?templateid=" + PageTemplateID), "SetHelpTopic('helpTopic', 'page_templates_aspx_code');");
                        i++;
                    }
                }
            }

            if (PageTemplate.PageTemplateType != PageTemplateTypeEnum.Dashboard)
            {
                // Header tab
                SetTab(i, GetString("Administration-PageTemplate_Header.Header"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_HeaderTab.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'header');");
                i++;

                // Documents tab
                SetTab(i, GetString("general.documents"), URLHelper.ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Documents.aspx?templateid=" + PageTemplateID + dialog), "SetHelpTopic('helpTopic', 'page_templates_documents');");
                i++;
            }
        }
    }
Пример #14
0
    /// <summary>
    /// Groups created event handler.
    /// </summary>
    protected void ucUIToolbar_OnGroupsCreated(object sender, List <Group> groups)
    {
        // Try handle culture menu for page not found caused by untranslated document
        if (IsPageNotFound)
        {
            PageInfo pi = DocumentContext.CurrentCultureInvariantPageInfo;
            if ((pi != null) && (pi.NodeID != 0))
            {
                ReplaceCultureButton(groups);
            }
        }
        // Do not process groups for page not found
        else
        {
            // Show "Save" button only when the current page contains an editor widget zone.
            Group widgetsCategory = groups.Find(g => g.CssClass.Contains("OnSiteWidgetsCategory"));
            if ((widgetsCategory != null) &&
                (PortalManager.PageTemplate != null) && (PortalManager.PageTemplate.TemplateInstance != null) && (PortalManager.PageTemplate.TemplateInstance.WebPartZones != null))
            {
                bool showSaveButton = false;
                foreach (var zoneInstance in PortalManager.PageTemplate.TemplateInstance.WebPartZones)
                {
                    if (zoneInstance.WidgetZoneType == WidgetZoneTypeEnum.Editor)
                    {
                        showSaveButton = true;
                        break;
                    }
                }

                if (!showSaveButton)
                {
                    // No editor widget zones found => remove Save button
                    groups.Remove(widgetsCategory);
                }
            }

            ReplaceCultureButton(groups);

            // Replace Device profile button
            Group deviceProfile = groups.Find(g => g.CssClass.Contains("OnSiteDeviceProfile"));
            if (deviceProfile != null)
            {
                // Hide device profile selector when there is only one device defined or device profile module is disabled or license is not sufficient
                if (!DeviceProfileInfoProvider.IsDeviceProfilesEnabled(SiteContext.CurrentSiteName) || !LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.DeviceProfiles))
                {
                    // Remove the device profile button
                    groups.Remove(deviceProfile);
                }
                else
                {
                    deviceProfile.ControlPath = "~/CMSModules/DeviceProfile/Controls/ProfilesMenuControl.ascx";
                }
            }

            // Replace the Highlight and Hidden buttons
            Group otherGroup = groups.Find(g => g.CssClass.Contains("OnSiteOthers"));
            if (otherGroup != null)
            {
                otherGroup.ControlPath = "~/CMSAdminControls/UI/UniMenu/OnSiteEdit/OtherMenu.ascx";
            }

            Group adminsGroup = groups.Find(g => g.CssClass.Contains("OnSiteAdmins"));
            if (adminsGroup != null)
            {
                adminsGroup.CssClass += " BigCMSDeskButton";
            }
        }
    }
Пример #15
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Setup the page variables
        templateId      = QueryHelper.GetInteger("templateid", 0);
        deviceProfileId = QueryHelper.GetInteger("deviceprofileid", 0);

        if (deviceProfileId > 0)
        {
            // Display device profile label
            showNewDeviceSelector = false;

            DeviceProfileInfo deviceLayout = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId);
            if (deviceLayout != null)
            {
                lblNewDevice.Text = GetString("devicelayout.createdevicelayout") + ": <strong>" + HTMLHelper.HTMLEncode(deviceLayout.ProfileDisplayName) + "</strong>";
            }
        }
        else
        {
            // Display device profile selector
            pnlNewDevice.Visible = true;
            lblNewDevice.Visible = false;
        }

        // Setup the page title
        CurrentMaster.Title.TitleText     = GetString("devicelayout.new");
        CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_DeviceProfile/new.png");
        CurrentMaster.Title.HelpTopicName = "CMS_Design_page_device_layout";
        CurrentMaster.Title.HelpName      = "helpTopic";

        // Source device profile selector
        ucDeviceProfile.WhereCondition = "ProfileID IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE PageTemplateID = " + templateId + ")";
        ucDeviceProfile.SpecialFields  = new string[, ] {
            { GetString("devicelayout.defaultdeviceprofile"), "0" }
        };

        // New device profile selector
        // Do not display profiles which have layout already defined
        ucNewDeviceProfile.WhereCondition = "(ProfileEnabled = 1) AND (ProfileID NOT IN (SELECT ProfileID FROM CMS_TemplateDeviceLayout WHERE (PageTemplateID = " + templateId + ")))";
        ucNewDeviceProfile.OrderBy        = "ProfileOrder";
        ucNewDeviceProfile.SpecialFields  = new string[, ] {
            { GetString("devicelayout.selectdeviceprofile"), "" }
        };
        ucNewDeviceProfile.OnBeforeClientChanged = "EnableSelection(this.value.length > 0);";

        // Javascript
        rbtnDevice.Attributes.Add("onclick", "EnableSelection(true)");
        rbtnLayout.Attributes.Add("onclick", "EnableSelection(true)");
        rbtnEmptyLayout.Attributes.Add("onclick", "EnableSelection(true)");

        if (!RequestHelper.IsPostBack())
        {
            rbtnDevice.Checked = true;
        }

        // Register the page javascript
        string script = @"

function EnableSelection(enabled) {
    var pnlContent = jQuery('#" + pnlContent.ClientID + @" :input');
    if (enabled) {
        pnlContent.removeAttr('disabled');
        
        var rbtnDevice = jQuery('#" + rbtnDevice.ClientID + @"');
        var rbtnLayout = jQuery('#" + rbtnLayout.ClientID + @"');
        var pnlLayout = jQuery('#" + pnlLayout.ClientID + @" :input');
        var pnlDevice = jQuery('#" + pnlDevice.ClientID + @" :input');
        if (rbtnDevice.is(':checked')) {
            pnlLayout.attr('disabled', 'disabled');
        }
        else if (rbtnLayout.is(':checked')) {
            pnlDevice.attr('disabled', 'disabled');
        }
        else {
            pnlLayout.attr('disabled', 'disabled');
            pnlDevice.attr('disabled', 'disabled');
        }
    }
    else {
        pnlContent.attr('disabled', 'disabled');
    }

    jQuery('#" + pnlNewDevice.ClientID + @" :input').removeAttr('disabled');
}

jQuery(document).ready(function () {
    EnableSelection(" + (showNewDeviceSelector ? "false" : "true") + @");
});";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "layoutScript", script, true);
        ScriptHelper.RegisterJQuery(Page);

        // Empty footer container
        if (CurrentMaster.PanelFooter != null)
        {
            CurrentMaster.PanelFooter.Controls.Clear();
        }

        // Add the Cancel button to the footer panel
        LocalizedButton btnOk = new LocalizedButton
        {
            ID             = "btnOk",
            ResourceString = "general.ok",
            CssClass       = "SubmitButton",
        };

        btnOk.Click += new EventHandler(SaveAction);

        // Add the Cancel button to the footer panel
        LocalizedButton btnCancel = new LocalizedButton
        {
            ID             = "btnCancel",
            ResourceString = "general.cancel",
            CssClass       = "SubmitButton",
            OnClientClick  = "CloseDialog(); return false;"
        };

        // Button container panel
        Panel pnlRight = new Panel
        {
            ID       = "pnlRight",
            CssClass = "TextRight"
        };

        pnlRight.Controls.Add(btnOk);
        pnlRight.Controls.Add(btnCancel);

        // Add the Ok, Cancel buttons to the footer controls collection
        if (CurrentMaster.PanelFooter != null)
        {
            CurrentMaster.PanelFooter.Controls.Add(pnlRight);
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(CMSContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice);
     LoadDevicesMenu();
 }
    /// <summary>
    /// Loads device profile menu.
    /// </summary>
    private void LoadDevicesMenu()
    {
        if (UseSmallButton)
        {
            plcSmallButton.Visible = true;
        }
        else
        {
            plcBigButton.Visible = true;
        }

        string        defaultString    = HTMLHelper.HTMLEncode(GetString("deviceselector.default", ResourceCulture));
        StringBuilder sbDeviceProfiles = new StringBuilder();
        MenuItem      devMenuItem      = null;

        if (!UseSmallButton)
        {
            devMenuItem = new MenuItem
            {
                Text    = defaultString,
                Tooltip = defaultString,
            };

            // Display icon in On-site editing
            if ((Page is PortalPage) || (Page is TemplatePage))
            {
                devMenuItem.IconClass = "icon-monitor-smartphone";
            }

            SetStyles(devMenuItem);
            buttons.Buttons.Add(devMenuItem);
        }

        // Load enabled profiles
        InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfiles()
                                             .WhereEquals("ProfileEnabled", 1)
                                             .OrderBy("ProfileOrder")
                                             .TypedResult;

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Create default item
            SubMenuItem defaultMenuItem = new SubMenuItem
            {
                Text          = defaultString,
                Tooltip       = defaultString,
                OnClientClick = "ChangeDevice('');",
            };

            if (UseSmallButton)
            {
                // Insert the current device profile to the button
                btnProfilesSelector.Actions.Add(new CMSButtonAction()
                {
                    OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(defaultString)),
                    Text          = defaultString
                });
            }
            else
            {
                // Insert the current device profile to the context menu
                devMenuItem.SubItems.Add(defaultMenuItem);
            }

            // Load the profiles list
            foreach (DeviceProfileInfo profileInfo in ds.Items)
            {
                string          profileName  = GetString(profileInfo.ProfileDisplayName, ResourceCulture);
                CMSButtonAction deviceButton = null;

                if (UseSmallButton)
                {
                    deviceButton = new CMSButtonAction()
                    {
                        OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(profileInfo.ProfileName)),
                        Text          = profileName,
                        Name          = profileName
                    };

                    btnProfilesSelector.Actions.Add(deviceButton);
                }
                else
                {
                    SubMenuItem menuItem = new SubMenuItem
                    {
                        Text          = HTMLHelper.HTMLEncode(profileName),
                        Tooltip       = HTMLHelper.HTMLEncode(profileName),
                        OnClientClick = String.Format("ChangeDevice({0});", ScriptHelper.GetString(profileInfo.ProfileName))
                    };
                    devMenuItem.SubItems.Add(menuItem);
                }

                // Update main button if current device profile is equal currently processed profile
                if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0))
                {
                    if (UseSmallButton)
                    {
                        btnProfilesSelector.SelectedActionName = profileName;
                    }
                    else
                    {
                        devMenuItem.Text    = HTMLHelper.HTMLEncode(profileName);
                        devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName);
                    }
                }
            }
        }
    }
Пример #18
0
    /// <summary>
    /// Gets the edited object.
    /// </summary>
    /// <param name="templateId">The template id - if template/device layout is being edited</param>
    /// <param name="layoutId">The layout id - if shared layout is being edited</param>
    /// <param name="newSharedLayoutId">The new shared layout id - when changing shared layouts for template/device layouts</param>
    /// <param name="oldSharedLayoutId">The old shared layout id - when changing shared layouts for template/device layouts</param>
    /// <param name="deviceProfileId">The device profile id</param>
    private object GetEditedObject(int templateId, int layoutId, int newSharedLayoutId, int oldSharedLayoutId, int deviceProfileId)
    {
        object editedObject = null;

        if (templateId > 0)
        {
            PageTemplateInfo           pti         = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
            DeviceProfileInfo          profileInfo = DeviceProfileInfoProvider.GetDeviceProfileInfo(deviceProfileId);
            PageTemplateLayoutTypeEnum type        = PageTemplateLayoutTypeEnum.PageTemplateLayout;

            // Standard page template layout
            if (pti != null)
            {
                // Check modify shared templates permission
                if (pti.IsReusable && !CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", "Design.ModifySharedTemplates"))
                {
                    RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Design.ModifySharedTemplates");
                }

                // Default state - no radio buttons used
                if ((newSharedLayoutId == -1) && (oldSharedLayoutId == -1))
                {
                    editedObject = PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(pti, profileInfo, out type);
                }
                else
                {
                    // If new shared layout is set, than it should be used as edited object
                    // This happens when switched from custom to a shared layout
                    if (newSharedLayoutId > 0)
                    {
                        // Standard page layout
                        editedObject = LayoutInfoProvider.GetLayoutInfo(newSharedLayoutId);
                    }
                    else if (newSharedLayoutId == 0)
                    {
                        // This means user switched from shared layout to custom
                        // Data has to be copied to PageTemplateInfo

                        PageTemplateDeviceLayoutInfo deviceLayout = null;
                        if (deviceProfileId > 0)
                        {
                            // Get the current device layout if exists
                            deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(templateId, deviceProfileId);
                            if (deviceLayout != null)
                            {
                                // Custom device layout (use old layout)
                                editedObject = PageTemplateDeviceLayoutInfoProvider.CloneInfoObject(deviceLayout, oldSharedLayoutId) as PageTemplateDeviceLayoutInfo;
                            }
                        }
                        else
                        {
                            // We have to work with the clone, because we need to change the data of the object
                            // (copy from shared layout)
                            editedObject = PageTemplateDeviceLayoutInfoProvider.CloneInfoObject(pti, oldSharedLayoutId) as PageTemplateInfo;
                        }
                    }
                }
            }
        }
        else
        {
            // Load the object
            if (layoutId > 0)
            {
                editedObject = LayoutInfoProvider.GetLayoutInfo(layoutId);
            }
        }

        return(editedObject);
    }
Пример #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialize menu
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

        Group content = new Group
        {
            Caption     = GetString("ContentMenu.ContentManagement"),
            ControlPath = "~/CMSAdminControls/UI/UniMenu/Content/ContentMenu.ascx",
            CssClass    = "ContentMenuGroup"
        };

        contentMenu.Groups.Add(content);

        CMSUserControl modeMenu = Page.LoadUserControl("~/CMSAdminControls/UI/UniMenu/Content/ModeMenu.ascx") as CMSUserControl;

        if (modeMenu != null)
        {
            modeMenu.ID = "grpMode";
            modeMenu.SetValue("SelectedMode", SelectedMode);
            Group view = new Group
            {
                Caption  = GetString("ContentMenu.ViewMode"),
                Control  = modeMenu,
                CssClass = "ContentMenuGroup"
            };
            contentMenu.Groups.Add(view);
        }

        if (DeviceProfileInfoProvider.IsDeviceProfilesEnabled(CMSContext.CurrentSiteName))
        {
            CMSUserControl devicesMenu = Page.LoadUserControl("~/CMSModules/DeviceProfile/Controls/ProfilesMenuControl.ascx") as CMSUserControl;
            if (devicesMenu != null)
            {
                devicesMenu.ID = "grpDevices";
                devicesMenu.SetValue("SelectedDevice", SelectedDevice);
                Group view = new Group
                {
                    Caption  = GetString("ContentMenu.Device"),
                    Control  = devicesMenu,
                    CssClass = "ContentMenuGroup"
                };
                contentMenu.Groups.Add(view);
            }
        }

        // Do not display language menu
        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS) && (siteCulturesDS.Tables[0].Rows.Count > 1))
        {
            CMSUserControl langMenu = Page.LoadUserControl("~/CMSModules/Content/Controls/LanguageMenu.ascx") as CMSUserControl;
            if (langMenu != null)
            {
                langMenu.ID = "grpLang";
                langMenu.SetValue("SelectedCulture", SelectedCulture);
                Group lang = new Group
                {
                    Control  = langMenu,
                    Caption  = GetString("contentmenu.language"),
                    CssClass = "ContentMenuGroup"
                };
                contentMenu.Groups.Add(lang);
            }
        }

        Group other = new Group
        {
            Caption     = GetString("contentmenu.other"),
            ControlPath = "~/CMSAdminControls/UI/UniMenu/Content/OtherMenu.ascx",
            CssClass    = "ContentMenuGroup"
        };

        contentMenu.Groups.Add(other);
    }
Пример #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check if current device is desktop
        if ((CookieHelper.CurrentCookieLevel < CookieLevel.Essential) || (String.IsNullOrEmpty(DeviceContext.CurrentDeviceProfileName) && String.IsNullOrEmpty(DeviceProfileInfoProvider.GetOriginalCurrentDevicProfileName(CurrentSite.SiteName))))
        {
            pnlContent.Visible = false;
            return;
        }

        bool useDesktop = ViewMode.IsLiveSite() ? ShowDesktopVersion : String.IsNullOrEmpty(DeviceContext.CurrentDeviceProfileName);

        lnkLink.Text = ContextResolver.ResolveMacros(useDesktop ? LinkContentDesktop : LinkContentMobile);
    }
    /// <summary>
    /// Loads device profile menu.
    /// </summary>
    private void LoadDevicesMenu()
    {
        string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_list.png");
        string defaultBigIconUrl   = GetImageUrl("CMSModules/CMS_DeviceProfile/default.png");

        if ((Page is PortalPage) || (Page is TemplatePage))
        {
            // Display grayscale icon in On-site editing
            defaultBigIconUrl   = GetImageUrl("CMSModules/CMS_DeviceProfile/default_grayscale.png");
            defaultSmallIconUrl = defaultBigIconUrl;
        }

        string deviceSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/list.png");
        string deviceBigIconUrl   = GetImageUrl("CMSModules/CMS_DeviceProfile/module.png");

        string defaultString = HTMLHelper.HTMLEncode(GetString("general.default"));

        MenuItem devMenuItem = new MenuItem
        {
            Text         = defaultString,
            Tooltip      = defaultString,
            ImagePath    = defaultBigIconUrl,
            ImageAltText = defaultString
        };

        SetStyles(devMenuItem);
        buttons.Buttons.Add(devMenuItem);

        // Load enabled profiles
        InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfileInfos("ProfileEnabled = 1", "ProfileOrder");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Create default item
            SubMenuItem defaultMenuItem = new SubMenuItem
            {
                Text          = defaultString,
                Tooltip       = defaultString,
                ImagePath     = defaultSmallIconUrl,
                ImageAltText  = defaultString,
                OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice('');", ScriptHelper.GetString(defaultString), ScriptHelper.GetString(ResolveUrl(defaultBigIconUrl)))
            };

            devMenuItem.SubItems.Add(defaultMenuItem);

            foreach (DeviceProfileInfo profileInfo in ds.Items)
            {
                string bigIconUrl   = null;
                string smallIconUrl = null;
                if (profileInfo.ProfileIconGuid == Guid.Empty)
                {
                    smallIconUrl = deviceSmallIconUrl;
                    bigIconUrl   = deviceBigIconUrl;
                }
                else
                {
                    string iconUrl = MetaFileURLProvider.GetMetaFileUrl(profileInfo.ProfileIconGuid, profileInfo.ProfileName);
                    smallIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "16");
                    bigIconUrl   = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "24");
                }

                string      profileName = GetString(profileInfo.ProfileDisplayName);
                SubMenuItem menuItem    = new SubMenuItem
                {
                    Text          = HTMLHelper.HTMLEncode(profileName),
                    Tooltip       = HTMLHelper.HTMLEncode(profileName),
                    ImagePath     = smallIconUrl,
                    ImageAltText  = HTMLHelper.HTMLEncode(profileName),
                    OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice({2});", ScriptHelper.GetString(profileName), ScriptHelper.GetString(ResolveUrl(bigIconUrl)), ScriptHelper.GetString(profileInfo.ProfileName))
                };

                devMenuItem.SubItems.Add(menuItem);

                // Update main button if current device profile is equal currently processed profile
                if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0))
                {
                    devMenuItem.Text         = HTMLHelper.HTMLEncode(profileName);
                    devMenuItem.Tooltip      = HTMLHelper.HTMLEncode(profileName);
                    devMenuItem.ImagePath    = bigIconUrl;
                    devMenuItem.ImageAltText = HTMLHelper.HTMLEncode(profileName);
                }
            }
        }
    }