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); }
/// <summary> /// Delete all children of a gallery /// </summary> /// <param name="core">Core token</param> /// <param name="gallery">Gallery being deleted</param> /// <returns>An array containing the number of gallery photos deleted /// (index 0), and the number of bytes consumed by said photos /// (index 1).</returns> private static long[] galleryDeleteChildren(Core core, Gallery gallery) { long itemsDeleted = 0; // index 0 long bytesDeleted = 0; // index 1 List<Gallery> galleries = gallery.GetGalleries(); foreach (Gallery galleryGallery in galleries) { long[] stuffDeleted = galleryDeleteChildren(core, galleryGallery); itemsDeleted += stuffDeleted[0]; bytesDeleted += stuffDeleted[1]; } object objectsDeleted = core.Db.Query(string.Format("SELECT SUM(gallery_item_bytes) AS bytes_deleted FROM gallery_items WHERE user_id = {0} AND gallery_item_parent_path = '{1}';", core.LoggedInMemberId, Mysql.Escape(gallery.FullPath))).Rows[0]["bytes_deleted"]; if (!(objectsDeleted is DBNull)) { bytesDeleted += (long)(decimal)objectsDeleted; } core.Db.BeginTransaction(); itemsDeleted += core.Db.UpdateQuery(string.Format("DELETE FROM gallery_items WHERE user_id = {0} AND gallery_item_parent_path = '{1}'", core.Session.LoggedInMember.UserId, Mysql.Escape(gallery.FullPath))); core.Db.UpdateQuery(string.Format("DELETE FROM user_galleries WHERE user_id = {0} AND gallery_id = {1}", core.Session.LoggedInMember.UserId, gallery.GalleryId)); return new long[] { itemsDeleted, bytesDeleted }; }