Ejemplo n.º 1
0
    protected void Page_Load(System.Object sender, System.EventArgs e)
    {
        ApplicationAPI AppUI = new ApplicationAPI();
        EkContent cContObj = new EkContent(AppUI.RequestInformationRef);
        taskObj = new EkTask(AppUI.RequestInformationRef);
        long cid;
        string[] tasksArray;
        int lCounter;
        string RefType;
        long CurrentUserID;
        string AppPath;
        string AppImgPath;
        string SitePath;
        string AppeWebPath;
        long CommentKeyId = 0;
        long CommentId = 0;
        string Action;
        object ActionType;
        object IsMac;
        object platform;
        bool Flag;
        object retVal;
        object CommentText;
        object NS4;
        object OrderBy;
        object iMaxContLength;
        object localeFileString;
        object var1;
        object var2;
        string taskIDs;
        object height;
        object width;
        int EnableMultilingual;
        int ContentLanguage;
        Ektron.Cms.Common.EkMessageHelper MsgHelper;
        System.Text.StringBuilder sbScript = new System.Text.StringBuilder();

        MsgHelper = AppUI.EkMsgRef;
        AppPath = AppUI.AppPath;
        AppImgPath = AppUI.AppImgPath;
        SitePath = AppUI.SitePath;
        AppeWebPath = AppUI.AppeWebPath;
        AppPath = AppUI.AppPath;
        AppName = AppUI.AppName;
        EnableMultilingual = AppUI.EnableMultilingual;
        ContentLanguage = 1033; //set default value
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        if (Convert.ToBoolean(AppUI.RequestInformationRef.IsMembershipUser))
        {
            Response.Redirect("reterror.aspx?info=" + MsgHelper.GetMessage("msg login cms user"), false);
            return;
        }
        if (!string.IsNullOrEmpty(Request.QueryString["LangType"]))
        {
            ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
            AppUI.SetCookieValue("LastValidLanguageID", ContentLanguage.ToString());
        }
        else
        {
            if (!string.IsNullOrEmpty(AppUI.GetCookieValue("LastValidLanguageID")))
            {
                ContentLanguage = Convert.ToInt32(AppUI.GetCookieValue("LastValidLanguageID"));
            }
        }

        platform = Request.ServerVariables["HTTP_USER_AGENT"];
        if (platform.ToString().IndexOf("Windows") + 1 > 0)
        {
            IsMac = 0;
        }
        else
        {
            IsMac = 1;
        }

        RefType = "T";
        Flag = false;
        iMaxContLength = 65000;
        localeFileString = "0000";
        var1 = Request.ServerVariables["SERVER_NAME"];
        if (!string.IsNullOrEmpty(Request.QueryString["commentkey_id"]))
        {
            CommentKeyId = Convert.ToInt64(Request.QueryString["commentkey_id"]);
        }
        Action = Request.QueryString["action"];
        ActionType = Request.QueryString["ty"];
        OrderBy = Request.QueryString["orderby"];
        cid = Convert.ToInt64(Request.QueryString["id"]);
        if (!string.IsNullOrEmpty(Request.QueryString["Comment_Id"]))
        {
            CommentId = Convert.ToInt64(Request.QueryString["Comment_Id"]);
        }
        if (!string.IsNullOrEmpty((Request.QueryString["height"])))
        {
            height = Convert.ToDouble(Request.QueryString["height"]);
        }
        if (!string.IsNullOrEmpty((Request.QueryString["width"])))
        {
            width = Convert.ToDouble(Request.QueryString["width"]);
        }
        lCounter = 0;
        CurrentUserID = AppUI.UserId;

        ltrComments.Text = MsgHelper.GetMessage("lbl task comment") + ":";
        if (Request.QueryString["action"] != null && Request.QueryString["action"].ToString().ToLower() == "declinecontentaction")
            ltrComments.Text = MsgHelper.GetMessage("reason to decline");

        cContObj = AppUI.EkContentRef;

        if (Request.ServerVariables["http_user_agent"].ToString().IndexOf("Mozilla") + 1 > 0 && Request.ServerVariables["http_user_agent"].ToString().IndexOf("4.7") + 1 > 0 && Request.ServerVariables["http_user_agent"].ToString().IndexOf("GECKO") < 0)
        {
            NS4 = true;
        }
        else
        {
            NS4 = false;
        }

        var2 = cContObj.GetEditorVariablev2_0(0, "tasks");
        ctlEditor.Validate();
        if (Action == "Add" && ctlEditor.IsValid)
        {
            CommentText = this.ctlEditor.Content;
            if (cid != 0)
            {
                //Get all tasks associated with the content and add same comment
                taskObj = AppUI.EkTaskRef;
                object strStates;
                strStates = EkEnumeration.TaskState.NotStarted.ToString() + "," + EkEnumeration.TaskState.Active.ToString() + "," + EkEnumeration.TaskState.AwaitingData.ToString() + "," + EkEnumeration.TaskState.OnHold.ToString() + "," + EkEnumeration.TaskState.Pending.ToString() + "," + EkEnumeration.TaskState.Reopened.ToString();
                taskIDs = taskObj.GetTaskIDs(cid, strStates, -1, (int)EkEnumeration.CMSTaskItemType.TasksByStateAndContentID);

                if (taskIDs != "")
                {
                    tasksArray = Strings.Split(taskIDs.ToString(), ",", -1, 0);
                    while (lCounter <= (tasksArray.Length - 1))
                    {
                        retVal = cContObj.AddComment(Convert.ToInt64(CommentKeyId), Convert.ToInt64(CommentId), Convert.ToInt64(tasksArray.GetValue(lCounter)), RefType, CurrentUserID, Strings.Replace(CommentText.ToString(), "\'", "\'\'", 1, -1, 0));
                        lCounter++;
                    }
                }

            }
            Flag = true;
        }
        if (true == Flag)
        {
            sbScript.Append("<script language=\"JavaScript\" type=\"text/javascript\">" + "\r\n");
            sbScript.Append("<!--");
            sbScript.Append("if (IsBrowserIE())");
            sbScript.Append("{");
            sbScript.Append("   parent.ReturnChildValue(\"action=\" + document.getElementById(\"actionName\").value + \"&id=\" + document.getElementById(\"cid\").value + \"&fldid=\" + document.getElementById(\"fldid\").value + \"&page=\" + document.getElementById(\"page\").value );");
            sbScript.Append("}");
            sbScript.Append("else");
            sbScript.Append("{");
            sbScript.Append("   top.opener.ReturnChildValue(\"action=\" + document.getElementById(\"actionName\").value + " + ID == " + document.getElementById(\"cid\").value + \"&fldid=\" + document.getElementById(\"fldid\").value + \"&page=\" + document.getElementById(\"page\").value );");
            sbScript.Append("   close();");
            sbScript.Append("}");
            sbScript.Append("//-->");
            sbScript.Append("</script>" + "\r\n");
            ClosePanel.Text = sbScript.ToString();
        }

        if ((Request.QueryString["action"]) == "Add")
        {
            actionName.Value = Request.QueryString["actionName"];
        }
        else
        {
            actionName.Value = Request.QueryString["action"];
        }

        this.ctlEditor.AllowFonts = true;
        ctlEditor.ErrorMessage = MsgHelper.GetMessage("content size exceeded");
        ctlEditor.ValidationExpression = Utilities.BuildRegexToCheckMaxLength(System.Convert.ToInt32(iMaxContLength));
    }
