public Para EditArticleParaSave() { Para p = null; if (ContainerPage.Url["New"] == 1) { p = new Para(); p.ArticleK = CurrentPara.ArticleK; p.Page = CurrentPara.Page; Query qHigher = new Query(); qHigher.QueryCondition = new And( new Q(Para.Columns.ArticleK, CurrentPara.ArticleK), new Q(Para.Columns.Page, CurrentPara.Page), new Q(Para.Columns.Order, QueryOperator.GreaterThanOrEqualTo, CurrentPara.Order) ); qHigher.TopRecords = 2; qHigher.OrderBy = new OrderBy(Para.Columns.Order, OrderBy.OrderDirection.Ascending); ParaSet ps = new ParaSet(qHigher); if (ps.Count == 2) { //put this para in between p.Order = (ps[0].Order + ps[1].Order) / 2.0; } else if (ps.Count == 1) { p.Order = ps[0].Order + 1.0; } else { throw new Exception("Prror placing para sdfmhdsaljkhsdaflkjh. Contact support quoting this error."); } } else { p = CurrentPara; } if (EditArticleParaTypeTitle.Checked) p.Type = Para.TypeEnum.Title; else if (EditArticleParaTypePara.Checked) p.Type = Para.TypeEnum.Para; else p.Type = Para.TypeEnum.Photo; if (p.Type.Equals(Para.TypeEnum.Title)) p.Text = EditArticleParaHtml.GetPlainText(); else p.Text = EditArticleParaHtml.GetHtml(); p.Update(); if (ContainerPage.Url["New"] == 1) { p.Article.ReOrder(CurrentPara.Page); } return p; }
public void AddButtonDone(object o, System.EventArgs e) { if (Page.IsValid) { //Add article and paragraphs Article art = new Article(); art.AddedDateTime = DateTime.Now; art.Title = Cambro.Web.Helpers.StripHtml(AddArticleTitleTextBox.Text.Trim()); art.Summary = Cambro.Web.Helpers.StripHtml(AddArticleSummaryTextBox.Text.Trim()); string[] paraAry = AddArticleBodyHtml.GetParaHtml(); art.Update(); int order = 1; foreach (string s in paraAry) { if (s.Length > 0) { Para p = new Para(); p.ArticleK = art.K; p.Page = 1; p.Order = order; order++; p.Type = Para.TypeEnum.Para; p.PhotoK = 0; p.Text = s; p.ThreadK = 0; p.Update(); } } art.OwnerUsrK = Usr.Current.K; art.Status = Article.StatusEnum.New; if (CurrentEvent != null) { art.ParentObjectType = Model.Entities.ObjectType.Event; art.Relevance = Model.Entities.Article.RelevanceEnum.Venue; art.ParentObjectK = CurrentEvent.K; } else if (AddArticleScopeEvent.Checked) { art.ParentObjectType = Model.Entities.ObjectType.Event; art.Relevance = Model.Entities.Article.RelevanceEnum.Venue; art.ParentObjectK = this.AddArticleScopeMultiPicker.Event.K; } else if (AddArticleScopeVenue.Checked) { art.ParentObjectType = Model.Entities.ObjectType.Venue; art.Relevance = Model.Entities.Article.RelevanceEnum.Venue; art.ParentObjectK = this.AddArticleScopeMultiPicker.Venue.K; } else if (AddArticleScopePlace.Checked) { art.ParentObjectType = Model.Entities.ObjectType.Place; art.Relevance = Model.Entities.Article.RelevanceEnum.Place; art.ParentObjectK = this.AddArticleScopeMultiPicker.Place.K; } else if (AddArticleScopeCountry.Checked) { art.ParentObjectType = Model.Entities.ObjectType.Country; art.Relevance = Model.Entities.Article.RelevanceEnum.Country; art.ParentObjectK = this.AddArticleScopeMultiPicker.Country.K; } else { art.ParentObjectType = Model.Entities.ObjectType.None; art.Relevance = Model.Entities.Article.RelevanceEnum.Worldwide; } art.HasSingleThread = true; art.AdminNote = "Article added by owner " + DateTime.Now.ToString(); art.Update(); art.UpdateAncestorLinks(); Response.Redirect(UrlInfo.PageUrl("myarticles", "mode", "edit", "k", art.K.ToString())); } }
public void EditArticlePanel_Load(object o, System.EventArgs e) { if (ContainerPage.Url["Mode"].Equals("Edit")) { if ((CurrentArticle != null && !Usr.Current.CanEdit(CurrentArticle)) || (CurrentPara != null && !Usr.Current.CanEdit(CurrentPara.Article))) { ChangePanel(CantEditPanel); return; } EditArticleAdminTab.Visible = Usr.Current.IsAdmin; EditArticleAdminPanel.Visible = Usr.Current.IsAdmin; if (Usr.Current.IsAdmin) { EditArticleStatusDisplay.Visible = CurrentArticle.Status == Model.Entities.Article.StatusEnum.Enabled; if (CurrentArticle.Status == Model.Entities.Article.StatusEnum.Enabled) { EditArticleStatusDisplay.InnerHtml = "Article enabled " + CurrentArticle.EnabledDateTime.ToString() + " by " + CurrentArticle.EnabledUsr.Link(); } } EditArticleContentTab.HRef = CurrentArticle.UrlEdit("tab", "content"); EditArticleTitleTab.HRef = CurrentArticle.UrlEdit("tab", "title"); EditArticleLinkTab.HRef = CurrentArticle.UrlEdit("tab", "link"); EditArticleIconTab.HRef = CurrentArticle.UrlEdit("tab", "icon"); EditArticlePhotosTab.HRef = CurrentArticle.UrlEdit("tab", "photos"); EditArticleAdminTab.HRef = CurrentArticle.UrlEdit("tab", "admin"); if (ContainerPage.Url["Tab"].Equals("Content") || ContainerPage.Url["Tab"].IsNull) { BindBodyPageRepeater(); ChangePanel(EditArticleBodyPanel); EditArticleContentTab.Attributes["class"] = "TabbedHeading Selected"; } else if (ContainerPage.Url["Tab"].Equals("Title")) { ChangePanel(EditArticleTitleSummaryPanel); EditArticleTitleTab.Attributes["class"] = "TabbedHeading Selected"; } else if (ContainerPage.Url["Tab"].Equals("Link")) { ChangePanel(EditArticleSubjectMatterPanel); EditArticleLinkTab.Attributes["class"] = "TabbedHeading Selected"; } else if (ContainerPage.Url["Tab"].Equals("Icon")) { EditArticlePicture.InputObject = CurrentArticle; if (!Page.IsPostBack) EditArticlePicture.InitPic(); ChangePanel(EditArticlePicturePanel); EditArticleIconTab.Attributes["class"] = "TabbedHeading Selected"; } else if (ContainerPage.Url["Tab"].Equals("Photos") || ContainerPage.Url["Photos"] == 1) { #region Photo upload panel EditArticlePhotoUploadLink.HRef = "/pages/galleries/add/articlek-" + CurrentArticle.K.ToString(); EditArticlePhotoEditLink.HRef = "/pages/galleries/add/articlek-" + CurrentArticle.K.ToString(); PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.ArticleK, CurrentArticle.K), Photo.DateTimeOrder(OrderBy.OrderDirection.Ascending))); if (ps.Count == 0) EditArticlePhotoNoPhotosPanel.Visible = false; else { EditArticlePhotoNoPhotosPanel.Visible = true; EditArticlePhotoGalleryDataList.DataSource = ps; EditArticlePhotoGalleryDataList.ItemTemplate = this.LoadTemplate("/Templates/Photos/MyArticlesUpload.ascx"); EditArticlePhotoGalleryDataList.DataBind(); } #endregion ChangePanel(EditArticlePhotoUploadPanel); EditArticlePhotosTab.Attributes["class"] = "TabbedHeading Selected"; } else if (ContainerPage.Url["Tab"].Equals("Admin") && Usr.Current.IsAdmin) { ChangePanel(EditArticleAdminPanel); EditArticleAdminTab.Attributes["class"] = "TabbedHeading Selected"; } EditArticleIndexPublishPanel.Visible = CurrentArticle.Status.Equals(Article.StatusEnum.New) && !CurrentArticle.Pic.Equals(Guid.Empty); EditArticleIndexToDoPanel.Visible = CurrentArticle.Status.Equals(Article.StatusEnum.New) && CurrentArticle.Pic.Equals(Guid.Empty); EditArticleIndexPanelPreviewAnchor.HRef = CurrentArticle.Url(); EditArticleIndexPanelArticleNameLabel.Text = CurrentArticle.Name; if (!Page.IsPostBack) { EditArticleTitleTextBox.Text = CurrentArticle.Title; EditArticleSummaryTextBox.Text = CurrentArticle.Summary; if (CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Event)) { EditArticleScopeEvent.Checked = true; updateEditArticleScope(); EditArticleScopeMultiPicker.Event = CurrentArticle.ParentEvent; } else if (CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Venue)) { EditArticleScopeVenue.Checked = true; updateEditArticleScope(); EditArticleScopeMultiPicker.Venue = CurrentArticle.ParentVenue; } else if (CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Place)) { EditArticleScopePlace.Checked = true; updateEditArticleScope(); EditArticleScopeMultiPicker.Place = CurrentArticle.ParentPlace; } else if (CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Country)) { EditArticleScopeCountry.Checked = true; updateEditArticleScope(); EditArticleScopeMultiPicker.Country = CurrentArticle.ParentCountry; } else { EditArticleScopeGeneral.Checked = true; updateEditArticleScope(); } EditArticleRelevanceEvent.Checked = CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Event) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Venue) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Place) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Country) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.None); EditArticleRelevanceVenue.Checked = CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Venue) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Place) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Country) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.None); EditArticleRelevancePlace.Checked = CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Place) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Country) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.None); EditArticleRelevanceCountry.Checked = CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Country) || CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.None); EditArticleRelevanceCountry.Checked = CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.None); if (Usr.Current.IsAdmin) { EditArticleAdminStatusDrop.SelectedValue = ((int)CurrentArticle.Status).ToString(); EditArticleRelevanceGeneral.Checked = CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Worldwide; EditArticleRelevanceCountry.Checked = CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Worldwide || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Country; EditArticleRelevancePlace.Checked = CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Worldwide || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Country || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Place; EditArticleRelevanceVenue.Checked = CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Worldwide || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Country || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Place || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Venue; EditArticleRelevanceEvent.Checked = CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Worldwide || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Country || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Place || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Venue || CurrentArticle.Relevance == Model.Entities.Article.RelevanceEnum.Event; EditArticleRelevanceCountry.Visible = CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Country || CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Place || CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Venue || CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Event; EditArticleRelevancePlace.Visible = CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Place || CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Venue || CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Event; EditArticleRelevanceVenue.Visible = CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Venue || CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Event; EditArticleRelevanceEvent.Visible = CurrentArticle.ParentObjectType == Model.Entities.ObjectType.Event; EditArticleRelevanceGeneral.Enabled = CurrentArticle.ParentObjectType != Model.Entities.ObjectType.None; EditArticleRelevanceCountry.Enabled = CurrentArticle.ParentObjectType != Model.Entities.ObjectType.Country; EditArticleRelevancePlace.Enabled = CurrentArticle.ParentObjectType != Model.Entities.ObjectType.Place; EditArticleRelevanceVenue.Enabled = CurrentArticle.ParentObjectType != Model.Entities.ObjectType.Venue; EditArticleRelevanceEvent.Enabled = CurrentArticle.ParentObjectType != Model.Entities.ObjectType.Event; EditArticleMixmag.Checked = CurrentArticle.IsMixmagNews; EditArticleExtended.Checked = CurrentArticle.IsExtendedDisplay; for ( int i = 0; i < MixmagSectionsListBox.Rows; i++ ) { MixmagSectionsListBox.Items[i].Selected = CurrentArticle.MixmagIsSection(i); } EditArticleRelevanceFrontPageAboveFold.Checked = CurrentArticle.ShowAboveFoldOnFrontPage; } this.DataBind(); if (ContainerPage.Url["ParaK"].IsInt) { Para p = new Para(ContainerPage.Url["ParaK"]); ChangePanel(EditArticleBodyPanel); ContainerPage.AnchorSkip("ArticlePage" + p.Page.ToString()); } } } }
public static IBob Get(Model.Entities.ObjectType type, int k) { IBob b = null; bool wrongType = false; try { switch (type) { case Model.Entities.ObjectType.Photo: b = new Photo(k); break; case Model.Entities.ObjectType.Event: b = new Event(k); break; case Model.Entities.ObjectType.Venue: b = new Venue(k); break; case Model.Entities.ObjectType.Place: b = new Place(k); break; case Model.Entities.ObjectType.Thread: b = new Thread(k); break; case Model.Entities.ObjectType.Country: b = new Country(k); break; case Model.Entities.ObjectType.Article: b = new Article(k); break; case Model.Entities.ObjectType.Para: b = new Para(k); break; case Model.Entities.ObjectType.Brand: b = new Brand(k); break; case Model.Entities.ObjectType.Promoter: b = new Promoter(k); break; case Model.Entities.ObjectType.Usr: b = new Usr(k); break; case Model.Entities.ObjectType.Region: b = new Region(k); break; case Model.Entities.ObjectType.Gallery: b = new Gallery(k); break; case Model.Entities.ObjectType.Group: b = new Group(k); break; case Model.Entities.ObjectType.Banner: b = new Banner(k); break; case Model.Entities.ObjectType.GuestlistCredit: b = new GuestlistCredit(k); break; case Model.Entities.ObjectType.Ticket: b = new Ticket(k); break; case Model.Entities.ObjectType.Invoice: b = new Invoice(k); break; case Model.Entities.ObjectType.InsertionOrder: b = new InsertionOrder(k); break; case Model.Entities.ObjectType.CampaignCredit: b = new CampaignCredit(k); break; case Model.Entities.ObjectType.UsrDonationIcon: b = new UsrDonationIcon(k); break; default: wrongType = true; b = null; break; } } catch { } if (wrongType) throw new Exception("Bob.Get attempted to get " + type.ToString() + " - can't do it!!! DUH!"); return b; }