PageRenderTime 25ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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/*
 4 * Smarty plugin
 5 * -------------------------------------------------------------
 6 * Type:     function
 7 * Name:     popupwindow
 8 * Purpose:  make an onclick attribute for popping up a window
 9 * -------------------------------------------------------------
10 */
11function smarty_function_popupwindow($params, &$smarty)
12{
13    if(!isset($params['url']))
14	{
15        $smarty->trigger_error("assign: missing 'url' parameter");
16        return;
17    }
18    
19    $url = $params['url'];
20    
21    if(isset($params['left']))
22    	$leftClause = 'left=' . $params['left'] . ',';
23    else
24    	$leftClause = '';
25    
26    if(isset($params['top']))
27		$topClause = 'top=' . $params['top'] . ',';
28	else
29		$topClause = '';
30    
31    if(isset($params['width']))
32    	$width = $params['width'];
33    else
34    	$width = 900;
35    
36    if(isset($params['height']))
37		$height = $params['height'];
38	else
39		$height = 700;
40	
41	if(isset($params['name']))
42		$name = $params['name'];
43	else
44		$name = 'popup';
45    
46    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;\"";
47
48    
49    $smarty->assign($var, $value);
50}
51
52/* vim: set expandtab: */
53
54?>
55