2 rcs_id('$Id: FrameInclude.php,v 1.6 2003-01-18 21:41:01 carstenklapp Exp $');
4 Copyright 2002 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * FrameInclude: Displays a url or page in a seperate frame inside our body.
27 * <?plugin-head FrameInclude src=http://www.internet-technology.de/fourwins_de.htm ?>
28 * <?plugin-head FrameInclude page=OtherPage ?>
29 * at the VERY BEGINNING in the content! Otherwise it will be ignored.
31 * Author: Reini Urban <rurban@x-ray.at>
35 * This is a dirty hack into the whole system. To display the page as
36 * frameset we must know in advance about the plugin existence.
38 * 1. Check the page content for the start string '<?plugin-head '
39 * which we currently do.
41 * 2. We can buffer the output stream (which in certain cases is not
44 * 3. Redirect to a new page with the frameset only. ?frameset=pagename
45 * $request->setArg('framesrc', $src);
46 * $request->redirect('frameset', $request->getName());
48 * In any cases we can now serve only specific templates with the new
49 * frame argument. The whole page is now ?frame=html (before it was
50 * named "top") For the Sidebar theme (or derived from it) we provide
51 * a left frame also, otherwise only top, content and bottom.
53 * This plugin doesn't return a typical html stream inside a <body>,
54 * only a <frameset> which has to go before <body>, right after
58 class WikiPlugin_FrameInclude
62 return _("FrameInclude");
65 function getDescription() {
66 return _("Displays a url in a seperate frame inside our body. Only one frame allowed.");
69 function getVersion() {
70 return preg_replace("/[Revision: $]/", '',
74 function getDefaultArguments() {
75 return array( 'src' => false, // the src url to include
77 'name' => 'content', // name of our frame
79 'rows' => '10%,*,10%', // names: top, $name, bottom
80 'cols' => '10%,*', // names: left, $name
81 // only useful on Theme "Sidebar"
83 'marginwidth' => false,
84 'marginheight' => false,
86 'scrolling' => 'auto', // '[ yes | no | auto ]'
90 function run($dbi, $argstr, $request) {
93 $args = ($this->getArgs($argstr, $request));
99 $this->error(sprintf(_("%s or %s parameter missing"),
102 if ($page == $request->get('pagename')) {
104 $this->error(sprintf(_("recursive inclusion of page %s"),
107 $src = WikiURL($page);
111 // How to normalize url's to compare against recursion?
112 if ($src == $request->getURLtoSelf() ) {
113 return $this->error(sprintf(_("recursive inclusion of url %s"),
117 // pass FRAMEPARAMS directly to the Template call in Template.php:214
118 // which goes right after <HEAD>
119 $topuri = $request->getURLtoSelf(array('frame' => 'top'));
120 $bottomuri = $request->getURLtoSelf(array('frame' => 'bottom'));
121 $top = HTML::frame(array('name' => "top", "src" => $topuri));
122 $bottom = HTML::frame(array('name' => "bottom", "src" => $bottomuri));
123 //$bottom = "<frame name=\"bottom\" src=\"$bottomuri\" />";
125 $content_opts = array('name' => $name, "src" => $src,
126 'frameborder' => $frameborder);
127 // $content = "<frame name=\"$name\" src=\"$src\" frameborder=\"$frameborder\" ";
129 $content_opts['marginwidth'] = $marginwidth;
131 $content_opts['marginheight'] = $marginheight;
133 $content_opts['noresize'] = "noresize";
134 $content_opts['scrolling'] = $scrolling;
135 $content = HTML::frame($content_opts);
137 // include this into top.tmpl instead
138 //$memo = HTML(HTML::p(array('class' => 'transclusion-title'),
139 // fmt("Included frame from %s", $src)));
140 if (isa($Theme, 'Theme_Sidebar')) {
142 $lefturi = $request->getURLtoSelf(array('frame' => 'navbar'));
143 $frameset = HTML::frameset(array('rows' => $rows));
144 $frameset->pushContent($top);
145 $colframeset = HTML::frameset(array('cols' => $cols));
146 $colframeset->pushContent(HTML::frame(array('name' => "left",
147 "src" => $lefturi)));
148 $colframeset->pushContent($content);
149 $frameset->pushContent($colframeset);
150 $frameset->pushContent($bottom);
152 unset($args['cols']);
153 // only top, body, bottom
154 $frameset = HTML::frameset(array('rows' => $rows));
155 $frameset->pushContent($top);
156 $frameset->pushContent($content);
157 $frameset->pushContent($bottom);
159 $args['FRAMESET'] = $frameset;
160 return printXML(new Template('frameset', $request, $args));
164 // $Log: not supported by cvs2svn $
171 // c-hanging-comment-ender-p: nil
172 // indent-tabs-mode: nil