forked from fex-team/fis-plus-smarty-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.script.php
33 lines (31 loc) · 1.52 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
33
<?php
function smarty_compiler_script($params, $smarty){
$strPriority = isset($params['priority']) ? $params['priority'] : '0';
$strCode = '<?php ';
if (isset($params['id'])) {
$strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php');
$strCode .= 'if(!class_exists(\'FISResource\', false)){require_once(\'' . $strResourceApiPath . '\');}';
$strCode .= 'FISResource::$cp = ' . $params['id'].';';
}
$strCode .= '$fis_script_priority = ' . $strPriority . ';';
$strCode .= 'ob_start();?>';
return $strCode;
}
function smarty_compiler_scriptclose($params, $smarty){
$strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php');
$strCode = '<?php ';
$strCode .= '$script=ob_get_clean();';
$strCode .= 'if($script!==false){';
$strCode .= 'if(!class_exists(\'FISResource\', false)){require_once(\'' . $strResourceApiPath . '\');}';
$strCode .= 'if(FISResource::$cp) {';
$strCode .= 'if (!in_array(FISResource::$cp, FISResource::$arrEmbeded)){';
$strCode .= 'FISResource::addScriptPool($script, $fis_script_priority);';
$strCode .= 'FISResource::$arrEmbeded[] = FISResource::$cp;';
$strCode .= '}';
$strCode .= '} else {';
$strCode .= 'FISResource::addScriptPool($script, $fis_script_priority);';
$strCode .= '}';
$strCode .= '}';
$strCode .= 'FISResource::$cp = null;?>';
return $strCode;
}