/// <summary> /// This is used to update the content in the ContentItems table. Should be called when an Article is updated. /// </summary> public void UpdateContentItem(Article objArticle, int tabId) { var origArticle = ArticleController.GetArticle(objArticle.ArticleId); var objContent = Util.GetContentController().GetContentItem(objArticle.ContentItemId); if (objContent == null) { return; } objContent.Content = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description); objContent.TabID = tabId; objContent.Metadata.Add("SimpleArticleThumbImg", objArticle.ThumbImg); objContent.Metadata.Add("SimpleArticleLargeImg", objArticle.LargeImg); //TODO: removed 7/19/2012 because metadata is useless //delete only works if there is only one description in metadata //Util.GetContentController().DeleteMetaData(objContent, "Description", origArticle.Metadata["Description"]); //Util.GetContentController().AddMetaData(objContent, "Description", objArticle.Description); Util.GetContentController().UpdateContentItem(objContent); // Update Terms var cntTerm = new Terms(); cntTerm.ManageArticleTerms(objArticle, objContent); }
//[DnnAuthorize(AllowAnonymous = true)] public HttpResponseMessage GetArticle(int articleId) { try { var a = ArticleController.GetArticle(articleId); var newArt = new ArticleViewModel { ArticleId = a.ArticleId, Body = WebUtility.HtmlDecode(a.Body), CreatedByUser = a.CreatedByUser, CreatedByUserId = a.CreatedByUserId, CreatedOnDate = a.CreatedOnDate, Description = WebUtility.HtmlDecode(a.Description), LastModifiedByUser = a.LastUpdatedByUser, LastModifiedByUserId = a.LastModifiedByUserId, LastModifiedOnDate = a.LastModifiedOnDate, ModuleId = a.ModuleId, Title = a.Title, url = DotNetNuke.Common.Globals.NavigateURL(a.TabID, "", "&aid=" + a.ArticleId) }; return(Request.CreateResponse(HttpStatusCode.OK, newArt)); } catch (Exception exc) { DnnLog.Error(exc); //todo: obsolete return(Request.CreateResponse(HttpStatusCode.BadRequest, "error in request")); //todo: probably should localize that? } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// ----------------------------------------------------------------------------- private void Page_Load(object sender, EventArgs e) { try { //Implement your edit logic for your module if (!Page.IsPostBack) { var article = new Article(); tsTerms.Terms = article.Terms; article = ArticleController.GetArticle(ArticleId); tsTerms.PortalId = PortalId; urlImage.UrlType = "F"; urlImage.FileFilter = "jpg,jpeg,jpe,gif,bmp,png"; if (article != null) { txtTitle.Text = article.Title; txtDescription.Text = article.Description; txtBody.Text = article.Body; tsTerms.Terms = article.Terms; urlImage.Url = article.LargeImg; } tsTerms.DataBind(); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["ArticleId"])) { _articleInfo = _articleController.GetArticle(Int32.Parse(Request.QueryString["ArticleId"])); } if (Page.IsPostBack) { return; } LoadCategory(); LoadTime(); LoadRoles(); if (_articleInfo.ArticleId != -1) { RenderForm(); qa.Visible = review.Visible = true; } else { qa.Visible = review.Visible = false; } }
protected void LbSaveClick(object sender, EventArgs e) { Article a; if (ArticleId > 0) { a = ArticleController.GetArticle(ArticleId); a.Title = txtTitle.Text.Trim(); a.Description = txtDescription.Text.Trim(); a.Body = txtBody.Text; a.LastModifiedOnDate = DateTime.Now; a.LastModifiedByUserId = UserInfo.UserID; a.ModuleId = ModuleId; a.LargeImg = urlImage.Url; } else { a = new Article { Title = txtTitle.Text.Trim(), Description = txtDescription.Text.Trim(), Body = txtBody.Text, CreatedOnDate = DateTime.Now, CreatedByUserId = UserInfo.UserID, LastModifiedOnDate = DateTime.Now, LastModifiedByUserId = UserInfo.UserID, ModuleId = ModuleId, LargeImg = urlImage.Url }; } if (tsTerms.Terms != null) { a.Terms.Clear(); a.Terms.AddRange(tsTerms.Terms); } a.Save(TabId); Response.Redirect(Globals.NavigateURL(TabId)); }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { if (ArticleId > 0) { var curArticle = ArticleController.GetArticle(ArticleId); //display article info on the view control if (curArticle != null) { plArticleTitle.Controls.Add(new LiteralControl(curArticle.Title)); //display the author name pnlAuthorInfo.Controls.Add(new LiteralControl(string.Format(Localization.GetString("AuthorInfo", LocalResourceFile), curArticle.CreatedByUser))); plArticleBody.Controls.Add(new LiteralControl(Server.HtmlDecode(curArticle.Body))); //display categories in the TagsControl tagsControl.ShowCategories = true; tagsControl.ShowTags = false; var mc = new ModuleController(); //look to see if the Content List module, for displaying tag results, is found var mi = mc.GetModuleByDefinition(PortalId, "Content List"); if (mi != null) { tagsControl.NavigateUrlFormatString = Globals.NavigateURL(mi.TabID, String.Empty, "Tag={0}"); tagsControl.ContentItem = Util.GetContentController().GetContentItem(curArticle.ContentItemId); } tagsControl.DataBind(); if (tagsControl.ContentItem == null || tagsControl.ContentItem.Terms.Count < 1) { ArticleTags.Visible = false; } //change the page title, description, and add categories to keywords var tp = (CDefault)Page; tp.Title = curArticle.Title; //we need to strip HTML from the description tp.Description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(Server.HtmlDecode(curArticle.Description), false); var listOfTerms = curArticle.Terms.ToDelimittedString(","); tp.KeyWords += "," + listOfTerms; if (!IsEditable) { ArticleAdmin.Visible = false; } else { ClientAPI.AddButtonConfirm(lnkDelete, Localization.GetString("ConfirmDelete", LocalResourceFile)); } } else { //no article found ArticleTags.Visible = ArticleAdmin.Visible = false; plArticleTitle.Controls.Add(new LiteralControl(Localization.GetString("noArticle.Text", LocalResourceFile))); } } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }