From: Dion O. <dol...@us...> - 2005-11-11 22:29:47
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30820/magicajax/Core Modified Files: MagicAjax NET 2.0.csproj MagicAjaxModule.cs Log Message: Added support for ASP.NET 2.0 Portal Framework Index: MagicAjax NET 2.0.csproj =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjax NET 2.0.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MagicAjax NET 2.0.csproj 11 Nov 2005 06:17:49 -0000 1.1 --- MagicAjax NET 2.0.csproj 11 Nov 2005 22:29:39 -0000 1.2 *************** *** 143,172 **** <SubType>ASPXCodeBehind</SubType> </Compile> - <Compile Include="UI\Controls\AjaxCascadeTable.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="UI\Controls\AjaxLinkedPanelListControl.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="UI\Controls\AjaxPanel.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="UI\Controls\AjaxTabbedPanel.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="UI\Design\AjaxCascadeTableDesigner.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="UI\Design\AjaxPanelDesigner.cs"> <SubType>Code</SubType> </Compile> - <Compile Include="UI\Design\AjaxTabbedPanelDesigner.cs"> - <SubType>Code</SubType> - </Compile> <Compile Include="UI\RenderedByScriptControl.cs"> <SubType>Code</SubType> </Compile> - <Content Include="Examples\Examples.aspx" /> - <Content Include="script\AjaxLinkedPanelListScripts.js" /> <Content Include="Web.config" /> <EmbeddedResource Include="script\CallBackObject.js" /> --- 143,155 ---- Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MagicAjaxModule.cs 11 Nov 2005 06:17:49 -0000 1.1 --- MagicAjaxModule.cs 11 Nov 2005 22:29:39 -0000 1.2 *************** *** 431,434 **** --- 431,454 ---- } + #if NET_2_0 + // Check if this request is to add/remove/replace a WebPart + // If so, send back updated WebPartManager drag&drop javascript (IE only) + if (!string.IsNullOrEmpty(_form["__EVENTTARGET"]) && !string.IsNullOrEmpty(_form["__EVENTARGUMENT"])) + { + Control webPartControl = requestPage.FindControl(_form["__EVENTTARGET"]); + if ((webPartControl is System.Web.UI.WebControls.WebParts.WebPartZone && (_form["__EVENTARGUMENT"].StartsWith("delete:") || _form["__EVENTARGUMENT"].StartsWith("Drag:") || _form["__EVENTARGUMENT"].StartsWith("close:"))) + || (webPartControl is System.Web.UI.WebControls.WebParts.CatalogZone && _form["__EVENTARGUMENT"] == "add")) + { + string wpmValue = _filter.GetWebPartManagerScriptValue(); + if (wpmValue != null) + { + // Send script to dispose current webpartmanager + CallBackHelper.Write("if (typeof(WebPartManager_Dispose) == 'function'){WebPartManager_Dispose();}\r\n"); + // Send script to setup webpartmanager drag&drop + webpartmenu's + CallBackHelper.Write(wpmValue); + } + } + } + #endif CallBackHelper.End(); } *************** *** 761,764 **** --- 781,785 ---- public string GetViewStateFieldValue() { + //TODO: use regular expression (much faster) #if NET_2_0 string search = "<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\""; *************** *** 779,790 **** } public string GetHtmlPage() { ! byte[] buffer = new byte[_memStream.Length]; ! _memStream.Position = 0; ! _memStream.Read (buffer, 0, (int)_memStream.Length); ! return HttpContext.Current.Response.ContentEncoding.GetString(buffer); } --- 800,848 ---- } + #if NET_2_0 + /// <summary> + /// Look for javascript generated for draggable webparts (IE only), and returns these javascripts. + /// </summary> + public string GetWebPartManagerScriptValue() + { + string html = GetHtmlPage(); + + string searchWPManager = "<script type=\"text\\/javascript\">\\r\\n\\r\\n(?<WPManagerScript>__wpm = new WebPartManager\\(\\);.*?)<\\/script>"; + Regex regExWPManager = new Regex(searchWPManager, RegexOptions.Singleline | RegexOptions.Compiled); + Match match = regExWPManager.Match(html); + + // If no webpartmanager script exists in html -> exit + if (!match.Success) + return null; + + StringBuilder wpmScript = new StringBuilder(match.Groups["WPManagerScript"].Value); + wpmScript.AppendLine(); + + // Now look for webpart menu scripts + string searchWPMenus = "<script type=\"text\\/javascript\">\\r\\n(?<MenuScript>var menuWebPart_.*?)<\\/script>"; + Regex regExMenuScripts = new Regex(searchWPMenus, RegexOptions.Singleline | RegexOptions.Compiled); + MatchCollection matches = regExMenuScripts.Matches(html); //ei + for (int i=0; i<matches.Count; i++) + { + wpmScript.AppendLine(matches[i].Groups["MenuScript"].Value); + } + + return wpmScript.ToString(); + } + #endif + + private string _htmlPage; public string GetHtmlPage() { ! if (_htmlPage == null) ! { ! byte[] buffer = new byte[_memStream.Length]; ! _memStream.Position = 0; ! _memStream.Read(buffer, 0, (int)_memStream.Length); ! _htmlPage = HttpContext.Current.Response.ContentEncoding.GetString(buffer); ! } ! return _htmlPage; } |