internal override string show() { StringBuilder sb = new StringBuilder(); Entities.Content content = Provider.Content; if (content == null) { sb.Append(Provider.GetResource("There is no content to show its comments")); return(sb.ToString()); //*** } int commentCount = Convert.ToInt32(Provider.Database.GetValue("select count(*) from [UserComment] where ContentId={0} and ParentId=0 and Visible=1", content.Id)); int responseCount = Convert.ToInt32(Provider.Database.GetValue("select count(*) from [UserComment] where ContentId={0} and ParentId>0 and Visible=1", content.Id)); string link = this.showComments ? "" : String.Format(" onclick=\"runModuleMethod('Comments',{0},'GetComments',{{parentId:{1}}},commentsShow);$(this).onclick=null;\" style=\"cursor:pointer\"", this.Id, 0); sb.AppendFormat("<span class=\"mainTitle\"{0}>" + Provider.GetModuleResource("Total {1} comment, {2} reply") + "</span>", link, commentCount, responseCount); if (this.active) { sb.AppendFormat("<span class=\"linkWriteComment\" onclick=\"{0}\">{1}</span>", getWriteCommentJS(), Provider.GetModuleResource("(Write comment)")); } sb.AppendFormat("<div id=\"comments{0}_{1}\">", this.Id, 0); if (this.showComments) { sb.Append(this.GetComments(0)); } sb.AppendFormat("</div>"); return(sb.ToString()); }
protected override IDatabaseEntity[] GetContentList() { Entities.Content content = Provider.Content; FilterParser filterForContent = new FilterParser(this.filter, "Content"); string whereMevcutIcerik = "and Content.Id<>" + (content == null ? 0 : content.Id); string where = filterForContent.GetWhere(); string sql = @" select distinct top " + this.HowManyItems + @" Content.Id, Content.ClassName, Content.Hierarchy, Content.Title, Content.SpotTitle, TCategoryId.Title as CategoryName, Content.PublishDate, TAuthorId.Name as AuthorName, Content.Picture, Content.Description, " + (this.ShowMetin ? "Content.Metin," : "") + @" Content.ShowInPage, Product.ListPrice, Product.DiscountRate from Content inner join Content as TCategoryId ON Content.CategoryId = TCategoryId.Id inner join Product ON Product.ContentId = Content.Id left join Author as TAuthorId ON TAuthorId.Id = Content.AuthorId where Content.Visible=1 " + (this.showCurrentContent ? "" : whereMevcutIcerik) + (where != "" ? " AND " + where : "") + @" order by " + this.OrderBy + " " + (this.Ascending ? "asc" : "desc"); IDatabaseEntity[] contents = Provider.Database.ReadList(typeof(Entities.Content), sql, filterForContent.GetParams()).SafeCastToArray <IDatabaseEntity>(); return(contents); }
protected override string getCellHTML(int row, int col) { StringBuilder sb = new StringBuilder(); sb.Append(base.getCellHTML(row, col)); int index = row * this.cols + col; if (this.contents.Length <= index) { return(String.Empty); } Entities.Content content = (Entities.Content) this.contents[index]; if (content["ListPrice"] == null) { content["ListPrice"] = Decimal.Zero; } if (content["DiscountRate"] == null) { content["DiscountRate"] = Decimal.Zero; } decimal listPrice = (decimal)content["ListPrice"]; decimal ourPrice = listPrice - listPrice * (decimal)content["DiscountRate"] / 100; sb.AppendFormat("<b>{0:0,0.00}</b><br/>", ourPrice); sb.AppendFormat("<a href=\"{0}?cmdName=add&itemId={1}\">{2}</a>", basketPage, content.Id, addToBasketLink); return(sb.ToString()); }
private void writeSubMenus(int parentId, bool isRoot, StringBuilder sb) { if (Provider.Content.IsUnder(parentId) || Provider.Content.Id == parentId) { IDatabaseEntity[] cats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId={0} and Visible=1" + (listContents ? "" : " and ClassName='Category'") + " order by OrderNo", parentId).SafeCastToArray <IDatabaseEntity>(); Provider.Translate(cats); if (cats.Length == 0) { return; } sb.AppendFormat("<div style=\"margin-left:{0}px\">", (isRoot ? 0 : 1) * this.indent); if (isRoot && this.showHomeLink) { Entities.Content cRoot = new Entities.Content(); cRoot.Id = 1; sb.Append(getLink(cRoot)); //addLink(sb, Provider.Configuration.MainPage, 1, "Ana Sayfa"); } foreach (Entities.Content c in cats) { string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(c, useTemplate); sb.Append(getLink(c)); //addLink(sb, template, c.Id, c.Title); writeSubMenus(c.Id, false, sb); } sb.Append("</div>"); } }
public void SaveContentTree(Entities.Page page, ContentItem content, Entities.Content parent) { var newParent = new Entities.Content { PageId = page.Id, ParentId = parent?.Id, Name = content.Name, Type = content.Type, Data = content.Data }; SaveContent(newParent); content.Items.ForEach(x => SaveContentTree(page, x, newParent)); }
internal override string show() { StringBuilder sb = new StringBuilder(); Entities.Content content = this.getContent(); if (content == null) { if (Provider.DesignMode) { sb.Append(Provider.GetResource("There is no content to display. Either define filter or click a content link to access this page.")); } return(sb.ToString()); //*** } // eğer otomatik oluşturulmuş içerik ise ve detayları henüz okunmamışsa, okuyalım. if (content.ContentSourceId > 0 && String.IsNullOrEmpty(content.Metin)) { Provider.FetchAutoContentDetails(content); } string[] fieldsArr = this.fieldOrder.Split(','); Hashtable fields = new Hashtable(); fields["title"] = String.IsNullOrEmpty(content.Title) ? "" : String.Format("<div class=\"title\">{0}</div>", content.Title); fields["author"] = content.Author == null ? "" : String.Format("<div class=\"author\">{0}</div>", content.Author.Name); fields["source"] = content.Source == null ? "" : String.Format("<div class=\"source\">{0}</div>", content.Source.Name); fields["date"] = String.Format("<div class=\"date\">{0}</div>", content.PublishDate.ToString(this.dateFormat)); fields["description"] = String.IsNullOrEmpty(content.Description) ? "" : String.Format("<div class=\"desc\">{0}</div>", content.Description); fields["text"] = String.IsNullOrEmpty(content.Metin) ? "" : String.Format("<div class=\"text\">{0}</div>", content.Metin); string sourceLinkText = String.IsNullOrEmpty(content.SourceLink) ? "" : (content.SourceLink.Length > 47 ? content.SourceLink.Substring(0, 40) + ".." + content.SourceLink.Substring(content.SourceLink.Length - 5) : content.SourceLink); fields["sourcelink"] = String.IsNullOrEmpty(content.SourceLink) ? "" : String.Format("<div class=\"sourceLink\"><span>{1}:</span> <a href=\"{0}\" target=\"_blank\">{2}</a></div>", content.SourceLink, Provider.GetResource("Source"), sourceLinkText); if (Array.IndexOf(fieldsArr, "tags") > -1) { fields["tags"] = String.IsNullOrEmpty(content.Tags) ? "" : String.Format("<div class=\"tags\">{0}</div>", getTagsWithLink(content.Tags)); } fields["region"] = ""; string conRegion = Provider.GetRegionInnerHtml(this.ChildModules); if (!String.IsNullOrEmpty(conRegion)) { fields["region"] = String.Format("<div id=\"conRegion{0}\" class=\"conRegion Region\">{1}</div>", this.Id, conRegion); } foreach (string fieldName in fieldsArr) { if (fields.ContainsKey(fieldName)) { sb.Append(fields[fieldName]); } } return(sb.ToString()); }
private void SaveContent(Entities.Page page, Entities.Content contentTree) { contentTree.PageId = page.Id; SaveContent(contentTree); foreach (var item in contentTree.Children) { item.ParentId = contentTree.Id; SaveContent(page, item); } }
internal override string show() { Entities.Content content = Provider.Content; if (content == null) { return("There must be a content in this page to access author details"); } if (content.AuthorId == 0) { return("Author of this content has not been defined"); } return(base.show()); }
internal override string show() { Entities.Content content = Provider.Content; if (content == null) { return(Provider.GetResource("There must be a content in this page to access source details")); } if (content.SourceId == 0) { return(Provider.GetResource("Source of this content has not been defined")); } return(base.show()); }
public string GetComments(int parentId) { StringBuilder sb = new StringBuilder(); Entities.Content content = Provider.Content; IDatabaseEntity[] comments = Provider.Database.ReadList(typeof(UserComment), "select * from [UserComment] where ContentId={0} and ParentId={1} and Visible=1 order by InsertDate", content.Id, parentId, Provider.User.Id).SafeCastToArray <IDatabaseEntity>(); foreach (UserComment comment in comments) { sb.Append(this.GetComment(comment, parentId)); } return(sb.ToString()); }
protected override IDatabaseEntity[] GetContentList() { Entities.Content content = Provider.Content; FilterParser filterForContent = new FilterParser(this.filter, "Content"); string whereMevcutIcerik = "and Content.Id<>" + (content == null ? 0 : content.Id); string where = filterForContent.GetWhere(); string sql = String.Format(@" select distinct top " + this.HowManyItems + @" Content.Id, Content.CategoryId, Content.ClassName, Content.Hierarchy, Content.Title, Content.SpotTitle, Content.PublishDate, Content.Description, {0} {1} {2} {3} {4} Content.ShowInPage from Content {5} {6} {7} where Content.Visible=1 {8} order by {9} {10}", this.ShowPicture ? (this.WhichPicture == "Content.Picture2" ? "Content.Picture2,Content.Picture," : this.WhichPicture + ",") : "", this.ShowMetin ? "Content.Metin," : "", (this.ShowAuthor || this.WhichPicture.Contains("Author")) ? "TAuthorId.Name as AuthorName," : "", (this.ShowSource || this.WhichPicture.Contains("Source")) ? "TSourceId.Name as SourceName," : "", this.ShowCategory ? "TCategoryId.Title as CategoryName," : "", this.ShowCategory ? "inner join Content as TCategoryId ON Content.CategoryId = TCategoryId.Id" : "", (this.ShowAuthor || this.WhichPicture.Contains("Author")) ? "left join Author as TAuthorId ON TAuthorId.Id = Content.AuthorId" : "", (this.ShowSource || this.WhichPicture.Contains("Source")) ? "left join Source as TSourceId ON TSourceId.Id = Content.SourceId" : "", (this.showCurrentContent ? "" : whereMevcutIcerik) + (where != "" ? " AND " + where : ""), this.OrderBy, this.Ascending ? "asc" : "desc" ); IDatabaseEntity[] contents = Provider.Database.ReadList(typeof(Entities.Content), sql, filterForContent.GetParams()).SafeCastToArray <IDatabaseEntity>(); return(contents); }
private Entities.Content GetContentTreeFromModel(ContentModel model) { var content = new Entities.Content { Name = model.Name, Type = model.Type, Data = model.Data }; foreach (var child in model.Children) { var contentChild = GetContentTreeFromModel(child); content.Children.Add(contentChild); } return(content); }
private ContentModel ContentModel(Entities.Content content, ContentModel parent = null) { var itemModel = new ContentModel { Name = content.Name, Data = content.Data, Type = content.Type }; foreach (var item in content.Children) { var child = ContentModel(item, itemModel); itemModel.Children.Add(child); } return(itemModel); }
internal override string show() { StringBuilder sb = new StringBuilder(); string commentLink = Provider.GetModuleResource("Comment"); string emailLink = Provider.GetModuleResource("Feedback"); string printLink = Provider.GetModuleResource("Print"); string recommendLink = Provider.GetModuleResource("Recommend"); Entities.Content content = Provider.Content; bool commentsModuleExist = this.ContainerPage == null; Comments mdlComments = null; if (this.ContainerPage != null) { commentsModuleExist = this.ContainerPage.HasModule(typeof(Comments)); if (commentsModuleExist) { mdlComments = (Comments)this.ContainerPage.GetModule(typeof(Comments)); } } if (String.IsNullOrEmpty(this.printPage)) { this.printPage = "Print.ashx"; } Hashtable tools = new Hashtable(); tools["comment"] = (commentsModuleExist || Provider.DesignMode) ? String.Format("<a class=\"comment\" href=\"javascript:{0}\">{1}</a>", mdlComments == null ? "void(0)" : mdlComments.getWriteCommentJS(), getToolHtml(commentIcon, commentLink)) : ""; tools["email"] = String.Format("<a class=\"email\" href=\"mailto:{0}?subject={1}\">{2}</a>", Provider.Configuration.AuthEmail, content == null ? "" : CMSUtility.HtmlEncode(content.Title), getToolHtml(emailIcon, emailLink)); tools["print"] = content != null?String.Format("<a class=\"print\" href=\"{0}?item={1}\" target=\"_blank\">{2}</a>", printPage, content.Id, getToolHtml(printIcon, printLink)) : ""; tools["recommendation"] = String.Format("<a class=\"recommend\" href=\"javascript:recommend({0})\">{1}</a>", this.Id, getToolHtml(recommendIcon, recommendLink)); foreach (string toolName in this.toolOrder.Split(',')) { if (tools.ContainsKey(toolName)) { sb.Append(tools[toolName]); } } return(sb.ToString()); }
private Entities.Content GetContentTreeFromModel(ContentModel model) { var content = new Entities.Content { Name = model.Name, Type = model.Type, Data = model.Data }; foreach (var child in model.Children) { var contentChild = GetContentTreeFromModel(child); content.Children.Add(contentChild); } return content; }
protected override IDatabaseEntity[] GetContentList() { Entities.Content content = Provider.Content; FilterParser filterForContent = new FilterParser(this.filter, "Content"); string whereMevcutIcerik = "and Content.Id<>" + (content == null ? 0 : content.Id); string tagJoin = "inner join ContentTag ON Content.Id = ContentTag.ContentId and ContentTag.TagId=" + (Provider.Tag != null ? Provider.Tag.Id : 0); string where = filterForContent.GetWhere(); string sql = String.Format(@" select distinct top " + this.HowManyItems + @" Content.Id, Content.CategoryId, Content.ClassName, Content.Hierarchy, Content.Title, Content.SpotTitle, TCategoryId.Title as CategoryName, Content.PublishDate, TAuthorId.Name as AuthorName, TSourceId.Name as SourceName, {0}, Content.Description, {1} Content.ShowInPage from Content inner join Content as TCategoryId ON Content.CategoryId = TCategoryId.Id {5} left join Author as TAuthorId ON TAuthorId.Id = Content.AuthorId left join Source as TSourceId ON TSourceId.Id = Content.SourceId where Content.Visible=1 {2} order by {3} {4}", this.WhichPicture, this.ShowMetin ? "Content.Metin," : "", (this.showCurrentContent ? "" : whereMevcutIcerik) + (where != "" ? " AND " + where : ""), this.OrderBy, this.Ascending ? "asc" : "desc", Provider.Tag != null ? tagJoin : ""); IDatabaseEntity[] contents = Provider.Database.ReadList(typeof(Entities.Content), sql, filterForContent.GetParams()).SafeCastToArray <IDatabaseEntity>(); return(contents); }
internal override string show() { Entities.Content category = Provider.Content; if (category == null) { return(Provider.GetResource("Category is null")); } string[] cats = (category.Hierarchy + (category.ClassName == "Category" ? "," + category.Id : "")).Split(','); for (int i = 0; i < cats.Length; i++) { cats[i] = cats[i].TrimStart('0'); } string hier = String.Join(",", cats); if (String.IsNullOrEmpty(hier)) { hier = "1"; //*** } IDatabaseEntity[] contents = Provider.Database.ReadList(typeof(Entities.Content), "select Id, Title, ClassName, Hierarchy, ShowInPage from Content where Id in (" + hier + ") and Visible=1").SafeCastToArray <IDatabaseEntity>(); Provider.Translate(contents); int skipFirstCounter = 0; StringBuilder sb = new StringBuilder(); foreach (Entities.Content content in contents) { if (skipFirstCounter < skipFirst) { skipFirstCounter++; continue; } sb.Append(getLink(content)); } return(sb.ToString()); }
internal override string show() { StringBuilder sb = new StringBuilder(); Entities.Content firstContent = null; if (this.contents != null && this.contents.Length > 0) { firstContent = (Entities.Content) this.contents[0]; } if (firstContent == null) { return(""); } Hashtable fields = new Hashtable(); fields["title"] = String.Format("<div id=\"Manset_{0}_title\" class=\"mansetTitle\">{1}</div>\n", this.Id, firstContent.Title.StrCrop(this.titleLength)); fields["spot"] = String.Format("<div id=\"Manset_{0}_title\" class=\"mansetSTitle\">{1}</div>\n", this.Id, firstContent.SpotTitle.StrCrop(this.titleLength)); fields["image"] = Provider.GetThumbImgHTML(firstContent.Picture, pictureWidthM, pictureHeightM, null, "mansetImage", "id=\"Manset_" + this.Id + "_pic\"", CropPictureM); fields["author"] = String.Format("<div id=\"Manset_{0}_auth\" class=\"mansetAuth\">{1}</div>\n", this.Id, firstContent["AuthorName"]); fields["date"] = String.Format("<div id=\"Manset_{0}_date\" class=\"mansetDate\">{1}</div>\n", this.Id, firstContent.PublishDate.ToString(this.dateFormat)); fields["description"] = String.Format("<div id=\"Manset_{0}_desc\" class=\"mansetDesc\">{1}</div>\n", this.Id, firstContent.Description.StrCrop(this.descriptionLength)); sb.AppendFormat("<table{0} width=\"100%\" border=\"0\">\n", this.withAnimation ? " onmouseover=\"showManset(event, " + this.Id + ")\"" : ""); sb.Append("<tr><td align=\"center\" valign=\"middle\">\n"); foreach (string fieldName in this.mansetFieldOrder.Split(',')) { if (fields.ContainsKey(fieldName)) { sb.Append(fields[fieldName]); } } sb.Append("</td><td>\n"); sb.Append(base.show()); sb.Append("</td></tr>\n"); sb.Append("</table>\n"); return(sb.ToString()); }
internal override string show() { StringBuilder sb = new StringBuilder(); Entities.Content firstContent = null; if (this.contents != null && this.contents.Length > 0) { firstContent = (Entities.Content) this.contents[0]; } if (firstContent == null) { return(""); } Hashtable fields = new Hashtable(); fields["title"] = String.Format("<tr><td colspan=\"2\" id=\"{0}_{1}_title\" class=\"mansetTitle\">{2}</td></tr>\n", this.Name, this.Id, firstContent.Title.StrCrop(this.titleLength)); fields["spot"] = String.Format("<tr><td colspan=\"2\" id=\"{0}_{1}_sTitle\" class=\"mansetSTitle\">{2}</td></tr>\n", this.Name, this.Id, firstContent.SpotTitle.StrCrop(this.titleLength)); fields["image"] = "<tr>\n\t<td align=\"center\" valign=\"middle\" width=\"1%\">" + Provider.GetThumbImgHTML(firstContent.Picture, pictureWidthM, pictureHeightM, null, "mansetImage", "id=\"" + this.Name + "_" + this.Id + "_pic\"", CropPictureM) + "</td>\n" + (this.showLinksBelowPicture ? "</tr><tr>" : "") + "\t<td width=\"99%\">" + base.show() + "\n" + "</td></tr>\n"; fields["description"] = String.Format("<tr><td colspan=\"2\"><div id=\"{0}_{1}_desc\" class=\"mansetDesc\">{2}</div></td></tr>\n", this.Name, this.Id, firstContent.Description.StrCrop(this.descriptionLength)); sb.AppendFormat("<table{0} width=\"100%\" border=\"0\">\n", this.withAnimation ? " onmouseover=\"showManset(event, " + this.Id + ")\"" : ""); foreach (string fieldName in this.MansetFieldOrder.Split(',')) { if (fields.ContainsKey(fieldName)) { sb.Append(fields[fieldName]); } } sb.Append("</table>\n"); return(sb.ToString()); }
public void AddContentToPage(Entities.Page page, Entities.Content content) { var component = new ContentComponent(Context); component.AddContent(page, content); }
public string GetWhere() { Entities.Content content = Provider.Content; if (content == null) { content = (Entities.Content)Provider.Database.Read(typeof(Entities.Content), 1); } Entities.Content category = null; if (content.ClassName == "Category") { category = content; } else { category = content.Category; } string where = ""; Hashtable htOperators = new Hashtable(); Hashtable htParams = new Hashtable(); alParams = new Dictionary <string, object>(); foreach (string criteria in this.filter.Split(new string[] { " AND ", " and ", " And " }, StringSplitOptions.RemoveEmptyEntries)) { string[] pair = criteria.Split(new string[] { "like@", "<=@", ">=@", "<>@", "<@", ">@", "=@", "like", "<=", ">=", "<>", "<", ">", "=" }, StringSplitOptions.None); htOperators[pair[0]] = criteria.Substring(pair[0].Length, criteria.Length - pair[0].Length - pair[1].Length); htParams[pair[0]] = pair[1]; } int fieldNo = 0; ArrayList fields = new ArrayList(htParams.Keys); foreach (string field in fields) { FieldOpValue fov = new FieldOpValue(entityName + "." + field, htOperators[field].ToString(), htParams[field].ToString()); #region özel durumlar if (fov.Op.Contains("@")) { fov.Op = fov.Op.Substring(0, fov.Op.Length - 1); if (htParams[field].Equals("Hierarchy")) { int parentCategoryId = category == null ? 1 : category.Id; fov.Value = Provider.GetHierarchyLike(parentCategoryId) + "%"; fov.Column = entityName + "." + "Hierarchy"; } else if (htParams[field].Equals("Category")) { if (category == null) { throw new Exception(Provider.GetResource("KategoriTam cannot be used as a parameter because there is no active category")); } fov.Value = category.Id; fov.Column = entityName + "." + "CategoryId"; } else if (htParams[field].Equals("Author")) { fov.Value = content.AuthorId; } else if (htParams[field].Equals("Source")) { fov.Value = content.SourceId; } else if (htParams[field].Equals("Content")) { fov.Value = content.Id; } else if (htParams[field].Equals("PreviousContent")) { fov.Value = Provider.PreviousContentId; //Provider.Database.GetInt("select Id from Content where Id<{0} AND CategoryId={1} order by Id desc limit 1", content.Id, content.CategoryId); } else if (htParams[field].Equals("NextContent")) { fov.Value = Provider.NextContentId; //Provider.Database.GetInt("select Id from Content where Id>{0} AND CategoryId={1} order by Id limit 1", content.Id, content.CategoryId); } else if (htParams[field].Equals("Yesterday")) { fov.Value = DateTime.Now.Date.AddDays(-1d); } else if (htParams[field].Equals("LastDay")) { fov.Value = DateTime.Now.Date.AddDays(-2d); } else if (htParams[field].Equals("LastWeek")) { fov.Value = DateTime.Now.Date.AddDays(-1 * 7d); } else if (htParams[field].Equals("LastMonth")) { fov.Value = DateTime.Now.Date.AddMonths(-1); } else { throw new Exception(Provider.GetResource("Invalid parameter name")); } } #endregion alParams.Add(field, fov.Value); where += (where == "" ? "" : " AND ") + fov.Column + " " + fov.Op + " {" + fieldNo + "}"; fieldNo++; } return(where); }
public CardView(Entities.Content content) { Grid outerGrid = new Grid { RowSpacing = 0, ColumnSpacing = 0, BackgroundColor = Color.Black, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Absolute) }, new RowDefinition { Height = GridLength.Star }, new RowDefinition { Height = new GridLength(1, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Absolute) } } }; Grid grid = new Grid { RowSpacing = 1, ColumnSpacing = 1, BackgroundColor = Color.FromHex("#292929"), VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(30, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Star } } }; int typeofurl = CheckIfValidUrl(content.Url); // 1 img, 2 vid if (typeofurl == 1) { Image img = new Image { HorizontalOptions = LayoutOptions.Fill, Aspect = Aspect.AspectFill }; img.Source = ImageSource.FromUri(new Uri(content.Url)); grid.Children.Add(img, 0, 0); } else if (typeofurl == 2) { Image img = new Image { HorizontalOptions = LayoutOptions.Fill, Aspect = Aspect.AspectFill }; string token = content.Url.Split('=')[1]; string thumbnailUrl = "https://img.youtube.com/vi/" + token + "/0.jpg"; img.Source = ImageSource.FromUri(new Uri(thumbnailUrl)); grid.Children.Add(img, 0, 0); } else { grid.RowDefinitions[0].Height = 1; } Grid innerGrid = new Grid { Padding = new Thickness(5, 1), RowSpacing = 1, ColumnSpacing = 1, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Star } }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Star } } }; Label labelTitle = new Label { Text = content.Title, TextColor = Color.White }; innerGrid.Children.Add(labelTitle, 0, 0); grid.Children.Add(innerGrid, 0, 1); outerGrid.Children.Add(grid, 1, 1); Content = outerGrid; }
private void writeSubMenus(int parentId, bool isRoot, StringBuilder sb) { if (Provider.Content.IsUnder(parentId) || Provider.Content.Id == parentId) { IDatabaseEntity[] cats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId={0} and Visible=1" + (listContents ? "" : " and ClassName='Category'") + " order by OrderNo", parentId).SafeCastToArray<IDatabaseEntity>(); Provider.Translate(cats); if (cats.Length == 0) return; sb.AppendFormat("<div style=\"margin-left:{0}px\">", (isRoot ? 0 : 1) * this.indent); if (isRoot && this.showHomeLink) { Entities.Content cRoot = new Entities.Content(); cRoot.Id = 1; sb.Append(getLink(cRoot)); //addLink(sb, Provider.Configuration.MainPage, 1, "Ana Sayfa"); } foreach (Entities.Content c in cats) { string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(c, useTemplate); sb.Append(getLink(c)); //addLink(sb, template, c.Id, c.Title); writeSubMenus(c.Id, false, sb); } sb.Append("</div>"); } }
public void SaveContentTree(Entities.Page page, ContentItem content, Entities.Content parent) { var newParent = new Entities.Content { PageId = page.Id, ParentId = parent?.Id, Name = content.Name, Type = content.Type, Data = content.Data }; SaveContent(newParent); content.Items.ForEach(x=>SaveContentTree(page, x, newParent)); }
internal override string show() { selectedCatId = this.ParentCategoryId; StringBuilder sb = new StringBuilder(); Int32.TryParse(Provider.Request["item"], out selectedCatId); if (selectedCatId == 0) { selectedCatId = 1; } Entities.Content selectedCat = (Entities.Content)Provider.Database.Read(typeof(Entities.Content), selectedCatId); if (this.showHomeLink) { addLink(sb, Provider.Configuration.MainPage, "nav", selectedCatId == 1, 1, "", Provider.GetModuleResource("Home Page")); } IDatabaseEntity[] cats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId=" + (this.Dynamic ? selectedCatId : this.ParentCategoryId) + " and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>(); if (cats.Length == 0 && this.Dynamic) { cats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId=" + selectedCat.CategoryId + " and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>(); } Provider.Translate(cats); foreach (Entities.Content dr in cats) { //string template = Provider.GetTemplate(dr, useTemplate); string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(dr, useTemplate); bool selected = selectedCat.IsUnder(dr.Id) || dr.Id == selectedCatId; addLink(sb, template, "nav", selected, dr.Id, dr.Category.Title, dr.Title); if (this.showChildCategories && (selectedCat.Id == dr.Id || selectedCat.Hierarchy.IndexOf(dr.Id.ToString().PadLeft(5, '0')) > -1)) { IDatabaseEntity[] subCats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId=" + dr.Id + " and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>(); Provider.Translate(subCats); foreach (Entities.Content drSub in subCats) { //template = Provider.GetTemplate(drSub, useTemplate); template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(drSub, useTemplate); selected = selectedCat.IsUnder(drSub.Id) || drSub.Id == selectedCatId; addLink(sb, template, "subNav", selected, drSub.Id, drSub.Category.Title, drSub.Title); } } } if (popupDepth > 0) { ArrayList alCats = new ArrayList(); foreach (Entities.Content cat in cats) { alCats.Add(cat.Id.ToString()); } IDatabaseEntity[] childItems = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage, CategoryId from Content where CategoryId in (" + string.Join(",", (string[])alCats.ToArray(typeof(string))) + ") and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>(); sb.Append("<div style=\"display:none;position:absolute\" class=\"popupMenuItems hideOnOut\">\n"); foreach (Entities.Content childContent in childItems) { string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(childContent, useTemplate); addPopupLink(sb, template, "popupMenuItem", childContent.Id, childContent.Title, childContent.CategoryId, childContent.Category.Title); } sb.Append("</div>\n"); sb.AppendFormat("<script type=\"text/javascript\">navigationPopupInit('Navigation_{0}',{1});</script>\n", this.Id, this.Horizontal?"true":"false"); } sb.Append("<div style=\"clear:both\"></div>\n"); return(sb.ToString()); }
private void SaveContent(Entities.Content content) { var store = new ContentStore(Context.FileSystem); store.Add(content); }
protected override IDatabaseEntity[] GetContentList() { Entities.Content content = Provider.Content; FilterParser filterForContent = new FilterParser(this.filter, "Content"); string whereMevcutIcerik = "and Content.Id<>" + (content == null ? 0 : content.Id); string ids = ""; string showPictureOf = this.groupBy == "CategoryId" ? "Content" : ("T" + this.groupBy); string where = filterForContent.GetWhere(); string distSQL = @" select top " + this.howManyItems + @" Content." + groupBy + @" as GroupId, max(Content.Id) as Id from Content " + (groupBy == "AuthorId" ? "inner" : "left") + @" join Author as TAuthorId ON TAuthorId.Id = Content.AuthorId " + (groupBy == "SourceId" ? "inner" : "left") + @" join Source as TSourceId ON TSourceId.Id = Content.SourceId " + (groupBy == "CategoryId" ? "inner" : "left") + @" join Content as TCategoryId ON TCategoryId.Id = Content.CategoryId where Content.Visible=1 " + (this.showCurrentContent ? "" : whereMevcutIcerik) + (where != "" ? " AND " + where : "") + @" group by Content." + groupBy; DataTable dt = Provider.Database.GetDataTable(distSQL, filterForContent.GetParams()); if (dt == null || dt.Rows.Count == 0) { throw new Exception(Provider.GetResource("There is no content with this criteria.")); } ArrayList al = new ArrayList(); foreach (DataRow dr in dt.Rows) { al.Add(dr["Id"].ToString()); } ids = String.Join(",", (string[])al.ToArray(typeof(String))); string sql = @" select Content.Id, Content.Title, Content.ClassName, Content.Hierarchy, Content.PublishDate, TAuthorId.Name as AuthorName, TSourceId.Name as SourceName, TCategoryId.Title as CategoryName, Content.ShowInPage, Content.Description, " + (this.ShowMetin ? "Content.Metin," : "") + @" " + showPictureOf + @".Picture from Content " + (groupBy == "AuthorId" ? "inner" : "left") + @" join Author as TAuthorId ON TAuthorId.Id = Content.AuthorId " + (groupBy == "SourceId" ? "inner" : "left") + @" join Source as TSourceId ON TSourceId.Id = Content.SourceId " + (groupBy == "CategoryId" ? "inner" : "left") + @" join Content as TCategoryId ON TCategoryId.Id = Content.CategoryId where Content.Id in (" + ids + @") order by " + this.OrderBy + " " + (this.Ascending ? "asc" : "desc"); return(Provider.Database.ReadList(typeof(Entities.Content), sql).SafeCastToArray <IDatabaseEntity>()); }
public void AddContent(Entities.Page page, Entities.Content contentTree) { var store = new ContentStore(Context.FileSystem); SaveContent(page, contentTree); }
protected override string getCellHTML(int row, int col) { StringBuilder sb = new StringBuilder(); int index = row * this.cols + col; if (this.contents.Length <= index) { return(String.Empty); } Entities.Content content = (Entities.Content) this.contents[index]; bool isFirstItem = row + col == 0; string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(content, useTemplate); Hashtable fields = new Hashtable(); fields["image"] = this.getImgHTML(template, content, row, col); fields["picture2"] = string.IsNullOrEmpty(content.Picture2) ? fields["image"] : this.getImg2HTML(template, content, row, col); fields["title"] = this.getTitleHTML(isFirstItem, template, content, row, col); fields["spot"] = this.getSpotTitleHTML(isFirstItem, template, content, row, col); fields["category"] = content["CategoryName"] == null ? "" : this.getCategoryHTML(content["CategoryName"].ToString(), isFirstItem, template, content, row, col); fields["author"] = content["AuthorName"] == null ? "" : this.getAuthorHTML(content["AuthorName"].ToString(), isFirstItem, template, content, row, col); fields["source"] = content["SourceName"] == null ? "" : this.getSourceHTML(content["SourceName"].ToString(), isFirstItem, template, content, row, col); fields["date"] = this.getPublishDateHTML(this.dateFormat.ToLower() == "ago" ? content.PublishDate.ToAgoString() : content.PublishDate.ToString(this.dateFormat), row, col); fields["description"] = this.getDescriptionHTML(isFirstItem, template, content, row, col); fields["cat_description"] = this.getCatDescriptionHTML(isFirstItem, template, content, row, col); fields["text"] = this.getMetinHTML(content.Metin, row, col); sb.Append("<div class=\"clItem\">"); bool firstItemWithPicture = isFirstItem && this.showFirstItemWithPicture; if (firstItemWithPicture) { foreach (string fieldName in "title,image,description".Split(',')) { if (fields.ContainsKey(fieldName)) { sb.Append(fields[fieldName]); } } } else { foreach (string fieldName in this.fieldOrder.Split(',')) { if (fields.ContainsKey(fieldName)) { sb.Append(fields[fieldName]); fields.Remove(fieldName); } } // bunu manset icin yazmak zorunda kaldık! :( //if(!this.showFirstItemWithPicture) // foreach (string fieldName in fields.Keys) // sb.Append(fields[fieldName]); } if (!string.IsNullOrEmpty(MoreLink)) { sb.AppendFormat(@"<div class=""clMore"">{0}</div>", getLinkHTML(MoreLink, template, content)); } sb.Append("</div>"); return(sb.ToString()); }
internal override string show() { StringBuilder sb = new StringBuilder(); Entities.Content content = Provider.Content; if (content == null) { if (Provider.DesignMode) { sb.Append(Provider.GetResource("There is no picture to show because there is no related content")); } return(sb.ToString()); //*** } // resimleri alalım. IDatabaseEntity[] pics = Provider.Database.ReadList(typeof(Entities.ContentPicture), "select * from ContentPicture where ContentId={0} order by OrderNo, Id", content.Id).SafeCastToArray <IDatabaseEntity>(); Provider.Translate(pics); if (pics.Length == 0) { if (Provider.DesignMode) { sb.Append(Provider.GetResource("There is no picture added for this content (gallery)")); } return(sb.ToString()); //*** } StringBuilder sbPaging = new StringBuilder(); if (String.IsNullOrEmpty(this.pagingSeperator)) { this.pagingSeperator = " | "; } for (int i = 0; i < pics.Length; i++) { sbPaging.AppendFormat("<a id=\"pg{0}_{1}\"{3} href=\"javascript:showImage{0}({1})\">{2}</a>", this.Id, i, i + 1, i == 0 ? " class=\"sel\"" : ""); if (i < pics.Length - 1) { sbPaging.Append(this.pagingSeperator); } } sb.AppendFormat("<script type=\"text/javascript\">\n"); sb.AppendFormat("var currImg{0} = 0;\n", this.Id); sb.AppendFormat("var imgGal{0} = [\n", this.Id); foreach (Entities.ContentPicture pic in pics) { sb.AppendFormat("\t{{fileName:{0}, title:{1}, desc:{2}}},\n", pic.FileName.ToJS(), pic.Title.ToJS(), pic.Description.ToJS()); } sb.Remove(sb.Length - 2, 2); sb.Append("\n];\n"); sb.AppendFormat("var defTitle{0} = {1};\n", this.Id, content.Title.ToJS()); sb.AppendFormat("var defDesc{0} = {1};\n", this.Id, content.Description.ToJS()); sb.AppendFormat("function showImage{0}(i){{\n", this.Id); sb.AppendFormat("\tif(i==imgGal{0}.length) i = 0;\n", this.Id); sb.AppendFormat("\t$('#pg{0}_'+i).addClass('sel');\n", this.Id); sb.AppendFormat("\t$('#pg{0}_'+currImg{0}).removeClass('sel');\n", this.Id); sb.AppendFormat("\tvar pic = imgGal{0}[i];\n", this.Id); sb.AppendFormat("\t$('#imgGalPic{0}').attr('src', pic.fileName);\n", this.Id); sb.AppendFormat("\t$('#imgGalTit{0}').html(pic.title?pic.title:defTitle{0});\n", this.Id); sb.AppendFormat("\t$('#imgGalDesc{0}').html(pic.desc?pic.desc:defDesc{0});\n", this.Id); sb.AppendFormat("\tcurrImg{0} = i;\n", this.Id); sb.AppendFormat("}}\n"); sb.AppendFormat("</script>\n"); Hashtable fields = new Hashtable(); Entities.ContentPicture pic0 = (Entities.ContentPicture)pics[0]; fields["paging"] = "<div class=\"paging\">" + sbPaging + "</div>\n"; fields["picture"] = String.Format("<img id=\"imgGalPic{1}\" src=\"{0}\" onclick=\"showImage{1}(currImg{1}+1)\"{2}{3}/>\n", pic0.FileName, this.Id, this.pictureWidth > 0 ? " width=\"" + this.pictureWidth + "\"" : "", this.pictureHeight > 0 ? " height=\"" + this.pictureHeight + "\"" : ""); fields["title"] = String.Format("<div id=\"imgGalTit{0}\" class=\"title\">{1}</div>\n", this.Id, String.IsNullOrEmpty(pic0.Title) ? content.Title : pic0.Title); fields["description"] = String.Format("<div id=\"imgGalDesc{0}\" class=\"desc\">{1}</div>\n", this.Id, String.IsNullOrEmpty(pic0.Description) ? content.Description : pic0.Description); foreach (string fieldName in this.fieldOrder.Split(',')) { if (fields.ContainsKey(fieldName)) { sb.Append(fields[fieldName]); } } return(sb.ToString()); }