コード例 #1
0
        /// <summary>
        /// Возвращает коллекцию параметров.
        /// </summary>
        public override Dictionary <string, string> GetParameters()
        {
            var parameters = base.GetParameters();

            parameters["owner_id"] = OwnerID.ToString();
            parameters["post_id"]  = PostID.ToString();
            if (NeedLikes != VKBoolean.False)
            {
                parameters["need_likes"] = "1";
            }
            if (StartCommentID != 0)
            {
                parameters["start_comment_id"] = StartCommentID.ToString();
            }
            if (Sort != VKSortByDate.asc)
            {
                parameters["sort"] = VKSortByDate.desc.ToString();
            }
            if (PreviewLength != 0)
            {
                parameters["preview_length"] = PreviewLength.ToString();
            }

            return(parameters);
        }
コード例 #2
0
ファイル: ModelsRedone.cs プロジェクト: zachary-kaelan/CSharp
        public Post[] GetReplies()
        {
            LastUpdated.Stop();
            if (LastUpdated.ElapsedMilliseconds == 0)
            {
                LastUpdated.Start();
                Posts = FourChan.MakeRequest <KeyValuePair <string, PostWithFileTemp[]> >(
                    "b/thread/" + PostID.ToString() + ".json"
                    ).Value.Select(
                    p => new Post(p)
                    ).ToArray();
                IfModifiedSince = DateTime.Now.ToString("R");
            }
            else if (LastUpdated.Elapsed.TotalSeconds >= 15.0)
            {
                if (FourChan.TryMakeRequest <KeyValuePair <string, PostWithFileTemp[]> >("b/thread" + PostID.ToString() + ".json", IfModifiedSince, out KeyValuePair <string, PostWithFileTemp[]> content))
                {
                    Posts = content.Value.Skip(Posts.Length).Select(p => new Post(p)).ToArray();
                    LastUpdated.Restart();
                    IfModifiedSince = DateTime.Now.ToString("R");
                }
                else
                {
                    LastUpdated.Start();
                }
            }
            else
            {
                LastUpdated.Start();
            }

            return(Posts);
        }
コード例 #3
0
        /***********************************************************************
         * // PostButton_Click
         * //
         * /// <summary>
         * /// This event handler fires when the preview button is clicked.  It needs
         * /// to show/hide the appropriate panels.
         * /// </summary>
         * /// <param name="sender"></param>
         * /// <param name="e"></param>
         ************************************************************************/
        private void PostButton_Click(Object sender, EventArgs e)
        {
            Control form;

            // Only proceed if the post is valid
            if (!Page.IsValid)
            {
                return;
            }

            // Get the user control that the click originated from
            form = ((Control)sender).Parent;

            // When we add a new post, we want to get back the NewPostID, so that we
            // can automagically redirect the user to the page showing the post.
            // If iNewPostID comes back as 0, though, that means that the post needs
            // to be approved first, so the user is taken to a page explaining this.
            Post newPost   = null;
            Post postToAdd = new Post();

            postToAdd.Username = Context.User.Identity.Name;
            postToAdd.ForumID  = postToAdd.ParentID = 0;
            postToAdd.Subject  = ((TextBox)form.FindControl("PostSubject")).Text;
            postToAdd.Body     = ((TextBox)form.FindControl("PostBody")).Text;
            postToAdd.IsLocked = allowNoReplies.Checked;

            // Are we in edit mode?

            /*
             * if (Mode == CreateEditPostMode.EditPost) {
             *  string editNotes = CreateEditNotes(form);
             *  postToAdd.Body = editNotes + postToAdd.Body;
             * }
             */

            // Are we pinning the post?
            if ((pinnedPost != null) && (Convert.ToInt32(pinnedPost.SelectedItem.Value) > 0))
            {
                switch (Convert.ToInt32(pinnedPost.SelectedItem.Value))
                {
                case 1:
                    postToAdd.PostDate = DateTime.Now.Date.AddDays(1);
                    break;

                case 3:
                    postToAdd.PostDate = DateTime.Now.Date.AddDays(3);
                    break;

                case 7:
                    postToAdd.PostDate = DateTime.Now.Date.AddDays(7);
                    break;

                case 14:
                    postToAdd.PostDate = DateTime.Now.Date.AddDays(14);
                    break;

                case 30:
                    postToAdd.PostDate = DateTime.Now.Date.AddMonths(1);
                    break;

                case 90:
                    postToAdd.PostDate = DateTime.Now.Date.AddMonths(3);
                    break;

                case 180:
                    postToAdd.PostDate = DateTime.Now.Date.AddMonths(6);
                    break;

                case 360:
                    postToAdd.PostDate = DateTime.Now.Date.AddYears(1);
                    break;

                case 999:
                    postToAdd.PostDate = DateTime.Now.Date.AddYears(25);
                    break;
                }
            }

            // Are we adding a new post, editing an existing one, or replying to an existing one?
            switch (Mode)
            {
            case CreateEditPostMode.NewPost:            // adding a new post
                postToAdd.ForumID = ForumID;            // specify the forum ID that the new post belongs

                try {
                    newPost = Posts.AddPost(postToAdd);
                }
                catch (PostDuplicateException) {
                    Context.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.DuplicatePost) + "&ForumId=" + ForumID);
                    Context.Response.End();
                }
                break;

            case CreateEditPostMode.ReplyToPost:        // replying to an existing post
                try {
//                        if (postView == ViewOptions.Threaded) {
                    postToAdd.ParentID = PostID;                                // specify the post we are replying to
//                        } else {
//                            postRepliedTo = Posts.GetPost(PostID, user.Username);
//                            postToAdd.ParentID = postRepliedTo.ThreadID;
//                        }

                    newPost = Posts.AddPost(postToAdd);
                }
                catch (Components.PostNotFoundException) {
                    // uh-oh, something is off... are we replying to a message that has been deleted?
                    Context.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.ProblemPosting));
                    Context.Response.End();
                }
                catch (PostDuplicateException) {
                    Context.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.DuplicatePost) + "&PostId=" + PostID);
                    Context.Response.End();
                }
                break;

            case CreateEditPostMode.EditPost:
                postToAdd.PostID = PostID;                      // specify the ID of the post we are updating
                string editedBy = Users.GetLoggedOnUser().Username;

                // update the post
                Posts.UpdatePost(postToAdd, editedBy);

                // send the user back to from where they came
                Context.Response.Redirect(RedirectURL);
                Context.Response.End();

                // exit from the event handler
                return;
            }

            // now that we've added the post, redirect the user to the post display (if the post
            // has been approved)
            if (newPost.Approved)
            {
                if (Mode == CreateEditPostMode.NewPost)
                {
                    Context.Response.Redirect(Globals.UrlShowPost + newPost.ThreadID);
                }
                else
                {
                    Context.Response.Redirect(Globals.UrlShowPost + newPost.ThreadID + "#" + newPost.PostID);
                }
                Context.Response.End();
            }
            else
            {
                // if the post HASN'T been approved, send the user to an explanation page, passing along the Post or ForumID
                String strRedirect = Globals.UrlMessage + Convert.ToInt32(Messages.PostPendingModeration);

                if (ForumID > 0)
                {
                    Context.Response.Redirect(strRedirect + "&ForumID=" + ForumID.ToString());
                }
                else
                {
                    Context.Response.Redirect(strRedirect + "&PostID=" + PostID.ToString());
                }
            }
        }
