protected bool Util_HasTargetLocales()
    {
        bool hasTargetLocales = true;
        long[] targetJobs = (new List<long>() { m_iID }).ToArray();
        Ektron.Cms.BusinessObjects.Localization.L10nManager businessMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef);
        string title = "Content with no Target Locale";

        LocalizationExportJob exportJob = new LocalizationExportJob(title);
        exportJob.SourceLanguageId = 1033;
        exportJob.Items = new List<LocalizableItem>();
        exportJob.Items.Add(new LocalizableItem(LocalizableCmsObjectType.LocaleTaxonomy, m_iID));
        exportJob.XliffVersion = this.xliffVersion;

        Criteria<LocalizationExportJob> criteria = new Criteria<LocalizationExportJob>();
        criteria.PagingInfo.RecordsPerPage = 5;
        List<LocalizableItem> fullList = businessMgr.GetLocaleTaxonomyContents(exportJob);

        if (fullList.Count > 0)
        {
            LocalizableItem item = fullList.ElementAt(0);
            List<LocalizationObjectData> localeObjectData = new List<LocalizationObjectData>();
            Ektron.Cms.Framework.Localization.LocalizationObject localizationObject = new Ektron.Cms.Framework.Localization.LocalizationObject();

            localeObjectData = localizationObject.GetLocalizationObjectList(LocalizableCmsObjectType.Content, item.Id, -1);
            if (0 == localeObjectData.Count)
            {
                localeObjectData = localizationObject.GetLocalizationObjectList(LocalizableCmsObjectType.DmsAsset, item.Id, -1);
            }
            if (0 == localeObjectData.Count)
            {
                hasTargetLocales = false;
                Util_ShowError("No Content found.");
                ltr_JobStatus.Text = "Error";
            }
            else if (1 == localeObjectData.Count)
            {
                hasTargetLocales = false;
                Util_ShowError(this.GetMessage("lbl target languages are not set for this handoff package"));
                ltr_JobStatus.Text = "Error";
            }
        }
        return hasTargetLocales;
    }
    private void GenerateTargetLanguageList(int ContentLanguage)
    {
        Ektron.Cms.Common.Criteria<LocaleProperty> criteria = new Ektron.Cms.Common.Criteria<LocaleProperty>(
        LocaleProperty.EnglishName, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        criteria.PagingInfo.RecordsPerPage = Int32.MaxValue;
        criteria.AddFilter(LocaleProperty.Enabled, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, true);

        List<LocaleData> locales = _locApi.GetList(criteria);
        List<LocaleData> displayLocales = new List<LocaleData>();

        if (m_intId > 0 &&
            (CmsTranslatableType.Content == m_Type || CmsTranslatableType.Product == m_Type)
            )
        {
            LocalizableCmsObjectType locObjType = LocalizableCmsObjectType.Content;
            switch (content_data.Type)
            {
                case (int)Ektron.Cms.Common.EkEnumeration.CMSContentType.Content:
                    locObjType = LocalizableCmsObjectType.Content;
                    break;
                case (int)Ektron.Cms.Common.EkEnumeration.CMSContentType.CatalogEntry:
                    locObjType = LocalizableCmsObjectType.Product;
                    break;
                default:
                    locObjType = LocalizableCmsObjectType.DmsAsset;
                    break;
            }
            List<LocalizationObjectData> localeObjectData = new List<LocalizationObjectData>();
            Ektron.Cms.Framework.Localization.LocalizationObject localizationObject = new Ektron.Cms.Framework.Localization.LocalizationObject();
            localeObjectData = localizationObject.GetLocalizationObjectList(locObjType, m_intId, -1);
            List<LocaleData> preselectedLocales = new List<LocaleData>();
            locales.ForEach(delegate(LocaleData loc)
            {
                LanguageState enabled = (localeObjectData.FindAll(x => x.ObjectLanguage == loc.Id).Count > 0 ? LanguageState.Active : LanguageState.Undefined);
                LocaleData uiDisplayLocale = new LocaleData(loc.Id, loc.LCID, loc.EnglishName, loc.NativeName, loc.IsRightToLeft, loc.Loc, loc.Culture, loc.UICulture, loc.LangCode, loc.XmlLang, loc.FlagFile, loc.FlagUrl, loc.FallbackId, enabled);
                displayLocales.Add(uiDisplayLocale);
            });
        }
        else
        {
            displayLocales = locales;
        }

        BoundField field = default(BoundField);

        LanguageGrid.Columns.Clear();

        // Selected?
        field = new BoundField();
        field.DataField = "";
        //.HeaderText = "Export"
        field.HeaderText = "<input type=\"checkbox\" name=\"chkAll\" onclick=\"onCheckAll(this)\" checked=\"checked\" />";
        field.HtmlEncode = false;
        field.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        field.HeaderStyle.Width = new Unit(20, UnitType.Pixel);
        field.ItemStyle.Wrap = false;
        field.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        LanguageGrid.Columns.Add(field);

        // Flag Icon
        field = new BoundField();
        field.DataField = "FlagFile";
        field.HeaderText = "";
        field.HeaderStyle.Width = new Unit(20, UnitType.Pixel);
        field.ItemStyle.Wrap = false;
        field.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        LanguageGrid.Columns.Add(field);

        // Language Name
        field = new BoundField();
        field.DataField = "CombinedName";
        field.HtmlEncode = false;
        field.SortExpression = LocaleProperty.EnglishName.ToString();
        field.HeaderText = GetMessage("generic name");
        field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
        field.ItemStyle.Wrap = false;
        LanguageGrid.Columns.Add(field);

        // Loc
        field = new BoundField();
        field.DataField = "Loc";
        field.SortExpression = LocaleProperty.Loc.ToString();
        field.HeaderText = GetMessage("lbl loc");
        field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
        field.HeaderStyle.Width = new Unit(6, UnitType.Em);
        field.ItemStyle.Wrap = false;
        field.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        LanguageGrid.Columns.Add(field);

        //// Language Code
        //field = new BoundField();
        //field.DataField = "XmlLang";
        //// or "BrowserCode"
        //field.SortExpression = EkDS.SortBy.XmlLang.ToString();
        //// or .BrowserCode
        //field.HeaderText = GetMessage("lbl code");
        //field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
        //field.HeaderStyle.Width = new Unit(6, UnitType.Em);
        //field.ItemStyle.Wrap = false;
        //field.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        //LanguageGrid.Columns.Add(field);

        // Language ID (decimal)
        field = new BoundField();
        field.DataField = "Id";
        field.SortExpression = LocaleProperty.Id.ToString();
        field.HeaderText = GetMessage("generic ID");
        field.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
        field.HeaderStyle.CssClass = "right";
        field.HeaderStyle.Width = new Unit(8, UnitType.Em);
        field.ItemStyle.Wrap = false;
        field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        field.ItemStyle.CssClass = "right";
        LanguageGrid.Columns.Add(field);

        //// Language ID (hex)
        //field = new BoundField();
        //field.DataField = "LanguageID";
        //field.HtmlEncode = false;
        //// necessary to make DataFormatString effective
        //field.DataFormatString = "{0:x4}";
        //field.HeaderText = GetMessage("lbl hex");
        //field.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
        //field.HeaderStyle.Width = new Unit(4, UnitType.Em);
        //field.ItemStyle.Wrap = false;
        //field.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
        //LanguageGrid.Columns.Add(field);

        // FireFox: border between cells is a result of the <table rules="all" attribute, which I do not know how to eliminate.

        LanguageGrid.RowDataBound += LanguageGrid_RowDataBound;

        LanguageGrid.DataSource = displayLocales;
        LanguageGrid.DataBind();
    }
    protected long Process_TranslationMemory()
    {
        if (0 == this.languageIds.Count)
        {
            return 0;
        }
        Ektron.Cms.Framework.Localization.LocalizationObject lobjApi = new Ektron.Cms.Framework.Localization.LocalizationObject();
        LocalizableCmsObjectType locType = LocalizableCmsObjectType.Content;
        LocalizationExportJob job = new LocalizationExportJob(transMemJobTitle);

        job.SourceLanguageId = this.languageIds[0];
        job.XliffVersion = this.xliffVersion;

        foreach (long contentId in contentIds)
        {
            long contentType = this.m_refContentApi.EkContentRef.GetContentType(contentId);
            if (Ektron.Cms.Common.EkConstants.IsAssetContentType(contentType, true))
                locType = LocalizableCmsObjectType.DmsAsset;
            job.AddItem(locType, contentId, this.languageIds);
            if (this.languageIds[0] != null)
                lobjApi.MarkNeedsTranslation(locType, contentId, this.languageIds[0]);
        }
        job.TargetLanguageIds = this.languageIds;

        Ektron.Cms.BusinessObjects.Localization.L10nManager businessMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef);
        return businessMgr.StartExportForTranslation(job);
    }
