Beispiel #1
0
 public static List <ListItem> GetTemplates(PortalSettings portalSettings, int moduleId, FileUri selectedTemplate, string moduleSubDir)
 {
     if (selectedTemplate == null)
     {
         return(GetTemplates(portalSettings, moduleId, null as TemplateManifest, moduleSubDir));
     }
     return(GetTemplates(portalSettings, moduleId, selectedTemplate.ToTemplateManifest(), moduleSubDir));
 }
        public List <PageDto> GetDetailPages(string template, int tabModuleId)
        {
            string format;
            int    othermoduleTabId = ActiveModule.TabID;
            int    moduleId         = ActiveModule.ModuleID;

            var listItems   = new List <PageDto>();
            var templateUri = new FileUri(template);
            var manifest    = templateUri.ToTemplateManifest();

            int othermoduleDetailTabId = -1;

            if (manifest != null && manifest.IsListTemplate && manifest.Manifest.Templates.Any(t => t.Value.Detail != null))
            {
                if (tabModuleId > 0)
                {
                    var dsModule = (new ModuleController()).GetTabModule(tabModuleId);
                    othermoduleTabId       = dsModule.TabID;
                    moduleId               = dsModule.ModuleID;
                    othermoduleDetailTabId = GetOtherModuleDetailTabId(othermoduleTabId, moduleId);
                    //if (othermoduleDetailTabId > 0)
                    //{
                    //    //add extra li with "Default Detail Page" directly to dropdown
                    //    format = LogContext.IsLogActive ? "Main Module Detail Page - [{0}]" : "Main Module Detail Page";
                    //    listItems.Add(new PageDto()
                    //    {
                    //        Text = string.Format(format, othermoduleDetailTabId),
                    //        TabId = othermoduleDetailTabId
                    //    });
                    //}
                }

                Dictionary <string, int> tabs = TabController.GetTabPathDictionary(ActiveModule.PortalID, DnnLanguageUtils.GetCurrentCultureCode());

                foreach (var tabId in tabs.Where(i => IsTabWithModuleWithSameMainModule(i.Value, moduleId) && IsAccessibleTab(i.Value)))
                {
                    string tabname = tabId.Key.Replace("//", " / ").TrimStart(" / ");

                    List <string> infoText = new List <string>();

                    if (othermoduleDetailTabId > 0 && tabId.Value == othermoduleDetailTabId)
                    {
                        infoText.Add("Main Module Detail");
                    }

                    if ((othermoduleTabId > 0 && tabId.Value == othermoduleTabId) || (othermoduleTabId == -1 && tabId.Value == ActiveModule.TabID))
                    {
                        //add extra li with "Main Module Page" directly to dropdown
                        //format = LogContext.IsLogActive ? "Main Module Page - {0} [{1}]" : "Main Module Page";
                        //listItems.Add(new PageDto()
                        //{
                        //    Text = string.Format(format, tabname, tabId.Value),
                        //    TabId = -1
                        //});
                        infoText.Add("Main Module ");
                    }
                    if (othermoduleTabId > 0 && tabId.Value == ActiveModule.TabID)
                    {
                        //add extra li with "CurrentPage" directly to dropdown
                        //format = LogContext.IsLogActive ? "Current Page - {0} [{1}]" : "Current Page";
                        //listItems.Add(new PageDto()
                        //{
                        //    Text = string.Format(format, tabname, tabId.Value),
                        //    TabId = tabId.Value
                        //});
                        infoText.Add("Current");
                    }

                    format = LogContext.IsLogActive ? "{0} [{1}]" : "{0}";
                    if (othermoduleTabId > 0 && tabId.Value == ActiveModule.TabID)
                    {
                        listItems.Add(new PageDto()
                        {
                            Text  = string.Format(format, tabname, tabId.Value) + " (Current)",
                            TabId = tabId.Value
                        });
                    }
                    else
                    {
                        listItems.Add(new PageDto()
                        {
                            Text  = string.Format(format, tabname, tabId.Value) + (infoText.Any() ? " (" + string.Join(",", infoText.ToArray()) + ")" : ""),
                            TabId = tabId.Value
                        });
                    }
                }

                return(listItems.OrderBy(x => x.Text).ToList());
            }
            return(listItems);
        }