コード例 #4
0
        public void Render(HtmlTextWriter writer, bool displayActions, ForumUtils.ForumView forumView, bool selected, DateTime lastVisited, Page page, int loggedOnUserID, string avatar, string images, string document)
        {
            // New row
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Left hand side contains user information (user alias, avatar, number of posts etc)
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow");
            writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "160");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // We will put this user information in its own table in the first column
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "3");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "160");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            // User alias and number of posts
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.RenderBeginTag(HtmlTextWriterTag.B);
            ForumText userAliasForumText = new ForumText(User.Alias);

            writer.Write(userAliasForumText.ProcessSingleLine(images));
            writer.RenderEndTag();              // B
            writer.RenderBeginTag(HtmlTextWriterTag.Br);
            writer.Write(string.Format("Posts: {0}", User.PostCount));
            writer.RenderEndTag();              // Br
            writer.RenderEndTag();              // Td
            writer.RenderEndTag();              // Tr

            // Avatar
            if (forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_avatarrow");
                if (!selected)
                {
                    writer.AddStyleAttribute("display", "none");
                }
            }
            if ((selected && forumView == ForumUtils.ForumView.TreeView) || forumView != ForumUtils.ForumView.TreeView)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                if (avatar != string.Empty)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                    writer.AddAttribute(HtmlTextWriterAttribute.Src, avatar);
                    writer.RenderBeginTag(HtmlTextWriterTag.Img);
                    writer.RenderEndTag();              // Img
                }
                writer.RenderEndTag();                  // Td
                writer.RenderEndTag();                  // Tr
            }

            // End user information table
            writer.RenderEndTag();              // Table
            writer.RenderEndTag();              // Td

            // Start row which will display subject, body and actions (reply, edit, etc)
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            if (forumView != ForumUtils.ForumView.FlatView && !selected)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            }
            if (forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_headercell");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // Start a new table for this information
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "3");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            if (forumView != ForumUtils.ForumView.FlatView && !selected)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            if (forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_messagetable");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            // Highlighted row (subject and when posted information)
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            if (forumView != ForumUtils.ForumView.FlatView)
            {
                RenderLevelIndentCell(writer);
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.RenderBeginTag(HtmlTextWriterTag.B);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, PostID.ToString());
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.RenderEndTag();

            // Provide link to select a different post
            writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", PostID), "forumaction=&searchpage=&threadspage=") + "#" + PostID);
            if (forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, "DynMessLink");
                writer.AddAttribute(HtmlTextWriterAttribute.Name, PostID.ToString());
            }
            writer.RenderBeginTag(HtmlTextWriterTag.A);

            ForumText subjectForumText = new ForumText(Subject);

            writer.Write(subjectForumText.ProcessSingleLine(images));
            writer.RenderEndTag();              // A
            writer.RenderEndTag();              // B

            // Display new image if this post is new since last time user visited
            if (lastVisited < PostDate)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "new.gif");
                writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Br);
            writer.Write(string.Format("Posted: {0} {1}", PostDate.ToString("dd MMM yy"), PostDate.ToString("t")));
            writer.RenderEndTag();              // Br
            writer.RenderEndTag();              // Td
            writer.RenderEndTag();              // Tr

            // Message row
            if ((selected && forumView == ForumUtils.ForumView.TreeView) || forumView != ForumUtils.ForumView.TreeView)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
                if (forumView == ForumUtils.ForumView.TreeViewDynamic)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_messagerow");
                    if (!selected)
                    {
                        writer.AddStyleAttribute("display", "none");
                    }
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                if (forumView != ForumUtils.ForumView.FlatView)
                {
                    RenderLevelIndentCell(writer);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                ForumText bodyForumText = new ForumText(Body);
                writer.Write(bodyForumText.Process(images));

                writer.RenderEndTag();                  // Td
                writer.RenderEndTag();                  // Tr
            }

            // Reply, Quote, Edit, Get Link row
            if (displayActions && ((selected && forumView == ForumUtils.ForumView.TreeView) || forumView != ForumUtils.ForumView.TreeView))
            {
                if (forumView == ForumUtils.ForumView.TreeViewDynamic)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_actionsrow");
                    if (!selected)
                    {
                        writer.AddStyleAttribute("display", "none");
                    }
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                if (forumView != ForumUtils.ForumView.FlatView)
                {
                    RenderLevelIndentCell(writer);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
                writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
                writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
                writer.RenderBeginTag(HtmlTextWriterTag.Table);
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                writer.AddAttribute(HtmlTextWriterAttribute.Align, "Left");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                // Reply link
                writer.Write("[");
                writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}&forumaction=reply", PostID), "searchpage=&threadspage="));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("Reply");
                writer.RenderEndTag();                  // A
                writer.Write("]");

                // Quote link
                writer.Write("[");
                writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}&forumaction=quote", PostID), "searchpage=&threadspage="));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("Quote");
                writer.RenderEndTag();                  // A
                writer.Write("]");

                if (forumView == ForumUtils.ForumView.TreeViewDynamic)
                {
                    // Get Link
                    writer.Write("[");
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", PostID), "forumaction=&searchpage=&threadspage=") + "#" + PostID);
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.Write("Get Link");
                    writer.RenderEndTag();                       // A
                    writer.Write("]");
                }

                writer.RenderEndTag();                  // Td

                writer.AddAttribute(HtmlTextWriterAttribute.Align, "Right");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);

                // Edit link (only allowed if this post by currently logged on user or an administrator)
                if (User.UserID == loggedOnUserID || page.User.IsInRole("ForumAdmin"))
                {
                    writer.Write("[");
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}&forumaction=edit", PostID), "searchpage=&threadspage="));
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.Write("Edit");
                    writer.RenderEndTag();                      // A
                    writer.Write("]");
                }

                writer.RenderEndTag();                  // Td
                writer.RenderEndTag();                  // Tr
                writer.RenderEndTag();                  // Table

                writer.RenderEndTag();                  // Td
                writer.RenderEndTag();                  // Tr
            }

            // Close out table and this row
            writer.RenderEndTag();              // Table
            writer.RenderEndTag();              // Td
            writer.RenderEndTag();              // Tr
        }
