[pmwiki-users] popup window recipe do not work in PHP 8.2
Gregor Klarič
klaric.gregor at gmail.com
Sat Jun 17 10:48:56 PDT 2023
Here is the modified code, not sure, if it works in all cases because I
don't know exactly what it should do:
<?php if (!defined('PmWiki')) exit();
/* popupwindow.php, a module written for pmwiki 2
for creating popup windows.
copyright 2007 Hans Bracker.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Simple syntax: %popwin%[[Group/PageName]] or %popwin%[[Group/PageName|
Title]]
Syntax with some parameters: %popwin height=300 width=400 top=20
left=20%[[link]]
See list of available parameters below under $defaults
For multiple popup-window links, each with some different parameters,
add id= parameter, for instance id=1, id=2 etc.
Additional markup:
(:popclose Close Window:) creates a link for closing the popup window,
replace "Close Window" with whatever label text.
(:input closewindow 'Close Window':) creates a 'Close Window' button.
replace "Close Window" with whatever label text.
add ?action=popopen to the %popwin%link
%popwin%[[PageName?action=popopen| link text]]
opens the popup and sets a page variable {$PopOpen}.
Use it in the popup page in conditionals to trim side menus etc:
(:if equal {$PopOpen} 1:)(:noleft:)(:popclose Close Window:)(:ifend:)
*/
$RecipeInfo['PopupWindow']['Version'] = '2023-06-17';
Markup('popwin1','<links','/%popwin\\s*(.*?)%\\[\\[(.*?)\\]\\]/i',
"PopupWindow");
Markup('popwin2','<popwin1',
"/%popwin\\s*(.*?)%(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/i",
"PopupWindow");
function PopupWindow ($m) {
global $LinkPopupFmt, $FmtPV, $PopupLinkPage;
$opts=$m[1];
$tgt=$m[2];
$lbl=$m[3];
$sfx=$m[4];
extract($GLOBALS['MarkupToHTML']);
static $cnt = 0; $cnt++;
$defaults = array(
'id' => '0',
'width' => 500,
'height' => 300,
'left' => 'center',
'top' => 'center',
'resizable' => 1,
'scrollbars' => 1,
'toolbar' => 0,
'location' => 0,
'directories' => 0,
'statusbar' => 0,
'menubar' => 0,
);
$opt = array_merge($defaults, ParseArgs($opts));
$FmtV['$PopupLinkPage'] = $PopupLinkPage = $pagename;
$FmtPV['$PopupLinkPage'] = '$GLOBALS["PopupLinkPage"]';
$LinkPopupFmt = "<a href='\$LinkUrl' onclick=\"return
popWin('\$LinkUrl','popup".$opt['id'].
"','".$opt['width']."','".$opt['height']."','".$opt['left']."','".$opt['top'].
"','".$opt['resizable']."','".$opt['scrollbars']."','".$opt['toolbar'].
"','".$opt['location']."','".$opt['directories']."','".$opt['statusbar'].
"','".$opt['menubar']."')\">\$LinkText</a>".
($cnt==1 ? "\n <script language='javascript'
type='text/javascript'><!--
function popWin(url,id,px,py,pl,pt,rs,sb,tb,lo,di,st,mb) {
if(pl=='center') var pl = (screen.width-px)/2; if(pt=='center') var pt
= (screen.height-py)/2;
newwindow=window.open(url,id,'toolbar='+tb+',scrollbars='+sb+',location='+lo+',statusbar='+st+',menubar='+mb+',directories='+di+',resizable='+rs+',width='+px+',height='+py+',left='+pl+',top='+pt+'');
if (window.focus) {newwindow.focus()} return false;} // -->
</script>" : "");
return
Keep(MakeLink($pagename,$tgt,$lbl,$sfx,$GLOBALS['LinkPopupFmt']),'L');
}
# set PV {$PopOpen} with action=popopen
$HandleActions['popopen'] = 'PopOpenHandle';
function PopOpenHandle($pagename) {
global $FmtPV;
$FmtPV['$PopOpen'] = '"1"';
HandleBrowse($pagename);
}
# create link for closing popup with (:popclose Close Window:)
Markup('popclose','directives','/\\(:popclose\\s*(.*?):\\)/i',
"PopCloseMarkup");
function PopCloseMarkup($pagename, $label='Close Window') {
if(strlen($m[1] < 1)){
$label='Close Window';
}else{
$label=$m[1] ;
}
extract($GLOBALS['MarkupToHTML']);
$out = "<a href=\"$PageUrl?action=popclose\"
onclick=\"self.close()\">$label</a>";
return Keep($out);
}
# add markup (:input closewindow 'Close Window':)
SDVA($InputTags['closewindow'], array(
':args' => array('value'),
'value' => XL('Close Window'),
':html' => "<input type='button' class='inputbutton' \$InputFormArgs
onClick='window.close()' />",
));
Am Sa., 17. Juni 2023 um 10:30 Uhr schrieb Piotr Dybczyński <
piotr at dybczynski.pl>:
> Hi all,
>
> after upgrading to Debian 12 I have a problem described in the subject.
>
> Are there any alternatives for this recipe?
>
> Thanks in advance,
> Piotr
> --
> /************************************************************************
> dr Piotr A. Dybczyński
> homepage: https://www.dybczynski.pl/Piotr e-mail: piotr at dybczynski.pl
> ******************************************************************PAD***/
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20230617/6ddb6b03/attachment.html>
More information about the pmwiki-users
mailing list