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 PartJsonResult ProcessJsonRequest(System.Collections.Specialized.NameValueCollection form, MerchantTribeApplication app, Catalog.Category containerCategory) { PartJsonResult result = new PartJsonResult(); string action = form["partaction"]; switch (action.ToLowerInvariant()) { case "showeditor": result.IsFinishedEditing = false; result.Success = true; result.ResultHtml = BuildEditor(); break; case "saveedit": string colsRequestedString = form["totalColumnsRequested"]; int columnsRequested = this.Columns.Count; if (int.TryParse(colsRequestedString, out columnsRequested)) { this.SetNumberOfColumns(columnsRequested); } ParseColumnChanges(form); if (form["spacerabove"] == "on") { this.SpacerAbove = true; } else { this.SpacerAbove = false; } app.CatalogServices.Categories.Update(containerCategory); result.Success = true; result.IsFinishedEditing = false; result.ResultHtml = BuildEditor(); break; case "canceledit": result.Success = true; result.IsFinishedEditing = true; result.ResultHtml = this.RenderForEdit(app, containerCategory); break; case "deletepart": containerCategory.GetCurrentVersion().Root.RemovePart(this.Id); app.CatalogServices.Categories.Update(containerCategory); result.Success = true; break; } return(result); }
public PartJsonResult ProcessJsonRequest(System.Collections.Specialized.NameValueCollection form, MerchantTribeApplication app, Catalog.Category containerCategory) { PartJsonResult result = new PartJsonResult(); string action = form["partaction"]; StringBuilder sb = new StringBuilder(); switch (action.Trim().ToLowerInvariant()) { case "showeditor": sb.Append("<textarea name=\"changedtext\" style=\"height:400px;width:675px;\">"); sb.Append(this.RawHtml); sb.Append("</textarea><br />"); 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\">"); result.IsFinishedEditing = false; result.Success = true; result.ResultHtml = sb.ToString(); break; case "saveedit": this.RawHtml = form["changedtext"]; result.IsFinishedEditing = true; result.Success = true; result.ResultHtml = this.RenderForEdit(app, containerCategory); app.CatalogServices.Categories.Update(containerCategory); break; case "canceledit": result.Success = true; result.IsFinishedEditing = true; result.ResultHtml = this.RenderForEdit(app, containerCategory); break; case "deletepart": containerCategory.GetCurrentVersion().Root.RemovePart(this.Id); app.CatalogServices.Categories.Update(containerCategory); break; } return(result); }
public PartJsonResult ProcessJsonRequest(System.Collections.Specialized.NameValueCollection form, MerchantTribeApplication app, Catalog.Category containerCategory) { PartJsonResult result = new PartJsonResult(); string action = form["partaction"]; StringBuilder sb = new StringBuilder(); switch (action.Trim().ToLowerInvariant()) { case "showeditor": result.IsFinishedEditing = false; result.Success = true; result.ResultHtml = BuildEditor(containerCategory, string.Empty, app); //result.ScriptFunction = initScript; break; case "saveedit": // Update from Form Here string editMessage = string.Empty; if (form["uploadedfilename"] != null) { string uploadedname = form["uploadedfilename"]; if (uploadedname.Length > 0) { if (this.Images.Count < 1) { this.Images.Add(new ImageDisplayFile() { AltText = uploadedname, FileName = uploadedname, SortOrder = 0 }); } else { this.Images[0].FileName = uploadedname; } } } if (this.Images.Count > 0) { string altText = form["altfield"]; this.Images[0].AltText = altText; editMessage = "Changes Saved!"; } else { editMessage = "Upload an Image before Saving Changes!"; } app.CatalogServices.Categories.Update(containerCategory); result.Success = true; result.IsFinishedEditing = false; result.ResultHtml = BuildEditor(containerCategory, editMessage, app); //result.ScriptFunction = initScript; break; case "canceledit": result.Success = true; result.IsFinishedEditing = true; result.ResultHtml = this.RenderForEdit(app, containerCategory); break; case "deletepart": containerCategory.GetCurrentVersion().Root.RemovePart(this.Id); app.CatalogServices.Categories.Update(containerCategory); break; } return(result); }
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()); }