//获取单个块的html public static string GetOneBlockHtmls(string blockId, string userId) { string blockHtmls = ""; string BlockBeginHtml = "<DIV class=\"drag_div\" id=\"drag_{0}\" style=\"BORDER-COLOR: {1}; BACKGROUND: #fff;Height:{2}\">"; 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='/Modules/WebPart/loading.gif'><SPAN id='loadeditortext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <DIV class='drag_content' style='background-color:{2}' id='drag_content_{0}'> <DIV id='loadcontentid_{0}' style='WIDTH: 100px'><IMG src='/Modules/WebPart/loading.gif'><SPAN id='loadcontenttext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <SCRIPT>{1}</SCRIPT> </DIV> </DIV>" ; WebPart bl = WebPart.Find(blockId); blockHtmls += string.Format(BlockBeginHtml, blockId, bl.ColorValue, bl.DefaultHeight); WebPartExt wb = new WebPartExt(bl, userId); blockHtmls += wb.GetHeadHtml(); //是否延时加载 if (bl.DelayLoadSecond.ToString().Trim() != "0") { blockHtmls += string.Format(BlockEndHtml, blockId, "window.setTimeout(\"loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "')\"," + Convert.ToString(bl.DelayLoadSecond * 1000) + ");", bl.ContentColor); } else { blockHtmls += string.Format(BlockEndHtml, blockId, "loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "');", bl.ContentColor); } return(blockHtmls); }
public static string GetCols(string col, string width, int i, DataCollection list, string userId) { string blockHtmls = ""; 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;Height:{2}\">"; 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='/Modules/WebPart/loading.gif'><SPAN id='loadeditortext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <DIV class='drag_content' id='drag_content_{0}' style='background-color:{2}'> <DIV id='loadcontentid_{0}' style='WIDTH: 100px'><IMG src='/Modules/WebPart/loading.gif'><SPAN id='loadcontenttext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> </DIV> </DIV> <SCRIPT>{1}</SCRIPT>"; blockHtmls += string.Format(colBeginHtml, Convert.ToString(i + 1), width); string[] blockIds = col.Split(','); //每列的各块 foreach (string blockId in blockIds) { if (blockId != "" && WebPart.Exists <String>(blockId)) { WebPart bl = WebPart.Find(blockId); //读取模版中实例化参数 DataElement item = list.GetElement("Id", blockId); if (item != null) { bl.BlockKey = item.GetAttr("BlockKey"); bl.BlockImage = item.GetAttr("BlockImage"); bl.BlockTitle = item.GetAttr("BlockTitle"); bl.BlockType = item.GetAttr("BlockType"); bl.ColorValue = item.GetAttr("ColorValue"); bl.Color = item.GetAttr("Color"); bl.RepeatItemCount = int.Parse(item.GetAttr("RepeatItemCount")); bl.RepeatItemLength = int.Parse(item.GetAttr("RepeatItemLength")); bl.DelayLoadSecond = int.Parse(item.GetAttr("DelayLoadSecond")); } blockHtmls += string.Format(BlockBeginHtml, blockId, bl.ColorValue, bl.DefaultHeight); WebPartExt wb = new WebPartExt(bl, userId); blockHtmls += wb.GetHeadHtml(); //是否延时加载 if (bl.DelayLoadSecond.ToString().Trim() != "0") { blockHtmls += string.Format(BlockEndHtml, blockId, "window.setTimeout(\"loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "')\"," + Convert.ToString(bl.DelayLoadSecond * 1000) + ");" + "\n" + bl.RelateScript, bl.ContentColor); } else { blockHtmls += string.Format(BlockEndHtml, blockId, "loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "');" + "\n" + bl.RelateScript, bl.ContentColor); } } } blockHtmls += string.Format(colEndHtml, Convert.ToString(i + 1)); return(blockHtmls); }
//获取单个块的html public static string GetOneBlockHtmls(string userId, string blockId, string blockType) { string blockHtmls = ""; string BlockBeginHtml = "<DIV class=\"drag_div\" id=\"drag_{0}\" style=\"BORDER-COLOR: {1}; BACKGROUND: #fff;Height:{2}\">"; 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='/Modules/WebPart/loading.gif'><SPAN id='loadeditortext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <DIV class='drag_content' id='drag_content_{0}' style='background-color:{2}'> <DIV id='loadcontentid_{0}' style='WIDTH: 100px'><IMG src='/Modules/WebPart/loading.gif'><SPAN id='loadcontenttext_{0}' style='COLOR: #333'></SPAN></DIV> </DIV> <SCRIPT>{1}</SCRIPT> </DIV> </DIV>" ; if (blockId != "") { WebPart bl = WebPart.Find(blockId); WebPartTemplate dr = WebPartTemplate.FindAllByProperties("UserId", userId, "IsDefault", "T", "BlockType", blockType)[0]; string templateXml = dr.TemplateXml; DataCollection list = new DataCollection(templateXml); DataElement item = list.GetElement("Id", blockId); if (item != null) { bl.BlockKey = item.GetAttr("BlockKey"); bl.BlockImage = item.GetAttr("BlockImage"); bl.BlockTitle = item.GetAttr("BlockTitle"); bl.BlockType = item.GetAttr("BlockType"); bl.ColorValue = item.GetAttr("ColorValue"); bl.Color = item.GetAttr("Color"); bl.RepeatItemCount = int.Parse(item.GetAttr("RepeatItemCount")); bl.RepeatItemLength = int.Parse(item.GetAttr("RepeatItemLength")); bl.DelayLoadSecond = int.Parse(item.GetAttr("DelayLoadSecond")); } blockHtmls += string.Format(BlockBeginHtml, blockId, bl.ColorValue, bl.DefaultHeight); WebPartExt wb = new WebPartExt(bl, userId); blockHtmls += wb.GetHeadHtml(); //是否延时加载 if (bl.DelayLoadSecond.ToString().Trim() != "0") { blockHtmls += string.Format(BlockEndHtml, blockId, "window.setTimeout(\"loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "')\"," + Convert.ToString(bl.DelayLoadSecond * 1000) + ");", bl.ContentColor); } else { blockHtmls += string.Format(BlockEndHtml, blockId, "loadDragContent('" + blockId + "','" + bl.RepeatItemCount + "');", bl.ContentColor); } } return(blockHtmls); }