/// <summary> /// Default show procedure for account sub module. /// </summary> /// <param name="sender">Object calling load event</param> /// <param name="e">Load EventArgs</param> void AccountBlogWrite_Show(object sender, EventArgs e) { SetTemplate("account_post"); VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list"); javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js"); VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list"); styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css"); core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute); Blog blog = new Blog(core, (User)Owner); /* Title TextBox */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* Post TextBox */ TextBox postTextBox = new TextBox("post"); postTextBox.IsFormatted = true; postTextBox.Lines = 15; /* Tags TextBox */ TagSelectBox tagsTextBox = new TagSelectBox(core, "tags"); //tagsTextBox.MaxLength = 127; CheckBox publishToFeedCheckBox = new CheckBox("publish-feed"); publishToFeedCheckBox.IsChecked = true; long postId = core.Functions.RequestLong("id", 0); byte licenseId = (byte)0; short categoryId = (short)1; DateTime postTime = core.Tz.Now; SelectBox postYearsSelectBox = new SelectBox("post-year"); for (int i = core.Tz.Now.AddYears(-7).Year; i <= core.Tz.Now.Year; i++) { postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } postYearsSelectBox.SelectedKey = postTime.Year.ToString(); SelectBox postMonthsSelectBox = new SelectBox("post-month"); for (int i = 1; i < 13; i++) { postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i))); } postMonthsSelectBox.SelectedKey = postTime.Month.ToString(); SelectBox postDaysSelectBox = new SelectBox("post-day"); for (int i = 1; i < 32; i++) { postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } postDaysSelectBox.SelectedKey = postTime.Day.ToString(); if (postId > 0 && core.Http.Query["mode"] == "edit") { try { BlogEntry be = new BlogEntry(core, postId); titleTextBox.Value = be.Title; postTextBox.Value = be.Body; licenseId = be.License; categoryId = be.Category; postTime = be.GetPublishedDate(tz); List<Tag> tags = Tag.GetTags(core, be); //string tagList = string.Empty; foreach (Tag tag in tags) { /*if (tagList != string.Empty) { tagList += ", "; } tagList += tag.TagText;*/ tagsTextBox.AddTag(tag); } //tagsTextBox.Value = tagList; if (be.OwnerId != core.LoggedInMemberId) { DisplayError("You must be the owner of the blog entry to modify it."); return; } } catch (InvalidBlogEntryException) { DisplayError(core.Prose.GetString("Blog", "BLOG_ENTRY_DOES_NOT_EXIST")); return; } } else { template.Parse("IS_NEW", "TRUE"); PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey); HiddenField aclModeField = new HiddenField("aclmode"); aclModeField.Value = "simple"; template.Parse("S_PERMISSIONS", permissionSelectBox); template.Parse("S_ACLMODE", aclModeField); } template.Parse("S_POST_YEAR", postYearsSelectBox); template.Parse("S_POST_MONTH", postMonthsSelectBox); template.Parse("S_POST_DAY", postDaysSelectBox); template.Parse("S_POST_HOUR", postTime.Hour.ToString()); template.Parse("S_POST_MINUTE", postTime.Minute.ToString()); SelectBox licensesSelectBox = new SelectBox("license"); DataTable licensesTable = db.Query(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense))); licensesSelectBox.Add(new SelectBoxItem("0", "Default License")); foreach (DataRow licenseRow in licensesTable.Rows) { ContentLicense li = new ContentLicense(core, licenseRow); licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title)); } licensesSelectBox.SelectedKey = licenseId.ToString(); SelectBox categoriesSelectBox = new SelectBox("category"); SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category)); query.AddSort(SortOrder.Ascending, "category_title"); DataTable categoriesTable = db.Query(query); foreach (DataRow categoryRow in categoriesTable.Rows) { Category cat = new Category(core, categoryRow); categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title)); } categoriesSelectBox.SelectedKey = categoryId.ToString(); /* Parse the form fields */ template.Parse("S_TITLE", titleTextBox); template.Parse("S_BLOG_TEXT", postTextBox); template.Parse("S_TAGS", tagsTextBox); template.Parse("S_BLOG_LICENSE", licensesSelectBox); template.Parse("S_BLOG_CATEGORY", categoriesSelectBox); template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox); template.Parse("S_ID", postId.ToString()); foreach (Emoticon emoticon in core.Emoticons) { if (emoticon.Category == "modifier") continue; if (emoticon.Category == "people" && emoticon.Code.Length < 3) { VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_list"); emoticonVariableCollection.Parse("CODE", emoticon.Code); emoticonVariableCollection.Parse("URI", emoticon.File); } else { VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_hidden_list"); emoticonVariableCollection.Parse("CODE", emoticon.Code); emoticonVariableCollection.Parse("URI", emoticon.File); } } Save(new EventHandler(AccountBlogWrite_Save)); if (core.Http.Form["publish"] != null) { AccountBlogWrite_Save(this, new EventArgs()); } }
public static void Show(Core core, TPage page, User owner) { if (core == null) { throw new NullCoreException(); } if (!owner.Access.Can("VIEW")) { core.Functions.Generate403(); return; } if (core.ResponseFormat == ResponseFormats.Xml) { ShowMore(core, page, owner); return; } core.Template.SetTemplate("Profile", "viewfeed"); if (core.Session.IsLoggedIn && owner == core.Session.LoggedInMember) { core.Template.Parse("OWNER", "TRUE"); } core.Template.Parse("PAGE_TITLE", core.Prose.GetString("FEED")); PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", owner.ItemKey); core.Template.Parse("S_STATUS_PERMISSIONS", permissionSelectBox); bool moreContent; long lastId = 0; bool first = true; List<Action> feedActions = CombinedFeed.GetItems(core, owner, page.TopLevelPageNumber, 20, page.TopLevelPageOffset, out moreContent); foreach (Action feedAction in feedActions) { if (first) { first = false; core.Template.Parse("NEWEST_ID", feedAction.Id.ToString()); } VariableCollection feedItemVariableCollection = core.Template.CreateChild("feed_days_list.feed_item"); 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)); } } } else { feedItemVariableCollection.Parse("IS_PUBLIC", "FALSE"); feedItemVariableCollection.Parse("SHAREABLE", "FALSE"); } if (feedAction.Owner is User) { feedItemVariableCollection.Parse("USER_TILE", ((User)feedAction.Owner).Tile); feedItemVariableCollection.Parse("USER_ICON", ((User)feedAction.Owner).Icon); } lastId = feedAction.Id; } core.Display.ParseBlogPagination(core.Template, "PAGINATION", core.Hyperlink.BuildCombinedFeedUri((User)owner), 0, moreContent ? lastId : 0); core.Template.Parse("U_NEXT_PAGE", core.Hyperlink.BuildCombinedFeedUri((User)owner) + "?p=" + (core.TopLevelPageNumber + 1) + "&o=" + lastId); /* pages */ core.Display.ParsePageList(owner, true); List<string[]> breadCrumbParts = new List<string[]>(); breadCrumbParts.Add(new string[] { "*profile", core.Prose.GetString("PROFILE") }); breadCrumbParts.Add(new string[] { "feed", core.Prose.GetString("FEED") }); owner.ParseBreadCrumbs(breadCrumbParts); }
void PostContent(HookEventArgs e) { VariableCollection styleSheetVariableCollection = core.Template.CreateChild("javascript_list"); styleSheetVariableCollection.Parse("URI", @"/scripts/load-image.min.js"); styleSheetVariableCollection = core.Template.CreateChild("javascript_list"); styleSheetVariableCollection.Parse("URI", @"/scripts/canvas-to-blob.min.js"); styleSheetVariableCollection = core.Template.CreateChild("javascript_list"); styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.iframe-transport.js"); styleSheetVariableCollection = core.Template.CreateChild("javascript_list"); styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.fileupload.js"); styleSheetVariableCollection = core.Template.CreateChild("javascript_list"); styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.fileupload-process.js"); styleSheetVariableCollection = core.Template.CreateChild("javascript_list"); styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.fileupload-image.js"); if (e.core.IsMobile) { return; } Template template = new Template(Assembly.GetExecutingAssembly(), "postphoto"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); string formSubmitUri = core.Hyperlink.AppendSid(e.Owner.AccountUriStub, true); template.Parse("U_ACCOUNT", formSubmitUri); template.Parse("S_ACCOUNT", formSubmitUri); template.Parse("USER_DISPLAY_NAME", e.Owner.DisplayName); CheckBox publishToFeedCheckBox = new CheckBox("publish-feed"); publishToFeedCheckBox.IsChecked = true; CheckBox highQualityCheckBox = new CheckBox("high-quality"); highQualityCheckBox.IsChecked = false; core.Display.ParseLicensingBox(template, "S_GALLERY_LICENSE", 0); template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox); template.Parse("S_HIGH_QUALITY", highQualityCheckBox); core.Display.ParseClassification(template, "S_PHOTO_CLASSIFICATION", Classifications.Everyone); PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", e.Owner.ItemKey); HiddenField aclModeField = new HiddenField("aclmode"); aclModeField.Value = "simple"; template.Parse("S_PERMISSIONS", permissionSelectBox); template.Parse("S_ACLMODE", aclModeField); //GallerySettings settings = new GallerySettings(core, e.Owner); Gallery rootGallery = new Gallery(core, e.Owner); List<Gallery> galleries = rootGallery.GetGalleries(); SelectBox galleriesSelectBox = new SelectBox("gallery-id"); foreach (Gallery gallery in galleries) { galleriesSelectBox.Add(new SelectBoxItem(gallery.Id.ToString(), gallery.GalleryTitle)); } template.Parse("S_GALLERIES", galleriesSelectBox); /* Title TextBox */ TextBox galleryTitleTextBox = new TextBox("gallery-title"); galleryTitleTextBox.MaxLength = 127; template.Parse("S_GALLERY_TITLE", galleryTitleTextBox); CheckBoxArray shareCheckBoxArray = new CheckBoxArray("share-radio"); shareCheckBoxArray.Layout = Layout.Horizontal; CheckBox twitterSyndicateCheckBox = null; CheckBox tumblrSyndicateCheckBox = null; CheckBox facebookSyndicateCheckBox = null; if (e.Owner is User) { User user = (User)e.Owner; if (user.UserInfo.TwitterAuthenticated) { twitterSyndicateCheckBox = new CheckBox("photo-share-twitter"); twitterSyndicateCheckBox.Caption = "Twitter"; twitterSyndicateCheckBox.Icon = "https://g.twimg.com/twitter-bird-16x16.png"; twitterSyndicateCheckBox.IsChecked = user.UserInfo.TwitterSyndicate; twitterSyndicateCheckBox.Width.Length = 0; shareCheckBoxArray.Add(twitterSyndicateCheckBox); } if (user.UserInfo.TumblrAuthenticated) { tumblrSyndicateCheckBox = new CheckBox("photo-share-tumblr"); tumblrSyndicateCheckBox.Caption = "Tumblr"; tumblrSyndicateCheckBox.Icon = "https://platform.tumblr.com/v1/share_4.png"; tumblrSyndicateCheckBox.IsChecked = user.UserInfo.TumblrSyndicate; tumblrSyndicateCheckBox.Width.Length = 0; shareCheckBoxArray.Add(tumblrSyndicateCheckBox); } if (user.UserInfo.FacebookAuthenticated) { facebookSyndicateCheckBox = new CheckBox("photo-share-facebook"); facebookSyndicateCheckBox.Caption = "Facebook"; facebookSyndicateCheckBox.Icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yU/r/fWK1wxX-qQn.png"; facebookSyndicateCheckBox.IsChecked = user.UserInfo.FacebookSyndicate; facebookSyndicateCheckBox.Width.Length = 0; shareCheckBoxArray.Add(facebookSyndicateCheckBox); } } if (shareCheckBoxArray.Count > 0) { template.Parse("S_SHARE", "TRUE"); } if (twitterSyndicateCheckBox != null) { template.Parse("S_SHARE_TWITTER", twitterSyndicateCheckBox); } if (tumblrSyndicateCheckBox != null) { template.Parse("S_SHARE_TUMBLR", tumblrSyndicateCheckBox); } if (facebookSyndicateCheckBox != null) { template.Parse("S_SHARE_FACEBOOK", facebookSyndicateCheckBox); } e.core.AddPostPanel(e.core.Prose.GetString("PHOTO"), template); }
public void ParseACL(Template template, Primitive owner, string variable) { Template aclTemplate = new Template("std.acl.html"); aclTemplate.Medium = core.Template.Medium; aclTemplate.SetProse(core.Prose); if (itemPermissions == null) { itemPermissions = GetPermissions(core, item); } if (itemGrants == null) { itemGrants = AccessControlGrant.GetGrants(core, item); } if (unsavedGrants == null) { unsavedGrants = new List<UnsavedAccessControlGrant>(); } if (itemGrants != null) { foreach (AccessControlGrant itemGrant in itemGrants) { core.PrimitiveCache.LoadPrimitiveProfile(itemGrant.PrimitiveKey); } } bool simple = item.IsSimplePermissions; string mode = core.Http["aclmode"]; switch (mode) { case "simple": simple = true; break; case "detailed": simple = false; break; } bool first = true; PermissionTypes lastType = PermissionTypes.View; VariableCollection permissionTypeVariableCollection = null; PermissionGroupSelectBox typeGroupSelectBox = null; List<PrimitivePermissionGroup> ownerGroups = null; if (itemPermissions != null) { foreach (AccessControlPermission itemPermission in itemPermissions) { if (first || itemPermission.PermissionType != lastType) { if (typeGroupSelectBox != null) { permissionTypeVariableCollection.Parse("S_SIMPLE_SELECT", typeGroupSelectBox); } permissionTypeVariableCollection = aclTemplate.CreateChild("permision_types"); typeGroupSelectBox = new PermissionGroupSelectBox(core, "group-select-" + itemPermission.PermissionType.ToString(), item.ItemKey); permissionTypeVariableCollection.Parse("TITLE", AccessControlLists.PermissionTypeToString(itemPermission.PermissionType)); first = false; lastType = itemPermission.PermissionType; } if (simple) { if (ownerGroups == null) { ownerGroups = new List<PrimitivePermissionGroup>(); int itemGroups = 0; Type type = item.GetType(); if (type.GetMethod(type.Name + "_GetItemGroups", new Type[] { typeof(Core) }) != null) { ownerGroups.AddRange((List<PrimitivePermissionGroup>)type.InvokeMember(type.Name + "_GetItemGroups", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { core })); itemGroups = ownerGroups.Count; } ownerGroups.AddRange(core.GetPrimitivePermissionGroups(owner)); } VariableCollection permissionVariableCollection = permissionTypeVariableCollection.CreateChild("permission_desc"); permissionVariableCollection.Parse("ID", itemPermission.Id.ToString()); permissionVariableCollection.Parse("TITLE", itemPermission.Name); permissionVariableCollection.Parse("DESCRIPTION", itemPermission.Description); if (itemGrants != null) { foreach (AccessControlGrant itemGrant in itemGrants) { if (itemGrant.PermissionId == itemPermission.Id) { switch (itemGrant.Allow) { case AccessControlGrants.Allow: PrimitivePermissionGroup ppg = null; ppg = new PrimitivePermissionGroup(itemGrant.PrimitiveKey, string.Empty, string.Empty); foreach (PrimitivePermissionGroup p in ownerGroups) { if (ppg.ItemKey.Equals(p.ItemKey)) { ppg = p; break; } } if (!typeGroupSelectBox.ItemKeys.Contains(ppg)) { typeGroupSelectBox.ItemKeys.Add(ppg); } break; default: break; } } } } } else { VariableCollection permissionVariableCollection = permissionTypeVariableCollection.CreateChild("permission"); permissionVariableCollection.Parse("ID", itemPermission.Id.ToString()); permissionVariableCollection.Parse("TITLE", itemPermission.Name); permissionVariableCollection.Parse("DESCRIPTION", itemPermission.Description); SelectBox groupsSelectBox = BuildGroupsSelectBox(string.Format("new-permission-group[{0}]", itemPermission.Id), owner); if (itemGrants != null) { foreach (AccessControlGrant itemGrant in itemGrants) { if (itemGrant.PermissionId == itemPermission.Id) { string gsbk = string.Format("{0},{1}", itemGrant.PrimitiveKey.TypeId, itemGrant.PrimitiveKey.Id); if (groupsSelectBox.ContainsKey(gsbk)) { groupsSelectBox[gsbk].Selectable = false; } VariableCollection grantVariableCollection = permissionVariableCollection.CreateChild("grant"); if (groupsSelectBox.ContainsKey(gsbk)) { string text = groupsSelectBox[gsbk].Text; if (text.StartsWith(" -- ", StringComparison.Ordinal)) { text = text.Substring(4); } grantVariableCollection.Parse("DISPLAY_NAME", text); groupsSelectBox[gsbk].Selectable = false; } else { try { grantVariableCollection.Parse("DISPLAY_NAME", core.PrimitiveCache[itemGrant.PrimitiveKey].DisplayName); } catch { grantVariableCollection.Parse("DISPLAY_NAME", "{{ERROR LOADING PRIMITIVE(" + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + ":" + (new ItemType(core, itemGrant.PrimitiveKey.TypeId)).Namespace + ")}}"); } } RadioList allowrl = new RadioList("allow[" + itemGrant.PermissionId.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]"); SelectBox allowsb = new SelectBox("allow[" + itemGrant.PermissionId.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]"); Button deleteButton = new Button("delete", "Delete", itemGrant.PermissionId.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString()); allowrl.Add(new RadioListItem(allowrl.Name, "allow", "Allow")); allowrl.Add(new RadioListItem(allowrl.Name, "deny", "Deny")); allowrl.Add(new RadioListItem(allowrl.Name, "inherit", "Inherit")); allowsb.Add(new SelectBoxItem("allow", "Allow")); allowsb.Add(new SelectBoxItem("deny", "Deny")); allowsb.Add(new SelectBoxItem("inherit", "Inherit")); switch (itemGrant.Allow) { case AccessControlGrants.Allow: allowrl.SelectedKey = "allow"; allowsb.SelectedKey = "allow"; break; case AccessControlGrants.Deny: allowrl.SelectedKey = "deny"; allowsb.SelectedKey = "deny"; break; case AccessControlGrants.Inherit: allowrl.SelectedKey = "inherit"; allowsb.SelectedKey = "inherit"; break; } if (core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]"] != null) { allowrl.SelectedKey = core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]"]; } grantVariableCollection.Parse("S_GRANT", allowsb); grantVariableCollection.Parse("S_ALLOW", allowrl["allow"]); grantVariableCollection.Parse("S_DENY", allowrl["deny"]); grantVariableCollection.Parse("S_INHERIT", allowrl["inherit"]); grantVariableCollection.Parse("S_DELETE", deleteButton); grantVariableCollection.Parse("ID", string.Format("{0},{1}", itemGrant.PrimitiveKey.TypeId, itemGrant.PrimitiveKey.Id)); grantVariableCollection.Parse("PERMISSION_ID", itemPermission.Id.ToString()); grantVariableCollection.Parse("IS_NEW", "FALSE"); } } foreach (AccessControlGrant itemGrant in itemGrants) { VariableCollection grantsVariableCollection = template.CreateChild("grants"); } } if (core.Http.Form["save"] == null) { foreach (SelectBoxItem gsbi in groupsSelectBox) { if (core.Http.Form[string.Format("new-grant[{0},{1}]", itemPermission.Id, gsbi.Key)] != null) { ItemKey ik = new ItemKey(gsbi.Key); UnsavedAccessControlGrant uacg = new UnsavedAccessControlGrant(core, ik, item.ItemKey, itemPermission.Id, AccessControlGrants.Inherit); VariableCollection grantVariableCollection = permissionVariableCollection.CreateChild("grant"); grantVariableCollection.Parse("DISPLAY_NAME", gsbi.Text); RadioList allowrl = new RadioList("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"); SelectBox allowsb = new SelectBox("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"); allowrl.Add(new RadioListItem(allowrl.Name, "allow", "Allow")); allowrl.Add(new RadioListItem(allowrl.Name, "deny", "Deny")); allowrl.Add(new RadioListItem(allowrl.Name, "inherit", "Inherit")); allowsb.Add(new SelectBoxItem("allow", "Allow")); allowsb.Add(new SelectBoxItem("deny", "Deny")); allowsb.Add(new SelectBoxItem("inherit", "Inherit")); if (core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"] != null) { allowrl.SelectedKey = core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"]; } else { switch (uacg.Allow) { case AccessControlGrants.Allow: allowrl.SelectedKey = "allow"; allowsb.SelectedKey = "allow"; break; case AccessControlGrants.Deny: allowrl.SelectedKey = "deny"; allowsb.SelectedKey = "deny"; break; case AccessControlGrants.Inherit: allowrl.SelectedKey = "inherit"; allowsb.SelectedKey = "inherit"; break; } } grantVariableCollection.Parse("S_GRANT", allowsb); grantVariableCollection.Parse("S_ALLOW", allowrl["allow"]); grantVariableCollection.Parse("S_DENY", allowrl["deny"]); grantVariableCollection.Parse("S_INHERIT", allowrl["inherit"]); grantVariableCollection.Parse("ID", string.Format("{0},{1}", ik.TypeId, ik.Id)); grantVariableCollection.Parse("PERMISSION_ID", itemPermission.Id.ToString()); grantVariableCollection.Parse("IS_NEW", "TRUE"); gsbi.Selectable = false; } } } if (core.Http.Form[string.Format("add-permission[{0}]", itemPermission.Id)] != null) { string groupSelectBoxId = core.Http.Form[string.Format("new-permission-group[{0}]", itemPermission.Id)]; ItemKey ik = new ItemKey(groupSelectBoxId); UnsavedAccessControlGrant uacg = new UnsavedAccessControlGrant(core, ik, item.ItemKey, itemPermission.Id, AccessControlGrants.Inherit); VariableCollection grantVariableCollection = permissionVariableCollection.CreateChild("grant"); grantVariableCollection.Parse("DISPLAY_NAME", groupsSelectBox[groupSelectBoxId].Text); RadioList allowrl = new RadioList("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"); SelectBox allowsb = new SelectBox("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"); allowrl.Add(new RadioListItem(allowrl.Name, "allow", "Allow")); allowrl.Add(new RadioListItem(allowrl.Name, "deny", "Deny")); allowrl.Add(new RadioListItem(allowrl.Name, "inherit", "Inherit")); allowsb.Add(new SelectBoxItem("allow", "Allow")); allowsb.Add(new SelectBoxItem("deny", "Deny")); allowsb.Add(new SelectBoxItem("inherit", "Inherit")); switch (uacg.Allow) { case AccessControlGrants.Allow: allowrl.SelectedKey = "allow"; allowsb.SelectedKey = "allow"; break; case AccessControlGrants.Deny: allowrl.SelectedKey = "deny"; allowsb.SelectedKey = "deny"; break; case AccessControlGrants.Inherit: allowrl.SelectedKey = "inherit"; allowsb.SelectedKey = "inherit"; break; } grantVariableCollection.Parse("S_GRANT", allowsb); grantVariableCollection.Parse("S_ALLOW", allowrl["allow"]); grantVariableCollection.Parse("S_DENY", allowrl["deny"]); grantVariableCollection.Parse("S_INHERIT", allowrl["inherit"]); grantVariableCollection.Parse("ID", string.Format("{0},{1}", ik.TypeId, ik.Id)); grantVariableCollection.Parse("PERMISSION_ID", itemPermission.Id.ToString()); grantVariableCollection.Parse("IS_NEW", "TRUE"); groupsSelectBox[groupSelectBoxId].Selectable = false; } permissionVariableCollection.Parse("S_PERMISSION_GROUPS", groupsSelectBox); RadioList allowNewrl = new RadioList("new-permission-group-allow"); SelectBox allowNewsb = new SelectBox("new-permission-group-allow"); allowNewrl.Add(new RadioListItem(allowNewrl.Name, "allow", "Allow")); allowNewrl.Add(new RadioListItem(allowNewrl.Name, "deny", "Deny")); allowNewrl.Add(new RadioListItem(allowNewrl.Name, "inherit", "Inherit")); allowNewsb.Add(new SelectBoxItem("allow", "Allow")); allowNewsb.Add(new SelectBoxItem("deny", "Deny")); allowNewsb.Add(new SelectBoxItem("inherit", "Inherit")); allowNewrl.SelectedKey = "inherit"; allowNewsb.SelectedKey = "inherit"; permissionVariableCollection.Parse("S_GRANT", allowNewsb); permissionVariableCollection.Parse("S_ALLOW", allowNewrl["allow"].ToString()); permissionVariableCollection.Parse("S_DENY", allowNewrl["deny"].ToString()); permissionVariableCollection.Parse("S_INHERIT", allowNewrl["inherit"].ToString()); } } if (typeGroupSelectBox != null) { permissionTypeVariableCollection.Parse("S_SIMPLE_SELECT", typeGroupSelectBox); } } if (string.IsNullOrEmpty(variable)) { variable = "S_PERMISSIONS"; } /*PermissionGroupSelectBox groupSelectBox = new PermissionGroupSelectBox(core, "group-select", item.ItemKey); groupSelectBox.SelectMultiple = true; aclTemplate.Parse("S_SIMPLE_SELECT", groupSelectBox);*/ if (simple) { aclTemplate.Parse("IS_SIMPLE", "TRUE"); } aclTemplate.Parse("U_DETAILED", Access.BuildAclUri(core, item, false)); aclTemplate.Parse("U_SIMPLE", Access.BuildAclUri(core, item, true)); HiddenField modeField = new HiddenField("aclmode"); if (simple) { modeField.Value = "simple"; } else { modeField.Value = "detailed"; } aclTemplate.Parse("S_ACLMODE", modeField); template.ParseRaw(variable, aclTemplate.ToString()); }
public Template GetPostTemplate(Core core, Primitive owner) { Template template = new Template(Assembly.GetExecutingAssembly(), "postblog"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); string formSubmitUri = core.Hyperlink.AppendSid(owner.AccountUriStub, true); template.Parse("U_ACCOUNT", formSubmitUri); template.Parse("S_ACCOUNT", formSubmitUri); template.Parse("USER_DISPLAY_NAME", owner.DisplayName); Blog blog = null; try { blog = new Blog(core, (User)owner); } catch (InvalidBlogException) { if (owner.ItemKey.Equals(core.LoggedInMemberItemKey)) { blog = Blog.Create(core); } else { return null; } } /* Title TextBox */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* Post TextBox */ TextBox postTextBox = new TextBox("post"); postTextBox.IsFormatted = true; postTextBox.Lines = 15; /* Tags TextBox */ TagSelectBox tagsTextBox = new TagSelectBox(core, "tags"); //tagsTextBox.MaxLength = 127; CheckBox publishToFeedCheckBox = new CheckBox("publish-feed"); publishToFeedCheckBox.IsChecked = true; PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey); HiddenField aclModeField = new HiddenField("aclmode"); aclModeField.Value = "simple"; template.Parse("S_PERMISSIONS", permissionSelectBox); template.Parse("S_ACLMODE", aclModeField); DateTime postTime = DateTime.Now; SelectBox postYearsSelectBox = new SelectBox("post-year"); for (int i = DateTime.Now.AddYears(-7).Year; i <= DateTime.Now.Year; i++) { postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } postYearsSelectBox.SelectedKey = postTime.Year.ToString(); SelectBox postMonthsSelectBox = new SelectBox("post-month"); for (int i = 1; i < 13; i++) { postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i))); } postMonthsSelectBox.SelectedKey = postTime.Month.ToString(); SelectBox postDaysSelectBox = new SelectBox("post-day"); for (int i = 1; i < 32; i++) { postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } postDaysSelectBox.SelectedKey = postTime.Day.ToString(); template.Parse("S_POST_YEAR", postYearsSelectBox); template.Parse("S_POST_MONTH", postMonthsSelectBox); template.Parse("S_POST_DAY", postDaysSelectBox); template.Parse("S_POST_HOUR", postTime.Hour.ToString()); template.Parse("S_POST_MINUTE", postTime.Minute.ToString()); SelectBox licensesSelectBox = new SelectBox("license"); System.Data.Common.DbDataReader licensesReader = core.Db.ReaderQuery(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense))); licensesSelectBox.Add(new SelectBoxItem("0", "Default License")); while(licensesReader.Read()) { ContentLicense li = new ContentLicense(core, licensesReader); licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title)); } licensesReader.Close(); licensesReader.Dispose(); SelectBox categoriesSelectBox = new SelectBox("category"); SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category)); query.AddSort(SortOrder.Ascending, "category_title"); System.Data.Common.DbDataReader categoriesReader = core.Db.ReaderQuery(query); while (categoriesReader.Read()) { Category cat = new Category(core, categoriesReader); categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title)); } categoriesReader.Close(); categoriesReader.Dispose(); categoriesSelectBox.SelectedKey = 1.ToString(); /* Parse the form fields */ template.Parse("S_TITLE", titleTextBox); template.Parse("S_BLOG_TEXT", postTextBox); template.Parse("S_TAGS", tagsTextBox); template.Parse("S_BLOG_LICENSE", licensesSelectBox); template.Parse("S_BLOG_CATEGORY", categoriesSelectBox); template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox); return template; }
/* * TODO: show status feed history */ public static void Show(Core core, ShowUPageEventArgs e) { if (core == null) { throw new NullCoreException(); } if (!e.Page.Owner.Access.Can("VIEW")) { core.Functions.Generate403(); return; } if (core.ResponseFormat == ResponseFormats.Xml) { ShowMore(core, e); return; } core.Template.SetTemplate("Profile", "viewstatusfeed"); if (core.Session.IsLoggedIn && e.Page.Owner == core.Session.LoggedInMember) { core.Template.Parse("OWNER", "TRUE"); } core.Template.Parse("PAGE_TITLE", e.Core.Prose.GetString("STATUS_FEED")); PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", e.Page.Owner.ItemKey); core.Template.Parse("S_STATUS_PERMISSIONS", permissionSelectBox); bool moreContent = false; long lastId = 0; List<StatusMessage> items = StatusFeed.GetItems(core, (User)e.Page.Owner, e.Page.TopLevelPageNumber, 20, e.Page.TopLevelPageOffset, out moreContent); foreach (StatusMessage item in items) { VariableCollection statusMessageVariableCollection = core.Template.CreateChild("status_messages"); //statusMessageVariableCollection.Parse("STATUS_MESSAGE", core.Functions.Tldr(item.Message)); core.Display.ParseBbcode(statusMessageVariableCollection, "STATUS_MESSAGE", core.Bbcode.FromStatusCode(item.Message), e.Page.Owner, true, string.Empty, string.Empty); statusMessageVariableCollection.Parse("STATUS_UPDATED", core.Tz.DateTimeToString(item.GetTime(core.Tz))); statusMessageVariableCollection.Parse("ID", item.Id.ToString()); statusMessageVariableCollection.Parse("TYPE_ID", item.ItemKey.TypeId.ToString()); statusMessageVariableCollection.Parse("USERNAME", item.Poster.DisplayName); statusMessageVariableCollection.Parse("USER_ID", item.Poster.Id); statusMessageVariableCollection.Parse("U_PROFILE", item.Poster.ProfileUri); statusMessageVariableCollection.Parse("U_QUOTE", string.Empty /*core.Hyperlink.BuildCommentQuoteUri(item.Id)*/); statusMessageVariableCollection.Parse("U_REPORT", string.Empty /*core.Hyperlink.BuildCommentReportUri(item.Id)*/); statusMessageVariableCollection.Parse("U_DELETE", string.Empty /*core.Hyperlink.BuildCommentDeleteUri(item.Id)*/); statusMessageVariableCollection.Parse("U_PERMISSIONS", item.Access.AclUri); statusMessageVariableCollection.Parse("USER_TILE", item.Poster.Tile); statusMessageVariableCollection.Parse("USER_ICON", item.Poster.Icon); statusMessageVariableCollection.Parse("URI", item.Uri); if (core.Session.IsLoggedIn) { if (item.Owner.Id == core.Session.LoggedInMember.Id) { statusMessageVariableCollection.Parse("IS_OWNER", "TRUE"); } } if (item.Info.Likes > 0) { statusMessageVariableCollection.Parse("LIKES", string.Format(" {0:d}", item.Info.Likes)); statusMessageVariableCollection.Parse("DISLIKES", string.Format(" {0:d}", item.Info.Dislikes)); } if (item.Info.Comments > 0) { statusMessageVariableCollection.Parse("COMMENTS", string.Format(" ({0:d})", item.Info.Comments)); } if (item.Access.IsPublic()) { statusMessageVariableCollection.Parse("IS_PUBLIC", "TRUE"); if (item.ItemKey.GetType(core).Shareable) { statusMessageVariableCollection.Parse("SHAREABLE", "TRUE"); statusMessageVariableCollection.Parse("U_SHARE", item.ShareUri); if (item.Info.SharedTimes > 0) { statusMessageVariableCollection.Parse("SHARES", string.Format(" {0:d}", item.Info.SharedTimes)); } } } lastId = item.Id; } core.Display.ParseBlogPagination(core.Template, "PAGINATION", core.Hyperlink.BuildStatusUri((User)e.Page.Owner), 0, moreContent ? lastId : 0); core.Template.Parse("U_NEXT_PAGE", core.Hyperlink.BuildStatusUri((User)e.Page.Owner) + "?p=" + (core.TopLevelPageNumber + 1) + "&o=" + lastId); /* pages */ core.Display.ParsePageList(e.Page.Owner, true); List<string[]> breadCrumbParts = new List<string[]>(); breadCrumbParts.Add(new string[] { "*profile", core.Prose.GetString("PROFILE") }); breadCrumbParts.Add(new string[] { "status-feed", core.Prose.GetString("STATUS_FEED") }); e.Page.Owner.ParseBreadCrumbs(breadCrumbParts); }
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))); statusMessageVariableCollection.Parse("ID", newStatus.Id.ToString()); statusMessageVariableCollection.Parse("TYPE_ID", newStatus.ItemKey.TypeId.ToString()); statusMessageVariableCollection.Parse("USERNAME", newStatus.Poster.DisplayName); statusMessageVariableCollection.Parse("U_PROFILE", newStatus.Poster.ProfileUri); statusMessageVariableCollection.Parse("U_QUOTE", string.Empty /*core.Hyperlink.BuildCommentQuoteUri(newStatus.Id)*/); statusMessageVariableCollection.Parse("U_REPORT", string.Empty /*core.Hyperlink.BuildCommentReportUri(newStatus.Id)*/); statusMessageVariableCollection.Parse("U_DELETE", string.Empty /*core.Hyperlink.BuildCommentDeleteUri(newStatus.Id)*/); statusMessageVariableCollection.Parse("U_PERMISSIONS", newStatus.Access.AclUri); statusMessageVariableCollection.Parse("USER_TILE", newStatus.Poster.Tile); statusMessageVariableCollection.Parse("USER_ICON", newStatus.Poster.Icon); statusMessageVariableCollection.Parse("URI", newStatus.Uri); statusMessageVariableCollection.Parse("IS_OWNER", "TRUE"); if (newStatus.Access.IsPublic()) { statusMessageVariableCollection.Parse("IS_PUBLIC", "TRUE"); statusMessageVariableCollection.Parse("SHAREABLE", "TRUE"); statusMessageVariableCollection.Parse("U_SHARE", newStatus.ShareUri); } Dictionary<string, string> returnValues = new Dictionary<string, string>(StringComparer.Ordinal); returnValues.Add("update", item.OwnerKey.Equals(newStatus.Owner.ItemKey) ? "true" : "false"); returnValues.Add("message", message); returnValues.Add("template", template.ToString()); core.Response.SendDictionary("statusPosted", returnValues); return; } else { string redirect = Request["redirect"]; if (!string.IsNullOrEmpty(redirect)) { template.Parse("REDIRECT_URI", redirect); } core.Display.ShowMessage("Shared", "You have shared this item to your status feed."); } }
void PostContent(HookEventArgs e) { Template template = new Template(Assembly.GetExecutingAssembly(), "poststatusmessage"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); string formSubmitUri = core.Hyperlink.AppendSid(e.Owner.AccountUriStub, true); template.Parse("U_ACCOUNT", formSubmitUri); template.Parse("S_ACCOUNT", formSubmitUri); template.Parse("USER_DISPLAY_NAME", e.Owner.DisplayName); PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", e.Owner.ItemKey); CheckBoxArray shareCheckBoxArray = new CheckBoxArray("share-radio"); shareCheckBoxArray.Layout = Layout.Horizontal; CheckBox twitterSyndicateCheckBox = null; CheckBox tumblrSyndicateCheckBox = null; CheckBox facebookSyndicateCheckBox = null; if (e.Owner is User) { User user = (User)e.Owner; if (user.UserInfo.TwitterAuthenticated) { twitterSyndicateCheckBox = new CheckBox("status-share-twitter"); twitterSyndicateCheckBox.Caption = "Twitter"; twitterSyndicateCheckBox.Icon = "https://g.twimg.com/twitter-bird-16x16.png"; twitterSyndicateCheckBox.IsChecked = user.UserInfo.TwitterSyndicate; twitterSyndicateCheckBox.Width.Length = 0; shareCheckBoxArray.Add(twitterSyndicateCheckBox); } if (user.UserInfo.TumblrAuthenticated) { tumblrSyndicateCheckBox = new CheckBox("status-share-tumblr"); tumblrSyndicateCheckBox.Caption = "Tumblr"; tumblrSyndicateCheckBox.Icon = "https://platform.tumblr.com/v1/share_4.png"; tumblrSyndicateCheckBox.IsChecked = user.UserInfo.TumblrSyndicate; tumblrSyndicateCheckBox.Width.Length = 0; shareCheckBoxArray.Add(tumblrSyndicateCheckBox); } if (user.UserInfo.FacebookAuthenticated) { facebookSyndicateCheckBox = new CheckBox("status-share-facebook"); facebookSyndicateCheckBox.Caption = "Facebook"; facebookSyndicateCheckBox.Icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yU/r/fWK1wxX-qQn.png"; facebookSyndicateCheckBox.IsChecked = user.UserInfo.FacebookSyndicate; facebookSyndicateCheckBox.Width.Length = 0; shareCheckBoxArray.Add(facebookSyndicateCheckBox); } } template.Parse("S_STATUS_PERMISSIONS", permissionSelectBox); if (shareCheckBoxArray.Count > 0) { template.Parse("S_SHARE", "TRUE"); } if (twitterSyndicateCheckBox != null) { template.Parse("S_SHARE_TWITTER", twitterSyndicateCheckBox); } if (tumblrSyndicateCheckBox != null) { template.Parse("S_SHARE_TUMBLR", tumblrSyndicateCheckBox); } if (facebookSyndicateCheckBox != null) { template.Parse("S_SHARE_FACEBOOK", facebookSyndicateCheckBox); } e.core.AddPostPanel(e.core.Prose.GetString("STATUS"), template); }
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); } } catch (InvalidApplicationException) { } } } core.Display.ParseBbcode(feedItemVariableCollection, "TEXT", feedAction.Body, itemOwner, true, string.Empty, string.Empty); } feedItemVariableCollection.Parse("USER_DISPLAY_NAME", feedAction.Owner.DisplayName); ItemKey interactItemKey = null; if (feedAction.InteractItemKey.Id > 0) { interactItemKey = feedAction.InteractItemKey; feedItemVariableCollection.Parse("ID", feedAction.InteractItemKey.Id); feedItemVariableCollection.Parse("TYPE_ID", feedAction.InteractItemKey.TypeId); } else { interactItemKey = feedAction.ActionItemKey; feedItemVariableCollection.Parse("ID", feedAction.ActionItemKey.Id); feedItemVariableCollection.Parse("TYPE_ID", feedAction.ActionItemKey.TypeId); } if (interactItemKey.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 (interactItemKey.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 (interactItemKey.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)); } } } else { feedItemVariableCollection.Parse("IS_PUBLIC", "FALSE"); feedItemVariableCollection.Parse("SHAREABLE", "FALSE"); } if (feedAction.Owner is User) { feedItemVariableCollection.Parse("USER_TILE", ((User)feedAction.Owner).Tile); feedItemVariableCollection.Parse("USER_ICON", ((User)feedAction.Owner).Icon); } lastId = feedAction.Id; } } core.Display.ParseBlogPagination(template, "PAGINATION", core.Hyperlink.BuildHomeUri(), 0, moreContent ? lastId : 0); template.Parse("U_NEXT_PAGE", core.Hyperlink.BuildHomeUri() + "?p=" + (core.TopLevelPageNumber + 1) + "&o=" + lastId); core.AddMainPanel(template); }