aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template/twig/twig.php
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-08-28 15:21:35 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-08-28 15:23:38 -0500
commitaae7677d71112e468b56be7e10d16f3b381fcad7 (patch)
tree0140929b3ddc902fb7f072af2425040d7a43d814 /phpBB/phpbb/template/twig/twig.php
parent68ed2b603556dd509172a2c061622ded693e88db (diff)
downloadforums-aae7677d71112e468b56be7e10d16f3b381fcad7.tar
forums-aae7677d71112e468b56be7e10d16f3b381fcad7.tar.gz
forums-aae7677d71112e468b56be7e10d16f3b381fcad7.tar.bz2
forums-aae7677d71112e468b56be7e10d16f3b381fcad7.tar.xz
forums-aae7677d71112e468b56be7e10d16f3b381fcad7.zip
[ticket/11628] Create base template class with common functions
E.g. assign_vars PHPBB3-11628
Diffstat (limited to 'phpBB/phpbb/template/twig/twig.php')
-rw-r--r--phpBB/phpbb/template/twig/twig.php180
1 files changed, 1 insertions, 179 deletions
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index a96bdcbdb9..1ed89d3ccc 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -19,16 +19,9 @@ if (!defined('IN_PHPBB'))
* Twig Template class.
* @package phpBB3
*/
-class phpbb_template_twig implements phpbb_template
+class phpbb_template_twig extends phpbb_template_base
{
/**
- * Template context.
- * Stores template data used during template rendering.
- * @var phpbb_template_context
- */
- protected $context;
-
- /**
* Path of the cache directory for the template
*
* Cannot be changed during runtime.
@@ -76,13 +69,6 @@ class phpbb_template_twig implements phpbb_template
protected $twig;
/**
- * Array of filenames assigned to set_filenames
- *
- * @var array
- */
- protected $filenames = array();
-
- /**
* Constructor.
*
* @param string $phpbb_root_path phpBB root path
@@ -154,19 +140,6 @@ class phpbb_template_twig implements phpbb_template
}
/**
- * Sets the template filenames for handles.
- *
- * @param array $filename_array Should be a hash of handle => filename pairs.
- * @return phpbb_template $this
- */
- public function set_filenames(array $filename_array)
- {
- $this->filenames = array_merge($this->filenames, $filename_array);
-
- return $this;
- }
-
- /**
* Get the style tree of the style preferred by the current user
*
* @return array Style tree, most specific first
@@ -276,31 +249,6 @@ class phpbb_template_twig implements phpbb_template
}
/**
- * Clears all variables and blocks assigned to this template.
- *
- * @return phpbb_template $this
- */
- public function destroy()
- {
- $this->context->clear();
-
- return $this;
- }
-
- /**
- * Reset/empty complete block
- *
- * @param string $blockname Name of block to destroy
- * @return phpbb_template $this
- */
- public function destroy_block_vars($blockname)
- {
- $this->context->destroy_block_vars($blockname);
-
- return $this;
- }
-
- /**
* Display a template for provided handle.
*
* The template will be loaded and compiled, if necessary, first.
@@ -324,28 +272,6 @@ class phpbb_template_twig implements phpbb_template
}
/**
- * Calls hook if any is defined.
- *
- * @param string $handle Template handle being displayed.
- * @param string $method Method name of the caller.
- */
- protected function call_hook($handle, $method)
- {
- global $phpbb_hook;
-
- if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this))
- {
- if ($phpbb_hook->hook_return(array(__CLASS__, $method)))
- {
- $result = $phpbb_hook->hook_return_result(array(__CLASS__, $method));
- return array($result);
- }
- }
-
- return false;
- }
-
- /**
* Display the handle and assign the output to a template variable
* or return the compiled result.
*
@@ -367,99 +293,6 @@ class phpbb_template_twig implements phpbb_template
}
/**
- * Assign key variable pairs from an array
- *
- * @param array $vararray A hash of variable name => value pairs
- * @return phpbb_template $this
- */
- public function assign_vars(array $vararray)
- {
- foreach ($vararray as $key => $val)
- {
- $this->assign_var($key, $val);
- }
-
- return $this;
- }
-
- /**
- * Assign a single scalar value to a single key.
- *
- * Value can be a string, an integer or a boolean.
- *
- * @param string $varname Variable name
- * @param string $varval Value to assign to variable
- * @return phpbb_template $this
- */
- public function assign_var($varname, $varval)
- {
- $this->context->assign_var($varname, $varval);
-
- return $this;
- }
-
- /**
- * Append text to the string value stored in a key.
- *
- * Text is appended using the string concatenation operator (.).
- *
- * @param string $varname Variable name
- * @param string $varval Value to append to variable
- * @return phpbb_template $this
- */
- public function append_var($varname, $varval)
- {
- $this->context->append_var($varname, $varval);
-
- return $this;
- }
-
- /**
- * Assign key variable pairs from an array to a specified block
- * @param string $blockname Name of block to assign $vararray to
- * @param array $vararray A hash of variable name => value pairs
- * @return phpbb_template $this
- */
- public function assign_block_vars($blockname, array $vararray)
- {
- $this->context->assign_block_vars($blockname, $vararray);
-
- return $this;
- }
-
- /**
- * Change already assigned key variable pair (one-dimensional - single loop entry)
- *
- * An example of how to use this function:
- * {@example alter_block_array.php}
- *
- * @param string $blockname the blockname, for example 'loop'
- * @param array $vararray the var array to insert/add or merge
- * @param mixed $key Key to search for
- *
- * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
- *
- * int: Position [the position to change or insert at directly given]
- *
- * If key is false the position is set to 0
- * If key is true the position is set to the last entry
- *
- * @param string $mode Mode to execute (valid modes are 'insert' and 'change')
- *
- * If insert, the vararray is inserted at the given position (position counting from zero).
- * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
- *
- * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
- * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
- *
- * @return bool false on error, true on success
- */
- public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')
- {
- return $this->context->alter_block_array($blockname, $vararray, $key, $mode);
- }
-
- /**
* Get template vars in a format Twig will use (from the context)
*
* @return array
@@ -484,17 +317,6 @@ class phpbb_template_twig implements phpbb_template
}
/**
- * Get a filename from the handle
- *
- * @param string $handle
- * @return string
- */
- protected function get_filename_from_handle($handle)
- {
- return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle;
- }
-
- /**
* Get path to template for handle (required for BBCode parser)
*
* @return string