private string GetTabUrl(int portalId, int moduleTabId, string queryString) { var url = DnnUrlUtils.NavigateUrl(moduleTabId); return(url); //var portalSettings = new PortalSettings(portalId); //portalSettings.PortalAlias = PortalAliasController.Instance.GetPortalAlias(portalSettings.DefaultPortalAlias); //var url = TestableGlobals.Instance.NavigateURL(moduleTabId, portalSettings, string.Empty, queryString); //return url; }
public override JToken GetModelAsJson(bool onlyData = false, bool onlyMainData = false) { if (_portalSettings == null) { onlyData = true; } JObject model = new JObject(); var itemsModel = model; ExtendModel(model, onlyData, onlyMainData); ExtendSchemaOptions(itemsModel, onlyData || onlyMainData); ExtendItemsModel(itemsModel, onlyData || onlyMainData); if (!onlyData && !onlyMainData) { itemsModel["Context"]["RssUrl"] = _portalSettings.PortalAlias.HTTPAlias + "/DesktopModules/OpenContent/API/RssAPI/GetFeed?moduleId=" + _module.ViewModule.ModuleID + "&tabId=" + _detailTabId; } JArray items = new JArray();; itemsModel["Items"] = items; //string editRole = Manifest.GetEditRole(); if (_dataList != null && _dataList.Any()) { var mainUrl = Globals.NavigateURL(_detailTabId, false, _portalSettings, "", GetCurrentCultureCode(), ""); foreach (var item in _dataList) { JObject dyn = item.Data as JObject; JObject context = new JObject(); dyn["Context"] = context; context["Id"] = item.Id; EnhanceSelect2(dyn, onlyData); JsonUtils.SimplifyJson(dyn, GetCurrentCultureCode()); EnhanceUser(dyn, item.CreatedByUserId); EnhanceImages(dyn, itemsModel); if (onlyData) { RemoveNoData(itemsModel); } else { var editStatus = !_manifest.DisableEdit && IsEditAllowed(item.CreatedByUserId); context["IsEditable"] = editStatus; if (HasEditPermissions(item.CreatedByUserId)) { context["EditUrl"] = DnnUrlUtils.EditUrl("id", item.Id, _module.ViewModule.ModuleID, _portalSettings); } context["DetailUrl"] = GenerateDetailUrl(item, dyn, _manifest, _detailTabId); context["MainUrl"] = mainUrl; } items.Add(dyn); } } return(model); }
public static bool CheckOpenContentSettings(ModuleInfo module, OpenContentSettings settings) { bool result = true; if (module != null && settings != null && settings.TemplateKey != null && settings.TemplateKey.TemplateDir != null && !settings.TemplateKey.TemplateDir.FolderExists) { var url = DnnUrlUtils.NavigateUrl(module.TabID); Log.Logger.ErrorFormat("Error loading OpenContent Template on page [{5}-{4}-{1}] module [{2}-{3}]. Reason: Template not found [{0}]", settings.TemplateKey.ToString(), url, module.ModuleID, module.ModuleTitle, module.TabID, module.PortalID); result = false; } return(result); }
public static bool CheckOpenContentSettings(OpenContentModuleInfo module) { bool result = true; var settings = module.Settings; if (settings?.TemplateKey?.TemplateDir != null && !settings.TemplateKey.TemplateDir.FolderExists) { var url = DnnUrlUtils.NavigateUrl(module.ViewModule.TabID); Log.Logger.Error($"Error loading OpenContent Template on page [{module.ViewModule.PortalID}-{module.ViewModule.TabID}-{url}] module [{module.ViewModule.ModuleID}-{module.ViewModule.ModuleTitle}]. Reason: Template not found [{settings.TemplateKey}]"); result = false; } return(result); }
private void ExtendModelSingle(JObject model) { if (_data != null) { var context = model["Context"]; if (Detail) { context["DetailUrl"] = GenerateDetailUrl(_data, model, _manifest, _detailTabId); context["Id"] = _data.Id; var editIsAllowed = !_manifest.DisableEdit && IsEditAllowed(_data.CreatedByUserId); context["EditUrl"] = editIsAllowed ? DnnUrlUtils.EditUrl("id", _data.Id, _module.ViewModule.ModuleID, _portalSettings) : ""; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); JavaScript.RequestRegistration(CommonJs.DnnPlugins); cmdSave.Click += cmdSave_Click; var m = ModuleContext.Configuration; TabController tc = new TabController(); var mc = new ModuleController(); // its the same for each module -> to cache var til = TabController.GetTabsBySortOrder(PortalSettings.PortalId, m.CultureCode, true) .Where(t => /*!t.IsDeleted &&*/ t.ParentId != PortalSettings.AdminTabId && t.TabID != PortalSettings.AdminTabId && t.CultureCode == m.CultureCode); //var tid = tc.GetTabsByModuleID(m.ModuleID); var tmiLst = mc.GetAllTabsModulesByModuleID(m.ModuleID).Cast <ModuleInfo>(); foreach (TabInfo ti in til) { { ListItem li = new ListItem(ti.TabName, ti.TabID.ToString()); li.Text = $"{ti.IndentedTabName} <a href='{DnnUrlUtils.NavigateUrl(ti.TabID)}' target='_blank' style='font-size: 10px;text-decoration: none;' class='clonetabid'>({ti.TabID})</span></a>"; li.Enabled = ti.TabID != m.TabID; cblPages.Items.Add(li); ModuleInfo tmi = tmiLst.SingleOrDefault(t => t.TabID == ti.TabID); //if (tid.Keys.Contains(ti.TabID)) if (tmi != null) { if (tmi.IsDeleted) { //li.Enabled = false; li.Text = $"<i>{li.Text}</i>"; } else { li.Selected = true; } } } } }
private static string PrepareErrorMessage(DnnApiController ctrl, Exception exc) { string friendlyMessage = string.Format("PortalId: {3} \nTab: {4} - {5} \nModule: {0} \nContext: {2} \nError: {1}", ctrl.ActiveModule.ModuleID, exc.Message, LoggingUtils.HttpRequestLogInfo(HttpContext.Current), ctrl.ActiveModule.PortalID, ctrl.ActiveModule.TabID, DnnUrlUtils.NavigateUrl(ctrl.ActiveModule.TabID) ); Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = exc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }
private static string PrepareErrorMessage(DotNetNuke.Web.Razor.RazorModuleBase ctrl, Exception exc) { string friendlyMessage = string.Format("Alias: {3} \nTab: {4} - {5} \nModule: {0} \nContext: {2} \nError: {1}", ctrl.ModuleContext.ModuleId, exc.Message, LoggingUtils.HttpRequestLogInfo(HttpContext.Current), ctrl.ModuleContext.PortalAlias.HTTPAlias, ctrl.ModuleContext.TabId, DnnUrlUtils.NavigateUrl(ctrl.ModuleContext.TabId) ); Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = lastExc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }
private static string PrepareErrorMessage(ModuleInfo module, Exception exc) { var ps = PortalSettings.Current; string friendlyMessage = string.Format("Alias: {3} \nTab: {4} - {5} \nModule: {0} \nContext: {2} \nError: {1}", module.ModuleID, exc.Message, LoggingUtils.HttpRequestLogInfo(HttpContext.Current), ps.PortalAlias.HTTPAlias, ps.ActiveTab.TabID, DnnUrlUtils.NavigateUrl(ps.ActiveTab.TabID) ); Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = lastExc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }
private static string PrepareErrorMessage(RenderEngine renderEngine, Exception exc) { var ps = PortalSettings.Current; string friendlyMessage; if (ps == null) { friendlyMessage = $"Alias: unknown \nTab: unknown - {DnnUrlUtils.NavigateUrl(renderEngine.ModuleConfig.TabId)} \nModule: {renderEngine.ModuleConfig.ModuleId} \nContext: {HttpRequestLogInfo(HttpContext.Current)} \nError: {exc.Message}"; } else { friendlyMessage = $"Alias: {ps.PortalAlias.HTTPAlias} \nTab: {ps.ActiveTab.TabID} - {DnnUrlUtils.NavigateUrl(ps.ActiveTab.TabID)} \nModule: {renderEngine.ModuleConfig.ModuleId} \nContext: {HttpRequestLogInfo(HttpContext.Current)} \nError: {exc.Message}"; } Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = lastExc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }
private void ExtendModelSingle(JObject model) { if (_data != null) { var context = model["Context"]; if (Detail) { string url = ""; if (!string.IsNullOrEmpty(_manifest?.DetailUrl)) { HandlebarsEngine hbEngine = new HandlebarsEngine(); var dynForHBS = JsonUtils.JsonToDictionary(model.ToString()); url = hbEngine.Execute(_manifest.DetailUrl, dynForHBS); url = HttpUtility.HtmlDecode(url); } context["DetailUrl"] = Globals.NavigateURL(_detailTabId, false, _portalSettings, "", GetCurrentCultureCode(), url.CleanupUrl(), "id=" + _data.Id); context["Id"] = _data.Id; var editIsAllowed = !_manifest.DisableEdit && IsEditAllowed(_data.CreatedByUserId); context["EditUrl"] = editIsAllowed ? DnnUrlUtils.EditUrl("id", _data.Id, _module.ViewModule.ModuleID, _portalSettings) : ""; } } }
private void ExtendItemsModel(JObject model, bool onlyData) { if (_portalSettings == null) { onlyData = true; } if (!onlyData) { // include CONTEXT in the Model JObject context; if (model["Context"] is JObject) { context = model["Context"] as JObject; } else { context = new JObject(); model["Context"] = context; } context["AddUrl"] = DnnUrlUtils.EditUrl(_module.ViewModule.ModuleID, _portalSettings); } }
private JToken GetModelAsJsonFromList(bool onlyData) { JObject model = new JObject(); if (!onlyData) { CompleteModel(model, onlyData); model["Context"]["RssUrl"] = PortalSettings.PortalAlias.HTTPAlias + "/DesktopModules/OpenContent/API/RssAPI/GetFeed?moduleId=" + Module.ModuleID + "&tabId=" + MainTabId; } JArray items = new JArray();; model["Items"] = items; string editRole = Manifest.GetEditRole(); if (DataList != null && DataList.Any()) { foreach (var item in DataList) { JObject dyn = item.Data as JObject; if (LocaleController.Instance.GetLocales(PortalId).Count > 1) { JsonUtils.SimplifyJson(dyn, GetCurrentCultureCode()); } if (Manifest != null && Manifest.AdditionalDataExists() && model["AdditionalData"] != null && model["Options"] != null) { JsonUtils.LookupJson(dyn, model["AdditionalData"] as JObject, model["Options"] as JObject); } if (Options != null && model["Options"] != null) { JsonUtils.ImagesJson(dyn, Options, model["Options"] as JObject, IsEditable); } JObject context = new JObject(); dyn["Context"] = context; context["Id"] = item.Id; if (onlyData) { if (model["Settings"] != null) { model.Remove("Settings"); } if (model["Schema"] != null) { model.Remove("Schema"); } if (model["Options"] != null) { model.Remove("Options"); } if (model["AdditionalData"] != null) { model.Remove("AdditionalData"); } } else { string url = ""; if (Manifest != null && !string.IsNullOrEmpty(Manifest.DetailUrl)) { HandlebarsEngine hbEngine = new HandlebarsEngine(); dynamic dynForHBS = JsonUtils.JsonToDynamic(dyn.ToString()); url = hbEngine.Execute(Manifest.DetailUrl, dynForHBS); url = HttpUtility.HtmlDecode(url); } var editStatus = GetEditStatus(item.CreatedByUserId); context["IsEditable"] = editStatus; context["EditUrl"] = editStatus ? DnnUrlUtils.EditUrl("id", item.Id, Module.ModuleID, PortalSettings) : ""; context["DetailUrl"] = Globals.NavigateURL(MainTabId, false, PortalSettings, "", GetCurrentCultureCode(), url.CleanupUrl(), "id=" + item.Id); context["MainUrl"] = Globals.NavigateURL(MainTabId, false, PortalSettings, "", GetCurrentCultureCode(), ""); } items.Add(dyn); } } return(model); }
internal string EditUrl(int moduleId) { return(DnnUrlUtils.EditUrl(moduleId, _portalSettings)); }
public string GetDocUrl(SearchResult searchResult) { return(DnnUrlUtils.NavigateUrl(searchResult.TabId)); }
internal string GetUrl(int detailTabId, string cultureCode, string pagename, string idParam) { return(DnnUrlUtils.NavigateUrl(detailTabId, cultureCode, _portalSettings, pagename, idParam)); }
private static string PrepareErrorMessage(ModuleInfo module, Exception exc) { var ps = PortalSettings.Current; var friendlyMessage = $"Alias: {ps.PortalAlias.HTTPAlias} \nTab: {ps.ActiveTab.TabID} - {DnnUrlUtils.NavigateUrl(ps.ActiveTab.TabID)} \nModule: {module.ModuleID} \nContext: {LoggingUtils.HttpRequestLogInfo(HttpContext.Current)} \nError: {exc.Message}"; Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = lastExc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }
public List <MenuAction> GetMenuActions() { var actions = new List <MenuAction>(); TemplateManifest template = _settings.Template; bool templateDefined = template != null; bool isListPageRequest = _renderinfo.IsListPageRequest; bool isDetailPageRequest = _renderinfo.IsDetailPageRequest; //Add item / Edit Item if (templateDefined && template.DataNeeded() && !_settings.Manifest.DisableEdit) { string title = App.Services.Localizer.GetString(isListPageRequest ? "Add.Action" : "Edit.Action", ResourceFile); if (!string.IsNullOrEmpty(_settings.Manifest.Title)) { title = title + " " + _settings.Manifest.Title; } actions.Add( new MenuAction( title, isListPageRequest ? "~/DesktopModules/OpenContent/images/addcontent2.png" : "~/DesktopModules/OpenContent/images/editcontent2.png", isDetailPageRequest ? RenderContext.EditUrl("id", _renderinfo.DetailItemId) : RenderContext.EditUrl(), ActionType.Add ) ); } //Add AdditionalData manage actions if (templateDefined && template.Manifest.AdditionalDataDefined() && !_settings.Manifest.DisableEdit) { foreach (var addData in template.Manifest.AdditionalDataDefinition) { if (addData.Value.SourceRelatedDataSource == RelatedDataSourceType.AdditionalData) { actions.Add( new MenuAction( addData.Value.Title, "~/DesktopModules/OpenContent/images/editcontent2.png", RenderContext.EditUrl("key", addData.Key, "EditAddData"), ActionType.Edit ) ); } else { actions.Add( new MenuAction( addData.Value.Title, "~/DesktopModules/OpenContent/images/editcontent2.png", DnnUrlUtils.NavigateUrl(addData.Value.DataTabId), ActionType.Edit ) ); } } } //Manage Form Submissions if (templateDefined && OpenContentUtils.FormExist(_settings.Template.ManifestFolderUri)) { actions.Add( new MenuAction( "Submissions", "~/DesktopModules/OpenContent/images/editcontent2.png", RenderContext.EditUrl("Submissions"), ActionType.Edit ) ); } //Edit Template Settings if (templateDefined && _settings.Template.SettingsNeeded()) { actions.Add( new MenuAction( App.Services.Localizer.GetString("EditSettings.Action", ResourceFile), "~/DesktopModules/OpenContent/images/editsettings2.png", RenderContext.EditUrl("EditSettings"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); } //Edit Form Settings if (templateDefined && OpenContentUtils.FormExist(_settings.Template.ManifestFolderUri)) { actions.Add( new MenuAction( App.Services.Localizer.GetString("FormSettings.Action", ResourceFile), "~/DesktopModules/OpenContent/images/editsettings2.png", RenderContext.EditUrl("formsettings"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); } //Edit Notifications Settings if (templateDefined) { actions.Add( new MenuAction( App.Services.Localizer.GetString("Notifications.Action", ResourceFile), "~/DesktopModules/OpenContent/images/editsettings2.png", RenderContext.EditUrl("notifications"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); } //if (templateDefined) //{ // actions.Add(ModuleContext.GetNextActionID(), // Localization.GetString("Notifications.Action", LocalResourceFile), // ModuleActionType.ContentOptions, // "", // "~/DesktopModules/OpenContent/images/editsettings2.png", // ModuleContext.EditUrl("notifications"), // false, // SecurityAccessLevel.Admin, // true, // false); //} //Switch Template actions.Add( new MenuAction( App.Services.Localizer.GetString("EditInit.Action", ResourceFile), "~/DesktopModules/OpenContent/images/editinit.png", RenderContext.EditUrl("EditInit"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); //Edit Filter Settings if (templateDefined && _renderinfo.IsListMode) { if (_settings.Manifest.Index) { actions.Add( new MenuAction( App.Services.Localizer.GetString("EditQuery.Action", ResourceFile), "~/DesktopModules/OpenContent/images/editfilter.png", RenderContext.EditUrl("EditQuery"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); } } //Form Builder if (templateDefined && OpenContentUtils.BuildersExist(_settings.Template.ManifestFolderUri)) { actions.Add( new MenuAction( App.Services.Localizer.GetString("Builder.Action", ResourceFile), "~/DesktopModules/OpenContent/images/formbuilder.png", RenderContext.EditUrl("FormBuilder"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); } //Edit Template Files if (templateDefined) { actions.Add( new MenuAction( App.Services.Localizer.GetString("EditTemplate.Action", ResourceFile), "~/DesktopModules/OpenContent/images/edittemplate.png", RenderContext.EditUrl("EditTemplate"), ActionType.Misc, SecurityAccessLevel.SuperUserRights ) ); } //Edit Raw Data if (templateDefined && _settings.Manifest != null && (template.DataNeeded() || template.SettingsNeeded() || template.Manifest.AdditionalDataDefined()) && !_settings.Manifest.DisableEdit) { actions.Add( new MenuAction( App.Services.Localizer.GetString("EditData.Action", ResourceFile), "~/DesktopModules/OpenContent/images/edit.png", isDetailPageRequest ? RenderContext.EditUrl("id", _renderinfo.DetailItemId, "EditData") : RenderContext.EditUrl("EditData"), ActionType.Edit, SecurityAccessLevel.SuperUserRights ) ); } //Template Exchange actions.Add( new MenuAction( App.Services.Localizer.GetString("ShareTemplate.Action", ResourceFile), "~/DesktopModules/OpenContent/images/exchange.png", RenderContext.EditUrl("ShareTemplate"), ActionType.Misc, SecurityAccessLevel.SuperUserRights ) ); //Clone Module actions.Add( new MenuAction( App.Services.Localizer.GetString("CloneModule.Action", ResourceFile), "~/DesktopModules/OpenContent/images/clonemodule.png", RenderContext.EditUrl("CloneModule"), ActionType.Misc, SecurityAccessLevel.AdminRights ) ); //Edit Global Settings actions.Add( new MenuAction( App.Services.Localizer.GetString("EditGlobalSettings.Action", ResourceFile), "~/DesktopModules/OpenContent/images/settings.png", RenderContext.EditUrl("EditGlobalSettings"), ActionType.Misc, SecurityAccessLevel.SuperUserRights ) ); //Help actions.Add( new MenuAction( App.Services.Localizer.GetString("Help.Action", ResourceFile), "~/DesktopModules/OpenContent/images/help.png", "https://opencontent.readme.io", ActionType.Misc, SecurityAccessLevel.SuperUserRights, true ) ); return(actions); }
private void CompleteModel(JObject model, bool onlyData) { if (!onlyData && TemplateFiles != null && TemplateFiles.SchemaInTemplate) { // schema string schemaFilename = PhysicalTemplateFolder + "schema.json"; model["Schema"] = JsonUtils.GetJsonFromFile(schemaFilename); } if (TemplateFiles != null && TemplateFiles.OptionsInTemplate) { // options JToken optionsJson = null; // default options string optionsFilename = PhysicalTemplateFolder + "options.json"; if (File.Exists(optionsFilename)) { string fileContent = File.ReadAllText(optionsFilename); if (!string.IsNullOrWhiteSpace(fileContent)) { optionsJson = fileContent.ToJObject("Options"); } } // language options optionsFilename = PhysicalTemplateFolder + "options." + GetCurrentCultureCode() + ".json"; if (File.Exists(optionsFilename)) { string fileContent = File.ReadAllText(optionsFilename); if (!string.IsNullOrWhiteSpace(fileContent)) { var extraJson = fileContent.ToJObject("Options cultureSpecific"); if (optionsJson == null) { optionsJson = extraJson; } else { optionsJson = optionsJson.JsonMerge(extraJson); } } } if (optionsJson != null) { model["Options"] = optionsJson; } } // additional data if (TemplateFiles != null && TemplateFiles.AdditionalDataInTemplate && Manifest.AdditionalDataExists()) { var additionalData = model["AdditionalData"] = new JObject(); foreach (var item in Manifest.AdditionalData) { var dataManifest = item.Value; var ds = DataSourceManager.GetDataSource(Manifest.DataSource); var dsContext = new DataSourceContext() { PortalId = PortalId, TabId = Module.TabID, ModuleId = MainModuleId, TabModuleId = Module.TabModuleID, Config = Manifest.DataSourceConfig, }; var dsItem = ds.GetData(dsContext, dataManifest.ScopeType, dataManifest.StorageKey ?? item.Key); JToken additionalDataJson = new JObject(); if (dsItem != null && dsItem.Data != null) { if (LocaleController.Instance.GetLocales(PortalId).Count > 1) { JsonUtils.SimplifyJson(dsItem.Data, GetCurrentCultureCode()); } additionalDataJson = dsItem.Data; } additionalData[(item.Value.ModelKey ?? item.Key).ToLowerInvariant()] = additionalDataJson; } } // settings if (!onlyData && TemplateManifest.SettingsNeeded() && !string.IsNullOrEmpty(settingsJson)) { try { dataJson = JToken.Parse(settingsJson); if (LocaleController.Instance.GetLocales(PortalId).Count > 1) { JsonUtils.SimplifyJson(dataJson, GetCurrentCultureCode()); } model["Settings"] = dataJson; } catch (Exception ex) { throw new Exception("Error parsing Json of Settings", ex); } } // static localization if (!onlyData) { JToken localizationJson = null; string localizationFilename = PhysicalTemplateFolder + GetCurrentCultureCode() + ".json"; if (File.Exists(localizationFilename)) { string fileContent = File.ReadAllText(localizationFilename); if (!string.IsNullOrWhiteSpace(fileContent)) { localizationJson = fileContent.ToJObject("Localization: " + localizationFilename); } } if (localizationJson != null) { model["Localization"] = localizationJson; } } if (!onlyData) { // context JObject context = new JObject(); model["Context"] = context; context["ModuleId"] = Module.ModuleID; context["ModuleTitle"] = Module.ModuleTitle; context["AddUrl"] = DnnUrlUtils.EditUrl(Module.ModuleID, PortalSettings); var editStatus = GetEditStatus(-1); context["IsEditable"] = editStatus; context["PortalId"] = PortalId; context["MainUrl"] = Globals.NavigateURL(MainTabId, false, PortalSettings, "", GetCurrentCultureCode()); if (Data != null) { string url = ""; if (Manifest != null && !string.IsNullOrEmpty(Manifest.DetailUrl)) { HandlebarsEngine hbEngine = new HandlebarsEngine(); dynamic dynForHBS = JsonUtils.JsonToDynamic(model.ToString()); url = hbEngine.Execute(Manifest.DetailUrl, dynForHBS); url = HttpUtility.HtmlDecode(url); } context["DetailUrl"] = Globals.NavigateURL(MainTabId, false, PortalSettings, "", GetCurrentCultureCode(), url.CleanupUrl(), "id=" + Data.Id); context["Id"] = Data.Id; context["EditUrl"] = editStatus ? DnnUrlUtils.EditUrl("id", Data.Id, Module.ModuleID, PortalSettings) : ""; } } }
public string EditAddDataUrl(string id, string itemId, int viewModuleModuleId) { return(DnnUrlUtils.EditAddDataUrl(id, itemId, viewModuleModuleId, _portalSettings)); }
public override JToken GetModelAsJson(bool onlyData = false, bool onlyMainData = false) { if (_portalSettings == null) { onlyData = true; } JObject model = new JObject(); var itemsModel = model; ExtendModel(model, onlyData, onlyMainData); ExtendSchemaOptions(itemsModel, onlyData || onlyMainData); ExtendItemsModel(itemsModel, onlyData || onlyMainData); if (!onlyData && !onlyMainData) { itemsModel["Context"]["RssUrl"] = _portalSettings.PortalAlias.HTTPAlias + "/DesktopModules/OpenContent/API/RssAPI/GetFeed?moduleId=" + _module.ViewModule.ModuleID + "&tabId=" + _detailTabId; } JArray items = new JArray();; itemsModel["Items"] = items; //string editRole = Manifest.GetEditRole(); if (_dataList != null && _dataList.Any()) { var mainUrl = Globals.NavigateURL(_detailTabId, false, _portalSettings, "", GetCurrentCultureCode(), ""); foreach (var item in _dataList) { JObject dyn = item.Data as JObject; JObject context = new JObject(); dyn["Context"] = context; context["Id"] = item.Id; if (LocaleController.Instance.GetLocales(_portalId).Count > 1) { JsonUtils.SimplifyJson(dyn, GetCurrentCultureCode()); } EnhanceSelect2(dyn); EnhanceUser(dyn, item.CreatedByUserId); EnhanceImages(dyn, itemsModel); if (onlyData) { RemoveNoData(itemsModel); } else { string url = ""; if (!string.IsNullOrEmpty(_manifest.DetailUrl)) { HandlebarsEngine hbEngine = new HandlebarsEngine(); var dynForHBS = JsonUtils.JsonToDictionary(dyn.ToString()); url = hbEngine.Execute(_manifest.DetailUrl, dynForHBS); url = HttpUtility.HtmlDecode(url); } var editStatus = !_manifest.DisableEdit && IsEditAllowed(item.CreatedByUserId); context["IsEditable"] = editStatus; if (HasEditPermissions(item.CreatedByUserId)) { context["EditUrl"] = DnnUrlUtils.EditUrl("id", item.Id, _module.ViewModule.ModuleID, _portalSettings); } context["DetailUrl"] = Globals.NavigateURL(_detailTabId, false, _portalSettings, "", GetCurrentCultureCode(), UrlHelpers.CleanupUrl(url), "id=" + item.Id); context["MainUrl"] = mainUrl; } items.Add(dyn); } } return(model); }
public string GetUrl(int detailTabId, string getCurrentCultureCode) { return(DnnUrlUtils.NavigateUrl(detailTabId, _portalSettings, getCurrentCultureCode)); }
private static string PrepareErrorMessage(DotNetNuke.Web.Razor.RazorModuleBase ctrl, Exception exc) { string friendlyMessage = $"\n{exc.Message} \n\nAlias: {ctrl.ModuleContext.PortalAlias.HTTPAlias} \nTab: {ctrl.ModuleContext.TabId} - {DnnUrlUtils.NavigateUrl(ctrl.ModuleContext.TabId)} \nModule: {ctrl.ModuleContext.ModuleId} \n{LoggingUtils.HttpRequestLogInfo(HttpContext.Current)} "; Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = lastExc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }
private static string PrepareErrorMessage(DnnApiController ctrl, Exception exc) { string friendlyMessage; if (ctrl?.ActiveModule == null) { friendlyMessage = $"\n{exc.Message} \n{LoggingUtils.HttpRequestLogInfo(HttpContext.Current)} "; } else { friendlyMessage = $"\n{exc.Message} \n\n PortalId: {ctrl.ActiveModule.PortalID} \nTab: {ctrl.ActiveModule.TabID} - {DnnUrlUtils.NavigateUrl(ctrl.ActiveModule.TabID)} \nModule: {ctrl.ActiveModule.ModuleID} \n{LoggingUtils.HttpRequestLogInfo(HttpContext.Current)} "; } Exception lastExc = exc; while (lastExc.InnerException != null) { lastExc = lastExc.InnerException; friendlyMessage += "\n" + lastExc.Message; } return(friendlyMessage); }