Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\template; |
| 15 | |
| 16 | interface template |
| 17 | { |
| 18 | /** |
| 19 | * Sets the template filenames for handles. |
| 20 | * |
| 21 | * @param array $filename_array Should be a hash of handle => filename pairs. |
| 22 | * @return \phpbb\template\template $this |
| 23 | */ |
| 24 | public function set_filenames(array $filename_array); |
| 25 | |
| 26 | /** |
| 27 | * Get the style tree of the style preferred by the current user |
| 28 | * |
| 29 | * @return array Style tree, most specific first |
| 30 | */ |
| 31 | public function get_user_style(); |
| 32 | |
| 33 | /** |
| 34 | * Set style location based on (current) user's chosen style. |
| 35 | * |
| 36 | * @param array $style_directories The directories to add style paths for |
| 37 | * E.g. array('ext/foo/bar/styles', 'styles') |
| 38 | * Default: array('styles') (phpBB's style directory) |
| 39 | * @return \phpbb\template\template $this |
| 40 | */ |
| 41 | public function set_style($style_directories = array('styles')); |
| 42 | |
| 43 | /** |
| 44 | * Set custom style location (able to use directory outside of phpBB). |
| 45 | * |
| 46 | * Note: Templates are still compiled to phpBB's cache directory. |
| 47 | * |
| 48 | * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. |
| 49 | * @param string|array $paths Array of style paths, relative to current root directory |
| 50 | * @return \phpbb\template\template $this |
| 51 | */ |
| 52 | public function set_custom_style($names, $paths); |
| 53 | |
| 54 | /** |
| 55 | * Clears all variables and blocks assigned to this template. |
| 56 | * |
| 57 | * @return \phpbb\template\template $this |
| 58 | */ |
| 59 | public function destroy(); |
| 60 | |
| 61 | /** |
| 62 | * Reset/empty complete block |
| 63 | * |
| 64 | * @param string $blockname Name of block to destroy |
| 65 | * @return \phpbb\template\template $this |
| 66 | */ |
| 67 | public function destroy_block_vars($blockname); |
| 68 | |
| 69 | /** |
| 70 | * Display a template for provided handle. |
| 71 | * |
| 72 | * The template will be loaded and compiled, if necessary, first. |
| 73 | * |
| 74 | * This function calls hooks. |
| 75 | * |
| 76 | * @param string $handle Handle to display |
| 77 | * @return \phpbb\template\template $this |
| 78 | */ |
| 79 | public function display($handle); |
| 80 | |
| 81 | /** |
| 82 | * Display the handle and assign the output to a template variable |
| 83 | * or return the compiled result. |
| 84 | * |
| 85 | * @param string $handle Handle to operate on |
| 86 | * @param string $template_var Template variable to assign compiled handle to |
| 87 | * @param bool $return_content If true return compiled handle, otherwise assign to $template_var |
| 88 | * @return \phpbb\template\template|string if $return_content is true return string of the compiled handle, otherwise return $this |
| 89 | */ |
| 90 | public function assign_display($handle, $template_var = '', $return_content = true); |
| 91 | |
| 92 | /** |
| 93 | * Assign key variable pairs from an array |
| 94 | * |
| 95 | * @param array $vararray A hash of variable name => value pairs |
| 96 | * @return \phpbb\template\template $this |
| 97 | */ |
| 98 | public function assign_vars(array $vararray); |
| 99 | |
| 100 | /** |
| 101 | * Assign a single scalar value to a single key. |
| 102 | * |
| 103 | * Value can be a string, an integer or a boolean. |
| 104 | * |
| 105 | * @param string $varname Variable name |
| 106 | * @param mixed $varval Value to assign to variable |
| 107 | * @return \phpbb\template\template $this |
| 108 | */ |
| 109 | public function assign_var(string $varname, mixed $varval); |
| 110 | |
| 111 | /** |
| 112 | * Append text to the string value stored in a key. |
| 113 | * |
| 114 | * Text is appended using the string concatenation operator (.). |
| 115 | * |
| 116 | * @param string $varname Variable name |
| 117 | * @param string $varval Value to append to variable |
| 118 | * @return \phpbb\template\template $this |
| 119 | */ |
| 120 | public function append_var($varname, $varval); |
| 121 | |
| 122 | /** |
| 123 | * Retrieve multiple template values |
| 124 | * |
| 125 | * @param array $vararray An array with variable names |
| 126 | * @return array A hash of variable name => value pairs (value is null if not set) |
| 127 | */ |
| 128 | public function retrieve_vars(array $vararray); |
| 129 | |
| 130 | /** |
| 131 | * Retrieve a single scalar value from a single key. |
| 132 | * |
| 133 | * @param string $varname Variable name |
| 134 | * @return mixed Variable value, or null if not set |
| 135 | */ |
| 136 | public function retrieve_var($varname); |
| 137 | |
| 138 | /** |
| 139 | * Assign key variable pairs from an array to a specified block |
| 140 | * @param string $blockname Name of block to assign $vararray to |
| 141 | * @param array $vararray A hash of variable name => value pairs |
| 142 | * @return \phpbb\template\template $this |
| 143 | */ |
| 144 | public function assign_block_vars($blockname, array $vararray); |
| 145 | |
| 146 | /** |
| 147 | * Assign key variable pairs from an array to a whole specified block loop |
| 148 | * @param string $blockname Name of block to assign $block_vars_array to |
| 149 | * @param array $block_vars_array An array of hashes of variable name => value pairs |
| 150 | * @return \phpbb\template\template $this |
| 151 | */ |
| 152 | public function assign_block_vars_array($blockname, array $block_vars_array); |
| 153 | |
| 154 | /** |
| 155 | * Retrieve variable values from an specified block |
| 156 | * @param string $blockname Name of block to retrieve $vararray from |
| 157 | * @param array $vararray An array with variable names, empty array gets all vars |
| 158 | * @return array A hash of variable name => value pairs (value is null if not set) |
| 159 | */ |
| 160 | public function retrieve_block_vars($blockname, array $vararray); |
| 161 | |
| 162 | /** |
| 163 | * Change already assigned key variable pair (one-dimensional - single loop entry) |
| 164 | * |
| 165 | * An example of how to use this function: |
| 166 | * {@example alter_block_array.php} |
| 167 | * |
| 168 | * @param string $blockname the blockname, for example 'loop' |
| 169 | * @param array $vararray the var array to insert/add or merge |
| 170 | * @param mixed $key Key to search for |
| 171 | * |
| 172 | * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] |
| 173 | * |
| 174 | * int: Position [the position to change or insert at directly given] |
| 175 | * |
| 176 | * If key is false the position is set to 0 |
| 177 | * If key is true the position is set to the last entry |
| 178 | * |
| 179 | * @param string $mode Mode to execute (valid modes are 'insert', 'change' and 'delete') |
| 180 | * |
| 181 | * If insert, the vararray is inserted at the given position (position counting from zero). |
| 182 | * 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). |
| 183 | * If delete, the vararray is ignored, and the block at the given position (counting from zero) is removed. |
| 184 | * |
| 185 | * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) |
| 186 | * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) |
| 187 | * |
| 188 | * @return bool false on error, true on success |
| 189 | */ |
| 190 | public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert'); |
| 191 | |
| 192 | /** |
| 193 | * Find the index for a specified key in the innermost specified block |
| 194 | * |
| 195 | * @param string $blockname the blockname, for example 'loop' |
| 196 | * @param mixed $key Key to search for |
| 197 | * |
| 198 | * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] |
| 199 | * |
| 200 | * int: Position [the position to search for] |
| 201 | * |
| 202 | * If key is false the position is set to 0 |
| 203 | * If key is true the position is set to the last entry |
| 204 | * |
| 205 | * @return mixed false if not found, index position otherwise; be sure to test with === |
| 206 | */ |
| 207 | public function find_key_index($blockname, $key); |
| 208 | |
| 209 | /** |
| 210 | * Get path to template for handle (required for BBCode parser) |
| 211 | * |
| 212 | * @param string $handle Handle to retrieve the source file |
| 213 | * @return string |
| 214 | */ |
| 215 | public function get_source_file_for_handle($handle); |
| 216 | } |