public long GetContentIdForAlias(string Alias, int LanguageId) { AliasData aliasData = null; long TargetId = 0; if (Alias.StartsWith("http")) { aliasData = CommonAPI.AliasInstance.GetTarget(new Uri(Alias), LanguageId); } else { aliasData = CommonAPI.AliasInstance.GetTarget(new Uri(string.Format("{0}{1}", EktronCredentials.Credentials.BaseUrl, Alias.TrimStart('/'))), LanguageId); } if (aliasData != null) { TargetId = aliasData.TargetId; } return(TargetId); }
public string GetPageBuilderEditAnchor(long Id, int languageId, string quickLink, bool isPrimary) { //make popup window with link to this pageids wireframe, and pass in the id and an edit flag ContentAPI capi = new ContentAPI(); FolderData fd = capi.GetFolderById(capi.GetFolderIdForContentId(Id)); AliasData aliasData = new AliasData(); string URL = ""; AliasSettings aliasSettings = ObjectFactory.GetAliasSettingsManager(this.m_refAPI.RequestInformationRef).Get(); if (aliasSettings.IsAliasingEnabled) { IAliasManager aliasManager = ObjectFactory.GetAliasManager(this.m_refAPI.RequestInformationRef); aliasData = aliasManager.GetAlias(Id, languageId, EkEnumeration.TargetType.Content); URL = aliasData.Alias; } // Note that the internal API changed, if a content items has a default alias it will be passed into this funciton as param quicklink. // Keeping this code incase other places are calling this function without alias in quicklink param if (String.IsNullOrEmpty(URL)) { URL = quickLink; } // If it is a multi site, use the quicklink as the alias will not function in other domains. ALias is tied to domain. if (fd.IsDomainFolder && aliasData != null && !string.IsNullOrEmpty(aliasData.TargetURL)) { URL = aliasData.TargetURL.TrimStart('/'); } else if (fd.IsDomainFolder) { URL = URL.TrimStart('/'); } if (URL.Contains("?")) { URL = URL + "&ektronPageBuilderEdit=true"; } else { URL = URL + "?ektronPageBuilderEdit=true"; } if (URL.IndexOf("LangType=") == -1) { URL = URL + "&LangType=" + languageId.ToString(); } URL = this.m_refAPI.SitePath + URL; URL = GetButtonEventsWCaption(m_refAPI.AppImgPath + "layout_edit.gif", "#", m_refMsg.GetMessage("generic edit page layout"), m_refMsg.GetMessage("generic edit page layout"), "OnClick=\"window.open(\'" + URL + "\', \'CMS400EditPage\');return false;\"", EditButtonCssClass, isPrimary); return URL; }
private void processValidResponse(HttpContext context, AliasData target) { var aRequestInfo = RequestInfoProvider.GetRequestInformation(); this.TraceMessage("Detected Language: " + aRequestInfo.ContentLanguage); this.TraceMessage("Target found, rewrite will be performed: " + target.TargetURL); // Languages might be different if alias fallback feature is enabled. //Also if this is regex, there will be no proper language id, it will be 0, so need to make sure it is greater than zero. if (target.LanguageId != aRequestInfo.ContentLanguage && !String.IsNullOrEmpty(target.TargetURL) && target.LanguageId > 0) { this.TraceMessage("Target is in a different language: " + target.LanguageId); // If there is a langtype in querystring then do not modify Cookie. User just changed their language. // If there is not a language in querystring assume they are new visitor to the site so change their cookie. bool modifyUserCookie = (!String.IsNullOrEmpty(context.Request.QueryString[LangTypeParam])) ? false : true; if (modifyUserCookie) { RequestInformationManager.SetECMCookieValue("SiteLanguage", target.LanguageId.ToString()); this.TraceMessage("Users language updated to match alias"); } } this.rewritePath(context, target.TargetURL); }