3 namespace Org\Mxchange\CoreFramework\Template;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7 use Org\Mxchange\CoreFramework\Response\Responseable;
10 * An interface for template engines
12 * @author Roland Haeder <webmaster@shipsimu.org>
14 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
15 * @license GNU GPL 3.0 or any newer version
16 * @link http://www.shipsimu.org
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 interface CompileableTemplate extends FrameworkInterface {
33 * Assign variables for templates
35 * @param $variableName The "variable" we want to assign
36 * @param $value The value we want to store in the variable
39 function assignVariable (string $variableName, $value);
42 * Load a specified HTML template into the engine
44 * @param $template The web template we shall load which is located in
48 function loadHtmlTemplate (string $template);
51 * Load a specified code template into the engine for later compilation
52 * with other code/web/email templates.
54 * @param $template The code template we shall load which is
55 * located in "html" by default
58 function loadCodeTemplate (string $template);
61 * Load a specified email template into the engine for later compilation
62 * with other code/web/email templates.
64 * @param $template The email template we shall load which is
65 * located in "html" by default
68 function loadEmailTemplate (string $template);
71 * Compile all variables by inserting their respective values
75 function compileVariables ();
79 * Compile all required code/web/email-templates into the current one
83 function compileTemplate ();
86 * Adds a variable to current group
88 * @param $variableName Variable to set
89 * @param $value Value to store in variable
92 function addGroupVariable (string $variableName, $value);
95 * Removes a given variable
97 * @param $variableName The variable we are looking for
98 * @param $variableGroup Name of variable group (default: 'general')
101 function removeVariable (string $variableName, string $variableGroup = 'general');
104 * Assign a given congfiguration variable with a value
106 * @param $variableName The configuration variable we want to assign
109 function assignConfigVariable (string $variableName);
112 * Compiles configuration place-holders in all variables. This 'walks'
113 * through the variable stack 'general'. It interprets all values from that
114 * variables as configuration entries after compiling them.
118 function compileConfigInVariables ();
121 * Assigns the last loaded raw template content with a given variable
123 * @param $templateName Name of the template we want to assign
124 * @param $variableName Name of the variable we want to assign
127 function assignTemplateWithVariable (string $templateName, string $variableName);
130 * Transfers the content of this template engine to a given response instance
132 * @param $responseInstance An instance of a Responseable class
135 function transferToResponse (Responseable $responseInstance);
138 * Assigns all the application data with template variables
142 function assignApplicationData ();
145 * "Compiles" a variable by replacing {?var?} with it's content
147 * @param $rawCode Raw code to compile
148 * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: false)
149 * @return $rawCode Compile code with inserted variable value
151 function compileRawCode (string $rawCode, bool $setMatchAsCode = false);
154 * Renames a variable in code and in stack
156 * @param $oldName Old name of variable
157 * @param $newName New name of variable
160 function renameVariable (string $oldName, string $newName);
163 * Enables or disables language support
165 * @param $languageSupport New language support setting
168 function enableLanguageSupport (bool $languageSupport = true);
171 * Checks whether language support is enabled
173 * @return $languageSupport Whether language support is enabled or disabled
175 function isLanguageSupportEnabled ();
178 * Getter for given variable group
180 * @param $variableGroup Variable group to check
181 * @return $varStack Found variable group
183 function getVarStack (string $variableGroup);
186 * Settter for variable group
188 * @param $groupName Name of variable group
189 * @param $add Whether add this group
192 function setVariableGroup (string $groupName, bool $add = true);
195 * Getter for template type
197 * @return $templateType The current template's type
199 function getTemplateType ();
202 * Getter for base path
204 * @return $templateBasePath The relative base path for all templates
206 function getTemplateBasePath ();
209 * Getter for generic base path
211 * @return $templateBasePath The relative base path for all templates
213 function getGenericBasePath ();
216 * Getter for template extension
218 * @return $templateExtension The file extension for all uncompiled
221 function getRawTemplateExtension ();
224 * Getter for code-template extension
226 * @return $codeExtension The file extension for all code-
229 function getCodeTemplateExtension ();
232 * Getter for raw template data
234 * @return $rawTemplateData The raw data from the template
236 function getRawTemplateData ();
239 * Assigns a lot variables into the stack of currently loaded template.
240 * This method should only be used in very rare circumstances, e.g. when
241 * you have to copy a whole set of variables into the template engine.
242 * Before you use this method, please make sure you have considered all
243 * other possiblities.
245 * @param $variables An array with variables to be assigned
248 function assignMultipleVariables (array $variables);
251 * Getter for variable group array
253 * @return $variableGroups All variable groups
255 function getVariableGroups ();