aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-07-24 12:24:35 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-07-24 12:24:35 -0500
commit5d1afb453211d42a8deacb66684c136385918192 (patch)
treedec14540ed07ca03bf223738aee405e4b604cd99 /phpBB
parent44a82dd0837a4693b6a4a410c21c438f244094d3 (diff)
downloadforums-5d1afb453211d42a8deacb66684c136385918192.tar
forums-5d1afb453211d42a8deacb66684c136385918192.tar.gz
forums-5d1afb453211d42a8deacb66684c136385918192.tar.bz2
forums-5d1afb453211d42a8deacb66684c136385918192.tar.xz
forums-5d1afb453211d42a8deacb66684c136385918192.zip
[ticket/11628] Remove phpbb_style (move methods to phpbb_template)
PHPBB3-11628
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/adm/index.php2
-rw-r--r--phpBB/adm/swatch.php2
-rw-r--r--phpBB/common.php1
-rw-r--r--phpBB/config/services.yml11
-rw-r--r--phpBB/includes/bbcode.php3
-rw-r--r--phpBB/includes/functions_module.php6
-rw-r--r--phpBB/install/index.php3
-rw-r--r--phpBB/install/install_update.php4
-rw-r--r--phpBB/phpbb/controller/resolver.php16
-rw-r--r--phpBB/phpbb/style/style.php175
-rw-r--r--phpBB/phpbb/template/template.php30
-rw-r--r--phpBB/phpbb/template/twig/twig.php107
-rw-r--r--phpBB/phpbb/user.php4
13 files changed, 156 insertions, 208 deletions
diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php
index 8cd1967c75..3f29072899 100644
--- a/phpBB/adm/index.php
+++ b/phpBB/adm/index.php
@@ -50,7 +50,7 @@ $module_id = request_var('i', '');
$mode = request_var('mode', '');
// Set custom style for admin area
-$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
+$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
$template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php
index 3ae38d0d8b..70441ffeed 100644
--- a/phpBB/adm/swatch.php
+++ b/phpBB/adm/swatch.php
@@ -22,7 +22,7 @@ $auth->acl($user->data);
$user->setup();
// Set custom template for admin area
-$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
+$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
$template->set_filenames(array(
'body' => 'colour_swatch.html')
diff --git a/phpBB/common.php b/phpBB/common.php
index 962a1f951f..6a1f307d64 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -121,7 +121,6 @@ $phpbb_extension_manager = $phpbb_container->get('ext.manager');
$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
$template = $phpbb_container->get('template');
-$phpbb_style = $phpbb_container->get('style');
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 7acc44f24d..d0753322da 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -98,7 +98,7 @@ services:
arguments:
- @user
- @service_container
- - @style
+ - @template
cron.task_collection:
class: phpbb_di_service_collection
@@ -251,15 +251,6 @@ services:
request:
class: phpbb_request
- style:
- class: phpbb_style
- arguments:
- - %core.root_path%
- - %core.php_ext%
- - @config
- - @user
- - @template
-
template:
class: phpbb_template_twig
arguments:
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 9b1939030a..2fa6a8b099 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -133,8 +133,7 @@ class bbcode
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
- $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template);
- $style->set_style();
+ $template->set_style();
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
}
diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php
index 99c24fcb19..a5ece1ecac 100644
--- a/phpBB/includes/functions_module.php
+++ b/phpBB/includes/functions_module.php
@@ -455,7 +455,7 @@ class p_master
*/
function load_active($mode = false, $module_url = false, $execute_module = true)
{
- global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $phpbb_style;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $template;
$module_path = $this->include_path . $this->p_class;
$icat = request_var('icat', '');
@@ -508,7 +508,7 @@ class p_master
if (is_dir($module_style_dir))
{
- $phpbb_style->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), '');
+ $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), '');
}
}
@@ -537,7 +537,7 @@ class p_master
if (is_dir($phpbb_root_path . $module_style_dir))
{
- $phpbb_style->set_style(array($module_style_dir, 'styles'));
+ $template->set_style(array($module_style_dir, 'styles'));
}
}
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 46660723ba..fd0d8a2d48 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -213,8 +213,7 @@ $config = new phpbb_config(array(
));
$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
-$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template);
-$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
+$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
$template->assign_var('T_ASSETS_PATH', '../assets');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index df9b6c1c7e..51fbd1975c 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -71,7 +71,7 @@ class install_update extends module
function main($mode, $sub)
{
- global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language;
+ global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language;
global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container;
// Create a normal container now
@@ -138,7 +138,7 @@ class install_update extends module
}
// Set custom template again. ;)
- $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
+ $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
$template->assign_vars(array(
'S_USER_LANG' => $user->lang['USER_LANG'],
diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php
index 95dfc8da8e..850df84a0f 100644
--- a/phpBB/phpbb/controller/resolver.php
+++ b/phpBB/phpbb/controller/resolver.php
@@ -38,23 +38,23 @@ class phpbb_controller_resolver implements ControllerResolverInterface
protected $container;
/**
- * phpbb_style object
- * @var phpbb_style
+ * phpbb_template object
+ * @var phpbb_template
*/
- protected $style;
+ protected $template;
/**
* Construct method
*
* @param phpbb_user $user User Object
* @param ContainerInterface $container ContainerInterface object
- * @param phpbb_style $style
+ * @param phpbb_template_interface $template
*/
- public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style = null)
+ public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_template $template = null)
{
$this->user = $user;
$this->container = $container;
- $this->style = $style;
+ $this->template = $template;
}
/**
@@ -96,13 +96,13 @@ class phpbb_controller_resolver implements ControllerResolverInterface
$controller_dir = explode('_', get_class($controller_object));
// 0 phpbb, 1 ext, 2 vendor, 3 extension name, ...
- if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext')
+ if (!is_null($this->template) && isset($controller_dir[3]) && $controller_dir[1] === 'ext')
{
$controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles';
if (is_dir($controller_style_dir))
{
- $this->style->set_style(array($controller_style_dir, 'styles'));
+ $this->template->set_style(array($controller_style_dir, 'styles'));
}
}
diff --git a/phpBB/phpbb/style/style.php b/phpBB/phpbb/style/style.php
deleted file mode 100644
index 283e3015ca..0000000000
--- a/phpBB/phpbb/style/style.php
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-/**
-*
-* @package phpBB3
-* @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
-* Base Style class.
-* @package phpBB3
-*/
-class phpbb_style
-{
- /**
- * Template class.
- * Handles everything related to templates.
- * @var phpbb_template
- */
- private $template;
-
- /**
- * phpBB root path
- * @var string
- */
- private $phpbb_root_path;
-
- /**
- * PHP file extension
- * @var string
- */
- private $php_ext;
-
- /**
- * phpBB config instance
- * @var phpbb_config
- */
- private $config;
-
- /**
- * Current user
- * @var phpbb_user
- */
- private $user;
-
- /**
- * Constructor.
- *
- * @param string $phpbb_root_path phpBB root path
- * @param user $user current user
- * @param phpbb_template $template template
- */
- public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template $template)
- {
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
- $this->config = $config;
- $this->user = $user;
- $this->template = $template;
- }
-
- /**
- * Get the style tree of the style preferred by the current user
- *
- * @return array Style tree, most specific first
- */
- public function get_user_style()
- {
- $style_list = array(
- $this->user->style['style_path'],
- );
-
- if ($this->user->style['style_parent_id'])
- {
- $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree'])));
- }
-
- return $style_list;
- }
-
- /**
- * Set style location based on (current) user's chosen style.
- *
- * @param array $style_directories The directories to add style paths for
- * E.g. array('ext/foo/bar/styles', 'styles')
- * Default: array('styles') (phpBB's style directory)
- * @return bool true
- */
- public function set_style($style_directories = array('styles'))
- {
- $this->names = $this->get_user_style();
-
- $paths = array();
- foreach ($style_directories as $directory)
- {
- foreach ($this->names as $name)
- {
- $path = $this->get_style_path($name, $directory);
-
- if (is_dir($path))
- {
- $paths[] = $path;
- }
- }
- }
-
- $new_paths = array();
- foreach ($paths as $path)
- {
- $new_paths[] = $path . '/template/';
- }
-
- $this->template->set_style_names($this->names, $new_paths, ($style_directories === array('styles')));
-
- return true;
- }
-
- /**
- * Set custom style location (able to use directory outside of phpBB).
- *
- * Note: Templates are still compiled to phpBB's cache directory.
- *
- * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
- * @param array or string $paths Array of style paths, relative to current root directory
- * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used.
- * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
- * @return bool true
- */
- public function set_custom_style($name, $paths, $names = array(), $template_path = false)
- {
- if (is_string($paths))
- {
- $paths = array($paths);
- }
-
- if (empty($names))
- {
- $names = array($name);
- }
- $this->names = $names;
-
- $new_paths = array();
- foreach ($paths as $path)
- {
- $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/');
- }
-
- $this->template->set_style_names($names, $new_paths);
-
- return true;
- }
-
- /**
- * Get location of style directory for specific style_path
- *
- * @param string $path Style path, such as "prosilver"
- * @param string $style_base_directory The base directory the style is in
- * E.g. 'styles', 'ext/foo/bar/styles'
- * Default: 'styles'
- * @return string Path to style directory, relative to current path
- */
- public function get_style_path($path, $style_base_directory = 'styles')
- {
- return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path;
- }
-}
diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php
index 89a01e924d..537c4eaf01 100644
--- a/phpBB/phpbb/template/template.php
+++ b/phpBB/phpbb/template/template.php
@@ -34,6 +34,36 @@ interface phpbb_template
public function set_filenames(array $filename_array);
/**
+ * Get the style tree of the style preferred by the current user
+ *
+ * @return array Style tree, most specific first
+ */
+ public function get_user_style();
+
+ /**
+ * Set style location based on (current) user's chosen style.
+ *
+ * @param array $style_directories The directories to add style paths for
+ * E.g. array('ext/foo/bar/styles', 'styles')
+ * Default: array('styles') (phpBB's style directory)
+ * @return bool true
+ */
+ public function set_style($style_directories = array('styles'));
+
+ /**
+ * Set custom style location (able to use directory outside of phpBB).
+ *
+ * Note: Templates are still compiled to phpBB's cache directory.
+ *
+ * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
+ * @param array or string $paths Array of style paths, relative to current root directory
+ * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used.
+ * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
+ * @return bool true
+ */
+ public function set_custom_style($name, $paths, $names = array(), $template_path = false);
+
+ /**
* Sets the style names/paths corresponding to style hierarchy being compiled
* and/or rendered.
*
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 92a37d1634..92a52d26b8 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -178,6 +178,97 @@ class phpbb_template_twig implements phpbb_template
}
/**
+ * Get the style tree of the style preferred by the current user
+ *
+ * @return array Style tree, most specific first
+ */
+ public function get_user_style()
+ {
+ $style_list = array(
+ $this->user->style['style_path'],
+ );
+
+ if ($this->user->style['style_parent_id'])
+ {
+ $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree'])));
+ }
+
+ return $style_list;
+ }
+
+ /**
+ * Set style location based on (current) user's chosen style.
+ *
+ * @param array $style_directories The directories to add style paths for
+ * E.g. array('ext/foo/bar/styles', 'styles')
+ * Default: array('styles') (phpBB's style directory)
+ * @return bool true
+ */
+ public function set_style($style_directories = array('styles'))
+ {
+ $this->names = $this->get_user_style();
+
+ $paths = array();
+ foreach ($style_directories as $directory)
+ {
+ foreach ($this->names as $name)
+ {
+ $path = $this->get_style_path($name, $directory);
+
+ if (is_dir($path))
+ {
+ $paths[] = $path;
+ }
+ }
+ }
+
+ $new_paths = array();
+ foreach ($paths as $path)
+ {
+ $new_paths[] = $path . '/template/';
+ }
+
+ $this->set_style_names($this->names, $new_paths, ($style_directories === array('styles')));
+
+ return true;
+ }
+
+ /**
+ * Set custom style location (able to use directory outside of phpBB).
+ *
+ * Note: Templates are still compiled to phpBB's cache directory.
+ *
+ * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
+ * @param array or string $paths Array of style paths, relative to current root directory
+ * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used.
+ * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
+ * @return bool true
+ */
+ public function set_custom_style($name, $paths, $names = array(), $template_path = false)
+ {
+ if (is_string($paths))
+ {
+ $paths = array($paths);
+ }
+
+ if (empty($names))
+ {
+ $names = array($name);
+ }
+ $this->names = $names;
+
+ $new_paths = array();
+ foreach ($paths as $path)
+ {
+ $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/');
+ }
+
+ $this->set_style_names($names, $new_paths);
+
+ return true;
+ }
+
+ /**
* Sets the style names/paths corresponding to style hierarchy being compiled
* and/or rendered.
*
@@ -194,7 +285,7 @@ class phpbb_template_twig implements phpbb_template
// Set as __main__ namespace
$this->twig->getLoader()->setPaths($style_paths);
- // Core style namespace from phpbb_style::set_style()
+ // Core style namespace from this::set_style()
if ($is_core)
{
$this->twig->getLoader()->setPaths($style_paths, 'core');
@@ -462,4 +553,18 @@ class phpbb_template_twig implements phpbb_template
{
return $this->twig->getLoader()->getCacheKey($this->get_filename_from_handle($handle));
}
+
+ /**
+ * Get location of style directory for specific style_path
+ *
+ * @param string $path Style path, such as "prosilver"
+ * @param string $style_base_directory The base directory the style is in
+ * E.g. 'styles', 'ext/foo/bar/styles'
+ * Default: 'styles'
+ * @return string Path to style directory, relative to current path
+ */
+ protected function get_style_path($path, $style_base_directory = 'styles')
+ {
+ return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path;
+ }
}
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php
index 5530fe3f03..2828bab6a8 100644
--- a/phpBB/phpbb/user.php
+++ b/phpBB/phpbb/user.php
@@ -75,7 +75,7 @@ class phpbb_user extends phpbb_session
*/
function setup($lang_set = false, $style_id = false)
{
- global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
+ global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
global $phpbb_dispatcher;
if ($this->data['user_id'] != ANONYMOUS)
@@ -236,7 +236,7 @@ class phpbb_user extends phpbb_session
}
}
- $phpbb_style->set_style();
+ $template->set_style();
$this->img_lang = $this->lang_name;