Source for file function.pnformcontextmenuitem.php
Documentation is available at function.pnformcontextmenuitem.php
* @copyright (c) 2006, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: function.pnformdateinput.php 21129 2007-01-19 19:08:26Z jornlind $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_Template_Plugins
* This plugin represents a menu item.
* Language constants can be used here.
* Command name passed to the event handler
* JavaScript code to execute when menu item is selected
* Your script will be wrapped in a function that passes a parameter "commandArgument". This parameter
* contains the command argument of the pnformcontextmenureference plugin. In this way your script
* can work with the menu item data you clicked. Example:
* <!--[pnformcontextmenuitem title=Preview imageURL="preview.gif" commandScript="popupPreview(commandArgument)"]-->
* <script type="text/javascript">
* function popupPreview(commandArgument)
* alert(commandArgument);
* URL to redirect to when menu item is selected
* You can place {commandArgument} (including the braces) in your URL. This will get substituted with the
* command argument value of the pnformcontextmenureference plugin. In this way you can redirect to something
* If you set a confirmation message then a ok/cancel dialog box pops and asks the user to confirm
* the menu item click - very usefull for menu selections that deletes items.
* You can use _XXX language defines directly as the message, no need to call <!--[pnml]--> for
function create(&$render, &$params)
// Avoid creating menu multiple times if included in a repeated template
if (!$contextMenu->firstTime())
$click = 'javascript:' . $this->renderConfirm($render, $render->pnFormGetPostBackEventReference($this, $this->commandName));
$hiddenName = "contentMenuArgument" . $contextMenu->id;
$click = 'javascript:' . $this->renderConfirm($render, "pnForm.contextMenu.commandScript('$hiddenName', function(commandArgument){" . $this->commandScript . "})");
$hiddenName = "contentMenuArgument" . $contextMenu->id;
$click = 'javascript:' . $this->renderConfirm($render, "pnForm.contextMenu.redirect('$hiddenName','$url')");
pn_exit('Missing commandName, commandScript, or commandRedirect in context menu item');
$title = $render->pnFormTranslateForDisplay($this->title);
$style = " style=\"background-image: url($this->imageURL)\"";
$html = "<li$style><a href=\"$url\">$title</a></li>";
$msg = $render->pnFormTranslateForDisplay($this->confirmMessage) . '?';
return "if (confirm('$msg')) { $script }";
// Called by pnForms framework due to the use of pnFormGetPostBackEventReference() above
$hiddenName = "contentMenuArgument" . $contextMenu->id;
$args = array('commandName' => $eventArgument, 'commandArgument' => $commandArgument);
$render->pnFormRaiseEvent($contextMenu->onCommand == null ? 'handleCommand' : $contextMenu->onCommand, $args);
// Locate parent context menu
$contextMenu = &$this->parentPlugin;
$contextMenu = &$contextMenu->parentPlugin;
return $render->pnFormRegisterPlugin('pnFormContextMenuItem', $params);
|