Re: popup window recipe do not work in PHP 8.2

Piotr Dybczyński <[email protected]>
Newsgroups gmane.comp.web.wiki.pmwiki.user
Message-ID <[email protected]>
Hi Gregor,

thanks a lot!

Quick tests showed it works.

Thanks again,

regards,
Piotr
-- 
/************************************************************************
                          dr Piotr A. Dybczyński
  homepage: https://www.dybczynski.pl/Piotr   e-mail: [email protected]
******************************************************************PAD***/

W dniu 17.06.2023 o 19:48, Gregor Klarič pisze:

> 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()' />",
>    ));
> 

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.