-
Notifications
You must be signed in to change notification settings - Fork 11
/
compiler.script.php
32 lines (30 loc) · 1.33 KB
/
compiler.script.php
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
<?php
function smarty_compiler_script($params, $smarty){
$strCode = '<?php ';
$strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/lib/FISPagelet.class.php');
$strCode .= 'if(!class_exists(\'FISPagelet\', false)){require_once(\'' . $strResourceApiPath . '\');}';
if (isset($params['id'])) {
$strCode .= 'FISPagelet::$cp = ' . $params['id'].';';
}
$strCode .= 'ob_start();?>';
return $strCode;
}
function smarty_compiler_scriptclose($params, $smarty){
$strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/lib/FISPagelet.class.php');
$strCode = '<?php ';
$strCode .= '$script = ob_get_clean();';
$strCode .= 'if($script!==false){';
$strCode .= 'if(class_exists(\'FISPagelet\', false)){';
$strCode .= 'if(FISPagelet::$cp) {';
$strCode .= 'if (!in_array(FISPagelet::$cp, FISPagelet::$arrEmbeded)){';
$strCode .= 'FISPagelet::addScript($script);';
$strCode .= 'FISPagelet::$arrEmbeded[] = FISPagelet::$cp;';
$strCode .= '}';
$strCode .= '} else {';
$strCode .= 'FISPagelet::addScript($script);';
$strCode .= '}';
$strCode .= '}';
$strCode .= '}';
$strCode .= 'FISPagelet::$cp = null;?>';
return $strCode;
}