[ticket/11628] Remove template_path option on set_custom_style

This was set to default 'template/' to append template/ to all the paths,
but every location was actually just setting it to '' to not append anything.
So removed the option entirely (additional paths can be appended to the paths
being sent to the function already)

PHPBB3-11628
This commit is contained in:
Nathaniel Guse 2013-07-24 13:25:20 -05:00
parent 863592a8be
commit 12c2258506
13 changed files with 15 additions and 23 deletions

View file

@ -50,7 +50,7 @@ $module_id = request_var('i', '');
$mode = request_var('mode', ''); $mode = request_var('mode', '');
// Set custom style for admin area // Set custom style for admin area
$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_custom_style('admin', $phpbb_admin_path . 'style');
$template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');

View file

@ -22,7 +22,7 @@ $auth->acl($user->data);
$user->setup(); $user->setup();
// Set custom template for admin area // Set custom template for admin area
$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_custom_style('admin', $phpbb_admin_path . 'style');
$template->set_filenames(array( $template->set_filenames(array(
'body' => 'colour_swatch.html') 'body' => 'colour_swatch.html')

View file

@ -660,7 +660,7 @@ class messenger
{ {
$this->setup_template(); $this->setup_template();
$this->template->set_custom_style($path_name, $paths, ''); $this->template->set_custom_style($path_name, $paths);
} }
} }

View file

@ -508,7 +508,7 @@ class p_master
if (is_dir($module_style_dir)) if (is_dir($module_style_dir))
{ {
$template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), ''); $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'));
} }
} }

View file

@ -213,7 +213,7 @@ $config = new phpbb_config(array(
)); ));
$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_custom_style('admin', $phpbb_admin_path . 'style');
$template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_ASSETS_PATH', '../assets');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');

View file

@ -138,7 +138,7 @@ class install_update extends module
} }
// Set custom template again. ;) // Set custom template again. ;)
$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_custom_style('admin', $phpbb_admin_path . 'style');
$template->assign_vars(array( $template->assign_vars(array(
'S_USER_LANG' => $user->lang['USER_LANG'], 'S_USER_LANG' => $user->lang['USER_LANG'],

View file

@ -57,10 +57,9 @@ interface phpbb_template
* *
* @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions.
* @param array or string $paths Array of style paths, relative to current root directory * @param array or string $paths Array of style paths, relative to current root directory
* @param string $template_path Path to templates, relative to style directory. Default (template/).
* @return phpbb_template $this * @return phpbb_template $this
*/ */
public function set_custom_style($names, $paths, $template_path = 'template/'); public function set_custom_style($names, $paths);
/** /**
* Clears all variables and blocks assigned to this template. * Clears all variables and blocks assigned to this template.

View file

@ -225,7 +225,7 @@ class phpbb_template_twig implements phpbb_template
$this->twig->getLoader()->setPaths($paths, 'core'); $this->twig->getLoader()->setPaths($paths, 'core');
} }
$this->set_custom_style($names, $paths, ''); $this->set_custom_style($names, $paths);
return $this; return $this;
} }
@ -237,10 +237,9 @@ class phpbb_template_twig implements phpbb_template
* *
* @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions.
* @param array or string $paths Array of style paths, relative to current root directory * @param array or string $paths Array of style paths, relative to current root directory
* @param string $template_path Path to templates, relative to style directory. Default (template/).
* @return phpbb_template $this * @return phpbb_template $this
*/ */
public function set_custom_style($names, $paths, $template_path = 'template/') public function set_custom_style($names, $paths)
{ {
if (is_string($paths)) if (is_string($paths))
{ {
@ -252,14 +251,8 @@ class phpbb_template_twig implements phpbb_template
$names = array($names); $names = array($names);
} }
$style_paths = array();
foreach ($paths as $path)
{
$style_paths[] = $path . '/' . ltrim($template_path, '/');
}
// Set as __main__ namespace // Set as __main__ namespace
$this->twig->getLoader()->setPaths($style_paths); $this->twig->getLoader()->setPaths($paths);
// Add all namespaces for all extensions // Add all namespaces for all extensions
if ($this->extension_manager instanceof phpbb_extension_manager) if ($this->extension_manager instanceof phpbb_extension_manager)

View file

@ -46,7 +46,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
$this->setup_engine(array('tpl_allow_php' => true)); $this->setup_engine(array('tpl_allow_php' => true));
$this->template->set_custom_style('tests', $cache_dir, ''); $this->template->set_custom_style('tests', $cache_dir);
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php"); $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php");

View file

@ -107,6 +107,6 @@ Zeta test event in all',
dirname(__FILE__) . "/datasets/$dataset/" dirname(__FILE__) . "/datasets/$dataset/"
); );
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager);
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path), ''); $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
} }
} }

View file

@ -410,7 +410,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->setup_engine(array('tpl_allow_php' => true)); $this->setup_engine(array('tpl_allow_php' => true));
$this->template->set_custom_style('tests', $cache_dir, ''); $this->template->set_custom_style('tests', $cache_dir);
$this->run_template('php.html', array(), array(), array(), 'test'); $this->run_template('php.html', array(), array(), array(), 'test');
} }

View file

@ -65,7 +65,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->template_path = $this->test_path . '/templates'; $this->template_path = $this->test_path . '/templates';
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context());
$this->template->set_custom_style('tests', $this->template_path, ''); $this->template->set_custom_style('tests', $this->template_path);
} }
protected function setUp() protected function setUp()

View file

@ -21,6 +21,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$this->template_path = $this->test_path . '/templates'; $this->template_path = $this->test_path . '/templates';
$this->parent_template_path = $this->test_path . '/parent_templates'; $this->parent_template_path = $this->test_path . '/parent_templates';
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
} }
} }