From: Reini U. <ru...@us...> - 2002-09-02 12:39:07
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory usw-pr-cvs1:/tmp/cvs-serv9846/lib/plugin Modified Files: FrameInclude.php Log Message: fixed plugin/FrameInclude: missing are the targets at the top, left and bottom frames Index: FrameInclude.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/FrameInclude.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -2 -b -p -d -r1.3 -r1.4 --- FrameInclude.php 27 Aug 2002 21:51:31 -0000 1.3 +++ FrameInclude.php 2 Sep 2002 12:39:02 -0000 1.4 @@ -22,6 +22,11 @@ rcs_id('$Id$'); /** - * FrameInclude: Displays a url in a seperate frame inside our body. - * Usage: <?plugin FrameInclude src=http://www.internet-technology.de/fourwins_de.htm ?> + * FrameInclude: Displays a url or page in a seperate frame inside our body. + * + * Usage: + * <?plugin-head FrameInclude src=http://www.internet-technology.de/fourwins_de.htm ?> + * <?plugin-head FrameInclude page=OtherPage ?> + * at the VERY BEGINNING in the content! Otherwise it will be ignored. + * * Author: Reini Urban <ru...@x-...> * @@ -29,7 +34,7 @@ rcs_id('$Id$'); * This is a dirty hack into the whole system. To display the page as frameset * we must know in advance about the plugin existence. - * 1. We can buffer the output stream (which in certain cases is not doable). - * 2. Check the page content for the start string '<?plugin FrameInclude' + * 1. Check the page content for the start string '<?plugin-head ' * which we currently do. + * 2. We can buffer the output stream (which in certain cases is not doable). * 3. Redirect to a new page with the frameset only. ?frameset=pagename * $request->setArg('framesrc', $src); @@ -37,5 +42,5 @@ rcs_id('$Id$'); * In any cases we can now serve only specific templates with the new frame * argument. The whole page is now ?frame=html (before it was named "top") - * For the Sidebar theme we provide a left frame also, otherwise + * For the Sidebar theme (or derived from it) we provide a left frame also, otherwise * only top, content and bottom. * @@ -58,4 +63,5 @@ extends WikiPlugin function getDefaultArguments() { return array( 'src' => false, // the src url to include + 'page' => false, 'name' => 'content', // name of our frame 'title' => false, @@ -77,8 +83,17 @@ extends WikiPlugin extract($args); - if (!$src) - return $this->error(sprintf(_("%s parameter missing"), 'src')); + if (!$src) { + if (!$page) { + return $this->error(sprintf(_("%s or %s parameter missing"), 'src', 'page')); + } else { + if ($page == $request->get('pagename')) { + return $this->error(sprintf(_("recursive inclusion of page %s"), $page)); + } + $src = WikiURL($page); + } + } else { // FIXME: unmunged url hack $src = preg_replace('/src=(.*)\Z/','$1',$argstr); + } // How to normalize url's to compare against recursion? if ($src == $request->getURLtoSelf() ) { @@ -88,14 +103,17 @@ extends WikiPlugin // pass FRAMEPARAMS directly to the Template call in Template.php:214 // which goes right after <HEAD> - $topuri = $request->getURLtoSelf('frame=top'); - $bottomuri = $request->getURLtoSelf('frame=bottom'); - $top = "<frame name=\"top\" src=\"$topuri\" />"; - $bottom = "<frame name=\"bottom\" src=\"$bottomuri\" />"; + $topuri = $request->getURLtoSelf(array('frame' => 'top')); + $bottomuri = $request->getURLtoSelf(array('frame' => 'bottom')); + $top = HTML::frame(array('name' => "top", "src" => $topuri)); + $bottom = HTML::frame(array('name' => "bottom", "src" => $bottomuri)); + //$bottom = "<frame name=\"bottom\" src=\"$bottomuri\" />"; - $content = "<frame name=\"$name\" src=\"$src\" frameborder=\"$frameborder\" "; - if ($marginwidth) $content .= "marginwidth=\"$marginwidth\" "; - if ($marginheight) $content .= "marginheight=\"$marginheight\" "; - if ($noresize) $content .= "noresize=\"noresize\" "; - $content .= "scrolling=\"$scrolling\" />"; + $content_opts = array('name' => $name, "src" => $src, 'frameborder' => $frameborder); + // $content = "<frame name=\"$name\" src=\"$src\" frameborder=\"$frameborder\" "; + if ($marginwidth) $content_opts['marginwidth'] = $marginwidth; + if ($marginheight) $content_opts['marginheight'] = $marginheight; + if ($noresize) $content_opts['noresize'] = "noresize"; + $content_opts['scrolling'] = $scrolling; + $content = HTML::frame($content_opts); // include this into top.tmpl instead @@ -103,21 +121,20 @@ extends WikiPlugin // fmt("Included frame from %s", $src))); if (isa($Theme,'Theme_Sidebar')) { - // left also"\n". - $lefturi = $request->getURLtoSelf('frame=navbar'); - $frameset = "\n". - "<FRAMESET ROWS=\"$rows\">\n". - " $top\n". - " <FRAMESET COLS=\"$cols\">\n". - " <frame name=\"left\" src=\"$lefturi\" />\n". - " $content\n". - " </FRAMESET>\n". - "</FRAMESET>\n"; + // left also. + $lefturi = $request->getURLtoSelf(array('frame' => 'navbar')); + $frameset = HTML::frameset(array('rows' => $rows)); + $frameset->pushContent($top); + $colframeset = HTML::frameset(array('cols' => $cols)); + $colframeset->pushContent(HTML::frame(array('name' => "left", "src" => $lefturi))); + $colframeset->pushContent($content); + $frameset->pushContent($colframeset); + $frameset->pushContent($bottom); } else { + unset($args['cols']); // only top, body, bottom - $frameset = "\n". - "<FRAMESET ROWS=\"$rows\">\n". - " $top\n". - " $content\n". - "</FRAMESET>\n"; + $frameset = HTML::frameset(array('rows' => $rows)); + $frameset->pushContent($top); + $frameset->pushContent($content); + $frameset->pushContent($bottom); } $args['FRAMESET'] = $frameset; @@ -125,24 +142,4 @@ extends WikiPlugin } }; - -// This is an excerpt from the CSS file. (from IncludePage) -// -// .transclusion-title { -// font-style: oblique; -// font-size: 0.75em; -// text-decoration: underline; -// text-align: right; -// } -// -// DIV.transclusion { -// background: lightgreen; -// border: thin; -// border-style: solid; -// padding-left: 0.8em; -// padding-right: 0.8em; -// padding-top: 0px; -// padding-bottom: 0px; -// margin: 0.5ex 0px; -// } // For emacs users |