[pmwiki-devel] Popup handling

Hans design5 at softflow.co.uk
Tue Mar 20 15:26:01 CDT 2007


I have a couple of questions regards code I wrote for additional popup
window handling, as part of the PopupWindow script (update uploaded):
http://www.pmwiki.org/wiki/Cookbook/PopupWindow

1. I added a "Close Window" markup which generates a link for closing
the popup window. This works but is it okay and safe enough?

Markup('popclose','directives','/\\(:popclose\\s*(.*?):\\)/e',
    "Keep('<a href=\"$PageUrl?action=popclose\"
        onclick=\"self.close()\">$1</a>')");

The 'action=popclose' is a dummy and does not have a handler. Its just
for url display in the status line of the browser.

2. I wanted a page variable which I can check on the popup window and
which is present only if the window opened as a popup.
So I created a popopen action which set the PV. I don't know if this
is code overkill and there is a neater way.

# set PV {$PopOpen} with action=popopen
$HandleActions['popopen'] = 'PopOpenHandle';
function PopOpenHandle($pagename) {
    global $FmtPV;
    $FmtPV['$PopOpen'] = '"1"';
    HandleBrowse($pagename);
}

The beauty of having  a PV for the popup 'state' is that now I can add
markup inside a conditional to trim the page, remove the sidebar,
right bar, header, footer, actions etc. to get purely the page content
inside the popup window.
And the page can act quite normally when opened in a normal fashion.

Is this a reasonable way to do it?

-- 
Best regards,
 Hans




More information about the pmwiki-devel mailing list