Exemple #4
0
    protected string GenerateLocaleList(List<long> selections, int defaultLocale, bool? addRemoveReplace)
    {
        plcLangsSelected.Visible = addRemoveReplace == null;

        Ektron.Cms.Framework.Localization.LocaleManager locale = new Ektron.Cms.Framework.Localization.LocaleManager();
        Ektron.Cms.Framework.Localization.LocalizationObject lobj = new Ektron.Cms.Framework.Localization.LocalizationObject();

        List<Ektron.Cms.Localization.LocaleData> locales = locale.GetEnabledLocales();

        // If not adding/deleting, loop through each of the selected content items to try and find selected locales
        List<int> selectedLocales = new List<int>();
        if (addRemoveReplace == null)
        {
            List<int> contentLocales = new List<int>();
            lMultiNotice.Visible = false;
            foreach (long item in selections)
            {
                contentLocales = lobj.GetObjectLanguages(Ektron.Cms.Localization.LocalizableCmsObjectType.Content, item);
                contentLocales.Sort();
                if (selectedLocales.Count == 0)
                    selectedLocales.AddRange(contentLocales);
                if (!LocaleListsMatch(selectedLocales, contentLocales))
                {
                    selectedLocales = new List<int>();
                    lMultiNotice.Visible = true;
                    break;
                }
            }

            if (!selectedLocales.Contains(defaultLocale))
                selectedLocales.Add(defaultLocale);
        }

        DataTable dt = new DataTable("locales");
        dt.Columns.Add("Id", typeof(int));
        dt.Columns.Add("Enabled", typeof(bool));
        dt.Columns.Add("EnglishName", typeof(string));
        dt.Columns.Add("Loc", typeof(string));
        dt.Columns.Add("CombinedName", typeof(string));
        dt.Columns.Add("FlagUrl", typeof(string));
        dt.Columns.Add("Default", typeof(bool));

        DataRow dr;

        foreach (Ektron.Cms.Localization.LocaleData ld in locales)
        {
            dr = dt.NewRow();
            dr.ItemArray = new object[] { ld.Id, selectedLocales.Contains(ld.Id) || ld.Id == CurrentLanguageId, ld.EnglishName, ld.Loc, ld.CombinedName, ld.FlagUrl, ld.Id == defaultLocale };
            dt.Rows.Add(dr);
        }

        DataTable sdt, adt;
        sdt = GetRowsFromArray(dt.Select("Enabled = true", "Loc"));
        adt = GetRowsFromArray(dt.Select("Enabled = false", "Loc"));

        // Databind
        rptSelectedLangs.DataSource = sdt;
        rptAvailableLangs.DataSource = adt;
        pnlLangSelector.DataBind();

        List<int> availableLocales = locales.ConvertAll<int>(new Converter<Ektron.Cms.Localization.LocaleData, int>(delegate(Ektron.Cms.Localization.LocaleData ld) { return ld.Id; }));
        foreach (int l in selectedLocales)
            if (availableLocales.Contains(l))
                availableLocales.Remove(l);

        // Set up the links
        plcSelectLinks.Controls.Clear();

        if (adt.Rows.Count > 0)
        {
            string links = "<a onclick=\"" + SelectAllScript(true, availableLocales) +
                " return false;\" href=\"#\" title=\"" + GetMessage("lbl select all languages") + "\">" + GetMessage("lbl select all languages") + "</a> | " +
                "<a onclick=\"" + SelectAllScript(false, availableLocales) +
                " return false;\" href=\"#\" title=\"" + GetMessage("lbl deselect all languages") + "\">" + GetMessage("lbl deselect all languages") + "</a>";

            plcSelectLinks.Controls.Add(new LiteralControl(links));
        }
        else
        {
            rptAvailableLangs.Visible = false;
        }

        // Render
        return RenderControl(pnlLangSelector);
    }
