コード例 #1
0
ファイル: Xslt.cs プロジェクト: tomfulton/OurUmbraco
        public static XPathNodeIterator TopicPager(int topicId, int itemsPerPage, int currentPage)
        {
            XmlDocument xd = new XmlDocument();

            Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicId);

            XmlNode pages = umbraco.xmlHelper.addTextNode(xd, "pages", "");

            int i = 0;
            int p = 0;

            while (i < (t.Replies))
            {
                XmlNode page = umbraco.xmlHelper.addTextNode(xd, "page", "");
                page.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "index", p.ToString()));
                if (p == currentPage)
                {
                    page.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "current", "true"));
                }
                pages.AppendChild(page);

                p++;
                i = (i + itemsPerPage);
            }

            return(pages.CreateNavigator().Select("."));
        }
コード例 #2
0
ファイル: Xslt.cs プロジェクト: tomfulton/OurUmbraco
        public static XPathNodeIterator Topic(int topicID)
        {
            XmlDocument xd = new XmlDocument();

            Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicID);

            if (t.Exists)
            {
                xd.AppendChild(t.ToXml(xd));
            }

            return(xd.CreateNavigator().Select("."));
        }
コード例 #3
0
ファイル: Rest.cs プロジェクト: eitherxor/OurUmbraco
        public static string DeleteTopic(int topicId)
        {
            var currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;

            if (Xslt.IsMemberInGroup("admin", currentMember))
            {
                var topic = new Businesslogic.Topic(topicId);
                topic.Delete();

                return "true";
            }

            return "false";
        }
コード例 #4
0
ファイル: Rest.cs プロジェクト: eitherxor/OurUmbraco
        public static string EditTopic(int topicId)
        {
            var currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
            var topic = new Businesslogic.Topic(topicId);

            if (topic.Editable(currentMember))
            {
                var title = HttpContext.Current.Request["title"];
                var body = HttpContext.Current.Request["body"];

                topic.Body = body;
                topic.Title = title;
                topic.Save(false);

                return Xslt.NiceTopicUrl(topic.Id);
            }

            return "0";
        }
コード例 #5
0
ファイル: Xslt.cs プロジェクト: tomfulton/OurUmbraco
        public static XPathNodeIterator TopicComments(int topicID)
        {
            XmlDocument xd = new XmlDocument();

            Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicID);

            if (t.Exists)
            {
                XmlNode comments = umbraco.xmlHelper.addTextNode(xd, "comments", "");

                foreach (Businesslogic.Comment cc in t.Comments)
                {
                    comments.AppendChild(cc.ToXml(xd));
                }

                xd.AppendChild(comments);
            }

            return(xd.CreateNavigator().Select("."));
        }
コード例 #6
0
ファイル: Xslt.cs プロジェクト: tomfulton/OurUmbraco
        public static string NiceTopicUrl(int topicId)
        {
            Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicId);

            if (t != null && t.Exists)
            {
                string _url = umbraco.library.NiceUrl(t.ParentId);

                if (umbraco.GlobalSettings.UseDirectoryUrls)
                {
                    return("/" + _url.Trim('/') + "/" + t.Id.ToString() + "-" + t.UrlName);
                }
                else
                {
                    return("/" + _url.Substring(0, _url.LastIndexOf('.')).Trim('/') + "/" + t.Id.ToString() + "-" + t.UrlName + ".aspx");
                }
            }
            else
            {
                return("");
            }
        }
コード例 #7
0
ファイル: Rest.cs プロジェクト: eitherxor/OurUmbraco
        public static string MoveTopic(int topicId, int newForumId)
        {
            var currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;

            if (Xslt.IsMemberInGroup("admin", currentMember))
            {
                var topic = new Businesslogic.Topic(topicId);
                topic.Move(newForumId);

                return Xslt.NiceTopicUrl(topic.Id);
            }

            return "false";
        }