/// <summary> /// When we change a content's parent through the Update method (above) /// we need to update all the child content's lineages... /// </summary> /// <param name="id"></param> private void UpdateChildsLineage(long id) { string lineage = FormatLineage(id); var list = from l in _context.awContents where l.lineage.IndexOf(lineage) >= 0 select l; if (list == null || list.Count() == 0) { return; } foreach (awContent content in list) { if (content.parentContentId == null) { continue; } awContent parent = Get(content.parentContentId.Value); content.lineage = CreateContentLineage(parent.contentId); } _context.SubmitChanges(); }
/// <summary> /// ContentId is required /// Also deep parameter can be used.. /// if deep is 0 then looks for the siteTagId /// If deep is smaller than 0 then it will look for the parents /// if deep is greater than 0 then it will look for childs /// if Lineage is not empty, then first the deep will be found, then the /// Lineage will be checked... /// </summary> /// <param name="?"></param> /// <returns></returns> void GetByAlias(long siteId, string alias, string lineage, int deep, string cultureCode) { string tmpLineage = alias; if (!String.IsNullOrEmpty(Lineage)) { if (tmpLineage.EndsWith("|")) { tmpLineage = Lineage + alias; } else { tmpLineage = Lineage + "|" + alias; } } awContent contentToReturn = GetContent(siteId, 0, tmpLineage, deep, cultureCode); if (contentToReturn == null) { return; } List <SyndicationItem> items = new List <SyndicationItem>(); SyndicationItem contentItem = CreateContentSyndicationItem(contentToReturn); AddCustomField(contentToReturn.contentId, contentToReturn.parentContentId, cultureCode, ref contentItem); items.Add(contentItem); _feed.Items = items; }
/// <summary> /// creates lineage string /// example: |000000001|000000002| /// </summary> /// <param name="contentParentId"></param> /// <returns></returns> public string CreateContentLineage(Int64?contentParentId) { long?parentId = contentParentId; string lineage = ""; int n = 0; while (true || n < 20) { if (parentId == null || parentId.Value == 0) { break; } awContent content = Get(parentId.Value); if (content == null) { break; } lineage = FormatLineage(parentId.Value) + lineage; parentId = content.parentContentId; n++; } lineage = lineage.Replace("||", "|"); return(lineage); }
/// <summary> /// /// </summary> /// <param name="siteTagId"></param> /// <returns></returns> public AWAPI_Data.CustomEntities.ContentExtended Get(long contentId) { awContent tmp = _contentLibrary.Get(contentId); if (tmp == null) { return(null); } AWAPI_Data.CustomEntities.ContentExtended cont = new AWAPI_Data.CustomEntities.ContentExtended(); cont.contentId = tmp.contentId; cont.alias = tmp.alias; cont.title = tmp.title; cont.description = tmp.description; cont.lineage = tmp.lineage; cont.sortOrder = tmp.sortOrder; cont.pubDate = tmp.pubDate; cont.pubEndDate = tmp.pubEndDate; cont.contentType = tmp.contentType; cont.eventStartDate = tmp.eventStartDate; cont.eventEndDate = tmp.eventEndDate; cont.imageurl = tmp.imageurl; cont.isCommentable = tmp.isCommentable; cont.isEnabled = tmp.isEnabled; cont.link = tmp.link; cont.parentContentId = tmp.parentContentId; cont.lastBuildDate = tmp.lastBuildDate; cont.createDate = tmp.createDate; cont.siteId = tmp.siteId; cont.userId = tmp.userId; return(cont); }
void PopulateContent(Int64 contentId, string cultureCode) { ResetControls(); if (String.IsNullOrEmpty(cultureCode) && _culture.Items.FindByValue(App_Code.SessionInfo.CurrentSite.cultureCode) != null) { _culture.SelectedValue = App_Code.SessionInfo.CurrentSite.cultureCode; } awContent content = _contentLib.Get(contentId, cultureCode); if (content == null) { return; } _contentId.Text = content.contentId.ToString(); _alias.Text = content.alias; cbStatusContent_.Checked = content.isEnabled; _contentSortOrder.Text = content.sortOrder.ToString(); if (content.eventStartDate != null) { _contentEventStartDate.Text = content.eventStartDate.Value.ToString("MM/dd/yyyy HH:mm"); } if (content.eventEndDate != null) { _contentEventEndDate.Text = content.eventEndDate.Value.ToString("MM/dd/yyyy HH:mm"); } if (content.pubDate != null) { _contentPublishStartDate.Text = content.pubDate.Value.ToString("MM/dd/yyyy HH:mm"); } if (content.pubEndDate != null) { _contentPublishEndDate.Text = content.pubEndDate.Value.ToString("MM/dd/yyyy HH:mm"); } if (content.parentContentId == null) { content.parentContentId = 0; } _contentIsCommentable.Checked = content.isCommentable; _title.Text = content.title; _description.Value = content.description; _contentImageUrl.Text = content.imageurl; //_contentType.Text = content.contentType; SetImage(content.imageurl); PopulateCustomFields(contentId, content.parentContentId); PopulateContentsTags(contentId); //POPULATE OTHER --------------- PopulateContentParentList(content.contentId); _contentParentList.SelectedValue = content.parentContentId.ToString(); SetMethodLinks(); ShowHideContentButtons(true, content.contentType); }
/// <summary> /// ContentId is required /// Also deep parameter can be used.. /// if deep is 0 then looks for the siteTagId /// If deep is smaller than 0 then it will look for the parents /// if deep is greater than 0 then it will look for childs /// if Lineage is not empty, then first the deep will be found, then the /// Lineage will be checked... /// </summary> /// <param name="?"></param> /// <returns></returns> awContent GetContent(long siteId, long contentId, string contentLineageInAlias, int deep, string cultureCode) { long contentIdToReturn = 0; if (Deep == 0) // returns the current one { contentIdToReturn = contentId; } else { awContent content = _contentLib.Get(contentId, cultureCode, true); if (content == null) { return(null); } if (deep < 0) //look for parents { if (String.IsNullOrEmpty(content.lineage)) { return(null); } string[] parentIds = content.lineage.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (deep == -99 || (-1 * deep) >= parentIds.Length) //get the first one { contentIdToReturn = Convert.ToInt64(parentIds[0]); } else { contentIdToReturn = Convert.ToInt64(parentIds[parentIds.Length + Deep]); } } else if (Deep > 0) //look for childs { //TODO: Complete this. } } awContent contentToReturn = null; if (String.IsNullOrEmpty(contentLineageInAlias)) { contentToReturn = _contentLib.Get(contentIdToReturn, cultureCode, true); } else { contentToReturn = _contentLib.GetByAliasLineage(siteId, contentIdToReturn, contentLineageInAlias, cultureCode); } if (!_contentLib.IsParentsAvailable(true, contentToReturn)) { return(null); } return(contentToReturn); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="alias"></param> /// <param name="title"></param> /// <param name="description"></param> /// <param name="contentType"></param> /// <param name="userId"></param> /// <param name="parentContentId"></param> /// <param name="eventStartDate"></param> /// <param name="endDate"></param> /// <param name="link"></param> /// <param name="imageurl"></param> /// <param name="sortOrder"></param> /// <param name="isEnabled"></param> /// <param name="isCommentable"></param> /// <param name="pubDate"></param> /// <param name="pubEndDate"></param> /// <returns></returns> public bool Update(long id, string alias, string title, string description, string contentType, long userId, long?parentContentId, DateTime?eventStartDate, DateTime?endDate, string link, string imageurl, int?sortOrder, bool isEnabled, bool isCommentable, DateTime?pubDate, DateTime?pubEndDate) { awContent content = _context.awContents.FirstOrDefault(st => st.contentId.Equals(id)); if (content == null) { return(false); } bool parentHasBenChanged = parentContentId != content.parentContentId; if (String.IsNullOrEmpty(alias)) { throw new Exception("Alias is required."); } content.alias = alias.ToLower(); content.title = title; content.description = description; content.contentType = contentType; content.userId = userId; content.parentContentId = parentContentId; content.lineage = CreateContentLineage(parentContentId); content.eventStartDate = eventStartDate; content.eventEndDate = endDate; content.link = link; content.imageurl = imageurl; content.sortOrder = sortOrder == null ? 1 : sortOrder; content.isEnabled = isEnabled; content.isCommentable = isCommentable; content.lastBuildDate = DateTime.Now; if (pubDate != null) { content.pubDate = pubDate; } content.pubEndDate = pubEndDate; _context.SubmitChanges(); //Update child contents' lineage. if (parentHasBenChanged) { UpdateChildsLineage(content.contentId); } return(true); }
/// <summary> /// Populates breadcrumb /// </summary> /// <param name="contentId"></param> void PopulateBreadCrumb() { long contentId = 0; if (_contentId.Text != "") { contentId = Convert.ToInt64(_contentId.Text); } else { contentId = _parentContentId; } _rptBreadCrumb.DataSource = null; if (contentId > 0 && _contentList != null) { var list = from c in _contentList.ToList() where c.contentId.Equals(contentId) select c; if (list != null) { awContent cont = list.FirstOrDefault(); string lineage = cont.lineage.Trim(); System.Collections.ArrayList ids = new System.Collections.ArrayList(); if (!String.IsNullOrEmpty(lineage)) { string[] parentIds = lineage.Split('|'); for (int i = 0; i < parentIds.Length; i++) { if (!String.IsNullOrEmpty(parentIds[i])) { ids.Add(Convert.ToInt64(parentIds[i])); } } } //ids.Add(cont.contentId); var parentContents = from c in _contentList.ToList() where ids.Cast <long>().Contains(c.contentId) select c; _rptBreadCrumb.DataSource = parentContents; } } _rptBreadCrumb.DataBind(); _lblBreadCrumbCurrentContent.Text = _alias.Text; }
/// <summary> /// /// </summary> /// <param name="contentId"></param> /// <param name="alias"></param> /// <param name="title"></param> /// <param name="description"></param> /// <param name="contentType"></param> /// <param name="siteId"></param> /// <param name="userId"></param> /// <param name="parentContentId"></param> /// <param name="eventStartDate"></param> /// <param name="endDate"></param> /// <param name="link"></param> /// <param name="imageurl"></param> /// <param name="sortOrder"></param> /// <param name="isEnabled"></param> /// <param name="isCommentable"></param> /// <param name="pubDate"></param> /// <param name="pubEndDate"></param> /// <returns></returns> public long Add(long contentId, string alias, string title, string description, string contentType, long siteId, long userId, Int64?parentContentId, DateTime?eventStartDate, DateTime?endDate, string link, string imageurl, int?sortOrder, bool isEnabled, bool isCommentable, DateTime?pubDate, DateTime?pubEndDate) { awContent content = new awContent(); if (String.IsNullOrEmpty(alias.Trim())) { throw new Exception("Alias is required."); } content.contentId = contentId; content.alias = alias.ToLower(); content.title = title; content.description = description; content.contentType = String.IsNullOrEmpty(contentType) ? AWAPI_Common.values.TypeValues.ContentTypes.content.ToString() : contentType; content.userId = userId; content.siteId = siteId; content.parentContentId = parentContentId; content.lineage = CreateContentLineage(parentContentId);; content.eventStartDate = eventStartDate; content.eventEndDate = endDate; content.link = link; content.imageurl = imageurl; content.sortOrder = sortOrder == null? 1:sortOrder; content.isEnabled = isEnabled; content.isCommentable = isCommentable; content.lastBuildDate = DateTime.Now; if (pubDate == null) { content.pubDate = DateTime.Now; } else { content.pubDate = pubDate; } content.pubEndDate = pubEndDate; content.createDate = DateTime.Now; _context.awContents.InsertOnSubmit(content); _context.SubmitChanges(); return(contentId); }
/// <summary> /// /// </summary> /// <param name="blogId"></param> /// <returns></returns> public awContent Get(long contentId, string cultureCode, bool returnDefaultForLanguage) { if (contentId <= 0) { return(null); } var contList = from c in _context.awContents where c.contentId.Equals(contentId) select c; if (contList == null || contList.Count() == 0) { return(null); } awContent cont = contList.ToList()[0]; if (String.IsNullOrEmpty(cultureCode) || cont.awSite_.cultureCode == cultureCode) { return(cont); } var contLangList = from cl in _context.awContentCultures where cl.contentId.Equals(cont.contentId) && cl.cultureCode.ToLower().Equals(cultureCode.ToLower()) select cl; if (contLangList == null || contLangList.Count() == 0) { if (!returnDefaultForLanguage) { cont.title = null; cont.description = null; cont.link = null; cont.imageurl = null; } return(cont); } awContentCulture contLang = contLangList.FirstOrDefault <awContentCulture>(); cont.title = (returnDefaultForLanguage) ? ((contLang.title == null) ? cont.title : contLang.title) : contLang.title; cont.description = (returnDefaultForLanguage) ? ((contLang.description == null) ? cont.description : contLang.description) : contLang.description; cont.link = (returnDefaultForLanguage) ? ((contLang.link == null) ? cont.link : contLang.link) : contLang.link; cont.imageurl = (returnDefaultForLanguage) ? ((contLang.imageurl == null) ? cont.imageurl : contLang.imageurl) : contLang.imageurl; return(cont); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="enable"></param> /// <returns></returns> public bool EnableDisable(long id, bool enable) { awContent content = _context.awContents.FirstOrDefault(st => st.contentId.Equals(id)); if (content == null) { return(false); } content.isEnabled = enable; content.lastBuildDate = DateTime.Now; _context.SubmitChanges(); return(true); }
/// <summary> /// /// </summary> /// <param name="siteId"></param> /// <param name="blogId"></param> /// <param name="titleLineage"></param> /// <returns></returns> public awContent GetByAliasLineage(long siteId, long contentId, string aliasLineage, string cultureCode) { if (siteId <= 0 || aliasLineage.Trim() == "") { return(null); } //if blogId <=0 then we will look from the root, //else we will get sub groups under the contentid if (contentId < 0) { contentId = 0; } string[] contentNames = aliasLineage.ToLower().Split('|'); IList <awContent> contents = GetList(true, siteId, "", "", cultureCode); if (contents == null || contents.Count == 0) { return(null); } long parentContentId = contentId; awContent cnt = null; foreach (string alias in contentNames) { var list = from c in contents where c.isEnabled.Equals(true) && c.parentContentId.Equals(parentContentId) && c.alias.ToLower().Trim().Equals(alias) orderby c.sortOrder select c; if (list == null || list.Count() == 0) { return(null); } cnt = list.FirstOrDefault(); parentContentId = cnt.contentId; } //check if all the parents are enabled return(cnt); }
/// <summary> /// Checks if the current tag or the parent posts are available (isEnabled && publishing dates are ok) /// </summary> /// <param name="blog"></param> /// <returns></returns> public bool IsParentsAvailable(bool checkCurrentContentIsAvailable, awContent content) { DateTime dtNow = DateTime.Now; if (checkCurrentContentIsAvailable) { if (content == null || !content.isEnabled || content.pubDate != null && content.pubDate > dtNow || content.pubEndDate != null && content.pubEndDate < dtNow) { return(false); } } if (content.lineage == null || content.lineage.Trim() == "") { return(true); } string[] parentIdsTmp = content.lineage.Split('|'); System.Collections.ArrayList parentIds = new System.Collections.ArrayList(); foreach (string parentId in parentIdsTmp) { if (parentId != "") { parentIds.Add(Convert.ToInt64(parentId)); } } var parents = from p in _context.awContents where p.isEnabled && (p.pubDate == null || p.pubDate <= dtNow && p.pubEndDate == null || p.pubEndDate >= dtNow) && parentIds.ToArray().Contains(p.contentId) select p; if (parents == null || parents.Count() < parentIds.Count) { return(false); } return(true); }
/// <summary> /// ContentId is required /// Also deep parameter can be used.. /// if deep is 0 then looks for the siteTagId /// If deep is smaller than 0 then it will look for the parents /// if deep is greater than 0 then it will look for childs /// if Lineage is not empty, then first the deep will be found, then the /// Lineage will be checked... /// </summary> /// <param name="?"></param> /// <returns></returns> void Get(long siteId, long contentId, string Lineage, int deep, string cultureCode) { awContent contentToReturn = GetContent(siteId, contentId, Lineage, deep, cultureCode); if (contentToReturn == null) { return; } //if (!_contentLib.IsParentsAvailable(true, contentToReturn)) // return; contentId = contentToReturn.contentId; List <SyndicationItem> items = new List <SyndicationItem>(); SyndicationItem contentItem = CreateContentSyndicationItem(contentToReturn); AddCustomField(contentId, contentToReturn.parentContentId, cultureCode, ref contentItem); items.Add(contentItem); _feed.Items = items; }
void SetContentStaticValues(string staticFieldName, string textValue, bool booleanValue, awContent content) { switch (staticFieldName.ToLower().Trim()) { case "alias": content.alias = textValue; break; case "title": content.title = textValue; break; case "description": content.description = textValue; break; case "sortorder": content.sortOrder = Convert.ToInt32(textValue); break; case "isenabled": content.isEnabled = booleanValue; break; case "iscommentable": content.isCommentable = booleanValue; break; case "link": content.link = textValue; break; case "imageurl": content.imageurl = textValue; break; case "pubdate": content.pubDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(textValue); break; case "pubenddate": content.pubEndDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(textValue, true); break; case "eventstartdate": content.eventStartDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(textValue); break; case "eventenddate": content.eventEndDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(textValue, true); break; } }
protected void btnSaveContentForm__Click(object sender, ImageClickEventArgs e) { long id = _contentId.Text.Trim() == "" ? 0 : Convert.ToInt64(_contentId.Text); string cultureCode = App_Code.SessionInfo.CurrentSite.cultureCode; awContent content = new awContent(); bool newContent = false; try { if (id == 0) //Add new content { newContent = true; id = AWAPI_Common.library.MiscLibrary.CreateUniqueId(); } else //update the content { content = _contentLib.Get(id); if (content == null) { AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.ERROR, "Content not found."); return; } } content.siteId = App_Code.SessionInfo.CurrentSite.siteId; content.userId = App_Code.SessionInfo.CurrentUser.userId; #region SAVE CONTENT STATIC VALUES //SAVE THE CONTENT, FIRST (STATIC VALUES ONLY ) ---------------------------------------------- foreach (GridViewRow gr in _contentFieldList.Rows) { Boolean isCustomField = ((CheckBox)gr.FindControl("_isContentCustomField")).Checked; string fieldName = ((Literal)gr.FindControl("_title")).Text.ToLower().Trim(); string fieldType = ((Literal)gr.FindControl("_fieldType")).Text.ToLower(); Literal tmpContentCustomFieldId = (Literal)gr.FindControl("_contentCustomFieldId"); long contentCustomFieldId = (tmpContentCustomFieldId.Text == "" || tmpContentCustomFieldId.Text == "0") ? 0 : Convert.ToInt64(tmpContentCustomFieldId.Text); TextBox txb = (TextBox)gr.FindControl("_editBox"); CheckBox cb = (CheckBox)gr.FindControl("_checkBox"); if (!newContent && isCustomField && contentCustomFieldId > 0) { _customLib.UpdateFieldValue(id, contentCustomFieldId, App_Code.SessionInfo.CurrentUser.userId, txb.Text, cultureCode); } else { SetContentStaticValues(fieldName, txb.Text, cb.Checked, content); } } #endregion if (content.alias == null || content.alias.Trim() == "") { if (content.title.Trim() != "") { content.alias = AWAPI_Common.library.MiscLibrary.FormatAliasName(content.title); } else { content.alias = AWAPI_Common.library.MiscLibrary.FormatAliasName(_formTitle.Text.Trim() + "_" + id.ToString()); } } #region ADD or UPDATE CONTENT if (newContent) { content.parentContentId = 0; if (_formFeature_applyToSub.Checked && _formFeature_contentId.Text != "") { content.parentContentId = Convert.ToInt64(_formFeature_contentId.Text); } id = _contentLib.Add(id, content.alias, content.title, content.description, content.contentType, content.siteId, content.userId, content.parentContentId, content.eventStartDate, content.eventEndDate, content.link, content.imageurl, content.sortOrder, content.isEnabled, content.isCommentable, content.pubDate, content.pubEndDate); _contentId.Text = id.ToString(); } else { _contentLib.Update(id, content.alias, content.title, content.description, content.contentType, content.userId, content.parentContentId, content.eventStartDate, content.eventEndDate, content.link, content.imageurl, content.sortOrder, content.isEnabled, content.isCommentable, content.pubDate, content.pubEndDate); } #endregion #region SAVE CONTENT CUSTOM FIELDS //SAVE THE CUSTOM FIELDS foreach (GridViewRow gr in _contentFieldList.Rows) { Boolean isCustomField = ((CheckBox)gr.FindControl("_isContentCustomField")).Checked; Literal tmpContentCustomFieldId = (Literal)gr.FindControl("_contentCustomFieldId"); long contentCustomFieldId = (tmpContentCustomFieldId.Text == "" || tmpContentCustomFieldId.Text == "0") ? 0 : Convert.ToInt64(tmpContentCustomFieldId.Text); if (!isCustomField || contentCustomFieldId <= 0) { continue; } string fieldType = ((Literal)gr.FindControl("_fieldType")).Text.ToLower(); TextBox txb = (TextBox)gr.FindControl("_editBox"); CheckBox cb = (CheckBox)gr.FindControl("_checkBox"); string value = txb.Text; if (fieldType == "checkbox") { value = cb.Checked.ToString(); } _customLib.UpdateFieldValue(id, contentCustomFieldId, App_Code.SessionInfo.CurrentUser.userId, value, cultureCode); } #endregion PopulateFields(Convert.ToInt64(_formFeature_formId.Text), id); if (_formFeature_applyToSub.Checked) { PopulateChildContentList(Convert.ToInt64(_formFeature_contentId.Text)); } AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.INFO, "Content has been saved."); } catch (Exception ex) { AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.ERROR, ex.Message); } }
protected void btnSaveContent_Click(object sender, ImageClickEventArgs e) { long contentId = _contentId.Text.Trim().Length == 0 ? 0 : Convert.ToInt64(_contentId.Text); bool newContent = false; awContent content = new awContent(); content.alias = _alias.Text; content.title = _title.Text; content.description = _description.Value; content.link = ""; content.imageurl = _contentImageUrl.Text; content.userId = App_Code.SessionInfo.CurrentUser.userId; content.contentType = AWAPI_Common.values.TypeValues.ContentTypes.content.ToString(); content.parentContentId = Convert.ToInt64(_contentParentList.SelectedValue); if (contentId != 0 && //if content is selected !String.IsNullOrEmpty(_culture.SelectedValue) && !String.IsNullOrEmpty(App_Code.SessionInfo.CurrentSite.cultureCode) && App_Code.SessionInfo.CurrentSite.cultureCode != _culture.SelectedValue) { _contentLib.SaveContentLanguage(Convert.ToInt64(_contentId.Text), _culture.SelectedValue.ToLower(), content.title, content.description, content.link, content.imageurl, content.userId); } else { content.eventStartDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_contentEventStartDate.Text); content.eventEndDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_contentEventEndDate.Text, true); content.pubDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_contentPublishStartDate.Text); content.pubEndDate = AWAPI_Common.library.MiscLibrary.ConvertStringToDate(_contentPublishEndDate.Text, true); content.siteId = App_Code.SessionInfo.CurrentSite.siteId; if (_contentSortOrder.Text.Trim() != "") { content.sortOrder = Convert.ToInt32(_contentSortOrder.Text); } content.isEnabled = cbStatusContent_.Checked; content.isCommentable = _contentIsCommentable.Checked; if (contentId == 0) { newContent = true; contentId = _contentLib.Add(content.alias, content.title, content.description, content.contentType, content.siteId, content.userId, content.parentContentId, content.eventStartDate, content.eventEndDate, content.link, content.imageurl, content.sortOrder, content.isEnabled, content.isCommentable, content.pubDate, content.pubEndDate); _contentId.Text = contentId.ToString(); } else { contentId = Convert.ToInt64(_contentId.Text); _contentLib.Update(contentId, content.alias, content.title, content.description, content.contentType, content.userId, content.parentContentId, content.eventStartDate, content.eventEndDate, content.link, content.imageurl, content.sortOrder, content.isEnabled, content.isCommentable, content.pubDate, content.pubEndDate); } } SaveContentsTags(contentId); SaveCustomFields(contentId); SetImage(content.imageurl); ShowHideContentButtons(true, content.contentType); PopulateContentList(); PopulateContentParentList(content.contentId); PopulateContentsTags(contentId); if (newContent) { PopulateCustomFields(contentId, content.parentContentId); } _contentParentList.SelectedValue = content.parentContentId.ToString(); AdminMaster.WriteMessage(AWAPI.Admin.AdminMaster.MessageType.INFO, "Content has been saved."); HighlightContentNode("saved", new TreeNode(content.alias, content.contentId.ToString()), twContent.Nodes); }
/// <summary> /// /// </summary> /// <param name="where"></param> /// <param name="sortField"></param> /// <returns></returns> public System.Collections.Generic.IList <awContent> GetList(bool onlyAvailables, long siteId, string where, string sortField, string cultureCode) { StringBuilder sb = new StringBuilder(" SELECT * FROM awContent "); StringBuilder sbWhere = new StringBuilder(" WHERE siteId=" + siteId); if (onlyAvailables) { string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); sbWhere.Append(" AND isEnabled =1 "); sbWhere.Append(" AND (pubDate IS NULL OR pubDate<='" + date + "') "); sbWhere.Append(" AND (pubEndDate IS NULL OR pubEndDate>='" + date + "') "); } if (where.Trim().Length > 0) { sbWhere.Append(" AND (" + where + ") "); } sb.Append(sbWhere.ToString()); if (sortField.Trim().Length > 0) { sb.Append(" ORDER BY " + sortField); } else { sb.Append(" ORDER BY Lineage, sortOrder, title"); } var contents = _context.ExecuteQuery <awContent>(sb.ToString()); if (contents == null) { return(null); } //UPDATE CONTENT BASED ON THE CULTURE CODE ----------------------------------------- //if the default culture == groups' culture code, List <awContent> contentList = contents.ToList <awContent>(); if (contentList.Count == 0 || //if list is empty String.IsNullOrEmpty(cultureCode) || //if culture code is epty String.IsNullOrEmpty(contentList[0].awSite_.cultureCode) || //if site's default culture code is empty contentList[0].awSite_.cultureCode == cultureCode) //if default culture code is equal to culturecode { return(contentList); } //GET ALL THE IDS ArrayList contentIds = new ArrayList(); for (int i = 0; i < contentList.Count(); i++) { contentIds.Add(contentList[i].contentId); } var cLangList = from cl in _context.awContentCultures where cl.cultureCode.Equals(cultureCode) && contentIds.ToArray().Contains(cl.contentId) select cl; //UPDATE Title, Description, etc... IList <awContentCulture> langList = cLangList.ToList <awContentCulture>(); if (langList == null || cLangList.Count() == 0) { return(contentList); } foreach (awContentCulture cl in cLangList) { var conts = from c in contentList where c.contentId.Equals(cl.contentId) select c; awContent cont = conts.FirstOrDefault <awContent>(); if (cont == null) { continue; } cont.title = String.IsNullOrEmpty(cl.title) ? cont.title : cl.title; cont.description = String.IsNullOrEmpty(cl.description) ? cont.description : cl.description; cont.imageurl = String.IsNullOrEmpty(cl.imageurl) ? cont.imageurl : cl.imageurl; cont.link = String.IsNullOrEmpty(cl.link) ? cont.link : cl.link; } return(contentList); }
/// <summary> /// /// </summary> /// <param name="content"></param> /// <returns></returns> SyndicationItem CreateContentSyndicationItem(awContent content) { Uri uri = null; if (content.link != null && content.link.Trim() != "") { uri = new Uri(content.link); } string title = String.IsNullOrEmpty(content.title) ? content.alias : content.title; //SyndicationItem item = new SyndicationItem( // AWAPI_Common.library.MiscLibrary.AddCDATA(AWAPI_Common.library.MiscLibrary.CropSentence(title, MaximumTitleLength)), // AWAPI_Common.library.MiscLibrary.AddCDATA(AWAPI_Common.library.MiscLibrary.CropSentence(content.description, MaximumDescLength)), // uri, // content.contentId.ToString(), // content.lastBuildDate.Value); SyndicationItem item = new SyndicationItem(); item.Title = new TextSyndicationContent(AWAPI_Common.library.MiscLibrary.CropSentence(title, MaximumTitleLength), TextSyndicationContentKind.Html); item.Content = new TextSyndicationContent(AWAPI_Common.library.MiscLibrary.CropSentence(content.description, MaximumDescLength), TextSyndicationContentKind.Html); item.LastUpdatedTime = content.lastBuildDate.Value; item.BaseUri = uri; item.Id = content.contentId.ToString(); //item.ElementExtensions.Add("contentid", null, blog.siteTagId); if (content.alias != null) { item.ElementExtensions.Add("alias", null, content.alias); } if (content.contentType != null) { item.ElementExtensions.Add("contenttype", null, content.contentType); } if (content.createDate != null) { item.ElementExtensions.Add("createdate", null, content.createDate); } if (content.imageurl != null) { item.ElementExtensions.Add("imageurl", null, content.imageurl); } if (content.lineage != null) { item.ElementExtensions.Add("lineage", null, content.lineage); } if (content.parentContentId != null) { item.ElementExtensions.Add("parentcontentid", null, content.parentContentId); } if (content.pubDate != null) { item.ElementExtensions.Add("pubdate", null, content.pubDate); } if (content.pubEndDate != null) { item.ElementExtensions.Add("pubenddate", null, content.pubEndDate); } if (content.eventStartDate != null) { item.ElementExtensions.Add("eventstartdate", null, content.eventStartDate); item.ElementExtensions.Add("eventstartdate_dddd", null, content.eventStartDate.Value.ToString("dddd")); item.ElementExtensions.Add("eventstartdate_MMMM", null, content.eventStartDate.Value.ToString("MMMM")); } if (content.eventEndDate != null) { item.ElementExtensions.Add("eventenddate", null, content.eventEndDate); item.ElementExtensions.Add("eventenddate_dddd", null, content.eventEndDate.Value.ToString("dddd")); item.ElementExtensions.Add("eventenddate_MMMM", null, content.eventEndDate.Value.ToString("MMMM")); } item.ElementExtensions.Add("siteid", null, content.siteId); if (content.sortOrder != null) { item.ElementExtensions.Add("sortorder", null, content.sortOrder); } item.ElementExtensions.Add("userid", null, content.userId); return(item); }
/// <summary> /// /// </summary> /// <param name="siteId"></param> /// <param name="siteTagId"></param> /// <param name="Lineage"></param> /// <param name="deep"></param> void GetList(long siteId, long contentId, string Lineage, int deep, string tags, string cultureCode) { awContent parentContent = GetContent(siteId, contentId, Lineage, deep, cultureCode); if (parentContent == null) { return; } StringBuilder where = new StringBuilder(); where.Append(" parentContentId=" + parentContent.contentId); if (Where.Trim() != "") { where.Append(" AND ( " + Where + " ) "); } IList <awContent> contentList = _contentLib.GetList(true, SiteId, where.ToString(), SortBy, cultureCode).ToList(); if (contentList == null || contentList.Count() == 0) { return; } //FILTER FOR TAGS if (tags.Trim().Length > 0) { IList <awContent> taggedContents = _tagLib.GetTaggedContentList(tags); if (taggedContents == null || taggedContents.Count == 0) { return; } ArrayList arrIds = new ArrayList(); foreach (awContent c in taggedContents) { arrIds.Add(c.contentId); } var taggeds = from t in contentList where arrIds.Contains(t.contentId) select t; if (taggeds == null || taggeds.ToList().Count == 0) { return; } contentList = taggeds.ToList(); } //create syndication items for each blog item AWAPI_BusinessLibrary.library.ContentCustomFieldLibrary custFieldLib = new ContentCustomFieldLibrary(); List <SyndicationItem> items = new List <SyndicationItem>(); int rowNo = 0; int startRowNo = PageIndex * PageSize; foreach (awContent content in contentList.ToList()) { //Check if paging is enabled. if (PageSize > 0) { if (rowNo < startRowNo) { rowNo++; continue; } else if (rowNo >= startRowNo + PageSize) { break; } } SyndicationItem contentItem = CreateContentSyndicationItem(content); AddCustomField(content.contentId, content.parentContentId, cultureCode, ref contentItem); items.Add(contentItem); rowNo++; } _feed.Items = items; }
public bool IsParentsAvailable(awContent content) { return(IsParentsAvailable(false, content)); }