Exemple #5
0
    protected string CallbackDoAction(string key, Dictionary<string, string> data)
    {
        InitFromCallback(data);
        string what = data["action"];
        string sselected = data["selected"];
        List<long> selected = sselected.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll<long>(new Converter<string, long>(delegate(string s) { return long.Parse(s); }));

        Ektron.Cms.CommonApi commonApi = new CommonApi();
        Ektron.Cms.Content.EkContent contentManager = new Ektron.Cms.Content.EkContent(commonApi.RequestInformationRef);
        Ektron.Cms.API.Content.Content capi = new Ektron.Cms.API.Content.Content();
        Ektron.Cms.Framework.Localization.LocaleManager localeApi = new Ektron.Cms.Framework.Localization.LocaleManager();
        Ektron.Cms.Framework.Localization.LocalizationObject lobjApi = new Ektron.Cms.Framework.Localization.LocalizationObject();
        Ektron.Cms.API.Content.Taxonomy taxonomyApi = new Ektron.Cms.API.Content.Taxonomy();

        string title = string.Empty, html = string.Empty, okclick = string.Empty, action = string.Empty;

        switch (what)
        {
            case "locales":
                {
                    action = "showmodal";
                    bool? addRemoveReplace = null;
                    if (data.ContainsKey("mode"))
                        if (data["mode"] == "add")
                            addRemoveReplace = true;
                        else if (data["mode"] == "del")
                            addRemoveReplace = false;
                    title = (addRemoveReplace == null ? this.GetMessage("lbl Change selected locales") :
                        (addRemoveReplace == true ? "Add locale(s)" : "Remove locale(s)"))
                        + " " + this.GetMessage("generic for") + " " + (selected.Count == 1 ? "1 item" : (selected.Count.ToString() + " " + this.GetMessage("generic items")));
                    html = GenerateLocaleList(selected, CurrentLanguageId, addRemoveReplace);
                    okclick = this.ClientID + (addRemoveReplace == null ? "_LocaleSet" : (addRemoveReplace == true ? "_LocaleAdd" : "_LocaleDel"));
                }
                break;
            case "localeset":
                {
                    List<int> locales = data["locales"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList<string>().ConvertAll<int>(new Converter<string, int>(delegate(string s) { return int.Parse(s); }));
                    bool? addRemoveReplace = null;
                    if (data.ContainsKey("mode"))
                        if (data["mode"] == "add")
                            addRemoveReplace = true;
                        else if (data["mode"] == "del")
                            addRemoveReplace = false;
                    SetLocales(selected, locales, CurrentLanguageId, addRemoveReplace);
                    action = "hidemodal";
                    title = "";
                    Fill();
                    html = RenderControl(plcRenderMe);
                    okclick = "";
                }
                break;
            case "transstatus":
                {
                    action = "showmodal";
                    title = "Set Translation Readiness";
                    // ##TODO: Check current translation status
                    html = RenderControl(pnlSetTransStatus);
                    okclick = this.ClientID + "_TransStatusSet";
                }
                break;
            case "settranstatus":
                {
                    string status = data["status"].ToLower();
                    foreach (long id in selected)
                    {
                        Ektron.Cms.Localization.LocalizableCmsObjectType objectType = Ektron.Cms.Localization.LocalizableCmsObjectType.Content;
                        Ektron.Cms.Framework.Localization.LocalizationObject lobj = new Ektron.Cms.Framework.Localization.LocalizationObject();
                        switch (status)
                        {
                            case "ready":
                                lobjApi.MarkReadyForTranslation(objectType, id, CurrentLanguageId);
                                break;
                            case "notready":
                                lobjApi.MarkNotReadyForTranslation(objectType, id, CurrentLanguageId);
                                break;
                            case "donottranslate":
                                lobjApi.MarkDoNotTranslate(objectType, id, CurrentLanguageId);
                                break;
                        }
                    }
                    action = "hidemodal";
                    title = string.Empty;
                    Fill();
                    html = RenderControl(plcRenderMe);
                    okclick = string.Empty;
                }
                break;
            case "notes":
                {
                    action = "showmodal";
                    title = "Add notes for " + (selected.Count == 1 ? "1 item" : (selected.Count.ToString() + " items"));
                    lNoteN.Visible = selected.Count > 1;

                    if (selected.Count == 1) // Load notes if there is only one piece of content
                    {
                        // ##TODO: Add this!
                    }
                    html = RenderControl(pnlNotes);
                    okclick = this.ClientID + "_NotesSet";
                }
                break;
            case "setnotes":
                {
                    string notes = data["notes"];

                    long metadataId = commonApi.EkContentRef.GetMetadataTypeId("XliffNote", CurrentLanguageId, 0);

                    foreach (long cid in selected)
                    {
                        capi.UpdateContentMetaData(cid, metadataId, notes);
                    }

                    action = "hidemodal";
                    title = string.Empty;
                    Fill();
                    html = RenderControl(plcRenderMe);
                    okclick = string.Empty;
                }
                break;
            case "pseudo":
                {
                    action = "showmodal";
                    title = "Pseudo Localize " + (selected.Count == 1 ? "1 item" : (selected.Count.ToString() + " items")) + ".";

                    Ektron.Cms.Framework.Localization.LocaleManager locale = new Ektron.Cms.Framework.Localization.LocaleManager();
                    List<Ektron.Cms.Localization.LocaleData> pseudoLocales = locale.GetEnabledLocales().FindAll(d => d.XmlLang.Contains("-x-pseudo"));

                    if (pseudoLocales.Count > 0)
                        foreach (Ektron.Cms.Localization.LocaleData pseudoLocale in pseudoLocales)
                        {
                            CheckBox pseudoLoc = new CheckBox()
                            {
                                ID = "chkPS" + pseudoLocale.Id.ToString(),
                                Checked = true,
                                Text = pseudoLocale.Loc + " " + pseudoLocale.EnglishName
                            };
                            pnlPseudo.Controls.Add(pseudoLoc);
                            pnlPseudo.Controls.Add(new LiteralControl("<br />"));
                        }
                    else
                        lblPseudoInstructions.Text = "There are no Pseudo localization enabled locales.";

                    html = RenderControl(pnlPseudo);
                    okclick = this.ClientID + "_PseudoSet";
                }
                break;
            case "setpseudo":
                {
                    action = "showmodal";
                    title = "Pseudo Localize " + (selected.Count == 1 ? "1 item" : (selected.Count.ToString() + " items")) + ".";

                    string selectedIds = string.Join(",", selected.ConvertAll<string>(delegate(long i) { return i.ToString(); }).ToArray());
                    string pseudoLocaleIds = data["locales"];

                    ektronExportPseudoIframe.Attributes["src"] = "widgets/Modal/localizationjobs.aspx?action=pseudo&contentIds=" + selectedIds + "&languageIds=" + pseudoLocaleIds;
                    html = RenderControl(pnlSetPseudo);
                    okclick = this.ClientID + "_PseudoReset";
                }
                break;
            case "pseudocomplete":
                {
                    action = "hidemodal";
                    title = string.Empty;
                    Fill();
                    html = RenderControl(plcRenderMe);
                    okclick = string.Empty;
                }
                break;
            default:
                {
                    action = "showmodal";
                    title = "Invalid selection";
                    html = "The option that was selected is not available.";
                    okclick = this.ClientID + "_CloseModalDialog";
                }
                break;
        }

        Dictionary<string, string> output = new Dictionary<string, string>();
        output["action"] = action;
        output["title"] = title;
        output["html"] = html;
        output["okclick"] = okclick;

        return ConvertDictionaryToQueryString(output);
    }
Exemple #6
0
    /// <param name="addRemoveReplace">true for add, false for remove, null for replace</param>
    protected void SetLocales(List<long> selections, List<int> selectedLocales, int defaultLocale, bool? addRemoveReplace)
    {
        Ektron.Cms.Framework.Localization.LocaleManager locale = new Ektron.Cms.Framework.Localization.LocaleManager();
        Ektron.Cms.Framework.Localization.LocalizationObject lobj = new Ektron.Cms.Framework.Localization.LocalizationObject();

        List<Ektron.Cms.Localization.LocaleData> locales = locale.GetEnabledLocales();

        // Loop through each of the selected content items to try and find selected locales
        List<int> contentLocales = new List<int>();
        if (!selectedLocales.Contains(defaultLocale))
            selectedLocales.Add(defaultLocale);
        selectedLocales.Sort();

        List<int> localesToDelete = new List<int>();
        List<int> localesToAdd = new List<int>();
        List<Ektron.Cms.Localization.LocalizationObjectData> localeData = new List<Ektron.Cms.Localization.LocalizationObjectData>();

        foreach (long item in selections)
        {
            Ektron.Cms.Localization.LocalizableCmsObjectType objectType = Ektron.Cms.Localization.LocalizableCmsObjectType.Content;
            contentLocales = lobj.GetObjectLanguages(Ektron.Cms.Localization.LocalizableCmsObjectType.Content, item);
            if (contentLocales.Count == 0)
            {
                objectType = Ektron.Cms.Localization.LocalizableCmsObjectType.DmsAsset;
                contentLocales = lobj.GetObjectLanguages(Ektron.Cms.Localization.LocalizableCmsObjectType.DmsAsset, item);
            }
            bool skip = true;
            if (addRemoveReplace == null && !LocaleListsMatch(selectedLocales, contentLocales))
                skip = false;
            if (addRemoveReplace == true && !LocaleListContains(contentLocales, selectedLocales))
                skip = false;
            if (addRemoveReplace == false && LocaleListContains(contentLocales, selectedLocales))
                skip = false;

            if (!skip)
            {
                localeData = lobj.GetLocalizationObjectList(objectType, item, -1);
                localesToDelete.Clear();
                localesToAdd.Clear();
                if (addRemoveReplace == null || addRemoveReplace == true)
                    foreach (int i in selectedLocales)
                        if (!contentLocales.Contains(i))
                            localesToAdd.Add(i);
                if (addRemoveReplace == null)
                    foreach (int i in contentLocales)
                        if (!selectedLocales.Contains(i))
                            localesToDelete.Add(i);
                if (addRemoveReplace == false)
                    foreach (int i in contentLocales)
                        if (selectedLocales.Contains(i))
                            localesToDelete.Add(i);

                foreach (int i in localesToDelete)
                    foreach (Ektron.Cms.Localization.LocalizationObjectData ldata in localeData)
                        if (ldata.ObjectLanguage == i)
                            lobj.Delete(ldata.Id);

                foreach (int i in localesToAdd)
                    lobj.MarkReadyForTranslation(objectType, item, i);
            }
        }
    }
Exemple #7
0
    private void ViewToolBar()
    {
        System.Text.StringBuilder result;
            string strBackPage = "";
            ContentStateData content_state_data;
            result = new System.Text.StringBuilder();
            txtTitleBar.InnerHtml = m_refStyle.GetTitleBar((string) (m_refMsg.GetMessage("view forms title") + " \"" + form_data.Title + "\""));
            result.Append("<table><tr>");
            strBackPage = (string) ("LangType=" + ContentLanguage + "&Action=ViewForm&form_id=" + m_intFormId);
            strBackPage = EkFunctions.UrlEncode(strBackPage);

            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/back.png", (string)("content.aspx?LangType=" + ContentLanguage + "&action=ViewContentByCategory&id=" + form_data.FolderId), m_refMsg.GetMessage("alt back button text"), m_refMsg.GetMessage("btn back"), "", StyleHelper.BackButtonCssClass, true));

            bool appliedPrimaryCss = false;

            if (security_data.CanEdit)
            {
                // Currently, we do not support editing forms on the Mac:
                //If (Not IsMac()) Then  'Editing forms is now supported on MAC so making the change rquested in #34748
                result.Append(m_refStyle.GetEditAnchor(form_data.Id, 2, false, EkEnumeration.CMSContentSubtype.Content, !appliedPrimaryCss) + "\r\n");
                appliedPrimaryCss = true;

                if (form_data.Status == "O")
                {
                    if (security_data.IsAdmin)
                    {
                        //this is the adim so allow for the check in button
                        result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/checkIn.png", (string)("content.aspx?LangType=" + ContentLanguage + "&action=CheckIn&id=" + form_data.Id + "&fldid=" + form_data.FolderId + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + form_data.Id), m_refMsg.GetMessage("alt checkin button text"), m_refMsg.GetMessage("btn checkin"), "OnClick=\"DisplayHoldMsg(true);return true;\"", StyleHelper.CheckInButtonCssClass, !appliedPrimaryCss));

                        appliedPrimaryCss = true;
                    }
                    else
                    {
                        // go find out the state of this contet to see it this user can check it in.
                        content_state_data = m_refContentApi.GetContentState(form_data.Id);
                        if (content_state_data.CurrentUserId == m_refContentApi.UserId)
                        {
                            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/checkIn.png", (string)("content.aspx?LangType=" + ContentLanguage + "&action=CheckIn&id=" + form_data.Id + "&fldid=" + form_data.FolderId + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + form_data.Id), m_refMsg.GetMessage("alt checkin button text"), m_refMsg.GetMessage("btn checkin"), "OnClick=\"DisplayHoldMsg(true);return true;\"", StyleHelper.CheckInButtonCssClass, !appliedPrimaryCss));

                            appliedPrimaryCss = true;
                        }
                    }
                }
                else if (((form_data.Status == "I") || (form_data.Status == "T")) && (content_data.UserId == m_refContentApi.UserId))
                {
                    if (security_data.CanPublish)
                    {
                        bool metaRequuired = false;
                        bool categoryRequired = false;
                        bool manaliasRequired = false;
                        string msg = string.Empty;
                        m_refContentApi.EkContentRef.ValidateMetaDataTaxonomyAndAlias(content_data.FolderId, content_data.Id, content_data.LanguageId, ref metaRequuired, ref categoryRequired, ref manaliasRequired);
                        if (metaRequuired == false && categoryRequired == false && manaliasRequired == false)
                        {
                            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/contentPublish.png", (string) ("content.aspx?LangType=" + ContentLanguage + "&action=Submit&id=" + form_data.Id + "&fldid=" + form_data.FolderId + "&page=workarea&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId + "&parm3=LangType&value3=" + ContentLanguage), m_refMsg.GetMessage("alt publish button text"), m_refMsg.GetMessage("btn publish"), "OnClick=\"DisplayHoldMsg(true);return true;\"", StyleHelper.PublishButtonCssClass, !appliedPrimaryCss));

                            appliedPrimaryCss = true;
                        }
                        else
                        {
                            if (metaRequuired && categoryRequired && manaliasRequired)
                            {
                                msg = m_refMsg.GetMessage("validate meta and manualalias and category required");
                            }
                            else if (metaRequuired && categoryRequired && !manaliasRequired)
                            {
                                msg = m_refMsg.GetMessage("validate meta and category required");
                            }
                            else if (metaRequuired && !categoryRequired && manaliasRequired)
                            {
                                msg = m_refMsg.GetMessage("validate meta and manualalias required");
                            }
                            else if (!metaRequuired && categoryRequired && manaliasRequired)
                            {
                                msg = m_refMsg.GetMessage("validate manualalias and category required");
                            }
                            else if (metaRequuired)
                            {
                                msg = m_refMsg.GetMessage("validate meta required");
                            }
                            else if (manaliasRequired)
                            {
                                msg = m_refMsg.GetMessage("validate manualalias required");
                            }
                            else
                            {
                                msg = m_refMsg.GetMessage("validate category required");
                            }
                            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/contentPublish.png", "#", m_refMsg.GetMessage("alt publish button text"), m_refMsg.GetMessage("btn publish"), "onclick=\"alert(\'" + msg + "\');\"", StyleHelper.PublishButtonCssClass, !appliedPrimaryCss));

                            appliedPrimaryCss = true;
                        }
                    }
                    else
                    {
                        result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/approvalSubmitFor.png", (string)("content.aspx?LangType=" + ContentLanguage + "&action=Submit&id=" + form_data.Id + "&fldid=" + form_data.FolderId + "&page=workarea&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId + "&parm3=LangType&value3=" + ContentLanguage), m_refMsg.GetMessage("alt submit button text"), m_refMsg.GetMessage("btn submit"), "OnClick=\"DisplayHoldMsg(true);return true;\"", StyleHelper.SubmitForApprovalButtonCssClass, !appliedPrimaryCss));

                        appliedPrimaryCss = true;
                    }
                }

                if (form_data.Status == "S" || form_data.Status == "I" || form_data.Status == "T" || form_data.Status == "O" || form_data.Status == "P")
                {
                    if (Request.QueryString["staged"] != "")
                    {
                        result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/contentViewPublished.png", (string)("cmsform.aspx?LangType=" + ContentLanguage + "&action=ViewForm&form_id=" + m_intFormId + "&folder_id=" + form_data.FolderId), m_refMsg.GetMessage("alt view published button text"), m_refMsg.GetMessage("btn view publish"), "", StyleHelper.ViewPublishedButtonCssClass, !appliedPrimaryCss));
                    }
                    else
                    {
                        result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/preview.png", (string)("cmsform.aspx?LangType=" + ContentLanguage + "&action=ViewForm&form_id=" + m_intFormId + "&folder_id=" + form_data.FolderId + "&staged=true&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&value2=form_id&value2=" + m_intFormId), m_refMsg.GetMessage("alt view staged button text"), m_refMsg.GetMessage("btn view stage"), "", StyleHelper.ViewStagedButtonCssClass, !appliedPrimaryCss));
                    }

                    appliedPrimaryCss = true;
                }
            }
            if (form_data.Status == "S" || form_data.Status == "M")
            {
                if (security_data.CanEditSumit)
                {
                    // Don't show edit button for Mac when using XML config:
                    string SelectedEditControl = Utilities.GetEditorPreference(Request);
                    if (!(m_bIsMac && (content_data.XmlConfiguration != null)) || SelectedEditControl == "ContentDesigner")
                    {
                        result.Append(m_refStyle.GetEditAnchor(form_data.Id, 2, true, EkEnumeration.CMSContentSubtype.Content, !appliedPrimaryCss) + "\r\n");

                        appliedPrimaryCss = true;
                    }
                }
            }
            if (security_data.CanHistory)
            {
                result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/history.png", "#", m_refMsg.GetMessage("alt history button text"), m_refMsg.GetMessage("lbl generic history"), "OnClick=\"top.document.getElementById(\'ek_main\').src=\'historyarea.aspx?action=report&LangType=" + ContentLanguage + "&id=" + form_data.Id + "\';return false;\"", StyleHelper.HistoryButtonCssClass, !appliedPrimaryCss));

                appliedPrimaryCss = true;
            }
            if (form_data.Status == "S" || form_data.Status == "I" || form_data.Status == "T" || form_data.Status == "O")
            {
                result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/contentViewDifferences.png", "#", m_refMsg.GetMessage("alt view difference"), m_refMsg.GetMessage("btn view diff"), "onclick=\"PopEditWindow(\'compare.aspx?LangType=" + ContentLanguage + "&id=" + form_data.Id + "\', \'Compare\', 785, 650, 1, 1);\"", StyleHelper.ViewDifferenceButtonCssClass, !appliedPrimaryCss));

                appliedPrimaryCss = true;
            }
            if (security_data.CanEdit)
            {
                result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/contentEdit.png", (string)("cmsform.aspx?LangType=" + ContentLanguage + "&action=Editform&form_id=" + m_intFormId + "&folder_id=" + form_data.FolderId + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId), m_refMsg.GetMessage("alt form prop"), m_refMsg.GetMessage("btn edit prop"), "", StyleHelper.EditButtonCssClass, !appliedPrimaryCss));

                appliedPrimaryCss = true;
            }

            if (security_data.CanDelete)
            {
                result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/delete.png", (string)("content.aspx?LangType=" + ContentLanguage + "&action=submitDelContAction&delete_id=" + form_data.Id + "&folder_id=" + form_data.FolderId + "&form_id=" + form_data.Id + "&callbackpage=content.aspx&parm1=action&value1=viewcontentbycategory&parm2=id&value2=" + form_data.FolderId), m_refMsg.GetMessage("alt del form"), m_refMsg.GetMessage("btn delete"), "onclick=\"return ConfirmFormDelete();\"", StyleHelper.DeleteButtonCssClass, !appliedPrimaryCss));
            }
            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/linkSearch.png", (string)("isearch.aspx?LangType=" + ContentLanguage + "&action=dofindcontent&folderid=0&form_id=" + m_intFormId + "&ObjectType=forms" + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId), m_refMsg.GetMessage("alt Check for content that is linked to this"), m_refMsg.GetMessage("btn link search"), "", StyleHelper.SearchButtonCssClass, !appliedPrimaryCss));
            appliedPrimaryCss = true;

            result.Append(StyleHelper.ActionBarDivider);

            if (security_data.CanAddTask)
            {
                result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/taskAdd.png", (string) ("tasks.aspx?action=AddTask&cid=" + form_data.Id + "&LangType=" + ContentLanguage + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId + "&parm3=folder_id&value3=" + form_data.FolderId + "&parm4=LangType&value4=" + ContentLanguage), m_refMsg.GetMessage("btn add task"), m_refMsg.GetMessage("btn add task"), "", StyleHelper.AddTaskButtonCssClass));
            }
            if (TaskExists == true)
            {
                result.Append(m_refStyle.GetButtonEventsWCaption(AppImgPath + "btn_viewtask-nm.gif", (string) ("tasks.aspx?LangType=" + ContentLanguage + "&action=viewcontenttask&ty=both&cid=" + form_data.Id + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId + "&parm3=folder_id&value3=" + form_data.FolderId + "&parm4=LangType&value4=" + ContentLanguage), m_refMsg.GetMessage("btn view task"), m_refMsg.GetMessage("btn view task"), "", StyleHelper.ViewTaskButtonCssClass));
            }

            // Prep-work for adding move-forms capability:
            //If (security_data.IsAdmin) And (content_data.Status = "A") Then
            //    result.Append(m_refStyle.GetButtonEventsWCaption(AppImgPath & ../UI/Icons/contentCopy.png.png, "content.aspx?LangType=" & ContentLanguage & "&action=MoveContent&id=" & m_intFolderId & "&folder_id=" & content_data.FolderId, "Move Content", m_refMsg.GetMessage("btn move content"), ""))
            //End If

            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/chartBar.png", (string) ("cmsformsreport.aspx?LangType=" + ContentLanguage + "&id=" + m_intFormId + "&FormTitle=" + form_data.Title + "&folder_id=" + form_data.FolderId), m_refMsg.GetMessage("alt report"), m_refMsg.GetMessage("btn report"), "", StyleHelper.ViewReportButtonCssClass));
            string strAction;
            string propertiesCssClass;
            if (Utilities.IsMac())
            {
                strAction = "EditContentProperties";
                propertiesCssClass = StyleHelper.EditPropertiesButtonCssClass;
            }
            else
            {
                strAction = "View";
                propertiesCssClass = StyleHelper.ViewPropertiesButtonCssClass;
            }
            result.Append(m_refStyle.GetButtonEventsWCaption(m_refContentApi.AppPath + "images/UI/Icons/properties.png", (string)("content.aspx?LangType=" + ContentLanguage + "&action=" + strAction + "&id=" + form_data.Id + "&callerpage=cmsform.aspx&folder_id=" + form_data.FolderId + "&origurl=" + strBackPage), m_refMsg.GetMessage("generic form prop"), m_refMsg.GetMessage("btn content properties"), "", propertiesCssClass));

            //Sync API needs to know folder type to display the eligible sync profiles.
            if (folder_data == null)
            {
                folder_data = m_refContentApi.GetFolderById(content_data.FolderId);
            }

            SiteAPI site = new SiteAPI();
            EkSite ekSiteRef = site.EkSiteRef;
            if ((m_refContentApi.IsARoleMember(Ektron.Cms.Common.EkEnumeration.CmsRoleIds.SyncAdmin) || m_refContentApi.IsARoleMember(Ektron.Cms.Common.EkEnumeration.CmsRoleIds.SyncUser)) && LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Feature.eSync) && m_refContentApi.RequestInformationRef.IsSyncEnabled)
            {
                if ((m_strPageAction == "viewform") && (content_data.Status.ToUpper() == "A") && ServerInformation.IsStaged())
                {
                    if (folder_data.IsDomainFolder)
                    {
                        result.Append(m_refStyle.GetButtonEventsWCaption(AppImgPath + "sync_now_data.png", "#", m_refMsg.GetMessage("alt sync content"), m_refMsg.GetMessage("btn sync content"), "OnClick=\"Ektron.Workarea.Sync.Relationships.ShowSyncConfigurations(" + ContentLanguage + "," + m_intFormId + ",\'" + content_data.AssetData.Id + "\',\'" + content_data.AssetData.Version + "\'," + content_data.FolderId + ",true);return false;\"", StyleHelper.SyncButtonCssClass));
                    }
                    else
                    {
                        result.Append(m_refStyle.GetButtonEventsWCaption(AppImgPath + "sync_now_data.png", "#", m_refMsg.GetMessage("alt sync content"), m_refMsg.GetMessage("btn sync content"), "OnClick=\"Ektron.Workarea.Sync.Relationships.ShowSyncConfigurations(" + ContentLanguage + "," + m_intFormId + ",\'" + content_data.AssetData.Id + "\',\'" + content_data.AssetData.Version + "\'," + content_data.FolderId + ",false);return false;\"", StyleHelper.SyncButtonCssClass));
                    }
                }
            }

            if (EnableMultilingual == 1)
            {
                string strViewDisplay = "";
                string strAddDisplay = "";
                LanguageData[] result_language;
                int count = 0;
                ContentAPI m_refAPI = new ContentAPI();

                if (security_data.CanEdit)
                {
                    result.Append(StyleHelper.ActionBarDivider);
                    var l10nObj = new Ektron.Cms.Framework.Localization.LocalizationObject();
                    LocalizationState locState = l10nObj.GetContentLocalizationState(m_intFormId, form_data);
                    result.Append(m_refStyle.GetTranslationStatusMenu(form_data, m_refMsg.GetMessage("alt click here to update this content translation status"), m_refMsg.GetMessage("lbl mark ready for translation"), locState));
                    result.Append(m_refStyle.PopupTranslationMenu(form_data, locState));
                    if (locState.IsExportableState())
                    {
                        result.Append(m_refStyle.GetExportTranslationButton((string) ("content.aspx?LangType=" + ContentLanguage + "&action=Localize&id=" + m_intFormId + "&folder_id=" + form_data.FolderId + "&ContentType=" + EkConstants.CMSContentType_Forms + "&callbackpage=cmsform.aspx&parm1=action&value1=ViewForm&parm2=form_id&value2=" + m_intFormId + "&parm3=folder_id&value3=" + form_data.FolderId + "&parm4=LangType&value4=" + ContentLanguage), m_refMsg.GetMessage("alt form trans"), this.m_refMsg.GetMessage("lbl Export for translation")));
                    }
                }

                result_language = m_refAPI.DisplayAddViewLanguage(m_intFormId);
                for (count = 0; count <= result_language.Length - 1; count++)
                {
                    if (result_language[count].Type == "VIEW")
                    {
                        if (form_data.LanguageId == result_language[count].Id)
                        {
                            strViewDisplay = strViewDisplay + "<option value=" + result_language[count].Id + " selected=\"selected\">" + result_language[count].Name + "</option>";
                        }
                        else
                        {
                            strViewDisplay = strViewDisplay + "<option value=" + result_language[count].Id + ">" + result_language[count].Name + "</option>";
                        }
                    }
                }

                bool languageDividerAdded = false;

                if (strViewDisplay != "")
                {
                    result.Append(StyleHelper.ActionBarDivider);
                    languageDividerAdded = true;

                    result.Append("<td class=\"label\">");
                    result.Append(m_refMsg.GetMessage("lbl View") + ":");
                    result.Append("</td>");
                    result.Append("<td>");
                    result.Append("<select id=\"viewcontent\" name=\"viewcontent\" onchange=\"LoadContent(\'frmContent\',\'VIEW\');\">");
                    result.Append(strViewDisplay);
                    result.Append("</select>");
                    result.Append("</td>");
                }
                if (security_data.CanAdd)
                {
                    for (count = 0; count <= result_language.Length - 1; count++)
                    {
                        if (result_language[count].Type == "ADD")
                        {
                            strAddDisplay = strAddDisplay + "<option value=" + result_language[count].Id + ">" + result_language[count].Name + "</option>";
                        }
                    }
                    if (strAddDisplay != "")
                    {
                        if (!languageDividerAdded)
                        {
                            result.Append(StyleHelper.ActionBarDivider);
                        }
                        else
                        {
                            result.Append("<td>&nbsp;&nbsp;</td>");
                        }

                        result.Append("<td class=\"label\">" + m_refMsg.GetMessage("add title") + ":</td>");
                        result.Append("<td>");
                        result.Append("<select id=\"addcontent\" name=\"addcontent\" onchange=\"LoadContent(\'frmContent\',\'ADD\');\">");
                        result.Append("<option value=" + "0" + ">" + "-select language-" + "</option>");
                        result.Append(strAddDisplay);
                        result.Append("</select></td>");
                    }
                }
            }

            result.Append(StyleHelper.ActionBarDivider);

            result.Append("<td>");
            result.Append(m_refStyle.GetHelpButton(m_strPageAction, ""));
            result.Append("</td>");
            result.Append("</tr></table>");
            htmToolBar.InnerHtml = result.ToString();
    }