コード例 #5
0
    /// <summary>
    /// Returns parameters according to the upload mode.
    /// </summary>
    private string GetModeParameters()
    {
        string[] args = null;

        if (MediaLibraryID > 0)
        {
            // MediaLibrary mode
            args = new string[] {
                "MediaLibraryID", MediaLibraryID.ToString(),
                "MediaFolderPath", HttpUtility.UrlEncode(MediaFolderPath),
                "MediaFileID", MediaFileID.ToString(),
                "IsMediaThumbnail", IsMediaThumbnail.ToString(),
                "MediaFileName", HttpUtility.UrlEncode(MediaFileName)
            };

            return("MediaLibraryArgs=" + GetArgumentsString(args));
        }
        else
        {
            if ((NodeID > 0) && (SourceType == MediaSourceEnum.Content))
            {
                // CMS.File mode
                args = new string[] {
                    "NodeID", NodeID.ToString(),
                    "DocumentCulture", DocumentCulture,
                    "IncludeExtension", IncludeExtension.ToString(),
                    "NodeGroupID", NodeGroupID.ToString()
                };

                return("FileArgs=" + GetArgumentsString(args));
            }
            else
            {
                if (ObjectID > 0)
                {
                    // MetaFile mode
                    args = new string[] {
                        "MetaFileID", MetaFileID.ToString(),
                        "ObjectID", ObjectID.ToString(),
                        "SiteID", SiteID.ToString(),
                        "ObjectType", ObjectType,
                        "Category", Category
                    };

                    return("MetaFileArgs=" + GetArgumentsString(args));
                }
                else
                {
                    if (PostForumID > 0)
                    {
                        // Forum attachment
                        args = new string[] {
                            "PostForumID", PostForumID.ToString(),
                            "PostID", PostID.ToString()
                        };

                        return("ForumArgs=" + GetArgumentsString(args));
                    }
                    else
                    {
                        if ((DocumentID > 0) || (FormGUID != Guid.Empty))
                        {
                            // Attachment mode
                            args = new string[] {
                                "DocumentID", DocumentID.ToString(),
                                "DocumentParentNodeID", DocumentParentNodeID.ToString(),
                                "NodeClassName", NodeClassName,
                                "AttachmentGUIDColumnName", AttachmentGUIDColumnName,
                                "AttachmentGUID", AttachmentGUID.ToString(),
                                "AttachmentGroupGUID", AttachmentGroupGUID.ToString(),
                                "FormGUID", FormGUID.ToString(),
                                "IsFieldAttachment", mIsFiledAttachment.ToString()
                            };

                            return("AttachmentArgs=" + GetArgumentsString(args));
                        }
                    }
                }
            }
        }
        return(String.Empty);
    }
