Пример #1
0
    protected void Page_Init(object sender, EventArgs e)
    {
        JS.RegisterJS(this, JS.ManagedScript.EktronJS);
        JS.RegisterJS(this, JS.ManagedScript.EktronModalJS);
        Css.RegisterCss(this, Css.ManagedStyleSheet.EktronModalCss);
        _host = Ektron.Cms.Widget.WidgetHost.GetHost(this);
        _host.Title = "Content Dashboard";
        _host.Edit += new EditDelegate(EditEvent);
        _host.Maximize += new MaximizeDelegate(delegate() { Visible = true; });
        _host.Minimize += new MinimizeDelegate(delegate() { Visible = false; });
        _host.Create += new CreateDelegate(delegate() { EditEvent(""); });
        PreRender += new EventHandler(delegate(object PreRenderSender, EventArgs Evt) { SetOutput(); });
        _host.HelpFile = Page.ResolveClientUrl("~/WorkArea/help/personalization_new.82.1.html");

        ViewSet.SetActiveView(View);
        Ektron.Cms.ContentAPI cApi = new Ektron.Cms.ContentAPI();

        chkLocaleNotIn.Text = this.GetMessage("chk Does not include");
        btnFilter.Text = this.GetMessage("lbl advanced search filter results label");
        btnPrint.Text = this.GetMessage("lbl print");
        btnCreate.Text = this.GetMessage("btn Create Report");
        CancelButton.Text = this.GetMessage("generic cancel");
        SaveButton.Text = this.GetMessage("btn save");

        Utilities.ValidateUserLogin();
        if (!cApi.IsAdmin() && !cApi.IsARoleMember(EkEnumeration.CmsRoleIds.AdminUsers) && !cApi.IsARoleMember(EkEnumeration.CmsRoleIds.AdminXliff) && !cApi.IsARoleMember(EkEnumeration.CmsRoleIds.AdminTranslationState))
        {

            Response.Redirect((string)(cApi.RequestInformationRef.ApplicationPath + "reterror.aspx?info=Please login as an administrator or an Xliff Admin or a Translation state admin"), true);
            return;
        }

        ReportGrid1.ItemsPerPage = cApi.RequestInformationRef.PagingSize;

        if (!Page.IsCallback)
        {
            // Initialize the filters
            ddlLocale.Items.Clear();
            ddlLocale.Items.Add(new ListItem("(All)", "0"));
            ddlLocale.Items.Add(new ListItem("(NULL)", "-1"));
            Dictionary<int, string> locales = ReportGrid1.GetShortLocaleList();
            foreach (int id in locales.Keys)
            {
                string localecode = locales[id];
                ListItem li = ddlLocale.Items.FindByText(localecode);
                if (li != null) // Compensate for variant-sort locale codes
                {
                    li.Text = li.Text + " (" + li.Value + ")";
                    localecode = locales[id] + " (" + id.ToString() + ")";
                }
                ddlLocale.Items.Add(new ListItem(localecode, id.ToString()));
            }

            ddlAuthor.Items.Clear();
            ddlAuthor.Items.Add(new ListItem("(All)", "0"));
            Dictionary<long, string> authors = ReportGrid1.GetAuthorList();
            foreach (long id in authors.Keys)
                ddlAuthor.Items.Add(new ListItem(authors[id], id.ToString()));

            Dictionary<long, string> folders = ReportGrid1.GetFolderList(0, false);
            bool isIE = Request.Browser.Browser.StartsWith("IE") || (!string.IsNullOrEmpty(Request.ServerVariables["User-Agent"]) && (Request.ServerVariables["User-Agent"].Contains("MSIE") || Request.ServerVariables["User-Agent"].Contains("Internet Explorer")));
            foreach (long id in folders.Keys)
            {
                string foldername = folders[id];
                if (isIE && foldername.Length > 32)
                {
                    // Try to drop all but the last path
                    string[] paths = foldername.Split('/');
                    if (paths.Length <= 3) // Only one path, so we will just shorten it
                        foldername = foldername.Substring(0, 30) + "...";
                    else
                    {
                        // Generate some ../ instances to represent the depth
                        int depth = paths.Length - 3;
                        if (depth == 0) // Should never happen
                            depth = 1;
                        string path = paths[depth + 1];
                        if (path.Length > (32 - depth))
                            path = path.Substring(0, 30 - depth * 2) + "...";
                        foldername = "../../../../../../../../../../../../../../../../../../../../".Substring(0, depth * 3) +
                            path + "/";
                    }
                }
                ListItem item = new ListItem(foldername, id.ToString());
                ddlFolderID.Items.Add(item);
                if (isIE)
                    item.Attributes.Add("title", folders[id]);
            }

            ddlStatus.Items.Clear();
            ddlStatus.Items.Add(new ListItem(this.GetMessage("lbl Any"), string.Empty));
            ddlStatus.Items.Add(new ListItem(this.GetMessage("lbl not ready for translation"), Ektron.Cms.Localization.LocalizationState.NotReady.ToString()));
            ddlStatus.Items.Add(new ListItem(this.GetMessage("lbl ready for translation"), Ektron.Cms.Localization.LocalizationState.Ready.ToString()));
            //ddlStatus.Items.Add(new ListItem("Needs translation", Ektron.Cms.Localization.LocalizationState.NeedsTranslation.ToString()));
            //ddlStatus.Items.Add(new ListItem("Out for translation", Ektron.Cms.Localization.LocalizationState.OutForTranslation.ToString()));
            //ddlStatus.Items.Add(new ListItem("Translated", Ektron.Cms.Localization.LocalizationState.Translated.ToString()));
            ddlStatus.Items.Add(new ListItem(this.GetMessage("lbl Do not translate"), Ektron.Cms.Localization.LocalizationState.DoNotTranslate.ToString()));
            //ddlStatus.Items.Add(new ListItem("Unknown", Ektron.Cms.Localization.LocalizationState.Undefined.ToString()));
        }
    }
Пример #2
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        Utilities.ValidateUserLogin();
        m_SelectedEditControl = Utilities.GetEditorPreference(Request);
        objCookieObject = Ektron.Cms.CommonApi.GetEcmCookie();
        if (objCookieObject != null && !(objCookieObject.Values["editoroptions"] == null))
        {
            m_SelectedEditControl = objCookieObject.Values["editoroptions"].ToLower();
        }
        if (m_SelectedEditControl.ToLower() == "jseditor")
        {
            cdContent_teaser.Visible = false;
        }
        bool bPermissions = true;
        m_refContentApi = new Ektron.Cms.ContentAPI();
        iNewLang = m_refContentApi.ContentLanguage;
        if (!String.IsNullOrEmpty(Request.QueryString["dynamicbox"]))
        {
            bDynamicBox = Convert.ToBoolean(Request.QueryString["dynamicbox"]);
        }
        if (!String.IsNullOrEmpty(Request.QueryString["forum"]))
        {
            try
            {
                IsForum = Convert.ToBoolean(Convert.ToInt32(Request.QueryString["forum"]));
            }
            catch (Exception)
            {
                IsForum = false;
            }
        }
        setlabels();
        if (!IsForum && m_SelectedEditControl.ToLower() == "jseditor")
        {
            AddEkDoPostBack();
        }
        this.dialog_publish.Attributes.Add("onclick", "return publish_handler();");
        this.dialog_publish_top.Attributes.Add("onclick", "return publish_handler();");
        this.dialog_publish_asset.Attributes.Add("onclick", "return publish_handler();");
        if (!String.IsNullOrEmpty(Request.QueryString["mode"]))
        {
            if (Request.QueryString["mode"].Trim().ToLower() == "edit")
            {
                Mode = CurrentMode.Edit;
            }
            else if (Request.QueryString["mode"].Trim().ToLower() == "addlang")
            {
                Mode = CurrentMode.Edit;
                bWithLang = true;
                if (!String.IsNullOrEmpty(Request.QueryString["Lang"]))
                    iOrigLang = Convert.ToInt32(Request.QueryString["Lang"]);
            }
            else
            {
                Mode = CurrentMode.Add;
            }
        }

        SetCSS();
        if (!String.IsNullOrEmpty(Request.QueryString["mode_id"]))
        {
            try
            {
                ModeID = Convert.ToInt64(Request.QueryString["mode_id"]);
            }
            catch (Exception)
            {
                ModeID = 0;
            }
        }

        if (!String.IsNullOrEmpty(Request.QueryString["lang_id"]))
        {
            try
            {
                LangID = Convert.ToInt32(Request.QueryString["lang_id"]);
            }
            catch (Exception)
            {
                LangID = m_refContentApi.RequestInformationRef.DefaultContentLanguage;
            }
        }
        if (!String.IsNullOrEmpty(Request.QueryString["langtype"]))
        {
            try
            {
                LangID = Convert.ToInt32(Request.QueryString["langtype"]);
            }
            catch (Exception)
            {
                LangID = m_refContentApi.RequestInformationRef.DefaultContentLanguage;
            }
        }
        if (LangID == -1 || LangID == 0)
        {
            LangID = m_refContentApi.RequestInformationRef.DefaultContentLanguage;
        }

        m_refContentApi.RequestInformationRef.ContentLanguage = LangID;
        m_refContentApi.ContentLanguage = LangID;

        if (!Page.IsPostBack)
        {
            if (m_refContentApi.IsARoleMember(Ektron.Cms.Common.EkEnumeration.CmsRoleIds.TaxonomyAdministrator, m_refContentApi.RequestInformationRef.UserId, false))
            {
                TaxonomyRoleExists = true;
            }
            switch (Mode)
            {
                case CurrentMode.Add:
                    auto_generate_summary.Visible = false;
                    content_id.Value = "0";
                    security_data = m_refContentApi.LoadPermissions(ModeID, "folder", 0);

                    if (!security_data.CanAdd)
                    {
                        title_label.Text = "You do not have rights to add content in FolderID=" + ModeID;
                        bPermissions = false;
                    }
                    else
                    {
                        Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder();
                        folder_data = folderApi.GetFolder(ModeID);
                        if (folder_data != null)
                        {
                            if (cssFilesPath == "") //apply stylesheet from folderdata
                            {
                                cssFilesPath = this.m_refContentApi.RequestInformationRef.SitePath + folder_data.StyleSheet;
                            }

                            if (cssFilesPath.Length > 0)
                            {
                                cdContent_teaser.Stylesheet = cssFilesPath;
                            }
                        }
                        cdContent_teaser.FolderId = ModeID;

                        if (!IsForum && m_SelectedEditControl.ToLower() == "jseditor")
                        {
                            InnerEditor.ToolbarLayout = SetToolbar();
                            ftb_control.Text = InnerEditor.ToString();
                            ftb_control.Visible = true;
                            cdContent_teaser.Visible = false;
                        }
                        else if (!IsForum)
                        {
                            ftb_control.Visible = false;
                            cdContent_teaser.Visible = true;
                        }
                        SetTaxonomy(0, ModeID);
                    }
                    break;
                case CurrentMode.Edit:
                    auto_generate_summary.Visible = true;
                    content_id.Value = ModeID.ToString();
                    if (!String.IsNullOrEmpty(Request.QueryString["mode"]) && Request.QueryString["mode"].Trim().ToLower() == "addlang")
                    {
                        long folderid = 0;
                        if (!String.IsNullOrEmpty(Request.QueryString["folder"]))
                        {
                            long.TryParse(Request.QueryString["folder"], out folderid);
                        }
                        security_data = m_refContentApi.LoadPermissions(folderid, "folder", 0);
                        if (!security_data.CanAdd)
                        {
                            title_label.Text = "You do not have rights to add language content block ID=" + ModeID;
                            bPermissions = false;
                        }
                    }
                    else
                    {
                        security_data = m_refContentApi.LoadPermissions(ModeID, "content", 0);
                        if (!security_data.CanEdit && !IsForum)
                        {
                            title_label.Text = "You do not have rights to edit content block ID=" + ModeID;
                            bPermissions = false;
                        }
                        else
                        {
                            Ektron.Cms.API.Folder folderApi = new Ektron.Cms.API.Folder();
                            folder_data = folderApi.GetFolder(ModeID);
                            if (folder_data != null)
                            {
                                if (cssFilesPath == "") //apply stylesheet from folderdata
                                {
                                    cssFilesPath = this.m_refContentApi.RequestInformationRef.SitePath + folder_data.StyleSheet;
                                }

                                if (cssFilesPath.Length > 0)
                                {
                                    cdContent_teaser.Stylesheet = cssFilesPath;
                                }
                            }
                        }
                    }

                    if (bPermissions)
                    {
                        if (Request.QueryString["ctlupdateid"] != "")
                        {
                            commparams = (string)("&ctlupdateid=" + Request.QueryString["ctlupdateid"] + "&ctlmarkup=" + Request.QueryString["ctlmarkup"] + "&cltid=" + Request.QueryString["cltid"] + "&ctltype=" + Request.QueryString["ctltype"]);
                            updateFieldId = Request.QueryString["ctlupdateid"];
                            Page.ClientScript.RegisterHiddenField("ctlupdateid", updateFieldId);
                        }
                        if (Request.QueryString["ctlmarkup"] != "")
                        {
                            Page.ClientScript.RegisterHiddenField("ctlmarkup", Request.QueryString["ctlmarkup"]);
                        }
                        if (Request.QueryString["ctltype"] != "")
                        {
                            Page.ClientScript.RegisterHiddenField("ctltype", Request.QueryString["ctltype"]);
                        }
                        if (Request.QueryString["cltid"] != "")
                        {
                            Page.ClientScript.RegisterHiddenField("cltid", Request.QueryString["cltid"]);
                        }
                        SetContentBlock();
                    }
                    break;
            }
            if (!bPermissions)
            {
                ftb_control.Visible = false;
                title_value.Visible = false;
                dialog_publish.Visible = false;
                dialog_publish_top.Visible = false;
                dialog_publish_asset.Visible = false;
                cdContent_teaser.Visible = false;
                return;
            }
            ltr_js.Text = this.EditorJS();
            if (m_SelectedEditControl.ToLower() != "jseditor")
            {
                ftb_control.Visible = false;

                //set the equavalent SetToolbar() to contentdesigner
                if (cdContent_teaser != null)
                {
                    string ToolsOption = "";
                    if (security_data.CanAdd)
                    {
                        ToolsOption = "Wiki=1";
                    }
                    bool bLibraryAllowed = false;
                    if (security_data.IsReadOnlyLib)
                    {
                        bLibraryAllowed = true;
                    }
                    ToolsOption = ToolsOption + ("&LibraryAllowed=" + bLibraryAllowed.ToString());
                    bool bCanModifyImg = false;
                    if (security_data.CanAddToImageLib)
                    {
                        bCanModifyImg = true;
                    }
                    ToolsOption = ToolsOption + ("&CanModifyImg=" + bCanModifyImg.ToString());
                    if (ToolsOption.Length > 0)
                    {
                        ToolsOption = (string)("?" + ToolsOption);
                    }
                    cdContent_teaser.SetPermissions(security_data);
                    cdContent_teaser.ToolsFile = this.m_refContentApi.RequestInformationRef.ApplicationPath + "ContentDesigner/configurations/InterfaceBlog.aspx" + ToolsOption;

                    if (!(Request.QueryString["editorVisible"] == null))
                    {
                        //To avoid the editor's onbeforeunload checks being called
                        cdContent_teaser.Visible = System.Convert.ToBoolean(Request.QueryString["editorVisible"]);
                    }
                }
            }
        }

        if (dialog_publish.Visible == true)
        {
            tr_pub.Visible = true;
            tr_asset.Visible = false;
        }
        else
        {
            tr_pub.Visible = false;
            tr_asset.Visible = true;
        }

        string _helpUrl = string.Empty;
        if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ek_helpDomainPrefix"]))
        {
            string helpDomain = ConfigurationManager.AppSettings["ek_helpDomainPrefix"];
            Uri _uri = new Uri(helpDomain);
            if (_uri != null && !_uri.IsFile)
            {
                if ((helpDomain.IndexOf("[ek_cmsversion]") > 1))
                {
                    //defect # 64951 - This help file (It had been its own help project in previous releases as well).
                    _helpUrl = " http://documentation.ektron.com/current/memberhelp/wwhelp/wwhimpl/js/html/wwhelp.htm";
                }
            }
            else
            {
                _helpUrl = this.m_refContentApi.RequestInformationRef.ApplicationPath + "/helpmessage.aspx?error=isfile";
            }
        }
        else
        {
            _helpUrl = this.m_refContentApi.RequestInformationRef.ApplicationPath + "/help/memberhelp/index.html";
        }
        help_button.Text = "<a href=\"#\"><img  id=\"DeskTopHelp\" title=\"" + this.m_refMsg.GetMessage("alt help button text") + "\"  border=\"0\" src=\"" + this.m_refContentApi.RequestInformationRef.ApplicationPath + "/images/application/menu/help.gif\" onclick=\"javascript:PopUpWindow(\'" + _helpUrl + "\', \'SitePreview\', 600, 500, 1, 1);return false;\"></a>";

        if (IsForum)
        {
            SetForumMode();
        }
    }