当前位置: 首页>>代码示例>>C#>>正文


C# Template.CreateChild方法代码示例

本文整理汇总了C#中Template.CreateChild方法的典型用法代码示例。如果您正苦于以下问题:C# Template.CreateChild方法的具体用法?C# Template.CreateChild怎么用?C# Template.CreateChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Template的用法示例。


在下文中一共展示了Template.CreateChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderMessage

        internal static void RenderMessage(Core core, Template template, Message message)
        {
            MessageRecipient recipient = new MessageRecipient(core, core.Session.LoggedInMember, message.Id);

            VariableCollection messageVariableCollection = template.CreateChild("post_list");

            messageVariableCollection.Parse("SUBJECT", message.Subject);
            messageVariableCollection.Parse("POST_TIME", core.Tz.DateTimeToString(message.GetSentDate(core.Tz)));
            messageVariableCollection.Parse("URI", message.Uri);
            messageVariableCollection.Parse("ID", message.Id.ToString());
            core.Display.ParseBbcode(messageVariableCollection, "MESSAGE", message.Text);
            if (message.Sender != null)
            {
                messageVariableCollection.Parse("U_USER", message.Sender.Uri);
                messageVariableCollection.Parse("USER_DISPLAY_NAME", message.Sender.UserInfo.DisplayName);
                messageVariableCollection.Parse("USER_TILE", message.Sender.Tile);
                messageVariableCollection.Parse("USER_ICON", message.Sender.Icon);
                messageVariableCollection.Parse("USER_JOINED", core.Tz.DateTimeToString(message.Sender.UserInfo.GetRegistrationDate(core.Tz)));
                messageVariableCollection.Parse("USER_COUNTRY", message.Sender.Profile.Country);
                //core.Display.ParseBbcode(messageVariableCollection, "SIGNATURE", postersList[post.UserId].ForumSignature);

                if (message.Sender.Id == core.LoggedInMemberId)
                {
                    messageVariableCollection.Parse("OWNER", "TRUE");
                }
            }
            else
            {
                messageVariableCollection.Parse("USER_DISPLAY_NAME", "Anonymous");
            }

            if (recipient.IsRead)
            {
                messageVariableCollection.Parse("IS_READ", "TRUE");
            }
            else
            {
                messageVariableCollection.Parse("IS_READ", "FALSE");
            }

            recipient.MarkRead();
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:42,代码来源:AccountMessage.cs

示例2: RenderPreview

        public Template RenderPreview()
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "topicpost");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            VariableCollection postVariableCollection = template.CreateChild("post_list");

            Dictionary<long, ForumMember> postersList = ForumMember.GetMembers(core, Forum.Owner, new List<long> { UserId });

            postVariableCollection.Parse("SUBJECT", Title);
            postVariableCollection.Parse("POST_TIME", core.Tz.DateTimeToString(GetCreatedDate(core.Tz)));
            postVariableCollection.Parse("URI", Uri);
            //postVariableCollection.Parse("POST_MODIFIED", core.tz.DateTimeToString(post.GetModifiedDate(core.tz)));
            postVariableCollection.Parse("ID", Id.ToString());
            core.Display.ParseBbcode(postVariableCollection, "TEXT", Text);
            if (postersList.ContainsKey(UserId))
            {
                postVariableCollection.Parse("U_USER", postersList[UserId].Uri);
                postVariableCollection.Parse("USER_DISPLAY_NAME", postersList[UserId].UserInfo.DisplayName);
                postVariableCollection.Parse("USER_TILE", postersList[UserId].Tile);
                postVariableCollection.Parse("USER_ICON", postersList[UserId].Icon);
                postVariableCollection.Parse("USER_JOINED", core.Tz.DateTimeToString(postersList[UserId].UserInfo.GetRegistrationDate(core.Tz)));
                postVariableCollection.Parse("USER_COUNTRY", postersList[UserId].Profile.Country);
                postVariableCollection.Parse("USER_POSTS", postersList[UserId].ForumPosts.ToString());
                core.Display.ParseBbcode(postVariableCollection, "SIGNATURE", postersList[UserId].ForumSignature);

                /*if (ranksList.ContainsKey(postersList[post.UserId].ForumRankId))
                {
                    postVariableCollection.Parse("USER_RANK", ranksList[postersList[UserId].ForumRankId].RankTitleText);
                }*/
            }
            else
            {
                postVariableCollection.Parse("USER_DISPLAY_NAME", "Anonymous");
            }

            /*if (thisTopic.ReadStatus == null)
            {*/
                postVariableCollection.Parse("IS_READ", "FALSE");
            /*}
            else
            {
                if (thisTopic.ReadStatus.ReadTimeRaw < post.TimeCreatedRaw)
                {
                    postVariableCollection.Parse("IS_READ", "FALSE");
                }
                else
                {
                    postVariableCollection.Parse("IS_READ", "TRUE");
                }
            }*/

            return template;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:55,代码来源:TopicPost.cs

示例3: ShowGroupNews

        public void ShowGroupNews(HookEventArgs e)
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "viewprofilenews");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            if (e.Owner is UserGroup)
            {
                News news = new News(e.core, (UserGroup)e.Owner);

                List<Article> articles = news.GetArticles(1, 5);

                foreach (Article article in articles)
                {
                    VariableCollection articleVariableCollection = template.CreateChild("news_list");

                    articleVariableCollection.Parse("TITLE", article.ArticleSubject);
                }
            }

            e.core.AddSidePanel(template);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:22,代码来源:AppInfo.cs

示例4: Show

        public static void Show(Core core, TPage page, User owner)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (core.ResponseFormat == ResponseFormats.Xml)
            {
                ShowMore(core, page, owner);
                return;
            }

            Template template = new Template(core.Http.TemplatePath, "viewfeed.html");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", owner.ItemKey);

            template.Parse("S_STATUS_PERMISSIONS", permissionSelectBox);

            bool moreContent = false;
            long lastId = 0;
            bool first = true;

            List<Action> feedActions = Feed.GetItems(core, owner, page.TopLevelPageNumber, 20, page.TopLevelPageOffset, out moreContent);

            if (feedActions.Count > 0)
            {
                template.Parse("HAS_FEED_ITEMS", "TRUE");
                VariableCollection feedDateVariableCollection = null;
                string lastDay = core.Tz.ToStringPast(core.Tz.Now);

                foreach (Action feedAction in feedActions)
                {
                    DateTime feedItemDay = feedAction.GetTime(core.Tz);

                    if (feedDateVariableCollection == null || lastDay != core.Tz.ToStringPast(feedItemDay))
                    {
                        lastDay = core.Tz.ToStringPast(feedItemDay);
                        feedDateVariableCollection = template.CreateChild("feed_days_list");

                        feedDateVariableCollection.Parse("DAY", lastDay);
                    }

                    if (first)
                    {
                        first = false;
                        template.Parse("NEWEST_ID", feedAction.Id.ToString());
                    }

                    VariableCollection feedItemVariableCollection = feedDateVariableCollection.CreateChild("feed_item");

                    core.Display.ParseBbcode(feedItemVariableCollection, "TITLE", feedAction.FormattedTitle);
                    /*if ((!core.IsMobile) && (!string.IsNullOrEmpty(feedAction.BodyCache)))
                    {
                        core.Display.ParseBbcodeCache(feedItemVariableCollection, "TEXT", feedAction.BodyCache);
                    }
                    else*/
                    {
                        Primitive itemOwner = core.PrimitiveCache[feedAction.OwnerId];
                        if (feedAction.InteractItem is IActionableItem)
                        {
                            itemOwner = ((IActionableItem)feedAction.InteractItem).Owner;

                            if (((IActionableItem)feedAction.InteractItem).ApplicationId > 0)
                            {
                                try
                                {
                                    ApplicationEntry ae = new ApplicationEntry(core, ((IActionableItem)feedAction.InteractItem).ApplicationId);

                                    if (ae.ApplicationType == ApplicationType.OAuth)
                                    {
                                        OAuthApplication oae = new OAuthApplication(core, ae);

                                        feedItemVariableCollection.Parse("VIA_APP_TITLE", oae.DisplayTitle);
                                        feedItemVariableCollection.Parse("U_VIA_APP", oae.Uri);
                                    }
                                }
                                catch (InvalidApplicationException)
                                {
                                }
                            }
                        }
                        else if (feedAction.ActionedItem is IActionableItem)
                        {
                            itemOwner = ((IActionableItem)feedAction.ActionedItem).Owner;

                            if (((IActionableItem)feedAction.ActionedItem).ApplicationId > 0)
                            {
                                try
                                {
                                    ApplicationEntry ae = new ApplicationEntry(core, ((IActionableItem)feedAction.ActionedItem).ApplicationId);

                                    if (ae.ApplicationType == ApplicationType.OAuth)
                                    {
                                        OAuthApplication oae = new OAuthApplication(core, ae);

                                        feedItemVariableCollection.Parse("VIA_APP_TITLE", oae.DisplayTitle);
                                        feedItemVariableCollection.Parse("U_VIA_APP", oae.Uri);
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:Feed.cs

示例5: RenderPreview

        public Template RenderPreview()
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "blogentry");
            template.SetProse(core.Prose);

            VariableCollection blogPostVariableCollection = template.CreateChild("blog_list");

            blogPostVariableCollection.Parse("TITLE", Title);

            DateTime postDateTime = GetPublishedDate(core.Tz);

            string postUrl = HttpUtility.HtmlEncode(string.Format("{0}blog/{1}/{2:00}/{3}",
                    Owner.UriStub, postDateTime.Year, postDateTime.Month, PostId));

            blogPostVariableCollection.Parse("DATE", core.Tz.DateTimeToString(postDateTime));
            blogPostVariableCollection.Parse("URL", postUrl);
            blogPostVariableCollection.Parse("ID", Id);
            blogPostVariableCollection.Parse("TYPE_ID", ItemKey.TypeId);

            blogPostVariableCollection.Parse("POST", Functions.TrimStringToWord(HttpUtility.HtmlDecode(core.Bbcode.StripTags(HttpUtility.HtmlEncode(Body))), 256, true));

            if (core.Session.IsLoggedIn)
            {
                if (Owner.IsItemOwner(core.Session.LoggedInMember))
                {
                    blogPostVariableCollection.Parse("IS_OWNER", "TRUE");
                    blogPostVariableCollection.Parse("U_DELETE", DeleteUri);
                }
            }

            if (Info.Likes > 0)
            {
                blogPostVariableCollection.Parse("LIKES", string.Format(" {0:d}", Info.Likes));
                blogPostVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", Info.Dislikes));
            }

            if (Info.Comments > 0)
            {
                blogPostVariableCollection.Parse("COMMENTS", string.Format(" ({0:d})", Info.Comments));
            }

            return template;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:43,代码来源:BlogEntry.cs

示例6: AccountGalleriesUpload_Save


//.........这里部分代码省略.........
                        }

                        slug = core.Http.Files[i].FileName;

                        MemoryStream stream = new MemoryStream();
                        core.Http.Files[i].InputStream.CopyTo(stream);

                        db.BeginTransaction();

                        GalleryItem newGalleryItem = GalleryItem.Create(core, Owner, parent, title, ref slug, core.Http.Files[i].FileName, core.Http.Files[i].ContentType, (ulong)core.Http.Files[i].ContentLength, description, core.Functions.GetLicenseId(), core.Functions.GetClassification(), stream, highQualitySave /*, width, height*/);
                        stream.Close();

                        if (publishToFeed && i < 3)
                        {
                            core.CallingApplication.PublishToFeed(core, LoggedInMember, parent, newGalleryItem, Functions.SingleLine(core.Bbcode.Flatten(newGalleryItem.ItemAbstract)));
                        }
                    }

                    //db.CommitTransaction();

                    if (core.ResponseFormat == ResponseFormats.Xml)
                    {
                        long newestId = core.Functions.FormLong("newest-id", 0);
                        long newerId = 0;

                        List<BoxSocial.Internals.Action> feedActions = Feed.GetNewerItems(core, LoggedInMember, newestId);

                        Template template = new Template("pane.feeditem.html");
                        template.Medium = core.Template.Medium;
                        template.SetProse(core.Prose);

                        foreach (BoxSocial.Internals.Action feedAction in feedActions)
                        {
                            VariableCollection feedItemVariableCollection = template.CreateChild("feed_days_list.feed_item");

                            if (feedAction.Id > newerId)
                            {
                                newerId = feedAction.Id;
                            }

                            core.Display.ParseBbcode(feedItemVariableCollection, "TITLE", feedAction.FormattedTitle);
                            core.Display.ParseBbcode(feedItemVariableCollection, "TEXT", feedAction.Body, core.PrimitiveCache[feedAction.OwnerId], true, string.Empty, string.Empty);

                            feedItemVariableCollection.Parse("USER_DISPLAY_NAME", feedAction.Owner.DisplayName);

                            feedItemVariableCollection.Parse("ID", feedAction.ActionItemKey.Id);
                            feedItemVariableCollection.Parse("TYPE_ID", feedAction.ActionItemKey.TypeId);

                            if (feedAction.ActionItemKey.GetType(core).Likeable)
                            {
                                feedItemVariableCollection.Parse("LIKEABLE", "TRUE");

                                if (feedAction.Info.Likes > 0)
                                {
                                    feedItemVariableCollection.Parse("LIKES", string.Format(" {0:d}", feedAction.Info.Likes));
                                    feedItemVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", feedAction.Info.Dislikes));
                                }
                            }

                            if (feedAction.ActionItemKey.GetType(core).Commentable)
                            {
                                feedItemVariableCollection.Parse("COMMENTABLE", "TRUE");

                                if (feedAction.Info.Comments > 0)
                                {
                                    feedItemVariableCollection.Parse("COMMENTS", string.Format(" ({0:d})", feedAction.Info.Comments));
开发者ID:smithydll,项目名称:boxsocial,代码行数:67,代码来源:UploadForm.cs

示例7: ShowNetworkGallery

        /// <summary>
        /// Hook showing gallery items on a network profile.
        /// </summary>
        /// <param name="e">Hook event arguments</param>
        public void ShowNetworkGallery(HookEventArgs e)
        {
            Network theNetwork = (Network)e.Owner;

            Template template = new Template(Assembly.GetExecutingAssembly(), "viewprofilegallery");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            Gallery gallery = new Gallery(e.core, theNetwork);

            List<GalleryItem> galleryItems = gallery.GetItems(e.core, 1, 6, 0);

            template.Parse("PHOTOS", theNetwork.GalleryItems.ToString());

            foreach (GalleryItem galleryItem in galleryItems)
            {
                VariableCollection galleryVariableCollection = template.CreateChild("photo_list");

                galleryVariableCollection.Parse("TITLE", galleryItem.ItemTitle);
                galleryVariableCollection.Parse("PHOTO_URI", Gallery.BuildPhotoUri(core, theNetwork, galleryItem.Path));

                string thumbUri = string.Format("/network/{0}/images/_tiny/{1}",
                    theNetwork.NetworkNetwork, galleryItem.Path);
                galleryVariableCollection.Parse("THUMBNAIL", thumbUri);
            }

            template.Parse("U_NETWORK_GALLERY", Gallery.BuildGalleryUri(core, theNetwork));

            e.core.AddMainPanel(template);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:34,代码来源:AppInfo.cs

示例8: Page_Load


//.........这里部分代码省略.........
                catch (CommentTooShortException)
                {
                    core.Response.ShowMessage("commentTooShort", "Comment Too Short", "The comment you have attempted to post is too short, must be longer than two characters.");
                }
                catch (InvalidCommentException)
                {
                    core.Response.ShowMessage("invalidComment", "Invalid Comment", "The comment you have attempted to post is invalid. (0x05)");
                }
                catch (Exception ex)
                {
                    core.Response.ShowMessage("invalidComment", "Invalid Comment", "The comment you have attempted to post is invalid. (0x06) " + ex.ToString());
                }

                if (core.ResponseFormat == ResponseFormats.Xml)
                {
                    Template ct = new Template(Server.MapPath("./templates"), "pane.comment.html");
                    template.Medium = core.Template.Medium;
                    ct.SetProse(core.Prose);

                    if (core.Session.IsLoggedIn && loggedInMember != null)
                    {
                        ct.Parse("LOGGED_IN", "TRUE");
                        ct.Parse("USER_DISPLAY_NAME", core.Session.LoggedInMember.DisplayName);
                        ct.Parse("USER_TILE", core.Session.LoggedInMember.Tile);
                        ct.Parse("USER_ICON", core.Session.LoggedInMember.Icon);
                    }

                    if (item != null)
                    {
                        template.Parse("ITEM_ID", item.Id.ToString());
                        template.Parse("ITEM_TYPE", item.ItemKey.TypeId.ToString());
                    }

                    VariableCollection commentsVariableCollection = ct.CreateChild("comment-list");

                    //commentsVariableCollection.ParseRaw("COMMENT", Bbcode.Parse(HttpUtility.HtmlEncode(comment), core.session.LoggedInMember));
                    core.Display.ParseBbcode(commentsVariableCollection, "COMMENT", comment);
                    // TODO: finish comments this
                    commentsVariableCollection.Parse("ID", commentId.ToString());
                    commentsVariableCollection.Parse("TYPE_ID", ItemKey.GetTypeId(core, typeof(Comment)));
                    commentsVariableCollection.Parse("USERNAME", loggedInMember.DisplayName);
                    commentsVariableCollection.Parse("USER_ID", loggedInMember.Id.ToString());
                    commentsVariableCollection.Parse("U_PROFILE", loggedInMember.ProfileUri);
                    commentsVariableCollection.Parse("U_QUOTE", core.Hyperlink.BuildCommentQuoteUri(commentId));
                    commentsVariableCollection.Parse("U_REPORT", core.Hyperlink.BuildCommentReportUri(commentId));
                    commentsVariableCollection.Parse("U_DELETE", core.Hyperlink.BuildCommentDeleteUri(commentId));
                    commentsVariableCollection.Parse("TIME", tz.DateTimeToString(tz.Now));
                    commentsVariableCollection.Parse("USER_TILE", loggedInMember.Tile);
                    commentsVariableCollection.Parse("USER_ICON", loggedInMember.Icon);

                    try
                    {
                        if (core.Session.IsLoggedIn)
                        {
                            if (thisItem.Owner.CanModerateComments(loggedInMember))
                            {
                                commentsVariableCollection.Parse("MODERATE", "TRUE");
                            }

                            if (thisItem.Owner.IsItemOwner(loggedInMember))
                            {
                                commentsVariableCollection.Parse("OWNER", "TRUE");
                                commentsVariableCollection.Parse("NORMAL", "FALSE");
                            }
                            else
                            {
开发者ID:smithydll,项目名称:boxsocial,代码行数:67,代码来源:comment.aspx.cs

示例9: RenderPreview

        public Template RenderPreview()
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "search_result_galleryitem");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            VariableCollection statusMessageVariableCollection = template.CreateChild("status_messages");

            //statusMessageVariableCollection.Parse("STATUS_MESSAGE", item.Message);
            core.Display.ParseBbcode(statusMessageVariableCollection, "STATUS_MESSAGE", core.Bbcode.FromStatusCode(GetActionBody(new List<ItemKey>())), owner, true, string.Empty, string.Empty);
            statusMessageVariableCollection.Parse("STATUS_UPDATED", core.Tz.DateTimeToString(GetCreatedDate(core.Tz)));

            statusMessageVariableCollection.Parse("ID", Id.ToString());
            statusMessageVariableCollection.Parse("TYPE_ID", ItemKey.TypeId.ToString());
            statusMessageVariableCollection.Parse("USERNAME", Owner.DisplayName);
            statusMessageVariableCollection.Parse("USER_ID", Owner.Id);
            statusMessageVariableCollection.Parse("U_PROFILE", Owner.Uri); // TODO: ProfileUri for primitive
            statusMessageVariableCollection.Parse("U_PERMISSIONS", Parent.Access.AclUri);
            statusMessageVariableCollection.Parse("USER_TILE", Owner.Tile);
            statusMessageVariableCollection.Parse("USER_ICON", Owner.Icon);
            statusMessageVariableCollection.Parse("URI", Uri);

            if (core.Session.IsLoggedIn)
            {
                if (Owner is User && Owner.Id == core.Session.LoggedInMember.Id)
                {
                    statusMessageVariableCollection.Parse("IS_OWNER", "TRUE");
                }
            }

            if (Info.Likes > 0)
            {
                statusMessageVariableCollection.Parse("LIKES", string.Format(" {0:d}", Info.Likes));
                statusMessageVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", Info.Dislikes));
            }

            if (Info.Comments > 0)
            {
                statusMessageVariableCollection.Parse("COMMENTS", string.Format(" ({0:d})", Info.Comments));
            }

            return template;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:43,代码来源:GalleryItem.cs

示例10: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            bool isAjax = false;
            long itemId;
            long itemTypeId;
            ItemKey itemKey = null;
            IShareableItem item = null;

            if (Request["ajax"] == "true")
            {
                isAjax = true;
            }

            if (!core.Session.IsLoggedIn)
            {
                core.Response.ShowMessage("notLoggedIn", "Not Logged In", "Sign in to share this item.");
            }

            string mode = Request.QueryString["mode"];

            if (mode == "post")
            {
                template.SetTemplate("pane.share.post.html");

                try
                {
                    itemId = long.Parse((string)core.Http.Query["item"]);
                    itemTypeId = long.Parse((string)core.Http.Query["type"]);

                    itemKey = new ItemKey(itemId, itemTypeId);
                    item = (IShareableItem)NumberedItem.Reflect(core, itemKey);

                    TextBox messageTextBox = new TextBox("share-message");
                    PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "share-permissions", core.Session.LoggedInMember.ItemKey);

                    template.Parse("S_SHARE_MESSAGE", messageTextBox);
                    template.Parse("S_SHARE_PERMISSIONS", permissionSelectBox);
                    template.Parse("S_SHARED_URI", item.Info.ShareUri);
                    core.Display.ParseBbcode(template, "S_SHARED_STRING", core.Functions.Tldr("[share=\"[iurl=\"" + item.Uri + "\"]" + item.Owner.DisplayName + "[/iurl]\"]" + item.ShareString + "[/share]"), item.Owner);
                }
                catch
                {
                    core.Response.SendRawText("errorFetchingItem", "");
                    return;
                }

                core.Response.SendRawText("sharingForm", template.ToString());
                return;
            }

            // Save the Share
            try
            {
                itemId = long.Parse((string)core.Http.Form["item"]);
                itemTypeId = long.Parse((string)core.Http.Form["type"]);
            }
            catch
            {
                core.Response.SendRawText("errorFetchingItem", "");
                return;
            }

            itemKey = new ItemKey(itemId, itemTypeId);
            item = (IShareableItem)NumberedItem.Reflect(core, itemKey);

            if (item is IPermissibleItem)
            {
                IPermissibleItem pitem = (IPermissibleItem)item;

                if (!pitem.Access.IsPublic())
                {
                    core.Response.ShowMessage("cannotShare", "Cannot Share", "You can only share public items.");
                    return;
                }
            }

            string message = (string)core.Http.Form["share-message"] + "\n\n" + core.Functions.Tldr("[share=\"[iurl=\"" + item.Uri + "\"]" + item.Owner.DisplayName + "[/iurl]\"]" + item.ShareString + "[/share]");

            StatusMessage newStatus = StatusMessage.Create(core, core.Session.LoggedInMember, message);

            AccessControlLists acl = new AccessControlLists(core, newStatus);
            acl.SaveNewItemPermissions("share-permissions");

            core.Search.Index(newStatus);

            ApplicationEntry ae = core.GetApplication("Profile");
            ae.PublishToFeed(core, core.Session.LoggedInMember, newStatus, Functions.SingleLine(core.Bbcode.Flatten(newStatus.Message)));

            Share.ShareItem(core, itemKey);

            if (Request.Form["ajax"] == "true")
            {
                Template template = new Template("pane.statusmessage.html");
                template.Medium = core.Template.Medium;
                template.SetProse(core.Prose);

                VariableCollection statusMessageVariableCollection = template.CreateChild("status_messages");

                core.Display.ParseBbcode(statusMessageVariableCollection, "STATUS_MESSAGE", core.Bbcode.FromStatusCode(newStatus.Message), core.Session.LoggedInMember, true, string.Empty, string.Empty);
                statusMessageVariableCollection.Parse("STATUS_UPDATED", core.Tz.DateTimeToString(newStatus.GetTime(core.Tz)));
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:share.aspx.cs

示例11: ShowFriends

        void ShowFriends(HookEventArgs e)
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "todayfriendpanel");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            List<Friend> friends = e.core.Session.LoggedInMember.GetFriends(1, 10, true);

            foreach (UserRelation friend in friends)
            {
                VariableCollection friendVariableCollection = template.CreateChild("friend_list");

                friendVariableCollection.Parse("USER_DISPLAY_NAME", friend.DisplayName);
                friendVariableCollection.Parse("U_PROFILE", friend.Uri);
                friendVariableCollection.Parse("ICON", friend.Icon);
                friendVariableCollection.Parse("TILE", friend.Tile);
                friendVariableCollection.Parse("SQUARE", friend.Square);
                friendVariableCollection.Parse("SUBSCRIBERS", friend.Info.Subscribers);
                friendVariableCollection.Parse("IS_ONLINE", friend.IsOnline ? "TRUE" : "FALSE");
            }

            e.core.AddSidePanel(template);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:23,代码来源:AppInfo.cs

示例12: ShowMore

        public static void ShowMore(object sender, ShowPPageEventArgs e)
        {
            char[] trimStartChars = { '.', '/' };

            string galleryPath = e.Slug;

            if (galleryPath != null)
            {
                galleryPath = galleryPath.TrimEnd('/').TrimStart(trimStartChars);
            }
            else
            {
                galleryPath = "";
            }

            Gallery gallery;
            if (galleryPath != "")
            {
                try
                {
                    gallery = new Gallery(e.Core, e.Page.Owner, galleryPath);

                    if (!gallery.Access.Can("VIEW"))
                    {
                        e.Core.Functions.Generate403();
                        return;
                    }
                }
                catch (InvalidGalleryException)
                {
                    return;
                }
            }
            else
            {
                gallery = new Gallery(e.Core, e.Page.Owner);
            }

            Template template = new Template(Assembly.GetExecutingAssembly(), "pane_photo");
            template.Medium = e.Core.Template.Medium;
            template.SetProse(e.Core.Prose);

            bool moreContent = false;
            long lastId = 0;

            List<GalleryItem> galleryItems = gallery.GetItems(e.Core, e.Page.TopLevelPageNumber, 12, e.Page.TopLevelPageOffset);

            int i = 0;
            foreach (GalleryItem galleryItem in galleryItems)
            {
                VariableCollection galleryVariableCollection = template.CreateChild("photo_list");

                galleryVariableCollection.Parse("TITLE", galleryItem.ItemTitle);
                galleryVariableCollection.Parse("PHOTO_URI", Gallery.BuildPhotoUri(e.Core, e.Page.Owner, galleryItem.ParentPath, galleryItem.Path));
                galleryVariableCollection.Parse("COMMENTS", e.Core.Functions.LargeIntegerToString(galleryItem.Comments));
                galleryVariableCollection.Parse("VIEWS", e.Core.Functions.LargeIntegerToString(galleryItem.ItemViews));
                galleryVariableCollection.Parse("INDEX", i.ToString());
                galleryVariableCollection.Parse("ID", galleryItem.Id.ToString());
                galleryVariableCollection.Parse("TYPE_ID", galleryItem.ItemKey.TypeId.ToString());

                galleryVariableCollection.Parse("ICON", galleryItem.IconUri);
                galleryVariableCollection.Parse("TILE", galleryItem.TileUri);
                galleryVariableCollection.Parse("SQUARE", galleryItem.SquareUri);

                galleryVariableCollection.Parse("TINY", galleryItem.TinyUri);
                galleryVariableCollection.Parse("THUMBNAIL", galleryItem.ThumbnailUri);

                Display.RatingBlock(galleryItem.ItemRating, galleryVariableCollection, galleryItem.ItemKey);

                if (galleryItem.Info.Likes > 0)
                {
                    galleryVariableCollection.Parse("LIKES", string.Format(" {0:d}", galleryItem.Info.Likes));
                    galleryVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", galleryItem.Info.Dislikes));
                }

                switch (i % 3)
                {
                    case 0:
                        galleryVariableCollection.Parse("ABC", "a");
                        break;
                    case 1:
                        galleryVariableCollection.Parse("ABC", "b");
                        break;
                    case 2:
                        galleryVariableCollection.Parse("ABC", "c");
                        break;
                }

                switch (i % 4)
                {
                    case 0:
                        galleryVariableCollection.Parse("ABCD", "a");
                        break;
                    case 1:
                        galleryVariableCollection.Parse("ABCD", "b");
                        break;
                    case 2:
                        galleryVariableCollection.Parse("ABCD", "c");
                        break;
                    case 3:
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:Gallery.cs

示例13: CheckNewFeedItems

        private void CheckNewFeedItems()
        {
            string mode = core.Http["mode"];
            long newestId = core.Functions.RequestLong("newest-id", 0);
            long newerId = 0;

            if (!core.Session.IsLoggedIn)
            {
                Dictionary<string, string> returnValues = new Dictionary<string, string>();
                core.Response.SendDictionary("noNewContent", returnValues);
            }

            if (mode == "query")
            {
                int count = Feed.GetNewerItemCount(core, core.Session.LoggedInMember, newestId);

                Dictionary<string, string> returnValues = new Dictionary<string, string>();

                returnValues.Add("notifications", session.LoggedInMember.UserInfo.UnreadNotifications.ToString());
                returnValues.Add("mail", session.LoggedInMember.UserInfo.UnseenMail.ToString());

                if (count > 0)
                {
                    returnValues.Add("feed-count", count.ToString());

                    core.Response.SendDictionary("newContent", returnValues);
                }
                else
                {
                    core.Response.SendDictionary("noNewContent", returnValues);
                }
            }
            else if (mode == "fetch")
            {
                List<BoxSocial.Internals.Action> feedActions = Feed.GetNewerItems(core, core.Session.LoggedInMember, newestId);

                Template template = new Template("pane.feeditem.html");
                template.Medium = core.Template.Medium;
                template.SetProse(core.Prose);

                foreach (BoxSocial.Internals.Action feedAction in feedActions)
                {
                    VariableCollection feedItemVariableCollection = template.CreateChild("feed_days_list.feed_item");

                    if (feedAction.Id > newerId)
                    {
                        newerId = feedAction.Id;
                    }

                    core.Display.ParseBbcode(feedItemVariableCollection, "TITLE", feedAction.FormattedTitle);
                    core.Display.ParseBbcode(feedItemVariableCollection, "TEXT", feedAction.Body, core.PrimitiveCache[feedAction.OwnerId], true, string.Empty, string.Empty);

                    feedItemVariableCollection.Parse("USER_DISPLAY_NAME", feedAction.Owner.DisplayName);

                    feedItemVariableCollection.Parse("ID", feedAction.ActionItemKey.Id);
                    feedItemVariableCollection.Parse("TYPE_ID", feedAction.ActionItemKey.TypeId);

                    if (feedAction.ActionItemKey.GetType(core).Likeable)
                    {
                        feedItemVariableCollection.Parse("LIKEABLE", "TRUE");

                        if (feedAction.Info.Likes > 0)
                        {
                            feedItemVariableCollection.Parse("LIKES", string.Format(" {0:d}", feedAction.Info.Likes));
                            feedItemVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", feedAction.Info.Dislikes));
                        }
                    }

                    if (feedAction.ActionItemKey.GetType(core).Commentable)
                    {
                        feedItemVariableCollection.Parse("COMMENTABLE", "TRUE");

                        if (feedAction.Info.Comments > 0)
                        {
                            feedItemVariableCollection.Parse("COMMENTS", string.Format(" ({0:d})", feedAction.Info.Comments));
                        }
                    }

                    //Access access = new Access(core, feedAction.ActionItemKey, true);
                    if (feedAction.PermissiveParent.Access.IsPublic())
                    {
                        feedItemVariableCollection.Parse("IS_PUBLIC", "TRUE");
                        if (feedAction.ActionItemKey.GetType(core).Shareable)
                        {
                            feedItemVariableCollection.Parse("SHAREABLE", "TRUE");
                            //feedItemVariableCollection.Parse("U_SHARE", feedAction.ShareUri);

                            if (feedAction.Info.SharedTimes > 0)
                            {
                                feedItemVariableCollection.Parse("SHARES", string.Format(" {0:d}", feedAction.Info.SharedTimes));
                            }
                        }
                    }

                    if (feedAction.Owner is User)
                    {
                        feedItemVariableCollection.Parse("USER_TILE", ((User)feedAction.Owner).Tile);
                        feedItemVariableCollection.Parse("USER_ICON", ((User)feedAction.Owner).Icon);
                    }
                }
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:functions.aspx.cs

示例14: ShowMemberGroups

        public void ShowMemberGroups(HookEventArgs e)
        {
            User profileOwner = (User)e.Owner;
            Template template = new Template(Assembly.GetExecutingAssembly(), "viewprofilegroups");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            List<UserGroup> groups = UserGroup.GetUserGroups(e.core, profileOwner, 1, 4);
            if (groups.Count > 0)
            {
                template.Parse("HAS_GROUPS", "TRUE");
            }

            foreach(UserGroup group in groups)
            {
                VariableCollection groupVariableCollection = template.CreateChild("groups_list");

                groupVariableCollection.Parse("TITLE", group.DisplayName);
                groupVariableCollection.Parse("U_GROUP", group.Uri);
                groupVariableCollection.Parse("ICON", group.Icon);
                groupVariableCollection.Parse("TILE", group.Tile);
                groupVariableCollection.Parse("SQUARE", group.Square);
            }

            e.core.AddSidePanel(template);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:26,代码来源:AppInfo.cs

示例15: ShowToday

        void ShowToday(HookEventArgs e)
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "todayupcommingevents");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            long startTime = e.core.Tz.GetUnixTimeStamp(new DateTime(e.core.Tz.Now.Year, e.core.Tz.Now.Month, e.core.Tz.Now.Day, 0, 0, 0));
            long endTime = startTime + 60 * 60 * 24 * 7; // skip ahead one week into the future

            Calendar cal = null;
            try
            {
                cal = new Calendar(core, core.Session.LoggedInMember);
            }
            catch (InvalidCalendarException)
            {
                cal = Calendar.Create(core, core.Session.LoggedInMember);
            }

            List<Event> events = cal.GetEvents(core, e.core.Session.LoggedInMember, startTime, endTime);

            template.Parse("U_NEW_EVENT", core.Hyperlink.AppendSid(string.Format("{0}calendar/new-event",
                e.core.Session.LoggedInMember.AccountUriStub)));

            template.Parse("U_CALENDAR", core.Hyperlink.AppendSid(string.Format("{0}calendar",
                e.core.Session.LoggedInMember.UriStub)));

            VariableCollection appointmentDaysVariableCollection = null;
            DateTime lastDay = e.core.Tz.Now;

            if (events.Count > 0)
            {
                template.Parse("HAS_EVENTS", "TRUE");
            }

            foreach(Event calendarEvent in events)
            {
                DateTime eventDay = calendarEvent.GetStartTime(e.core.Tz);
                DateTime eventEnd = calendarEvent.GetEndTime(e.core.Tz);

                if (appointmentDaysVariableCollection == null || lastDay.Day != eventDay.Day)
                {
                    lastDay = eventDay;
                    appointmentDaysVariableCollection = template.CreateChild("appointment_days_list");

                    appointmentDaysVariableCollection.Parse("DAY", core.Tz.DateTimeToDateString(eventDay));
                }

                VariableCollection appointmentVariableCollection = appointmentDaysVariableCollection.CreateChild("appointments_list");

                appointmentVariableCollection.Parse("TIME", eventDay.ToShortTimeString() + " - " + eventEnd.ToShortTimeString());
                appointmentVariableCollection.Parse("SUBJECT", calendarEvent.Subject);
                appointmentVariableCollection.Parse("LOCATION", calendarEvent.Location);
                appointmentVariableCollection.Parse("URI", Event.BuildEventUri(core, calendarEvent));
            }

            e.core.AddMainPanel(template);

            //
            // Tasks panel
            //

            template = new Template(Assembly.GetExecutingAssembly(), "todaytaskspanel");
            template.SetProse(core.Prose);
            List<Task> tasks = cal.GetTasks(core, e.core.Session.LoggedInMember, startTime, endTime, true);

            VariableCollection taskDaysVariableCollection = null;
            lastDay = e.core.Tz.Now;

            if (tasks.Count > 0)
            {
                template.Parse("HAS_TASKS", "TRUE");
            }

            template.Parse("U_TASKS", Task.BuildTasksUri(e.core, e.core.Session.LoggedInMember));

            foreach (Task calendarTask in tasks)
            {
                DateTime taskDue = calendarTask.GetDueTime(e.core.Tz);

                if (taskDaysVariableCollection == null || lastDay.Day != taskDue.Day)
                {
                    lastDay = taskDue;
                    taskDaysVariableCollection = template.CreateChild("task_days");

                    taskDaysVariableCollection.Parse("DAY", taskDue.DayOfWeek.ToString());
                }

                VariableCollection taskVariableCollection = taskDaysVariableCollection.CreateChild("task_list");

                taskVariableCollection.Parse("DATE", taskDue.ToShortDateString() + " (" + taskDue.ToShortTimeString() + ")");
                taskVariableCollection.Parse("TOPIC", calendarTask.Topic);
                taskVariableCollection.Parse("ID", calendarTask.Id.ToString());
                taskVariableCollection.Parse("URI", Task.BuildTaskUri(core, calendarTask));
                taskVariableCollection.Parse("U_MARK_COMPLETE", Task.BuildTaskMarkCompleteUri(core, calendarTask));

                if (calendarTask.Status == TaskStatus.Overdue)
                {
                    taskVariableCollection.Parse("OVERDUE", "TRUE");
                    taskVariableCollection.Parse("CLASS", "overdue-task");
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:AppInfo.cs


注:本文中的Template.CreateChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。