コード例 #6
0
    /// <summary>
    /// Returns parameters according to the upload mode.
    /// </summary>
    private string GetModeParameters()
    {
        string[] args;

        if (MediaLibraryID > 0)
        {
            // MediaLibrary mode
            args = new[]
            {
                "MediaLibraryID", MediaLibraryID.ToString(),
                "MediaFolderPath", MediaFolderPath,
                "MediaFileID", MediaFileID.ToString(),
                "IsMediaThumbnail", IsMediaThumbnail.ToString(),
                "MediaFileName", MediaFileName
            };
            return("MediaLibraryArgs=" + GetArgumentsString(args, UploaderHelper.MEDIA_LIBRARY_ARGS_HASHING_PURPOSE));
        }

        if ((NodeID > 0) && (SourceType == MediaSourceEnum.Content))
        {
            // File mode
            args = new[]
            {
                "NodeID", NodeID.ToString(),
                "DocumentCulture", DocumentCulture,
                "IncludeExtension", IncludeExtension.ToString(),
                "NodeGroupID", NodeGroupID.ToString()
            };
            return("FileArgs=" + GetArgumentsString(args, UploaderHelper.FILE_ARGS_HASHING_PURPOSE));
        }

        if (ObjectID > 0)
        {
            // MetaFile mode
            args = new[]
            {
                "MetaFileID", MetaFileID.ToString(),
                "ObjectID", ObjectID.ToString(),
                "SiteID", SiteID.ToString(),
                "ObjectType", ObjectType,
                "Category", Category
            };
            return("MetaFileArgs=" + GetArgumentsString(args, UploaderHelper.META_FILE_ARGS_HASHING_PURPOSE));
        }

        if (PostForumID > 0)
        {
            // Forum attachment
            args = new[]
            {
                "PostForumID", PostForumID.ToString(),
                "PostID", PostID.ToString()
            };
            return("ForumArgs=" + GetArgumentsString(args, UploaderHelper.FORUM_ARGS_HASHING_PURPOSE));
        }

        if ((DocumentID > 0) || (FormGUID != Guid.Empty))
        {
            // Attachment mode
            args = new[]
            {
                "DocumentID", DocumentID.ToString(),
                "DocumentParentNodeID", DocumentParentNodeID.ToString(),
                "NodeClassName", NodeClassName,
                "AttachmentGUIDColumnName", AttachmentGUIDColumnName,
                "AttachmentGUID", AttachmentGUID.ToString(),
                "AttachmentGroupGUID", AttachmentGroupGUID.ToString(),
                "FormGUID", FormGUID.ToString(),
                "IsFieldAttachment", mIsFiledAttachment.ToString(),
                "FullRefresh", FullRefresh.ToString()
            };
            return("AttachmentArgs=" + GetArgumentsString(args, UploaderHelper.ATTACHEMENT_ARGS_HASHING_PURPOSE));
        }
        return(String.Empty);
    }
