private void AddDefaultMenuBar(string siteID) { Ektron.Cms.UrlAliasing.UrlAliasSettingsApi _aliasSettingsApi = new Ektron.Cms.UrlAliasing.UrlAliasSettingsApi(); System.Text.StringBuilder result = new System.Text.StringBuilder(); result.Append("<table><tr>" + "\r\n"); if (Request.QueryString["mode"] == "auto") { txtTitleBar.InnerHtml = _refStyle.GetTitleBar(msgHelper.GetMessage("lbl auto aliased page name maintenance")); if (_aliasSettingsApi.IsAutoAliasEnabled) { result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/add.png", "#", msgHelper.GetMessage("msg add alias"), msgHelper.GetMessage("msg add alias"), "onclick=\" addAlias(\'" + contentLanguage.ToString() + "\',\'auto\');\"", StyleHelper.AddButtonCssClass, true)); result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/driveDelete.png", "#", msgHelper.GetMessage("alt clear automatic alias cache"), msgHelper.GetMessage("btn clear cache"), "onclick=\" clearCache(\'auto\');\"", StyleHelper.DeleteDriveButtonCssClass)); result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/delete.png", "#", msgHelper.GetMessage("msg delete alias"), msgHelper.GetMessage("msg delete alias"), "onclick=\" removeAlias(\'auto\');\"", StyleHelper.DeleteButtonCssClass)); } } else if (Request.QueryString["mode"] == "community") { txtTitleBar.InnerHtml = _refStyle.GetTitleBar(msgHelper.GetMessage("lbl community aliased page name maintenance")); if (_aliasSettingsApi.IsCommunityAliasingEnabled) { if (contentLanguage != -1) { result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/add.png", "#", msgHelper.GetMessage("msg add alias"), msgHelper.GetMessage("msg add alias"), "onclick=\" addAlias(\'" + contentLanguage.ToString() + "\',\'community\');\"", StyleHelper.AddButtonCssClass, true)); } result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/driveDelete.png", "#", msgHelper.GetMessage("alt clear manual alias cache"), msgHelper.GetMessage("btn clear cache"), "onclick=\" clearCache(\'community\');\"", StyleHelper.DeleteDriveButtonCssClass)); if (contentLanguage != -1) { result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/delete.png", "#", msgHelper.GetMessage("msg delete alias"), msgHelper.GetMessage("msg delete alias"), "onclick=\" removeAlias(\'community\');\"", StyleHelper.DeleteButtonCssClass)); } } } else { txtTitleBar.InnerHtml = _refStyle.GetTitleBar(msgHelper.GetMessage("lbl manual aliased page name maintenance")); if (_aliasSettingsApi.IsManualAliasEnabled) { bool primaryCssApplied = false; if (contentLanguage != -1) { result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/add.png", "#", msgHelper.GetMessage("msg add alias"), msgHelper.GetMessage("msg add alias"), "onclick=\" addAlias(\'" + contentLanguage.ToString() + "\',\'manual\');\"", StyleHelper.AddButtonCssClass, !primaryCssApplied)); primaryCssApplied = true; } result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/driveDelete.png", "#", msgHelper.GetMessage("alt clear manual alias cache"), msgHelper.GetMessage("btn clear cache"), "onclick=\" clearCache(\'manual\');\"", StyleHelper.DeleteDriveButtonCssClass, !primaryCssApplied)); primaryCssApplied = true; if (contentLanguage != -1) { result.Append(_refStyle.GetButtonEventsWCaption(_refCommonApi.AppPath + "images/ui/icons/delete.png", "#", msgHelper.GetMessage("msg delete alias"), msgHelper.GetMessage("msg delete alias"), "onclick=\" removeAlias();\"", StyleHelper.DeleteButtonCssClass)); } } } if (_aliasSettingsApi.IsAutoAliasEnabled || _aliasSettingsApi.IsManualAliasEnabled) { } if (Request.QueryString["mode"] != "community") { result.Append(StyleHelper.ActionBarDivider); result.Append("<td class=\"label\">"); result.Append(" " + msgHelper.GetMessage("view in label") + ": " + _refStyle.ShowAllActiveLanguage(true, "", "", contentLanguage.ToString())); result.Append("</td>"); } ///' Hiding the following select dropwodn as to hide the site ''''' if (Request.QueryString["mode"] == "community") { result.Append("<td class=\"label\" style=\"display: none !important;\"> "); } else { result.Append("<td class=\"label\"> "); } result.Append(msgHelper.GetMessage("lbl site")); result.Append("</td>"); if (Request.QueryString["mode"] == "community") { result.Append("<td class=\"label\" style=\"display: none !important;\">"); } else { result.Append("<td class=\"label\">"); } result.Append("<select name=\"siteSearchItem\" id=\"siteSearchItem\" ONCHANGE=\"SubmitForm(\'form1\',\'\');\"/> "); siteDictionary = _manualAliasList.GetSiteList(); if (Page.IsPostBack) { long curr_sitekey = System.Convert.ToInt64(Request.Form["siteSearchItem"]); foreach (System.Collections.Generic.KeyValuePair<long, string> tempLoopVar_siteList in siteDictionary) { siteList = tempLoopVar_siteList; if (siteList.Key == curr_sitekey) { result.Append("<option value=\"" + siteList.Key.ToString() + "\">" + siteList.Value + "</option>"); break; } } foreach (System.Collections.Generic.KeyValuePair<long, string> tempLoopVar_siteList in siteDictionary) { siteList = tempLoopVar_siteList; if (siteList.Key != curr_sitekey) { result.Append("<option value=\"" + siteList.Key.ToString() + "\">" + siteList.Value + "</option>"); } } } else if (siteID != "") { foreach (System.Collections.Generic.KeyValuePair<long, string> tempLoopVar_siteList in siteDictionary) { siteList = tempLoopVar_siteList; if (siteList.Key == long.Parse(siteID)) { result.Append("<option value=\"" + siteList.Key.ToString() + "\">" + siteList.Value + "</option>"); break; } } foreach (System.Collections.Generic.KeyValuePair<long, string> tempLoopVar_siteList in siteDictionary) { siteList = tempLoopVar_siteList; if (siteList.Key != long.Parse(siteID)) { result.Append("<option value=\"" + siteList.Key.ToString() + "\">" + siteList.Value + "</option>"); } } } else { foreach (System.Collections.Generic.KeyValuePair<long, string> tempLoopVar_siteList in siteDictionary) { siteList = tempLoopVar_siteList; result.Append("<option value=\"" + siteList.Key.ToString() + "\">" + siteList.Value + "</option>"); } } result.Append("</select>"); result.Append("</td>"); if (Request.QueryString["mode"] == "auto") { CollectSearchText(); result.Append(StyleHelper.ActionBarDivider); result.Append("<td class=\"label\">"); result.Append("<label for=\'txtSearch\'>" + msgHelper.GetMessage("btn search") + "</label>"); result.Append("</td>"); result.Append("<td>"); result.Append("<input type=\"text\" class=\"ektronTextXXSmall\" id=\"txtSearch\" name=\"txtSearch\" value=\"" + strKeyWords + "\" autocomplete=\"off\" onkeydown=\"CheckForReturn(event)\">"); result.Append("<select id=\"searchlist\" name=\"searchlist\">"); result.Append("<option value=" + EkEnumeration.AutoAliasSearchField.All.ToString() + IsSelected("" + EkEnumeration.AutoAliasSearchField.All.ToString() + "") + ">All</option>"); result.Append("<option value=" + EkEnumeration.AutoAliasSearchField.SourceName.ToString() + IsSelected("" + EkEnumeration.AutoAliasSearchField.SourceName.ToString() + "") + ">Source Name</option>"); result.Append("</select>"); result.Append("</td>"); result.Append("<td><input type=\"image\" src=\"" + _refContentApi.AppPath + "images/ui/icons/magnifier.png\" value=" + msgHelper.GetMessage("btn search") + " alt=\"" + msgHelper.GetMessage("btn search") + "\" title=\"" + msgHelper.GetMessage("btn search") + "\" id=\"btnSearch\" name=\"btnSearch\" onclick=\"searchuser();return false;\" style=\"margin-left: .25em\" title=\"Search Users\" /></td>"); } else if (Request.QueryString["mode"] == "community") { } else { CollectSearchText(); result.Append(StyleHelper.ActionBarDivider); result.Append("<td class=\"label\">"); result.Append("<label for=\'txtSearch\'>" + msgHelper.GetMessage("btn search") + "</label>"); result.Append("</td>"); result.Append("<td>"); result.Append("<input type=\"text\" id=\"txtSearch\" class=\"ektronTextXXSmall\" name=\"txtSearch\" value=\"" + strKeyWords + "\" autocomplete=\"off\" onkeydown=\"CheckForReturn(event)\">"); result.Append("<select id=\"searchlist\" name=\"searchlist\">"); result.Append("<option value=" + EkEnumeration.UrlAliasSearchField.All.ToString() + IsSelected("" + EkEnumeration.UrlAliasSearchField.All.ToString() + "") + ">All</option>"); result.Append("<option value=" + EkEnumeration.UrlAliasSearchField.Alias.ToString() + IsSelected("" + EkEnumeration.UrlAliasSearchField.Alias.ToString() + "") + ">Alias</option>"); result.Append("<option value=" + EkEnumeration.UrlAliasSearchField.ContentId.ToString() + IsSelected("" + EkEnumeration.UrlAliasSearchField.ContentId.ToString() + "") + ">Content ID</option>"); result.Append("<option value=" + EkEnumeration.UrlAliasSearchField.ContentTitle.ToString() + IsSelected("" + EkEnumeration.UrlAliasSearchField.ContentTitle.ToString() + "") + ">Content Title</option>"); result.Append("<option value=" + EkEnumeration.UrlAliasSearchField.Target.ToString() + IsSelected("" + EkEnumeration.UrlAliasSearchField.Target.ToString() + "") + ">Original Link</option>"); result.Append("</select>"); result.Append("</td>"); result.Append("<td><input type=\"image\" src=\"" + _refContentApi.AppPath + "images/ui/icons/magnifier.png\" value=" + msgHelper.GetMessage("btn search") + " alt=\"" + msgHelper.GetMessage("btn search") + "\" title=\"" + msgHelper.GetMessage("btn search") + "\" id=\"btnSearch\" name=\"btnSearch\" onclick=\"searchuser();return false;\" style=\"margin-left: .25em\" title=\"Search Users\" /></td>"); } result.Append(StyleHelper.ActionBarDivider); if (Request.QueryString["mode"] == "auto") { result.Append("<td>" + _refStyle.GetHelpButton("AutoAliasPageMaint", "") + "</td>"); } else if (Request.QueryString["mode"] == "community") { result.Append("<td>" + _refStyle.GetHelpButton("CommunityAliasPageMaint", "") + "</td>"); } else { result.Append("<td>" + _refStyle.GetHelpButton("ManAliasPageMaint", "") + "</td>"); } result.Append("</tr></table>"); htmToolBar.InnerHtml = result.ToString(); result = null; StyleSheetJS.Text = (new StyleHelper()).GetClientScript(); }
private void checkAliasingEnabled() { // AliasRow is the table row holding the Url / Alias textfield and label. Ektron.Cms.UrlAliasing.UrlAliasSettingsApi settingsAliasApi = new Ektron.Cms.UrlAliasing.UrlAliasSettingsApi(); Ektron.Cms.UrlAliasing.UrlAliasAutoApi autoAliasApi = new UrlAliasAutoApi(); if (settingsAliasApi.IsManualAliasEnabled){ if (contentAPI.IsAdmin() || contentAPI.IsARoleMember(EkEnumeration.CmsRoleIds.UrlAliasingAdmin, m_refSiteApi.UserId, false) || contentAPI.IsARoleMember(EkEnumeration.CmsRoleIds.EditAlias, m_refSiteApi.UserId, false)) { ManualAliasing.SetActiveView(ManualAliasingEnabled); if(folderData == null) { folderData = contentAPI.GetFolderById(folderId); } pageBuilderCreateManualAlias.Enabled = !folderData.AliasRequired; } else { ManualAliasing.SetActiveView(ManualAliasingUnallowed); } }else{ ManualAliasing.SetActiveView(ManualAliasingDisabled); } if (settingsAliasApi.IsAutoAliasEnabled) { //for list of applicable aliases, we need to go up to root, checking for site folders on the way List<FolderData> parents = new List<FolderData>(); FolderData curFolder = folderData; long siterootID = 0; while(curFolder != null && curFolder.Id != 0){ if(curFolder.IsDomainFolder) siterootID = curFolder.Id; parents.Add(curFolder); curFolder = contentAPI.GetFolderById(curFolder.ParentId); } List<UrlAliasAutoData> aliasList = autoAliasApi.GetList(new PagingInfo(200), siterootID, ContentLanguage, EkEnumeration.AutoAliasSearchField.All, "", EkEnumeration.AutoAliasOrderBy.Active); List<string> folderAliases = new List<string>(); List<UrlAliasAutoData> taxonomyAliases = new List<UrlAliasAutoData>(); foreach (UrlAliasAutoData alias in aliasList) { if (alias.IsEnabled) { if (alias.AutoAliasType == EkEnumeration.AutoAliasType.Folder) { FolderData aliasrootfolder = parents.Find(delegate(FolderData f) { return (f.Id == alias.SourceId); }); if (aliasrootfolder != null) { string folderpath = folderData.NameWithPath; if (alias.ExcludedPath.Length > 0 && alias.ExcludedPath.Trim() != "Please Select") { int index = folderpath.IndexOf(alias.ExcludedPath); if (index >= 0) { folderpath = folderpath.Remove(index, alias.ExcludedPath.Length); } } if (alias.PageNameType == EkEnumeration.AutoAliasNameType.ContentId) folderpath += "354"; if (alias.PageNameType == EkEnumeration.AutoAliasNameType.ContentIdAndLanguage) folderpath += "354/1033"; if (alias.PageNameType == EkEnumeration.AutoAliasNameType.ContentTitle) folderpath += "Title"; folderpath += alias.FileExtension; folderAliases.Add(folderpath); } } else //taxonomy { if (folderData != null && folderData.FolderTaxonomy != null) { foreach (TaxonomyBaseData cat in folderData.FolderTaxonomy) { if (cat.TaxonomyId == alias.SourceId) { taxonomyAliases.Add(alias); break; } } } } } } if (taxonomyAliases.Count > 0) TaxonomyAliasing.SetActiveView(TaxonomyAliasingEnabled); else TaxonomyAliasing.SetActiveView(TaxonomyAliasingNoAliases); if (folderAliases.Count > 0) FolderAliasing.SetActiveView(FolderAliasingEnabled); else FolderAliasing.SetActiveView(FolderAliasingNoAliases); folderAliasRepeater.DataSource = folderAliases; folderAliasRepeater.DataBind(); taxonomyAliasRepeater.DataSource = taxonomyAliases; taxonomyAliasRepeater.DataBind(); } else { FolderAliasing.SetActiveView(FolderAliasingDisabled); TaxonomyAliasing.SetActiveView(TaxonomyAliasingDisabled); } if (!IsPostBack) { Ektron.Cms.UrlAliasing.UrlAliasSettingsApi urlsettings = new Ektron.Cms.UrlAliasing.UrlAliasSettingsApi(); string[] allowedextensions = urlsettings.PageExtensions.Split(','); ExtensionDropdown.Items.Clear(); ListItem li = new ListItem(); foreach (string ext in allowedextensions) { li = new ListItem(); li.Enabled = true; li.Selected = false; li.Text = ext; li.Value = ext; ExtensionDropdown.Items.Add(li); } } }