forked from fex-team/fis-plus-smarty-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.require.php
31 lines (27 loc) · 1.23 KB
/
compiler.require.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
<?php
function smarty_compiler_require($arrParams, $smarty){
$strName = $arrParams['name'];
$src = isset($arrParams['src']) ? $arrParams['src'] : false;
$type = isset($arrParams['type']) ? $arrParams['type'] : 'null';
$async = 'false';
if (isset($arrParams['async'])) {
$async = trim($arrParams['async'], "'\" ");
if ($async !== 'true') {
$async = 'false';
}
}
$strCode = '';
if($strName || $src){
$strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php');
$strCode .= '<?php if(!class_exists(\'FISResource\', false)){require_once(\'' . $strResourceApiPath . '\');}';
if ($strName) {
$strCode .= 'if (array_key_exists(\'fis_debug\', $_GET)) {echo "<!--require '.str_replace("\"", '\"', $strName).'-->\n";}';
$strCode .= 'FISResource::load(' . $strName . ',$_smarty_tpl->smarty, '.$async.');';
} else if (is_string($src)) {
$strCode .= 'if (array_key_exists(\'fis_debug\', $_GET)) {echo "<!--add static '.str_replace("\"", '\"', $str).'-->\n";}';
$strCode .= 'FISResource::addStatic(' . $src . ', ' . $type . ');';
}
$strCode .= '?>';
}
return $strCode;
}