コード例 #7
0
    protected void InitializeMenu()
    {
        // Check if maximum post level is not exceeded
        bool maxLevelExceeded = (PostInfo != null) && (PostInfo.PostLevel >= ForumPostInfoProvider.MaxPostLevel);

        var actionsElem = ((CMSPage)Page).HeaderActions;

        actionsElem.AddAction(new HeaderAction()
        {
            Text          = GetString("general.edit"),
            Tooltip       = GetString("ForumPost_View.EditToolTip"),
            OnClientClick = "EditPost(" + PostID + "); return false;"
        });
        actionsElem.AddAction(new HeaderAction()
        {
            Text          = GetString("general.delete"),
            Tooltip       = GetString("ForumPost_View.DeleteToolTip"),
            OnClientClick = "DeletePost(" + PostID + "); return false;"
        });
        actionsElem.AddAction(new HeaderAction()
        {
            Text          = GetString("ForumPost_View.IconReply"),
            Tooltip       = GetString("ForumPost_View.ReplyToolTip"),
            OnClientClick = maxLevelExceeded ? "return false;" : "ReplyToPost(" + PostID + "); return false;",
            Enabled       = !maxLevelExceeded,
        });

        // Stick thread
        if (PostInfo.PostLevel == 0)
        {
            mThreadMove.SetValue("AdminMode", true);
            mThreadMove.SetValue("SelectedThreadID", PostInfo.PostId);

            actionsElem.AddAction(new HeaderAction()
            {
                Text          = GetString("ForumPost_View.IconMove"),
                Tooltip       = GetString("ForumPost_View.MoveToolTip"),
                OnClientClick = ControlsHelper.GetPostBackEventReference(btnMoveThread, null) + "; return false;"
            });

            bool isUnstick = (PostInfo.PostStickOrder > 0);
            actionsElem.AddAction(new HeaderAction()
            {
                Text          = isUnstick ? GetString("ForumPost_View.IconUnStick") : GetString("ForumPost_View.IconStick"),
                Tooltip       = isUnstick ? GetString("ForumPost_View.UnStickToolTip") : GetString("ForumPost_View.StickToolTip"),
                OnClientClick = "StickThread(" + PostID + "); return false;"
            });

            bool isLocked = PostInfo.PostIsLocked;
            actionsElem.AddAction(new HeaderAction()
            {
                Text          = isLocked ? GetString("ForumPost_View.IconUnLock") : GetString("ForumPost_View.IconLock"),
                Tooltip       = isLocked ? GetString("ForumPost_View.UnLockToolTip") : GetString("ForumPost_View.LockToolTip"),
                OnClientClick = "LockThread(" + PostID + "); return false;"
            });
        }
        else
        {
            actionsElem.AddAction(new HeaderAction()
            {
                Text          = GetString("ForumPost_View.IconSplit"),
                Tooltip       = GetString("ForumPost_View.SplitToolTip"),
                OnClientClick = "SplitThread(" + PostID + "); return false;"
            });

            //Register split confirmation script
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumSplitConfirm",
                                                   ScriptHelper.GetScript(" function ForumSplitConfirm() {\n" +
                                                                          "if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.SplitConfirmation")) + ")) { \n ;SplitThread(" + PostID.ToString() + "); return false; \n}else{ return false; }\n}"
                                                                          ));
        }

        bool isApproved = PostInfo.PostApproved;

        actionsElem.AddAction(new HeaderAction()
        {
            Text          = isApproved ? GetString("general.reject") : GetString("general.approve"),
            Tooltip       = isApproved ? GetString("ForumPost_View.RejectToolTip") : GetString("ForumPost_View.ApproveToolTip"),
            OnClientClick = "ApprovePost(" + PostID + "); return false;"
        });


        if (isApproved)
        {
            actionsElem.AddAction(new HeaderAction()
            {
                Text          = GetString("ForumPost_View.IconRejectSubTree"),
                Tooltip       = GetString("ForumPost_View.RejectSubTreeToolTip"),
                OnClientClick = "RejectSubTree(" + PostID + "); return false;"
            });
        }
        else
        {
            actionsElem.AddAction(new HeaderAction()
            {
                Text          = GetString("ForumPost_View.IconApproveSubTree"),
                Tooltip       = GetString("ForumPost_View.ApproveSubTreeToolTip"),
                OnClientClick = "ApproveSubTree(" + PostID + "); return false;"
            });
        }
    }
