Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack more forward compatibility into Smarty2 #383

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Smarty/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,64 @@ public function getTemplateVars($varName = NULL, Smarty_Internal_Data $_ptr = NU
return $this->get_template_vars($varName);
}

/**
* Set template directory
*
* @param string|array $template_dir directory(s) of template sources
* @param bool $isConfig true for config_dir
*
* @return \Smarty current Smarty instance for chaining
*/
public function setTemplateDir($template_dir, $isConfig = false) {
$this->addTemplateDir($template_dir, null, $isConfig);
return $this;
}

/**
* Add template directory(s).
*
* @param string|array $template_dir directory(s) of template sources
* @param string $key (Smarty3+) of the array element to assign the template dir to
* @param bool $isConfig (Smarty3+) true for config_dir
*
* @return Smarty current Smarty instance for chaining
*/
public function addTemplateDir($template_dir, $key = NULL, $isConfig = FALSE) {
if (is_array($this->template_dir)) {
if (!in_array($template_dir, $this->template_dir)) {
array_unshift($this->template_dir, $template_dir);
}
}
else {
$this->template_dir = [$template_dir, $this->template_dir];
}
return $this;
}

public function getPluginsDir() {
return (array) $this->plugins_dir;
}

public function clearAllCache() {
$this->clear_all_cache();
}

public function setPluginsDir(array $directory) {
$this->plugins_dir = $directory;
}

public function setCompileDir($compileDirectory) {
$this->compile_dir = $compileDirectory;
}

public function registerPlugin($type, $name, $callback, $cacheable = TRUE, $cache_attr = NULL) {
if ($type === 'modifier') {
$this->register_modifier($name, $callback);
}
if ($type === 'block') {
$this->register_block('localize', 'smarty_block_localize');
}
}
/**
* Returns an array containing config variables
*
Expand Down