Example #1
0
    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);
            }
        }
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        msgHelper = _refCommonApi.EkMsgRef;
        Ektron.Cms.Content.EkContent objContentRef;
        objContentRef = _refContentApi.EkContentRef;
        RegisterResources();
        SetServerJSVariables();
        string pageAction = "";
        long siteID = 0;

        //Licensing For 7.6
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.UrlAliasing, false))
        {
            Utilities.ShowError(_refContentApi.EkMsgRef.GetMessage("feature locked error"));
            return;
        }
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        if (_refCommonApi.RequestInformationRef.IsMembershipUser > 0 || _refCommonApi.RequestInformationRef.UserId == 0)
        {
            Utilities.ShowError(_refContentApi.EkMsgRef.GetMessage("msg login cms user"));
            return;
        }

        if (!(_refCommonApi.IsAdmin() || objContentRef.IsARoleMember((long)Ektron.Cms.Common.EkEnumeration.CmsRoleIds.UrlAliasingAdmin, _refCommonApi.RequestInformationRef.UserId, false)))
        {
            Utilities.ShowError(_refContentApi.EkMsgRef.GetMessage("User not authorized"));
            return;
        }

        _manualAliasList = new Ektron.Cms.UrlAliasing.UrlAliasManualApi();
        _autoAliasList = new Ektron.Cms.UrlAliasing.UrlAliasAutoApi();
        _communityAliasList = new Ektron.Cms.UrlAliasing.UrlAliasCommunityApi();
        siteDictionary = new System.Collections.Generic.Dictionary<long, string>();

        PageLabel.Text = PageLabel.ToolTip = msgHelper.GetMessage("lbl pagecontrol page");
        OfLabel.Text = OfLabel.ToolTip = msgHelper.GetMessage("lbl pagecontrol of");

        FirstPage.ToolTip = msgHelper.GetMessage("lbl first page");
        PreviousPage1.ToolTip = msgHelper.GetMessage("lbl previous page");
        NextPage.ToolTip = msgHelper.GetMessage("lbl next page");
        LastPage.ToolTip = msgHelper.GetMessage("lbl last page");

        FirstPage.Text = "[" + msgHelper.GetMessage("lbl first page") + "]";
        PreviousPage1.Text = "[" + msgHelper.GetMessage("lbl previous page") + "]";
        NextPage.Text = "[" + msgHelper.GetMessage("lbl next page") + "]";
        LastPage.Text = "[" + msgHelper.GetMessage("lbl last page") + "]";

        if (!String.IsNullOrEmpty(Request.QueryString["LangType"]))
        {
            if (Request.QueryString["LangType"] != "")
            {
                contentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
                _refContentApi.SetCookieValue("LastValidLanguageID", contentLanguage.ToString());
            }
            else
            {
                if (_refContentApi.GetCookieValue("LastValidLanguageID") != "")
                {
                    contentLanguage = Convert.ToInt32(_refContentApi.GetCookieValue("LastValidLanguageID"));
                }
            }
        }
        else
        {
            if (_refContentApi.GetCookieValue("LastValidLanguageID") != "")
            {
                contentLanguage = Convert.ToInt32(_refContentApi.GetCookieValue("LastValidLanguageID"));
            }
        }
        _refContentApi.FilterByLanguage = contentLanguage;
        _refCommonApi.EkContentRef.RequestInformation.ContentLanguage = contentLanguage;
        if (!String.IsNullOrEmpty(Request.QueryString["action"]))
        {
            pageAction = Request.QueryString["action"];
        }
        if (!String.IsNullOrEmpty(Request.QueryString["fId"]))
        {
            siteID = Convert.ToInt64(Request.QueryString["fId"]);
        }
        if (pageAction == "removealias")
        {
            AddDeleteMenuBar(siteID.ToString());
            DeleteAlias(siteID.ToString());
        }
        else if (pageAction == "refresh")
        {
            RefreshManualAliasList(siteID.ToString());
            return;
        }
        else if ((string)(pageAction) == "clearcache")
        {
            ClearAutoAliasCache(siteID.ToString());
            return;
        }
        else if ((string)(pageAction) == "clearcommunitycache")
        {
            ClearCommunityCache(siteID.ToString());
            return;
        }
        else if ((string)(pageAction) == "")
        {
            AddDefaultMenuBar(siteID.ToString());
        }

        if (((pageAction == "" || pageAction == "removealias") && !Page.IsPostBack) || ((pageAction == "" || pageAction == "removealias") && Page.IsPostBack && Request.Form[isCPostData.UniqueID] != ""))
        {
            if (siteID > 0)
            {
                LoadManualAliasList(siteID.ToString());
            }
            else
            {
                LoadManualAliasList(string.Empty);
            }
        }
    }