コード例 #8
0
    protected void InitializeMenu()
    {
        // Check if maximum post level is not exceeded
        bool maxLevelExceeded = (PostInfo != null) && (PostInfo.PostLevel >= ForumPostInfoProvider.MaxPostLevel);

        // Edit
        lnkEdit.Text        = GetString("general.edit");
        lnkEdit.ToolTip     = GetString("ForumPost_View.EditToolTip");
        lnkEdit.NavigateUrl = "#";
        lnkEdit.Attributes.Add("onclick", "EditPost(" + PostID.ToString() + "); return false;");
        lnkEdit.Style.Add("color", "#000000;");

        lnkEditImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/edit.png");
        lnkEditImg.ToolTip     = GetString("ForumPost_View.EditToolTip");
        lnkEditImg.NavigateUrl = "#";
        lnkEditImg.Attributes.Add("onclick", "EditPost(" + PostID.ToString() + "); return false;");


        // Delete
        lnkDelete.Text        = GetString("general.delete");
        lnkDelete.ToolTip     = GetString("ForumPost_View.DeleteToolTip");
        lnkDelete.NavigateUrl = "#";
        lnkDelete.Attributes.Add("onclick", "DeletePost(" + PostID.ToString() + "); return false;");
        lnkDelete.Style.Add("color", "#000000;");

        lnkDeleteImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/delete.png");
        lnkDeleteImg.ToolTip     = GetString("ForumPost_View.DeleteToolTip");
        lnkDeleteImg.NavigateUrl = "#";
        lnkDeleteImg.Attributes.Add("onclick", "DeletePost(" + PostID.ToString() + "); return false;");


        // Reply
        lnkReply.Text        = GetString("ForumPost_View.IconReply");
        lnkReply.ToolTip     = GetString("ForumPost_View.ReplyToolTip");
        lnkReply.NavigateUrl = "#";
        lnkReply.Style.Add("color", "#000000;");
        if (maxLevelExceeded)
        {
            lnkReply.Enabled = false;
        }
        else
        {
            lnkReply.Attributes.Add("onclick", "ReplyToPost(" + PostID.ToString() + "); return false;");
        }

        lnkReplyImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/reply.png");
        lnkReplyImg.ToolTip     = GetString("ForumPost_View.ReplyToolTip");
        lnkReplyImg.NavigateUrl = "#";
        if (maxLevelExceeded)
        {
            lnkReplyImg.Enabled = false;
        }
        else
        {
            lnkReplyImg.Attributes.Add("onclick", "ReplyToPost(" + PostID.ToString() + "); return false;");
        }

        // Stick thread
        if (PostInfo.PostLevel == 0)
        {
            ThreadMove1.SetValue("AdminMode", true);
            ThreadMove1.SetValue("SelectedThreadID", PostInfo.PostId);

            lnkMoveThread.Text        = GetString("ForumPost_View.IconMove");
            lnkMoveThread.ToolTip     = GetString("ForumPost_View.MoveToolTip");
            lnkMoveThread.NavigateUrl = "#";
            lnkMoveThread.Attributes.Add("onclick", ControlsHelper.GetPostBackEventReference(btnMoveThread, null) + "; return false;");
            lnkMoveThread.Style.Add("color", "#000000;");

            lnkMoveThreadImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/move.png");
            lnkMoveThreadImg.ToolTip     = GetString("ForumPost_View.MoveToolTip");
            lnkMoveThreadImg.NavigateUrl = "#";
            lnkMoveThreadImg.Attributes.Add("onclick", ControlsHelper.GetPostBackEventReference(btnMoveThread, null) + "; return false;");

            plcSplit.Visible = false;

            if (PostInfo.PostStickOrder > 0)
            {
                lnkStick.Text        = GetString("ForumPost_View.IconUnStick");
                lnkStick.ToolTip     = GetString("ForumPost_View.UnStickToolTip");
                lnkStickImg.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/unstick.png");
                lnkStickImg.ToolTip  = GetString("ForumPost_View.UnStickToolTip");
            }
            else
            {
                lnkStick.Text        = GetString("ForumPost_View.IconStick");
                lnkStick.ToolTip     = GetString("ForumPost_View.StickToolTip");
                lnkStickImg.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/stick.png");
                lnkStickImg.ToolTip  = GetString("ForumPost_View.StickToolTip");
            }

            lnkStick.Attributes.Add("onclick", "StickThread(" + PostID.ToString() + "); return false;");
            lnkStick.Style.Add("color", "#000000;");
            lnkStick.NavigateUrl    = "#";
            lnkStickImg.NavigateUrl = "#";
            lnkStickImg.Attributes.Add("onclick", "StickThread(" + PostID.ToString() + "); return false;");

            // Lock thread
            if (PostInfo.PostIsLocked)
            {
                lnkLock.Text        = GetString("ForumPost_View.IconUnLock");
                lnkLock.ToolTip     = GetString("ForumPost_View.UnLockToolTip");
                lnkLockImg.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/unstick.png");
                lnkLockImg.ToolTip  = GetString("ForumPost_View.UnLockToolTip");
            }
            else
            {
                lnkLock.Text        = GetString("ForumPost_View.IconLock");
                lnkLock.ToolTip     = GetString("ForumPost_View.LockToolTip");
                lnkLockImg.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/lock.png");
                lnkLockImg.ToolTip  = GetString("ForumPost_View.LockToolTip");
            }

            lnkLock.Attributes.Add("onclick", "LockThread(" + PostID.ToString() + "); return false;");
            lnkLock.Style.Add("color", "#000000;");
            lnkLock.NavigateUrl    = "#";
            lnkLockImg.NavigateUrl = "#";
            lnkLockImg.Attributes.Add("onclick", "LockThread(" + PostID.ToString() + "); return false;");
        }
        else
        {
            // Hide lock and stick for posts which are not root of thread
            plcRoot.Visible = false;

            // Split
            lnkSplit.Text        = GetString("ForumPost_View.IconSplit");
            lnkSplit.ToolTip     = GetString("ForumPost_View.SplitToolTip");
            lnkSplit.NavigateUrl = "#";
            lnkSplit.Attributes.Add("onclick", "ForumSplitConfirm();return false;");
            lnkSplit.Style.Add("color", "#000000;");

            lnkSplitImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/split.png");
            lnkSplitImg.ToolTip     = GetString("ForumPost_View.SplitToolTip");
            lnkSplitImg.NavigateUrl = "#";
            lnkSplitImg.Attributes.Add("onclick", "SplitThread(" + PostID.ToString() + "); return false;");


            //Register split confirmation script
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumSplitConfirm",
                                                   ScriptHelper.GetScript(" function ForumSplitConfirm() {\n" +
                                                                          "if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.SplitConfirmation")) + ")) { \n ;SplitThread(" + PostID.ToString() + "); return false; \n}else{ return false; }\n}"
                                                                          ));
        }

        if (!PostInfo.PostApproved)
        {
            lnkApproveReject.Text        = GetString("general.approve");
            lnkApproveReject.ToolTip     = GetString("ForumPost_View.ApproveToolTip");
            lnkApproveRejectImg.ToolTip  = GetString("ForumPost_View.ApproveToolTip");
            lnkApproveRejectImg.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/approve.png");
        }
        else
        {
            lnkApproveReject.Text        = GetString("general.reject");
            lnkApproveReject.ToolTip     = GetString("ForumPost_View.RejectToolTip");
            lnkApproveRejectImg.ToolTip  = GetString("ForumPost_View.RejectToolTip");
            lnkApproveRejectImg.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/reject.png");
        }

        lnkApproveReject.NavigateUrl    = "#";
        lnkApproveRejectImg.NavigateUrl = "#";
        lnkApproveReject.Attributes.Add("onclick", "ApprovePost(" + PostID.ToString() + "); return false;");
        lnkApproveReject.Style.Add("color", "#000000;");
        lnkApproveRejectImg.Attributes.Add("onclick", "ApprovePost(" + PostID.ToString() + "); return false;");

        if (!PostInfo.PostApproved)
        {
            lnkApproveSub.Text        = GetString("ForumPost_View.IconApproveSubTree");
            lnkApproveSub.ToolTip     = GetString("ForumPost_View.ApproveSubTreeToolTip");
            lnkApproveSub.NavigateUrl = "#";
            lnkApproveSub.Attributes.Add("onclick", "ApproveSubTree(" + PostID.ToString() + "); return false;");
            lnkApproveSub.Style.Add("color", "#000000;");

            lnkApproveSubImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/approve.png");
            lnkApproveSubImg.ToolTip     = GetString("ForumPost_View.ApproveSubTreeToolTip");
            lnkApproveSubImg.NavigateUrl = "#";
            lnkApproveSubImg.Attributes.Add("onclick", "ApproveSubTree(" + PostID.ToString() + "); return false;");
        }
        else
        {
            lnkApproveSub.Text        = GetString("ForumPost_View.IconRejectSubTree");
            lnkApproveSub.ToolTip     = GetString("ForumPost_View.RejectSubTreeToolTip");
            lnkApproveSub.NavigateUrl = "#";
            lnkApproveSub.Attributes.Add("onclick", "RejectSubTree(" + PostID.ToString() + "); return false;");
            lnkApproveSub.Style.Add("color", "#000000;");

            lnkApproveSubImg.ImageUrl    = GetImageUrl("CMSModules/CMS_Forums/reject.png");
            lnkApproveSubImg.ToolTip     = GetString("ForumPost_View.RejectSubTreeToolTip");
            lnkApproveSubImg.NavigateUrl = "#";
            lnkApproveSubImg.Attributes.Add("onclick", "RejectSubTree(" + PostID.ToString() + "); return false;");
        }
    }
