]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/PopUp.php
Valid XHTML code
[SourceForge/phpwiki.git] / lib / plugin / PopUp.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /**
4  Copyright 2004 Nicolas Noble <pixels@users.sf.net>
5  Copyright 2009 Marc-Etienne Vargenau, Alcatel-Lucent
6
7  This file is part of PhpWiki.
8
9  PhpWiki is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13
14  PhpWiki is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with PhpWiki; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 /**
25  * Display a page in a clickable popup link.
26  *
27  * Usage:
28  * <?plugin PopUp
29  *     link="HomePage"
30  *     title="PopUpped HomePage"
31  *     text="Click here to popup the HomePage"
32  *     width=300
33  *     height=200
34  *     resizable=no
35  *     scrollbars=no
36  *     toolbar=no
37  *     location=no
38  *     directories=no
39  *     status=no
40  *     menubar=no
41  *     copyhistory=no
42  * ?>
43  * <?plugin PopUp close=yes ?>
44  */
45
46 class WikiPlugin_PopUp
47 extends WikiPlugin
48 {
49     function getName () {
50         return _("PopUp");
51     }
52     function getDescription () {
53         return _("Used to create a clickable popup link.");
54
55     }
56     function getVersion() {
57         return preg_replace("/[Revision: $]/", '',
58                             "\$Revision$");
59     }
60     function getDefaultArguments() {
61         return array('link'        => "HomePage",
62                      'title'       => "",
63                      'text'        => "",
64                      'width'       => "500",
65                      'height'      => "400",
66                      'resizable'   => "no",
67                      'scrollbars'  => "no",
68                      'toolbar'     => "no",
69                      'location'    => "no",
70                      'directories' => "no",
71                      'status'      => "no",
72                      'menubar'     => "no",
73                      'copyhistory' => "no",
74                      'close'       => "no",
75                     );
76     }
77
78     function run($dbi, $argstr, &$request, $basepage) {
79         extract($this->getArgs($argstr, $request));
80         return HTML::a(array('href' => WikiURL($link),
81                               'target' => "_blank",
82                               'onclick' => ($close == "yes" ? "window.close()" : ("window.open('" .
83                                   WikiURL($link) . "', '" .
84                                   ($title == "" ? ($text == "" ? $link : $text) : $title) . "', '" .
85                                   "width=$width," .
86                                   "height=$height," .
87                                   "resizable=$resizable," .
88                                   "scrollbars=$scrollbars," .
89                                   "toolbar=$toolbar," .
90                                   "location=$location," .
91                                   "directories=$directories," .
92                                   "status=$status," .
93                                   "menubar=$menubar," .
94                                   "copyhistory=$copyhistory')"
95                                   )) . ";return false;"
96                              ),
97                         ($text == "" ? ($close == "yes" ? "Close window" : $link) : $text)
98                        );
99     }
100 };
101
102 // For emacs users
103 // Local Variables:
104 // mode: php
105 // tab-width: 8
106 // c-basic-offset: 4
107 // c-hanging-comment-ender-p: nil
108 // indent-tabs-mode: nil
109 // End:
110 ?>