public string RenderForDisplay(MerchantTribeApplication app, Catalog.Category cat) { string sizeClass = "flexsize12"; if (this._Container != null) { sizeClass = "flexsize"; sizeClass += ((int)_Container.Size).ToString(); if (_Container.NoGutter && _Container.Size != ColumnSize.Size12) { sizeClass += "w"; } } string url = System.Web.VirtualPathUtility.ToAbsolute("~/images/system/flexedit/imagePlaceholder.png"); string alt = "Placeholder Image"; if (Images.Count > 0) { ImageDisplayFile img = this.Images[0]; long versionId = cat.GetCurrentVersion().Id; url = Storage.DiskStorage.FlexPageImageUrl(app, cat.Bvin, versionId.ToString(), img.FileName, true); alt = img.AltText; } return("<img src=\"" + url + "\" alt=\"" + alt + "\" class=\"" + sizeClass + "\" />"); }
public void DeserializeFromXml(string xml) { XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xml); this.Images.Clear(); XmlNode idNode = xdoc.SelectSingleNode("/part/id"); if (idNode != null) { this.Id = idNode.InnerText; } XmlNodeList imageNodes = xdoc.SelectNodes("/part/images/image"); if (imageNodes != null) { foreach (XmlNode node in imageNodes) { ImageDisplayFile img = new ImageDisplayFile(); XmlNode fileNameNode = node.SelectSingleNode("filename"); if (fileNameNode != null) { img.FileName = fileNameNode.InnerText; } XmlNode altNode = node.SelectSingleNode("alttext"); if (altNode != null) { img.AltText = altNode.InnerText; } XmlNode sortNode = node.SelectSingleNode("sortorder"); if (sortNode != null) { string tempsort = sortNode.InnerText; int temp = 0; if (int.TryParse(tempsort, out temp)) { img.SortOrder = temp; } } this.Images.Add(img); } } }
private string BuildEditor(Catalog.Category containerCategory, string message, MerchantTribeApplication app) { MerchantTribe.Commerce.RequestContext context = app.CurrentRequestContext; long versionId = containerCategory.GetCurrentVersion().Id; ImageDisplayFile img = new ImageDisplayFile(); if (this.Images.Count > 0) { img = this.Images[0]; } string previewUrl = ""; string alt = string.Empty; previewUrl = System.Web.VirtualPathUtility.ToAbsolute("~/images/system/flexedit/imagePlaceholder.png"); if (this.Images.Count > 0) { alt = this.Images[0].AltText; if (this.Images[0].FileName.Trim().Length > 0) { previewUrl = Storage.DiskStorage.FlexPageImageUrl(app, containerCategory.Bvin, versionId.ToString(), img.FileName, false); } } StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"flexeditarea\">"); sb.Append("<div id=\"uploadimagemessage\">" + message + "</div>"); sb.Append("<table width=\"100%\">"); sb.Append("<tr><td class=\"formlabel\">Image:</td><td class=\"formfield\">"); sb.Append("<img width=\"200px\" height=\"200px\" src=\"" + previewUrl + "\" id=\"uploadimagepreview\" name=\"uploadimagepreview\" /><br />"); sb.Append("<div id=\"silverlightControlHost\">"); sb.Append("<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"100\" height=\"55\">"); string SilverLightUrl = System.Web.VirtualPathUtility.ToAbsolute("~/ClientBin/BVSoftware.SilverlightFileUpload.xap"); sb.Append("<param name=\"source\" value=\"" + SilverLightUrl + "\"/>"); sb.Append("<param name=\"background\" value=\"black\" />"); sb.Append("<param name=\"onError\" value=\"onSilverlightError\" />"); sb.Append("<param name=\"minRuntimeVersion\" value=\"4.0.50826.0\" />"); sb.Append("<param name=\"autoUpgrade\" value=\"true\" />"); sb.Append("<param name=\"initParams\" value=\"scriptname=ImageWasUploaded,uploadurl="); // We have to pull the host out because the ToAbsolute of the virutal path utility // will append sub folder name if the web site is not the root app in IIS string currentFullRoot = app.StoreUrl(false, false); Uri fullUri = new Uri(currentFullRoot); string host = fullUri.DnsSafeHost; sb.Append("http://" + host); sb.Append(System.Web.VirtualPathUtility.ToAbsolute("~/fileuploadhandler/1/" + containerCategory.Bvin + "/" + versionId.ToString())); sb.Append("\"/>"); sb.Append("<a href=\"http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0\" style=\"text-decoration:none\">"); sb.Append("<img src=\"http://go.microsoft.com/fwlink/?LinkId=161376\" alt=\"Get Microsoft Silverlight\" style=\"border-style:none\"/>"); sb.Append("</a>"); sb.Append("</object><iframe id=\"_sl_historyFrame\" style=\"visibility:hidden;height:0px;width:0px;border:0px\"></iframe>"); sb.Append("</div>"); sb.Append("</td></tr>"); sb.Append("<tr><td class=\"formlabel\">Alt. Text:</td><td class=\"formfield\">"); sb.Append("<input type=\"text\" id=\"altfield\" name=\"altfield\" value=\"" + System.Web.HttpUtility.HtmlEncode(alt) + "\" />"); sb.Append("</td></tr>"); sb.Append("</table>"); sb.Append("</div>"); sb.Append("<div class=\"flexeditbuttonarea\">"); sb.Append("<input type=\"hidden\" name=\"uploadedfilename\" id=\"uploadedfilename\" value=\"\" />"); sb.Append("<input type=\"hidden\" name=\"partaction\" class=\"editactionhidden\" value=\"saveedit\" />"); sb.Append("<input type=\"submit\" name=\"canceleditbutton\" value=\"Close\">"); sb.Append("<input type=\"submit\" name=\"savechanges\" value=\"Save Changes\">"); sb.Append("</div>"); return(sb.ToString()); }
private string BuildEditor(Catalog.Category containerCategory, string message, MerchantTribeApplication app){ MerchantTribe.Commerce.RequestContext context = app.CurrentRequestContext; long versionId = containerCategory.GetCurrentVersion().Id; ImageDisplayFile img = new ImageDisplayFile(); if (this.Images.Count > 0) img = this.Images[0]; string previewUrl = ""; string alt = string.Empty; previewUrl = System.Web.VirtualPathUtility.ToAbsolute("~/images/system/flexedit/imagePlaceholder.png"); if (this.Images.Count > 0) { alt = this.Images[0].AltText; if (this.Images[0].FileName.Trim().Length > 0) { previewUrl = Storage.DiskStorage.FlexPageImageUrl(app, containerCategory.Bvin, versionId.ToString(), img.FileName, false); } } StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"flexeditarea\">"); sb.Append("<div id=\"uploadimagemessage\">" + message + "</div>"); sb.Append("<table width=\"100%\">"); sb.Append("<tr><td class=\"formlabel\">Image:</td><td class=\"formfield\">"); sb.Append("<img width=\"200px\" height=\"200px\" src=\"" + previewUrl + "\" id=\"uploadimagepreview\" name=\"uploadimagepreview\" /><br />"); sb.Append("<div id=\"silverlightControlHost\">"); sb.Append("<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"100\" height=\"55\">"); string SilverLightUrl = System.Web.VirtualPathUtility.ToAbsolute("~/ClientBin/BVSoftware.SilverlightFileUpload.xap"); sb.Append("<param name=\"source\" value=\""+ SilverLightUrl + "\"/>"); sb.Append("<param name=\"background\" value=\"black\" />"); sb.Append("<param name=\"onError\" value=\"onSilverlightError\" />"); sb.Append("<param name=\"minRuntimeVersion\" value=\"4.0.50826.0\" />"); sb.Append("<param name=\"autoUpgrade\" value=\"true\" />"); sb.Append("<param name=\"initParams\" value=\"scriptname=ImageWasUploaded,uploadurl="); // We have to pull the host out because the ToAbsolute of the virutal path utility // will append sub folder name if the web site is not the root app in IIS string currentFullRoot = app.StoreUrl(false, false); Uri fullUri = new Uri(currentFullRoot); string host = fullUri.DnsSafeHost; sb.Append("http://" + host); sb.Append(System.Web.VirtualPathUtility.ToAbsolute("~/fileuploadhandler/1/" + containerCategory.Bvin + "/" + versionId.ToString())); sb.Append("\"/>"); sb.Append("<a href=\"http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0\" style=\"text-decoration:none\">"); sb.Append("<img src=\"http://go.microsoft.com/fwlink/?LinkId=161376\" alt=\"Get Microsoft Silverlight\" style=\"border-style:none\"/>"); sb.Append("</a>"); sb.Append("</object><iframe id=\"_sl_historyFrame\" style=\"visibility:hidden;height:0px;width:0px;border:0px\"></iframe>"); sb.Append("</div>"); sb.Append("</td></tr>"); sb.Append("<tr><td class=\"formlabel\">Alt. Text:</td><td class=\"formfield\">"); sb.Append("<input type=\"text\" id=\"altfield\" name=\"altfield\" value=\"" + System.Web.HttpUtility.HtmlEncode(alt) + "\" />"); sb.Append("</td></tr>"); sb.Append("</table>"); sb.Append("</div>"); sb.Append("<div class=\"flexeditbuttonarea\">"); sb.Append("<input type=\"hidden\" name=\"uploadedfilename\" id=\"uploadedfilename\" value=\"\" />"); sb.Append("<input type=\"hidden\" name=\"partaction\" class=\"editactionhidden\" value=\"saveedit\" />"); sb.Append("<input type=\"submit\" name=\"canceleditbutton\" value=\"Close\">"); sb.Append("<input type=\"submit\" name=\"savechanges\" value=\"Save Changes\">"); sb.Append("</div>"); return sb.ToString(); }