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 * <<FrameInclude src=http://www.internet-technology.de/fourwins_de.htm >>
28 * <<FrameInclude page=OtherPage >>
29 * at the VERY BEGINNING in the content!
31 * Author: Reini Urban <rurban@x-ray.at>, rewrite by Jeff Dairiki <dairiki@dairiki.org>
35 * This is a dirty hack into the whole system. To display the page as
38 * 1. Discard any output buffered so far.
39 * 2. Recursively call displayPage with magic arguments to generate
40 * the frameset (or individual frame contents.)
41 * 3. Exit early. (So this plugin is usually a no-return.)
43 * In any cases we can now serve only specific templates with the new
44 * frame argument. The whole page is now ?frame=html (before it was
45 * named "top") For the Sidebar theme (or derived from it) we provide
46 * a left frame also, otherwise only top, content and bottom.
48 class WikiPlugin_FrameInclude
52 return _("FrameInclude");
55 function getDescription() {
56 return _("Displays a url in a seperate frame inside our body. Only one frame allowed.");
59 function getDefaultArguments() {
60 return array( 'src' => false, // the src url to include
62 'name' => 'content', // name of our frame
64 'rows' => '18%,*,15%', // names: top, $name, bottom
65 'cols' => '20%,*', // names: left, $name
66 // only useful on WikiTheme "Sidebar"
68 'marginwidth' => false,
69 'marginheight' => false,
71 'scrolling' => 'auto', // '[ yes | no | auto ]'
75 function run($dbi, $argstr, &$request, $basepage) {
78 $args = ($this->getArgs($argstr, $request));
81 if ($request->getArg('action') != 'browse')
82 return $this->disabled("(action != 'browse')");
83 if (! $request->isGetOrHead())
84 return $this->disabled("(method != 'GET')");
86 if (!$src and $page) {
87 if ($page == $request->get('pagename')) {
88 return $this->error(sprintf(_("Recursive inclusion of page %s"),
91 $src = WikiURL($page);
94 return $this->error(sprintf(_("%s or %s parameter missing"),
98 // FIXME: How to normalize url's to compare against recursion?
99 if ($src == $request->getURLtoSelf() ) {
100 return $this->error(sprintf(_("Recursive inclusion of url %s"),
104 static $noframes = false;
106 // Content for noframes version of page.
107 return HTML::p(fmt("See %s",
108 HTML::a(array('href' => $src), $src)));
112 if (($which = $request->getArg('frame'))) {
113 // Generate specialized frame output (header, footer, etc...)
114 $request->discardOutput();
115 displayPage($request, new Template("frame-$which", $request));
116 $request->finish(); //noreturn
119 // Generate the outer frameset
120 $frame = HTML::frame(array('name' => $name,
123 'frameborder' => (int)$frameborder,
124 'scrolling' => (string)$scrolling,
125 'noresize' => (bool)$noresize,
129 $frame->setArg('marginwidth', $marginwidth);
131 $frame->setArg('marginheight', $marginheight);
133 $tokens = array('CONTENT_FRAME' => $frame,
136 'FRAMEARGS' => sprintf('frameborder="%d"', $frameborder),
139 // Produce the frameset.
140 $request->discardOutput();
141 displayPage($request, new Template('frameset', $request, $tokens));
142 $request->finish(); //noreturn
150 // c-hanging-comment-ender-p: nil
151 // indent-tabs-mode: nil