2 rcs_id('$Id: FrameInclude.php,v 1.10 2004-06-14 11:31:39 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 or page in a seperate frame inside our body.
27 * <?plugin FrameInclude src=http://www.internet-technology.de/fourwins_de.htm ?>
28 * <?plugin 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 getVersion() {
60 return preg_replace("/[Revision: $]/", '',
61 "\$Revision: 1.10 $");
64 function getDefaultArguments() {
65 return array( 'src' => false, // the src url to include
67 'name' => 'content', // name of our frame
69 'rows' => '18%,*,15%', // names: top, $name, bottom
70 'cols' => '20%,*', // names: left, $name
71 // only useful on Theme "Sidebar"
73 'marginwidth' => false,
74 'marginheight' => false,
76 'scrolling' => 'auto', // '[ yes | no | auto ]'
80 function run($dbi, $argstr, &$request, $basepage) {
83 $args = ($this->getArgs($argstr, $request));
86 if ($request->getArg('action') != 'browse')
87 return $this->disabled("(action != 'browse')");
88 if (! $request->isGetOrHead())
89 return $this->disabled("(method != 'GET')");
91 if (!$src and $page) {
92 if ($page == $request->get('pagename')) {
93 return $this->error(sprintf(_("recursive inclusion of page %s"),
96 $src = WikiURL($page);
99 return $this->error(sprintf(_("%s or %s parameter missing"),
103 // FIXME: How to normalize url's to compare against recursion?
104 if ($src == $request->getURLtoSelf() ) {
105 return $this->error(sprintf(_("recursive inclusion of url %s"),
109 static $noframes = false;
111 // Content for noframes version of page.
112 return HTML::p(fmt("See %s",
113 HTML::a(array('href' => $src), $src)));
117 if (($which = $request->getArg('frame'))) {
118 // Generate specialized frame output (header, footer, etc...)
119 $request->discardOutput();
120 displayPage($request, new Template("frame-$which", $request));
121 $request->finish(); //noreturn
124 // Generate the outer frameset
125 $frame = HTML::frame(array('name' => $name,
128 'frameborder' => (int)$frameborder,
129 'scrolling' => (string)$scrolling,
130 'noresize' => (bool)$noresize,
134 $frame->setArg('marginwidth', $marginwidth);
136 $frame->setArg('marginheight', $marginheight);
138 $tokens = array('CONTENT_FRAME' => $frame,
141 'FRAMEARGS' => sprintf('frameborder="%d"', $frameborder),
144 // Produce the frameset.
145 $request->discardOutput();
146 displayPage($request, new Template('frameset', $request, $tokens));
147 $request->finish(); //noreturn
151 // $Log: not supported by cvs2svn $
152 // Revision 1.9 2004/02/17 12:11:36 rurban
153 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
155 // Revision 1.8 2003/02/26 22:32:06 dairiki
156 // Wups. Delete disused cruft.
158 // Revision 1.7 2003/02/26 22:27:19 dairiki
159 // Fix and refactor FrameInclude plugin (more or less).
161 // (This should now generate valid HTML. Woohoo!)
163 // The output when using the Sidebar theme is ugly enough that it should
164 // be considered broken. (But the Sidebar theme appears pretty broken in
165 // general right now.)
167 // (Personal comment (not to be taken personally): I must say that I
168 // remain unconvinced of the usefulness of this plugin.)
170 // Revision 1.6 2003/01/18 21:41:01 carstenklapp
172 // Reformatting & tabs to spaces;
173 // Added copyleft, getVersion, getDescription, rcs_id.
181 // c-hanging-comment-ender-p: nil
182 // indent-tabs-mode: nil