Example #3
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        msgHelper = _refCommonApi.EkMsgRef;
        string pageAction;
        Ektron.Cms.Content.EkContent objContentRef;
        objContentRef = _refContentApi.EkContentRef;
        RegisterResources();
        SetServerJSVariables();
        //Licensing For 7.6
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.UrlAliasing, false))
        {
            Utilities.ShowError(_refContentApi.EkMsgRef.GetMessage("feature locked error"));
            return;
        }
        if (!(_refCommonApi.IsAdmin() || objContentRef.IsARoleMember((long)Ektron.Cms.Common.EkEnumeration.CmsRoleIds.UrlAliasingAdmin, _refCommonApi.RequestInformationRef.UserId, false)))
        {
            Utilities.ShowError(_refContentApi.EkMsgRef.GetMessage("User not authorized"));
            return;
        }

        _autoAliasAPI = new Ektron.Cms.UrlAliasing.UrlAliasAutoApi();
        _manualAliasAPI = new Ektron.Cms.UrlAliasing.UrlAliasManualApi();

        //Labels got from resource file
        lblPrimary.Text = msgHelper.GetMessage("lbl primary");
        lblPrimary.ToolTip = lblPrimary.Text;
        lblActive.Text = msgHelper.GetMessage("active label");
        lblActive.ToolTip = lblActive.Text;
        lblType.Text = msgHelper.GetMessage("lbl source") + " " + msgHelper.GetMessage("generic type");
        lblType.ToolTip = lblType.Text;
        lblSource.Text = msgHelper.GetMessage("lbl alias root");
        lblSource.ToolTip = lblSource.Text;
        lblExt.Text = msgHelper.GetMessage("lbl extension");
        lblExt.ToolTip = lblExt.Text;
        lblOriginal.Text = msgHelper.GetMessage("lbl original url");
        lblOriginal.ToolTip = lblOriginal.Text;
        lblExample.Text = msgHelper.GetMessage("lbl link ex preview");
        lblExample.ToolTip = lblExample.Text;
        lblNameSrc.Text = msgHelper.GetMessage("lbl alias format");
        lblNameSrc.ToolTip = lblNameSrc.Text;
        lblReplaceChar.Text = msgHelper.GetMessage("lbl rpl char");
        lblReplaceChar.ToolTip = lblReplaceChar.Text;
        lblPathList.Text = msgHelper.GetMessage("lbl exclude path");
        lblPathList.ToolTip = lblPathList.Text;
        lblQueryStringParam.Text = msgHelper.GetMessage("lbl querystringparam");
        lblQueryStringParam.ToolTip = lblQueryStringParam.Text;

        pageAction = Request.QueryString["action"];
        langType = Request.QueryString["Langtype"];
        folderId = Request.QueryString["fId"];

        int.TryParse(langType, out langId);
        _autoType = _autoAliasAPI.GetAutoAliasTypes();

        if ((string)(pageAction) == "addalias")
        {
            DisplayAdd();
        }
        else if ((string)(pageAction) == "view")
        {
            DisplayView();
        }
        else if ((string)(pageAction) == "editalias")
        {
            DisplayEdit();
        }
    }