Esempio n. 1
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();
    }