Skip to content

Commit

Permalink
Smarty5 対応
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Apr 5, 2024
1 parent fadb5b1 commit 2b7468d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 43 deletions.
4 changes: 2 additions & 2 deletions data/class/SC_AdminView.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function init()
{
parent::init();

$this->_smarty->template_dir = realpath(TEMPLATE_ADMIN_REALDIR);
$this->_smarty->compile_dir = realpath(COMPILE_ADMIN_REALDIR);
$this->_smarty->setTemplateDir(realpath(TEMPLATE_ADMIN_REALDIR));
$this->_smarty->setCompileDir(realpath(COMPILE_ADMIN_REALDIR));
$this->assign('TPL_URLPATH_PC', ROOT_URLPATH . USER_DIR . USER_PACKAGE_DIR . TEMPLATE_NAME . '/');
$this->assign('TPL_URLPATH_DEFAULT', ROOT_URLPATH . USER_DIR . USER_PACKAGE_DIR . DEFAULT_TEMPLATE_NAME . '/');
$this->assign('TPL_URLPATH', ROOT_URLPATH . USER_DIR . USER_PACKAGE_DIR . 'admin/');
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_InstallView.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct($template_dir, $compile_dir = COMPILE_REALDIR)
{
parent::__construct();

$this->_smarty->template_dir = realpath($template_dir);
$this->_smarty->compile_dir = realpath($compile_dir);
$this->_smarty->setTemplateDir(realpath($template_dir));
$this->_smarty->setCompileDir(realpath($compile_dir));

Check warning on line 31 in data/class/SC_InstallView.php

View check run for this annotation

Codecov / codecov/patch

data/class/SC_InstallView.php#L30-L31

Added lines #L30 - L31 were not covered by tests
}
}
4 changes: 2 additions & 2 deletions data/class/SC_MobileView.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function init()
{
parent::init();

$this->_smarty->template_dir = realpath(MOBILE_TEMPLATE_REALDIR);
$this->_smarty->compile_dir = realpath(MOBILE_COMPILE_REALDIR);
$this->_smarty->setTemplateDir(realpath(MOBILE_TEMPLATE_REALDIR));
$this->_smarty->setCompileDir(realpath(MOBILE_COMPILE_REALDIR));
$this->assignTemplatePath(DEVICE_TYPE_MOBILE);
}
}
8 changes: 4 additions & 4 deletions data/class/SC_SiteView.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function init()
{
parent::init();

$this->_smarty->template_dir = realpath(TEMPLATE_REALDIR);
$this->_smarty->compile_dir = realpath(COMPILE_REALDIR);
$this->_smarty->setTemplateDir(realpath(TEMPLATE_REALDIR));
$this->_smarty->setCompileDir(realpath(COMPILE_REALDIR));

$this->assignTemplatePath(DEVICE_TYPE_PC);
}
Expand All @@ -38,7 +38,7 @@ public function init()
*/
public function setPrevURL()
{
$objCartSess = new SC_CartSession_Ex();
$objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
$objCartSess = new SC_CartSession_Ex();
$objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
}
}
4 changes: 2 additions & 2 deletions data/class/SC_SmartphoneView.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function init()
{
parent::init();

$this->_smarty->template_dir = realpath(SMARTPHONE_TEMPLATE_REALDIR);
$this->_smarty->compile_dir = realpath(SMARTPHONE_COMPILE_REALDIR);
$this->_smarty->setTemplateDir(realpath(SMARTPHONE_TEMPLATE_REALDIR));
$this->_smarty->setCompileDir(realpath(SMARTPHONE_COMPILE_REALDIR));
$this->assignTemplatePath(DEVICE_TYPE_SMARTPHONE);
}
}
25 changes: 15 additions & 10 deletions data/class/SC_View.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class SC_View
{
/** @var Smarty */
/** @var \Smarty\Smarty */
public $_smarty;

/** @var LC_Page */
Expand All @@ -41,9 +41,9 @@ public function __construct()
public function init()
{
// include_phpの利用のためSmartyBCを呼び出す、ホントはinclude_phpをなくしたいそうすれば、blank.tplもなくせる
$this->_smarty = new Smarty;
$this->_smarty->left_delimiter = '<!--{';
$this->_smarty->right_delimiter = '}-->';
$this->_smarty = new \Smarty\Smarty();
$this->_smarty->setLeftDelimiter('<!--{');
$this->_smarty->setRightDelimiter('}-->');
$this->_smarty->registerPlugin('modifier', 'sfDispDBDate', function ($dbdate, $time = true) { return SC_Utils_Ex::sfDispDBDate($dbdate, $time); });
$this->_smarty->registerPlugin('modifier', 'sfGetErrorColor', array('SC_Utils_Ex', 'sfGetErrorColor'));
$this->_smarty->registerPlugin('modifier', 'sfTrim', array('SC_Utils_Ex', 'sfTrim'));
Expand All @@ -58,6 +58,11 @@ public function init()
$this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', array('SC_Utils_Ex', 'sfMbConvertEncoding'));
$this->_smarty->registerPlugin('modifier', 'sfGetEnabled', array('SC_Utils_Ex', 'sfGetEnabled'));
$this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', array('SC_Utils_Ex', 'sfNoImageMainList'));
$this->_smarty->registerPlugin('modifier', 'file_exists', 'file_exists');
$this->_smarty->registerPlugin('modifier', 'function_exists', 'function_exists');
$this->_smarty->registerPlugin('modifier', 'preg_quote', 'preg_quote');
$this->_smarty->registerPlugin('modifier', 'is_numeric', 'is_numeric');
$this->_smarty->registerPlugin('modifier', 'php_uname', 'php_uname');
// XXX register_function で登録すると if で使用できないのではないか?
$this->_smarty->registerPlugin('function','sfIsHTTPS', array('SC_Utils_Ex', 'sfIsHTTPS'));
$this->_smarty->registerPlugin('function','sfSetErrorStyle', array('SC_Utils_Ex', 'sfSetErrorStyle'));
Expand Down Expand Up @@ -141,10 +146,10 @@ public function registFilter()
/**
* prefilter用のフィルタ関数。プラグイン用のフックポイント処理を実行
* @param string $source ソース
* @param Smarty_Internal_Template $smarty Smartyのコンパイラクラス
* @param \Smarty\Template $smarty Smartyのコンパイラクラス
* @return string $source ソース
*/
public function prefilter_transform($source, Smarty_Internal_Template $template)
public function prefilter_transform($source, \Smarty\Template $template)
{
if (!is_null($this->objPage)) {
// フックポイントを実行.
Expand All @@ -160,10 +165,10 @@ public function prefilter_transform($source, Smarty_Internal_Template $template)
/**
* outputfilter用のフィルタ関数。プラグイン用のフックポイント処理を実行
* @param string $source ソース
* @param Smarty_Internal_Template $smarty Smartyのコンパイラクラス
* @param \Smarty\Template $smarty Smartyのコンパイラクラス
* @return string $source ソース
*/
public function outputfilter_transform($source, Smarty_Internal_Template $template)
public function outputfilter_transform($source, \Smarty\Template $template)
{
if (!is_null($this->objPage)) {
// フックポイントを実行.
Expand Down Expand Up @@ -281,9 +286,9 @@ public function lower_compatibility_smarty($tpl_source, $smarty)
* @param Smarty_Internal_Template $template
* @return string 現在のテンプレートファイルパス
*/
public function getCurrentTemplateFile(Smarty_Internal_Template $template)
public function getCurrentTemplateFile(\Smarty\Template $template)
{
$current_file = str_replace($template->smarty->getTemplateDir(), '', $template->source->filepath);
$current_file = str_replace($template->getSmarty()->getTemplateDir(), '', $template->getSource()->getFilepath());
return str_replace('\\', '/', $current_file); // Windows 向けにパスの区切り文字を正規化する
}
}
4 changes: 0 additions & 4 deletions data/smarty_extends/function.from_to.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
*/
function smarty_function_from_to($params, &$smarty)
{
if (!is_callable('smarty_function_escape_special_chars')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
}

$from = null;
$to = null;
$separator = '';
Expand Down
17 changes: 0 additions & 17 deletions data/smarty_extends/function.html_radios_ex.php

This file was deleted.

0 comments on commit 2b7468d

Please sign in to comment.