Ejemplo n.º 2
0
    protected void Page_Load(System.Object sender, System.EventArgs e)
    {
        ApplicationAPI AppUI = new ApplicationAPI();
        long CurrentUserID;
        EkContent cObj1 =  new EkContent(AppUI.RequestInformationRef);
        Collection cComments;
        object retVal;
        string CommentText;
        string ErrorString = "";
        int iMaxContLength;
        string AppName;
        string AppeWebPath;
        int ContentLanguage;
        int EnableMultilingual;
        string platform;
        object IsMac;

        string AppImgPath = "";
        EkMessageHelper MsgHelper;

        MsgHelper = (new CommonApi()).EkMsgRef;

        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        ltrScript.Text = (new StyleHelper()).GetClientScript();
        if (m_siteRef.RequestInformationRef.IsMembershipUser == 1)
        {
            Response.Redirect("reterror.aspx?info=" + MsgHelper.GetMessage("msg login cms user"), false);
            return;
        }
        ContentLanguage = -1;
        if (!string.IsNullOrEmpty(Request.QueryString["LangType"]))
        {
            ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
            AppUI.SetCookieValue("LastValidLanguageID", ContentLanguage.ToString());
        }
        else
        {
            if (!string.IsNullOrEmpty(AppUI.GetCookieValue("LastValidLanguageID").ToString()))
            {
                ContentLanguage = Convert.ToInt32(AppUI.GetCookieValue("LastValidLanguageID"));
            }
        }
        AppUI.ContentLanguage = ContentLanguage;
        m_siteRef.RequestInformationRef.ContentLanguage = ContentLanguage;
        EnableMultilingual = AppUI.EnableMultilingual;
        cObj1 = AppUI.EkContentRef;
        CurrentUserID = AppUI.UserId;
        AppName = AppUI.AppName;
        AppeWebPath = AppUI.AppeWebPath;
        AppImgPath = AppUI.AppImgPath;
        AppPath = AppUI.AppPath;
        RefType = EkFunctions.HtmlEncode(Request["ref_type"]);
        iMaxContLength = 65000;
        if ("" == Request["commentkey_id"])
        {
            CommentKeyId = 0;
        }
        else
        {
            CommentKeyId = Convert.ToInt64(Request["commentkey_id"]);
        }
        Action = EkFunctions.HtmlEncode(Request.QueryString["action"]);
        ActionType = EkFunctions.HtmlEncode(Request.QueryString["ty"]);
        if ("" == Request["Comment_Id"])
        {
            CommentId = 0;
        }
        else
        {
            CommentId = Convert.ToInt64(Request["Comment_Id"]);
        }
        RefId = System.Convert.ToInt64(Request["ref_id"]);
        OrderBy = EkFunctions.HtmlEncode(Request["orderby"]);
        platform = Request.ServerVariables["HTTP_USER_AGENT"];
        if (platform.ToString().IndexOf("Windows") + 1 > 0)
        {
            IsMac = 0;
        }
        else
        {
            IsMac = 1;
        }
        this.Title = AppName + " Comments";
        ltrCancel.Text = MsgHelper.GetMessage("generic cancel");
        if (Action == null || "Add" == Action || "" == Action)
        {
            ltrSubmit.Text = MsgHelper.GetMessage("btn insert");
        }
        else if ("Edit" == Action)
        {
            ltrSubmit.Text = MsgHelper.GetMessage("btn update");
        }

        this.ctlEditor.ErrorMessage = MsgHelper.GetMessage("content size exceeded");
        this.ctlEditor.ValidationExpression = Utilities.BuildRegexToCheckMaxLength(System.Convert.ToInt32(iMaxContLength));

        CommentText = "";
        if (IsPostBack)
        {
            this.ctlEditor.Validate();
            if (this.ctlEditor.IsValid)
            {
                if (Action == null || "Add" == Action)
                {
                    CommentText = this.ctlEditor.Content;
                    retVal = cObj1.AddComment(CommentKeyId, CommentId, RefId, RefType, CurrentUserID, CommentText);
                    if (ErrorString != "")
                    {
                        Response.Redirect("../reterror.aspx?info=" + ErrorString);
                    }
                }
                else if ("Update" == Action)
                {
                    CommentText = this.ctlEditor.Content;
                    retVal = cObj1.UpdateComment(CommentId, CommentText);
                    if (ErrorString != "")
                    {
                        Response.Redirect("../reterror.aspx?info=" + ErrorString);
                    }
                }
                Response.Write("<script type=\"text/javascript\">" + "\r\n");
                Response.Write("<!--" + "\r\n");
                Response.Write("if (opener != null)" + "\r\n");
                Response.Write("{" + "\r\n");
                Response.Write("window.top.opener.location.href = window.top.opener.location.href;" + "\r\n");
                Response.Write("}" + "\r\n");
                Response.Write("self.close();" + "\r\n");
                Response.Write("//-->" + "\r\n");
                Response.Write("</script>");
            }
        }
        else
        {
            if ("Edit" == Action)
            {
                cComments = cObj1.GetAllComments(CommentKeyId, CommentId, RefId, RefType, CurrentUserID, "");
                if (ErrorString != "")
                {
                    Response.Redirect("../reterror.aspx?info=" + ErrorString);
                }
                for (int i = 1; i <= cComments.Count; i++)
                {
                    Collection coll = (Collection)cComments[i];
                    CommentText = coll["COMMENTS_TEXT"].ToString();
                }

                this.ctlEditor.Content = CommentText.ToString();
            }
        }
    }