Skip to content

Commit

Permalink
Fixes for the smarty integration for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
onli committed Jan 19, 2025
1 parent b9b39e5 commit 36696bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/functions_smarty.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
die ("Don't hack!");
}

use Smarty\Smarty;

/**
* Fetch a list of trackbacks for an entry
*
Expand Down Expand Up @@ -962,7 +964,7 @@ function serendipity_smarty_init($vars = array()) {
include_once SMARTY_DIR . 'Smarty.class.php';
}

if (!class_exists('Smarty')) {
if (!class_exists('\Smarty\Smarty')) {
return false;
}

Expand Down
17 changes: 13 additions & 4 deletions include/serendipity_smarty_class.inc.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
// serendipity_smarty_class.inc.php lm 2014-12-10 Ian

use Smarty\Smarty;

// define secure_dir and trusted_dirs for Serendipity_Smarty_Security_Policy class.
@define('S9Y_TEMPLATE_FALLBACK', $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default');
Expand All @@ -9,7 +10,7 @@


// Create a wrapper class extended from Smarty_Security - which allows access to S9Y-plugin and S9Y-template dirs
class Serendipity_Smarty_Security_Policy extends Smarty_Security
class Serendipity_Smarty_Security_Policy extends \Smarty\Security
{
// these are the allowed functions only. - default as is
public $php_functions = array('isset', 'empty', 'sizeof', 'count', 'in_array', 'is_array', 'time', 'nl2br', 'class_exists');
Expand Down Expand Up @@ -51,7 +52,7 @@ public static function test()
}

// Create a wrapper class extended from Smarty
class Serendipity_Smarty extends Smarty
class Serendipity_Smarty extends \Smarty\Smarty
{
// bc mode for plugins Smarty2 compat INCLUDE_ANY fetch() calls - to avoid an undefinied property error.
public $security_settings = false;
Expand Down Expand Up @@ -267,7 +268,15 @@ public function register_resource($type, $functions)
*/
public function assign_by_ref($tpl_var, &$value)
{
$this->assignByRef($tpl_var, $value);
$this->assign($tpl_var, $value);
}

/**
* Compatibility function for smarty 5
*/
public function assignByRef($tpl_var, &$value)
{
$this->assign($tpl_var, $value);
}

/**
Expand Down

0 comments on commit 36696bd

Please sign in to comment.