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 - 2020 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 ($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 ($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 ($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 ($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 ($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 ($variableName, $variableGroup = 'general');
104 * Assign a given congfiguration variable with a value
106 * @param $variableName The configuration variable we want to assign
109 function assignConfigVariable ($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 ($templateName, $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 ($rawCode, $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 ($oldName, $newName);
163 * Renders the given XML content
165 * @param $content Valid XML content or if not set the current loaded raw content
167 * @throws XmlParserException If an XML error was found
169 function renderXmlContent ($content = NULL);
172 * Enables or disables language support
174 * @param $languageSupport New language support setting
177 function enableLanguageSupport ($languageSupport = true);
180 * Checks whether language support is enabled
182 * @return $languageSupport Whether language support is enabled or disabled
184 function isLanguageSupportEnabled ();
187 * Enables or disables XML compacting
189 * @param $xmlCompacting New XML compacting setting
192 function enableXmlCompacting ($xmlCompacting = true);
195 * Checks whether XML compacting is enabled
197 * @return $xmlCompacting Whether XML compacting is enabled or disabled
199 function isXmlCompactingEnabled ();
202 * Removes all comments, tabs and new-line charcters to compact the content
204 * @param $uncompactedContent The uncompacted content
205 * @return $compactedContent The compacted content
207 function compactContent ($uncompactedContent);
210 * Getter for given variable group
212 * @param $variableGroup Variable group to check
213 * @return $varStack Found variable group
215 function getVarStack ($variableGroup);
218 * Settter for variable group
220 * @param $groupName Name of variable group
221 * @param $add Whether add this group
224 function setVariableGroup ($groupName, $add = true);
227 * Getter for template type
229 * @return $templateType The current template's type
231 function getTemplateType ();
234 * Getter for base path
236 * @return $templateBasePath The relative base path for all templates
238 function getTemplateBasePath ();
241 * Getter for generic base path
243 * @return $templateBasePath The relative base path for all templates
245 function getGenericBasePath ();
248 * Getter for template extension
250 * @return $templateExtension The file extension for all uncompiled
253 function getRawTemplateExtension ();
256 * Getter for code-template extension
258 * @return $codeExtension The file extension for all code-
261 function getCodeTemplateExtension ();
264 * Getter for raw template data
266 * @return $rawTemplateData The raw data from the template
268 function getRawTemplateData ();
271 * Assigns a lot variables into the stack of currently loaded template.
272 * This method should only be used in very rare circumstances, e.g. when
273 * you have to copy a whole set of variables into the template engine.
274 * Before you use this method, please make sure you have considered all
275 * other possiblities.
277 * @param $variables An array with variables to be assigned
280 function assignMultipleVariables (array $variables);
283 * Getter for variable group array
285 * @return $variableGroups All variable groups
287 function getVariableGroups ();