/framework/vendor/smarty2/plugins/function.popupwindow.php

http://zoop.googlecode.com/ · PHP · 55 lines · 33 code · 13 blank · 9 comment · 6 complexity · fc941c1f9f9dd130625db67e01f0fb9f MD5 · raw file

  1. <?
  2. /*
  3. * Smarty plugin
  4. * -------------------------------------------------------------
  5. * Type: function
  6. * Name: popupwindow
  7. * Purpose: make an onclick attribute for popping up a window
  8. * -------------------------------------------------------------
  9. */
  10. function smarty_function_popupwindow($params, &$smarty)
  11. {
  12. if(!isset($params['url']))
  13. {
  14. $smarty->trigger_error("assign: missing 'url' parameter");
  15. return;
  16. }
  17. $url = $params['url'];
  18. if(isset($params['left']))
  19. $leftClause = 'left=' . $params['left'] . ',';
  20. else
  21. $leftClause = '';
  22. if(isset($params['top']))
  23. $topClause = 'top=' . $params['top'] . ',';
  24. else
  25. $topClause = '';
  26. if(isset($params['width']))
  27. $width = $params['width'];
  28. else
  29. $width = 900;
  30. if(isset($params['height']))
  31. $height = $params['height'];
  32. else
  33. $height = 700;
  34. if(isset($params['name']))
  35. $name = $params['name'];
  36. else
  37. $name = 'popup';
  38. return "onclick=\"now = new Date(); printpopup = window.open('$url?cache_limiter=private&' + now.getTime(), '$name', '${leftClause}${topClause}width=$width,height=$height,toolbar=0,location=0,directories=1,resizable=1,status=0,menubar=0,scrollbars=1,locationbar=0'); printpopup.focus(); return false;\"";
  39. $smarty->assign($var, $value);
  40. }
  41. /* vim: set expandtab: */
  42. ?>