1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?php
namespace Bitweaver\Plugins;
use Bitweaver\KernelTools;
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* smarty_function_jspopup
*/
/**
* smarty_function_jspopup
*
* @param array $pParams hash of options
* @var string $pParams[href] link the popup should open
* @var string $pParams[title] title of the link
* @var string $pParams[img] source of an image that is to be displayed instead of the title
* @var string $pParams[href]
* @var string $pParams[href]
* @param array $pSmarty
* @return string
*/
function smarty_function_jspopup( $pParams, &$pSmarty=NULL ) {
global $gBitThemes, $gBitSmarty;
$ret = '';
if( empty( $pParams['href'] ) ) {
return 'assign: missing "href" parameter';
}
$title = empty( $pParams['title'] )
? basename( $pParams['href'] )
: ( empty( $pParams['notra'] ) ? $pParams['title'] : KernelTools::tra( $pParams['title'] ) );
if( empty( $pParams['text'] )){
$text = $title;
} else {
$text = empty( $pParams['notra'] ) ? $pParams['text'] : KernelTools::tra( $pParams['text'] );
// remove it from the hash since later the params are looped over for to formulate the a tag
unset( $pParams['text'] );
}
$optionHash = [ 'type', 'width', 'height', 'gutsonly', 'img' ];
$guts = '';
foreach( $pParams as $param => $val ) {
if( !in_array( $param, $optionHash ) ) {
if( $param == 'title' ) {
$guts .= ' '.$param.'="'.KernelTools::tra( 'This will open a new window: ' ).$title.'"';
}elseif( $param == 'href' && $gBitThemes->isJavascriptEnabled()){
$guts .= ' '.$param.'="javascript:void(0)"';
} else {
$guts .= ' '.$param.'="'.$val.'"';
}
}
}
if( !empty( $pParams['ibiticon'] ) ) {
// $gBitSmarty->loadPlugin( 'smarty_function_biticon' );
$tmp = explode( '/', $pParams['ibiticon'] );
$ibiticon = [
'ipackage' => $tmp[0],
'iname' => $tmp[1],
'iexplain' => $title,
];
if( !empty( $pParams['iforce'] ) ) {
$ibiticon['iforce'] = $pParams['iforce'];
}
$img = smarty_function_biticon( $ibiticon );
}
if( !empty( $pParams['img'] )) {
$img_size = NULL;
$file = str_replace( '//', '/', BIT_BASE_PATH.( str_replace( BIT_ROOT_URI, '', urldecode( $pParams['img'] ))));
if( is_file( $file )) {
if( $imgSizeHash = @getimagesize( $file )) {
$img_size = $imgSizeHash[3];
}
}
$img = '<img src="'.$pParams['img'].'" alt="'.$title.'" title="'.$title.'" '.$img_size.' />';
}
$js = !empty( $pParams['type'] ) && $pParams['type'] == 'fullscreen'
? 'BitBase.popUpWin( \''.$pParams['href'].'\',\'fullScreen\');'
: ( 'BitBase.popUpWin( \''.$pParams['href'].'\',\'standard\',' .
( !empty( $pParams['width'] ) ? $pParams['width'] : 600 ) .
',' . ( !empty( $pParams['height'] ) ? $pParams['height'] : 400 ) . ');' );
// deprecated slated for removal - onkeypress causes focus problems with browsers - if this is an ada issue get in touch -wjames5.
// $guts .= ' onkeypress="'.$js.'" onclick="'.$js.'return false;"';
$guts .= ' onclick="'.$js.'return false;"';
if( !empty( $pParams['gutsonly'] ) ) {
return $guts;
}
return '<a '.$guts.'>'.( !empty( $img ) ? $img : $text ).'</a>';
}
|