Ejemplo n.º 1
0
    /// <summary>
    /// PreInit event handler.
    /// </summary>
    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);

        // Init the page components
        manPortal.SetMainPagePlaceholder(plc);

        var ui = UIElementInfoProvider.GetUIElementInfo(QueryHelper.GetInteger("elementid", 0));

        // Clear UIContext data of element "Modules.UserInterface.Design" (put by UIElement attribute to check permissions)
        UIContext.Data = null;

        if (ui != null)
        {
            UIContext.UIElement = ui;

            // Store resource name
            UIContext.ResourceName = UIContextHelper.GetResourceName(ui.ElementResourceID);

            int pageTemplateId = ui.ElementPageTemplateID;

            // If no page template is set, dont show any content
            if (pageTemplateId == 0)
            {
                RedirectToInformation(GetString("uielement.design.notemplate"));
            }

            // Prepare the page info
            PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pageTemplateId);
            pi.DocumentNamePath = "/" + ResHelper.GetString("edittabs.design");

            DocumentContext.CurrentPageInfo = pi;

            // Set the design mode
            bool enable = (SystemContext.DevelopmentMode || (ui.ElementResourceID == QueryHelper.GetInteger("moduleId", 0) && ui.ElementIsCustom));
            PortalContext.SetRequestViewMode(ViewModeEnum.Design);

            // If displayed module is not selected, disable design mode
            if (!enable)
            {
                plc.ViewMode = ViewModeEnum.DesignDisabled;
            }

            ContextHelper.Add("DisplayContentInDesignMode", PortalHelper.DisplayContentInUIElementDesignMode, true, false, false, DateTime.MinValue);

            ManagersContainer    = plcManagers;
            ScriptManagerControl = manScript;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Gets HTML list code representing the <paramref name="uiElement"/> where can visitors go after the import has finished.
    /// </summary>
    /// <param name="uiElement">UI element the caption, icon and link are loaded from</param>
    /// <param name="description">Description of the element (i.e. some clarification what the application is good for)</param>
    /// <returns>HTML list code representing the <paramref name="uiElement"/> with given <paramref name="description"/></returns>
    private string GetContinueToSmartTipListContent(UIElementInfo uiElement, string description)
    {
        string applicationUrl = UIContextHelper.GetApplicationUrl(UIContextHelper.GetResourceName(uiElement.ElementResourceID), uiElement.ElementName);

        return(string.Format(@"
<li>
    <div class=""om-import-csv-next-steps-initial"">
        <i aria-hidden=""true"" class=""{0} cms-icon-100""></i>
    </div>
    <div class=""om-import-csv-next-steps-description"">
        <p class=""lead"">
            <a href=""{1}"" target=""_blank"">{2}</a>
        </p>
        <p>
            {3}
        </p>
    </div>
</li>", uiElement.ElementIconClass, URLHelper.ResolveUrl(applicationUrl), MacroResolver.Resolve(uiElement.ElementCaption), description));
    }
Ejemplo n.º 3
0
    protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode)
    {
        // Get data
        if (itemData != null)
        {
            int    id                 = ValidationHelper.GetInteger(itemData["ElementID"], 0);
            int    childCount         = ValidationHelper.GetInteger(itemData["ElementChildCount"], 0);
            bool   selected           = ValidationHelper.GetBoolean(itemData["ElementSelected"], false);
            string displayName        = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ValidationHelper.GetString(itemData["ElementDisplayName"], string.Empty)));
            string elementName        = ValidationHelper.GetString(itemData["ElementName"], string.Empty).ToLowerCSafe();
            int    parentID           = ValidationHelper.GetInteger(itemData["ElementParentID"], 0);
            int    resourceID         = ValidationHelper.GetInteger(itemData["ElementResourceID"], 0);
            string nodePath           = ValidationHelper.GetString(itemData["ElementIDPath"], string.Empty);
            string itemClass          = "ContentTreeItem";
            string onClickDeclaration = string.Format(" var chkElem_{0} = document.getElementById('chk_{0}'); ", id);
            string onClickCommon      = string.Format("  hdnValue.value = {0} + ';' + chkElem_{0}.checked; {1};", id, CallbackRef);
            string onClickSpan        = string.Format(" chkElem_{0}.checked = !chkElem_{0}.checked; ", id);

            // Expand for root
            if (parentID == 0)
            {
                defaultNode.Expanded = true;
            }

            string[] paths = treeElem.ExpandPath.ToLowerCSafe().Split(';');
            if (!nodePath.EndsWith("/"))
            {
                nodePath += "/";
            }

            bool chkEnabled = Enabled;
            if (!SingleModule && (ModuleID > 0))
            {
                bool isEndItem = false;
                bool isChild   = false;
                bool isParent  = false;

                // Check expanded paths
                for (int i = 0; i < paths.Length; i++)
                {
                    String path = paths[i];
                    if (path != String.Empty)
                    {
                        // Add slash - select only children
                        if (!path.EndsWith("/"))
                        {
                            path += "/";
                        }

                        if (!isChild)
                        {
                            isChild = nodePath.StartsWith(path);
                        }

                        // Module node is same node as specified in paths collection
                        isEndItem = (path == nodePath);

                        // Test for parent - expand
                        if ((path.StartsWithCSafe(nodePath)))
                        {
                            defaultNode.Expanded = true;
                            isParent             = true;
                            break;
                        }
                    }
                }

                // Display for non selected module items
                if (resourceID != ModuleID)
                {
                    // Parent special css
                    if (isParent)
                    {
                        itemClass += " highlighted disabled";
                    }
                    else
                    {
                        // Disable non parent
                        chkEnabled = false;
                        itemClass += " disabled";
                    }
                }
                else if (isEndItem)
                {
                    // Special class for end module item
                    itemClass += " highlighted";
                }
            }

            // Get button links
            string links = null;

            string nodeText;
            if (!String.IsNullOrEmpty(GroupPreffix) && elementName.ToLowerCSafe().StartsWithCSafe(GroupPreffix.ToLowerCSafe()))
            {
                if (childCount > 0 && chkEnabled)
                {
                    links = string.Format(SELECT_DESELECT_LINKS, id, "false", CallbackRef, GetString("uiprofile.selectall"), GetString("uiprofile.deselectall"));
                }
                nodeText = string.Format("<span class='{0}'>{1}</span>{2}", itemClass, displayName, links);
            }
            else
            {
                string warning = string.Empty;

                if (SiteName != null)
                {
                    if (!ResourceSiteInfoProvider.IsResourceOnSite(UIContextHelper.GetResourceName(resourceID), SiteName))
                    {
                        warning = UIHelper.GetAccessibleIconTag("icon-exclamation-triangle", String.Format(GetString("uiprofile.warningmodule"), "cms." + elementName), additionalClass: "color-orange-80");
                    }
                }

                if (childCount > 0 && chkEnabled)
                {
                    links = string.Format(SELECT_DESELECT_LINKS, id, "true", CallbackRef, GetString("uiprofile.selectall"), GetString("uiprofile.deselectall"));
                }

                nodeText = string.Format(@"<span class='checkbox tree-checkbox'><input type='checkbox' id='chk_{0}' name='chk_{0}'{1}{2} onclick=""{3}"" /><label for='chk_{0}'>&nbsp;</label><span class='{4}' onclick=""{5} return false;""><span class='Name'>{6}</span></span>{7}</span>{8}",
                                         id,
                                         chkEnabled ? string.Empty : " disabled='disabled'",
                                         selected ? " checked='checked'" : string.Empty,
                                         chkEnabled ? onClickDeclaration + onClickCommon : "return false;",
                                         itemClass,
                                         chkEnabled ? onClickDeclaration + onClickSpan + onClickCommon : "return false;",
                                         displayName,
                                         warning,
                                         links);
            }

            defaultNode.ToolTip = string.Empty;
            defaultNode.Text    = nodeText;
        }

        return(defaultNode);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Gets application path for dashboard tiles.
    /// </summary>
    /// <param name="resourceID">Resource ID</param>
    /// <param name="elementName">Element name</param>
    protected string GetApplicationPath(object resourceID, object elementName)
    {
        string path = UIContextHelper.GetApplicationUrl(UIContextHelper.GetResourceName(Convert.ToInt32(resourceID)), elementName.ToString());

        return(URLHelper.ResolveUrl(path));
    }