2 rcs_id('$Id: FrameInclude.php,v 1.2 2002-08-24 13:18:56 rurban 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 in a seperate frame inside our body.
25 * Usage: <?plugin FrameInclude src=http://www.internet-technology.de/fourwins_de.htm ?>
26 * Author: Reini Urban <rurban@x-ray.at>
29 * This is a dirty hack into the whole system. To display the page as frameset
30 * we must know in advance about the plugin existence.
31 * 1. We can buffer the output stream (which in certain cases is not doable).
32 * 2. Check the page content for the start string '<?plugin FrameInclude'
33 * which we currently do.
34 * 3. Redirect to a new page with the frameset only. ?frameset=pagename
35 * $request->setArg('framesrc', $src);
36 * $request->redirect('frameset', $request->getName());
37 * In any cases we can now serve only specific templates with the new frame
38 * argument. The whole page is now ?frame=html (before it was named "top")
39 * For the Sidebar theme we provide a left frame also, otherwise
40 * only top, content and bottom.
42 * This plugin doesn't return a typical html stream inside a <body>, only a
43 * <frameset> which has to go before <body>, right after <head>.
47 class WikiPlugin_FrameInclude
51 return _("FrameInclude");
54 function getDescription() {
55 return _("Displays a url in a seperate frame inside our body. Only one frame allowed.");
58 function getDefaultArguments() {
59 return array( 'src' => false, // the src url to include
60 'name' => 'content', // name of our frame
62 'rows' => '10%,*,10%', // names: top, $name, bottom
63 'cols' => '10%,*', // names: left, $name
64 // only useful on Theme "Sidebar"
66 'marginwidth' => false,
67 'marginheight' => false,
69 'scrolling' => 'auto', // '[ yes | no | auto ]'
73 function run($dbi, $argstr, $request) {
76 extract($this->getArgs($argstr, $request));
79 return $this->error(sprintf(_("%s parameter missing"), 'src'));
80 // FIXME: unmunged url hack
81 $src = preg_replace('/src=(.*)\Z/','$1',$argstr);
82 // How to normalize url's to compare against recursion?
83 if ($src == $request->getURLtoSelf() ) {
84 return $this->error(sprintf(_("recursive inclusion of url %s"), $src));
87 // pass FRAMEPARAMS directly to the Template call in Template.php:214
88 // which goes right after <HEAD>
89 $topuri = $request->getURLtoSelf('frame=top');
90 $bottomuri = $request->getURLtoSelf('frame=bottom');
91 $top = "<frame name=\"top\" src=\"$topuri\" />";
92 $bottom = "<frame name=\"bottom\" src=\"$bottomuri\" />";
94 $content = "<frame name=\"$name\" src=\"$src\" frameborder=\"$frameborder\" ";
95 if ($marginwidth) $content .= "marginwidth=\"$marginwidth\" ";
96 if ($marginheight) $content .= "marginheight=\"$marginheight\" ";
97 if ($noresize) $content .= "noresize=\"noresize\" ";
98 $content .= "scrolling=\"$scrolling\" />";
100 // include this into top.tmpl instead
101 //$memo = HTML(HTML::p(array('class' => 'transclusion-title'),
102 // fmt("Included frame from %s", $src)));
103 if ($Theme == 'Sidebar') {
105 $lefturi = $request->getURLtoSelf('frame=navbar');
107 "<FRAMESET ROWS=\"$rows\">\n".
109 " <FRAMESET COLS=\"$cols\">\n".
110 " <frame name=\"left\" src=\"$lefturi\" />\n".
115 // only top, body, bottom
117 "<FRAMESET ROWS=\"$rows\">\n".
123 // 1) either change the whole output stream to
124 // head, $frameset, <nobody>body</nobody> (buffered)
125 // 2) redirect to ?frameset=pagename
126 // $request->setArg('framesrc', $src);
127 // $request->redirect('frameset', $request->getName());
132 // This is an excerpt from the CSS file. (from IncludePage)
134 // .transclusion-title {
135 // font-style: oblique;
136 // font-size: 0.75em;
137 // text-decoration: underline;
138 // text-align: right;
141 // DIV.transclusion {
142 // background: lightgreen;
144 // border-style: solid;
145 // padding-left: 0.8em;
146 // padding-right: 0.8em;
148 // padding-bottom: 0px;
149 // margin: 0.5ex 0px;
157 // c-hanging-comment-ender-p: nil
158 // indent-tabs-mode: nil