コード例 #9
0
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        override protected void InitializeSkin(Control skin)
        {
            Label title;
            Label body;

            // Do some processing on the messages
            message.Body = message.Body.Replace("<UrlHome>", "<a href=\"" + Globals.UrlHome + "\">" + Globals.SiteName + " Home</a>");
            message.Body = message.Body.Replace("<UrlLogin>", "<a href=\"" + Globals.UrlLogin + "\">" + Globals.SiteName + " Login</a>");
            message.Body = message.Body.Replace("<UrlProfile>", "<a href=\"" + Globals.UrlEditUserProfile + "\">user profile</a>");

            // Handle duplicate post messages or moderation messages
            if ((message.Body.IndexOf("<DuplicatePost>") > 0) || (message.Body.IndexOf("<PendingModeration>") > 0))
            {
                if (ForumID > 0)
                {
                    message.Body = message.Body.Replace("<DuplicatePost>", "<a href=\"" + Globals.UrlShowForum + ForumID.ToString() + "\">" + "Return to forum</a>");
                    message.Body = message.Body.Replace("<PendingModeration>", "<a href=\"" + Globals.UrlShowForum + ForumID.ToString() + "\">" + "Return to forum</a>");
                }
                else if (PostID > 0)
                {
                    message.Body = message.Body.Replace("<DuplicatePost>", "<a href=\"" + Globals.UrlShowPost + PostID.ToString() + "\">" + "Return to post</a>");
                    message.Body = message.Body.Replace("<PendingModeration>", "<a href=\"" + Globals.UrlShowPost + PostID.ToString() + "\">" + "Return to post</a>");
                }
            }

            // Find the title
            title = (Label)skin.FindControl("MessageTitle");
            if (title != null)
            {
                title.Text = message.Title;
            }

            // Find the title
            body = (Label)skin.FindControl("MessageBody");
            if (body != null)
            {
                body.Text = message.Body;
            }
        }
