Skip to content

Commit

Permalink
Merge pull request #252 from nobuhiko/fixTemplate
Browse files Browse the repository at this point in the history
smartyの後方互換処理の追加
  • Loading branch information
Chihiro Adachi authored Apr 11, 2019
2 parents aecd8ce + 6f8b739 commit 66eed5d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions data/class/SC_View.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function init()
$this->_smarty->default_modifiers = array('script_escape');

// smarty:nodefaultsの後方互換を維持
$this->_smarty->registerFilter('pre', array($this, 'lower_compatibility_smarty_nodefaults'));

if (ADMIN_MODE == '1') {
$this->time_start = microtime(true);
Expand All @@ -70,6 +69,7 @@ public function init()
$this->_smarty->force_compile = SMARTY_FORCE_COMPILE_MODE === true;
// 各filterをセットします.
$this->registFilter();
$this->_smarty->registerFilter('pre', array($this, 'lower_compatibility_smarty'));
}

// テンプレートに値を割り当てる
Expand Down Expand Up @@ -251,16 +251,19 @@ public function debug($var = true)


/**
* smarty:nodefaultsをnofilterに置換する
* 2.13のテンプレートのまま動作するためにsmartyの後方互換処理
*
* @param mixed $tpl_source
* @param mixed $smarty
* @access public
* @return void
*/
public function lower_compatibility_smarty_nodefaults($tpl_source, $smarty)
public function lower_compatibility_smarty($tpl_source, $smarty)
{
return preg_replace("/\|smarty:nodefaults/",' nofilter', $tpl_source);
$pattern = array("/\|smarty:nodefaults/", "/include_php /", "/=`(.+?)`/");
$replace = array(' ', 'include_php_ex ', "=$1");

return preg_replace($pattern, $replace, $tpl_source);
}

}

0 comments on commit 66eed5d

Please sign in to comment.