forked from fex-team/fis-plus-smarty-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.html.php
39 lines (36 loc) · 1.5 KB
/
compiler.html.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
34
35
36
37
38
39
<?php
function smarty_compiler_html($arrParams, $smarty){
$strResourceApiPath = preg_replace('/[\\/\\\\]+/', '/', dirname(__FILE__) . '/FISResource.class.php');
$strFramework = $arrParams['framework'];
unset($arrParams['framework']);
$strAttr = '';
$strCode = '<?php ';
if (isset($strFramework)) {
$strCode .= 'if(!class_exists(\'FISResource\', false)){require_once(\'' . $strResourceApiPath . '\');}';
$strCode .= 'FISResource::setFramework(FISResource::getUri('.$strFramework.', $_smarty_tpl->smarty));';
}
$strCode .= ' ?>';
foreach ($arrParams as $_key => $_value) {
if (is_numeric($_key)) {
$strAttr .= ' <?php echo ' . $_value .';?>';
} else {
$strAttr .= ' ' . $_key . '="<?php echo ' . $_value . ';?>"';
}
}
/**
* 后端的服务器进程为常住进程,需要在页面头部取消上次 register 的事件,防止在 smarty.fetch 方法调用 ,导致清空临时资源数据
* Date: 2016-07-21
* Author: [email protected]
*/
$strCode .= '<?php ';
$strCode .= '$_smarty_tpl->unregisterFilter(\'output\', array(\'FISResource\', \'renderResponse\'));';
$strCode .= '?>';
return $strCode . "<html{$strAttr}>";
}
function smarty_compiler_htmlclose($arrParams, $smarty){
$strCode = '<?php ';
$strCode .= '$_smarty_tpl->registerFilter(\'output\', array(\'FISResource\', \'renderResponse\'));';
$strCode .= '?>';
$strCode .= '</html>';
return $strCode;
}