//获取单个块的html public static string GetOneBlockHtmls(string blockId) { Dictionary <string, object> dicBlock = new Dictionary <string, object>(); StringBuilder blockHtmls = new StringBuilder(); string BlockBeginHtml = "<DIV class=\"drag_div\" id=\"drag_{0}\" style=\"BORDER-COLOR: {1}; BACKGROUND: #fff;\">"; string BlockEndHtml = @"<DIV id='drag_switch_{0}'> <DIV class='drag_editor' id='drag_editor_{0}' style='DISPLAY: none'> <DIV id='loadeditorid_{0}' style='WIDTH: 100px'><IMG src='/Portal/Door/image/loading.gif'><SPAN id='loadeditortext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <DIV class='drag_content' id='drag_content_{0}'> <DIV id='loadcontentid_{0}' style='WIDTH: 100px'><IMG src='/Portal/Door/image/loading.gif'><SPAN id='loadcontenttext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> </DIV> </DIV>" ; BaseBlock bl = new BaseBlock(blockId); if (bl.Entity == null) { return(""); } blockHtmls.Append(string.Format(BlockBeginHtml, blockId, bl.Entity.ColorValue)); blockHtmls.Append(bl.GetHeadHtml()); blockHtmls.Append(string.Format(BlockEndHtml, blockId)); dicBlock["Html"] = blockHtmls.ToString(); dicBlock["DelayLoadSecond"] = bl.Entity.DelayLoadSecond.Value; dicBlock["RepeatItemCount"] = bl.Entity.RepeatItemCount; dicBlock["RelateScript"] = bl.Entity.RelateScript; return(JsonHelper.ToJson(dicBlock)); }
public static string GetCols(string col, string width, int i) { StringBuilder blockHtmls = new StringBuilder(); string colBeginHtml = "<DIV class=\"col_div\" id=\"col_{0}\" style=\"WIDTH: {1}\">"; string colEndHtml = @"<DIV class='drag_div no_drag' id='col_{0}_hidden_div'> <DIV id='col_{0}_hidden_div_h'></DIV> </DIV></DIV>" ; string BlockBeginHtml = "<DIV class=\"drag_div\" id=\"drag_{0}\" style=\"BORDER-COLOR: {1}; BACKGROUND: #fff;\">"; string BlockEndHtml = @"<DIV id='drag_switch_{0}'> <DIV class='drag_editor' id='drag_editor_{0}' style='DISPLAY: none'> <DIV id='loadeditorid_{0}' style='WIDTH: 100px'><IMG src='/Portal/Door/image/loading.gif'><SPAN id='loadeditortext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <DIV class='drag_content' id='drag_content_{0}'> <DIV id='loadcontentid_{0}' style='WIDTH: 100px'><IMG src='/Portal/Door/image/loading.gif'><SPAN id='loadcontenttext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <SCRIPT id='{0}' type='text/javascript'>{1}</SCRIPT> </DIV> </DIV>" ; blockHtmls.Append(string.Format(colBeginHtml, Convert.ToString(i), width)); string[] blockIds = col.Split(','); //每列的各块 foreach (string blockId in blockIds) { if (blockId != "") { BaseBlock bl = new BaseBlock(blockId); if (bl.Entity == null) { continue; } blockHtmls.Append(string.Format(BlockBeginHtml, blockId, bl.Entity.ColorValue)); blockHtmls.Append(bl.GetHeadHtml()); //是否延时加载 if (bl.Entity.DelayLoadSecond.Value > 0) { blockHtmls.Append(string.Format(BlockEndHtml, blockId, "window.setTimeout(\"loadDragContent('" + blockId + "','" + bl.Entity.RepeatItemCount + "')\"," + Convert.ToString(bl.Entity.DelayLoadSecond.Value * 1000) + ");\n" + bl.Entity.RelateScript)); } else { blockHtmls.Append(string.Format(BlockEndHtml, blockId, "loadDragContent('" + blockId + "','" + bl.Entity.RepeatItemCount + "');\n" + bl.Entity.RelateScript)); } } } blockHtmls.Append(string.Format(colEndHtml, Convert.ToString(i))); return(blockHtmls.ToString()); }