Exemple #8
0
 private void Do_UpdateTranslationStatus(string action)
 {
     try
     {
         long intId = Convert.ToInt64(Request.QueryString["id"].ToString());
         int intLangType = Convert.ToInt32(Request.QueryString["LangType"].ToString());
         var loc = new Ektron.Cms.Framework.Localization.LocalizationObject();
         string contType = Request.QueryString["ContType"].ToString();
         long intContType;
         Ektron.Cms.Localization.LocalizableCmsObjectType objType = Ektron.Cms.Localization.LocalizableCmsObjectType.Content;
         if (Int64.TryParse(contType, out intContType))
         {
             if (EkConstants.IsAssetContentType(intContType, false))
             {
                 objType = Ektron.Cms.Localization.LocalizableCmsObjectType.DmsAsset;
             }
             else if (intContType == EkEnumeration.CMSContentType.CatalogEntry.GetHashCode())
             {
                 objType = Ektron.Cms.Localization.LocalizableCmsObjectType.Product;
             }
         }
         switch (action)
         {
             case "translatereadystatus":
                 loc.MarkReadyForTranslation(objType, intId, intLangType);
                 break;
             case "translatenotreadystatus":
                 loc.MarkNotReadyForTranslation(objType, intId, intLangType);
                 break;
             case "translatenotallowstatus":
                 loc.MarkDoNotTranslate(objType, intId, intLangType);
                 break;
             case "translateneedstranslationstatus":
                 loc.MarkNeedsTranslation(objType, intId, intLangType);
                 break;
             case "translateoutfortranslationstatus":
                 loc.MarkOutForTranslation(objType, intId, intLangType);
                 break;
             case "translatetranslatedstatus":
                 loc.MarkTranslated(objType, intId, intLangType);
                 break;
         }
         Response.Redirect((string)("content.aspx?LangType=" + ContentLanguage + "&action=View&id=" + intId), false);
     }
     catch (Exception ex)
     {
         Utilities.ShowError(ex.Message);
     }
 }