コード例 #10
0
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        override protected void InitializeSkin(Control skin)
        {
            // We require a post id value
            if (PostID == -1)
            {
                throw new AspNetForums.Components.PostNotFoundException("You must set the PostID property of this control to the post being moderated.");
            }

            // Find the controls in our control template.

            // Approve Post
            approvePost = (LinkButton)skin.FindControl("ApprovePost");
            if (null != approvePost)
            {
                approvePost.Command += new CommandEventHandler(ApprovePost_Click);
            }

            // Approve Post and turn off moderation for the user
            approvePostAndTurnOffModeration = (LinkButton)skin.FindControl("ApprovePostAndTurnOffModeration");
            if (null != approvePostAndTurnOffModeration)
            {
                approvePostAndTurnOffModeration.Command += new CommandEventHandler(ApprovePostAndTurnOffModeration_Click);
            }

            // Approve Post and reply to the message
            approvePostAndReply = (LinkButton)skin.FindControl("ApprovePostAndReply");
            if (null != approvePostAndReply)
            {
                approvePostAndReply.Command += new CommandEventHandler(ApprovePostAndReply_Click);
            }

            // Approve Post and Edit
            approvePostAndEdit = (LinkButton)skin.FindControl("ApprovePostAndEdit");
            if (null != approvePostAndEdit)
            {
                approvePostAndEdit.Command += new CommandEventHandler(ApprovePostAndEdit_Click);
            }

            // Turn off moderation for this user
            turnOffModerationForUser = (LinkButton)skin.FindControl("TurnOffModeration");
            if (null != turnOffModerationForUser)
            {
                turnOffModerationForUser.CommandArgument = UsernamePostedBy;
                turnOffModerationForUser.Command        += new CommandEventHandler(TurnOffModerationForUser_Command);
            }

            // Delete the post/thread
            deletePost = (HyperLink)skin.FindControl("DeletePost");
            if (null != deletePost)
            {
                // Go to the delete view
                deletePost.NavigateUrl = Globals.UrlDeletePost + PostID + "&ReturnURL=" + Page.Server.UrlEncode(Page.Request.RawUrl);
            }

            // Moderation History
            moderationHistory = (HyperLink)skin.FindControl("ModerationHistory");
            if (null != moderationHistory)
            {
                // Go to the delete view
                moderationHistory.NavigateUrl = Globals.UrlModerationHistory + PostID + "&ReturnURL=" + Page.Server.UrlEncode(Page.Request.RawUrl);
            }

            // Move the post/thread
            movePost = (HyperLink)skin.FindControl("MovePost");
            if (null != movePost)
            {
                if (ThreadID == PostID)
                {
                    movePost.NavigateUrl = Globals.UrlMovePost + PostID + "&ReturnURL=" + Page.Server.UrlEncode(HttpContext.Current.Request.RawUrl);
                }
                else
                {
                    movePost.Enabled = false;
                }
            }

            // Edit the post
            editPost = (HyperLink)skin.FindControl("EditPost");
            if (null != editPost)
            {
                editPost.NavigateUrl = Globals.UrlEditPost + PostID;
            }

            // Moderate Thread
            moderateThread = (HyperLink)skin.FindControl("ModerateThread");
            if (null != moderateThread)
            {
                moderateThread.NavigateUrl = Globals.UrlModerateThread + PostID;
            }

            // Approve and move the post to a new forum
            approvePostAndMove = (DropDownList)skin.FindControl("ApprovePostAndMove");
            if (null != approvePostAndMove)
            {
                Forums forums   = new Forums();
                string username = base.ForumUser.Username;
                approvePostAndMove.AutoPostBack          = true;
                approvePostAndMove.SelectedIndexChanged += new System.EventHandler(ApprovePostAndMove_Changed);
                approvePostAndMove.DataValueField        = "Value";
                approvePostAndMove.DataTextField         = "Text";
                approvePostAndMove.DataSource            = forums.ForumListItemCollection(username, Forums.ForumListStyle.Flat);
                approvePostAndMove.DataBind();
                approvePostAndMove.Items.FindByValue("f-" + ForumID.ToString()).Selected = true;
            }

            // Username of user that created the post
            usernameLabel = (Label)skin.FindControl("Username");
            if (null != usernameLabel)
            {
                usernameLabel.Text = UsernamePostedBy;
            }

            // Display the PostID for the moderator
            postIDLabel = (Label)skin.FindControl("PostID");
            if (null != postIDLabel)
            {
                postIDLabel.Text = PostID.ToString();
            }
        }