/// <summary> /// renders the FlashObject control to the HtmlTextWriter in View Mode /// </summary> /// <param name="writer"></param> /// <param name="page"></param> /// <param name="identifier"></param> /// <param name="paramList"></param> public override void RenderInViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList) { FlashObjectDb db = (new FlashObjectDb()); FlashObjectData flash = db.getFlashObject(page, identifier, true); StringBuilder html = new StringBuilder(); if (flash.SWFPath != "" && flash.DisplayHeight > 0 && flash.DisplayWidth > 0) { string swfPath = flash.SWFPath; if (!swfPath.StartsWith(CmsContext.ApplicationPath)) { swfPath = CmsContext.ApplicationPath + swfPath; } // -- use the base parameter so that loadMovie and loadClip work string swfFilename = Path.GetFileName(swfPath); string baseUrl = swfPath.Substring(0, swfPath.Length - swfFilename.Length); html.Append("<div class=\"FlashObjectPlaceholder\">"); // -- http://kb.adobe.com/selfservice/viewContent.do?externalId=50c1cf38 html.Append("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\" http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" + flash.DisplayWidth.ToString() + "\" height=\"" + flash.DisplayHeight.ToString() + "\" align=\"middle\">" + Environment.NewLine); html.Append(" <param name=\"movie\" value=\"" + swfPath + "\">"); html.Append(" <param name=\"allowScriptAccess\" value=\"always\">"); html.Append(" <param name=\"base\" value=\"" + baseUrl + "\">"); html.Append(" <embed type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/go/getflashplayer\" width=\"" + flash.DisplayWidth.ToString() + "\" height=\"" + flash.DisplayHeight.ToString() + "\" align=\"middle\" src=\"" + swfPath + "\" allowScriptAccess=\"always\" base=\"" + baseUrl + "\"></embed>" + Environment.NewLine); html.Append("</object>" + Environment.NewLine); html.Append("</div>"); } writer.WriteLine(html.ToString()); } // RenderView
} // RenderView public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList) { string formName = "editFlashObject_" + page.ID.ToString() + identifier.ToString() + langToRenderFor.shortCode; FlashObjectDb db = (new FlashObjectDb()); FlashObjectData flashObject = db.getFlashObject(page, identifier, true); StringBuilder html = new StringBuilder(); // ------- CHECK THE FORM FOR ACTIONS string action = Hatfield.Web.Portal.PageUtils.getFromForm(formName + "_FlashObjectAction", ""); if (action.Trim().ToLower() == "saveflashobject") { flashObject.SWFPath = PageUtils.getFromForm(formName + "SWFPath", ""); flashObject.DisplayWidth = PageUtils.getFromForm(formName + "displayWidth", FlashObject.DefaultDisplayWidth); flashObject.DisplayHeight = PageUtils.getFromForm(formName + "displayHeight", FlashObject.DefaultDisplayHeight); bool b = db.saveUpdatedFlashObject(page, identifier, flashObject); if (!b) { html.Append("Error: Flash Object not saved - database error<p><p>"); } } // ------- START RENDERING // note: no need to put in the <form></form> tags. html.Append("<table>"); html.Append("<tr><td>"); html.Append("Flash (SWF) Object:"); html.Append("</td><td>"); string JSCallbackFunctionName = formName + "_selectPath"; StringBuilder js = new StringBuilder(); js.Append("function " + JSCallbackFunctionName + "(selText, selVal) { " + Environment.NewLine); // html.Append("alert(selVal);" + Environment.NewLine); js.Append(" var selectBox = document.getElementById('" + formName + "SWFPath'); " + Environment.NewLine); js.Append(" var found= false; " + Environment.NewLine); js.Append(" for (var i =0; i < selectBox.options.length; i++) {" + Environment.NewLine); js.Append(" if (selectBox.options[i].text == selText){ " + Environment.NewLine); js.Append(" selectBox.options[i].selected = true; found = true; " + Environment.NewLine); js.Append(" } // if" + Environment.NewLine); js.Append(" } // for" + Environment.NewLine); js.Append(" if (!found) { " + Environment.NewLine); js.Append(" var newOption = new Option(selText,selVal); " + Environment.NewLine); js.Append(" selectBox.options[selectBox.options.length]= newOption;" + Environment.NewLine); js.Append(" newOption.selected = true; " + Environment.NewLine); js.Append(" } // if ! found" + Environment.NewLine); js.Append("}" + Environment.NewLine); page.HeadSection.AddJSStatements(js.ToString()); string SWFPathDropDownHtml = getSWFPathDropdown(formName + "SWFPath", flashObject); html.Append(SWFPathDropDownHtml); string onclick = "window.open(this.href, 'newWin', 'resizable,height=" + PopupFlashObjectBrowser.PopupHeight + ",width=" + PopupFlashObjectBrowser.PopupWidth + "'); return false;"; html.Append(" <a href=\"" + PopupFlashObjectBrowser.getUrl(JSCallbackFunctionName) + "\" onclick=\"" + onclick + "\">browse for flash file</a>"); html.Append("</td></tr>"); html.Append("<tr><td>"); html.Append("Width:"); html.Append("</td><td>"); html.Append(PageUtils.getInputTextHtml(formName + "displayWidth", formName + "displayWidth", flashObject.DisplayWidth.ToString(), 7, 5)); html.Append("<br><em>values < 1 will not display the SWF</em>"); html.Append("</td></tr>"); html.Append("<tr><td>"); html.Append("Height:"); html.Append("</td><td>"); html.Append(PageUtils.getInputTextHtml(formName + "displayHeight", formName + "displayHeight", flashObject.DisplayHeight.ToString(), 7, 5)); html.Append("<br><em>values < 1 will not display the SWF</em>"); html.Append("</td></tr>"); html.Append("</table>"); // -- hidden field actions html.Append("<input type=\"hidden\" name=\"" + formName + "_FlashObjectAction\" value=\"saveflashobject\">"); writer.WriteLine(html.ToString()); }