private void AddSWFFilesToListRecursive(NameValueCollection ret, System.IO.DirectoryInfo di) { if (!CmsContext.currentUserIsSuperAdmin && di.Name.StartsWith("_")) { return; } if (PopupFlashObjectBrowser.DirHasSWFFiles(di)) { foreach (System.IO.FileInfo fi in PopupFlashObjectBrowser.GetFlashFiles(di)) { if ((fi.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && (fi.Attributes & FileAttributes.System) != FileAttributes.System) { string fileUrl = InlineImageBrowser2.ReverseMapPath(fi.FullName); // the key is the dropdown's value, options[key] is the display text string displayText = fileUrl; if (displayText.StartsWith("UserFiles/")) { displayText = displayText.Substring("UserFiles/".Length); } ret.Add(fileUrl, displayText); } // if } // foreach } // if System.IO.DirectoryInfo[] dirs = di.GetDirectories(); foreach (System.IO.DirectoryInfo d in dirs) { AddSWFFilesToListRecursive(ret, d); } } // AddImageFilesToListRecursive
} // 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()); }