3 namespace Org\Mxchange\CoreFramework\Template;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
8 use Org\Mxchange\CoreFramework\Response\Responseable;
11 * An interface for template engines
13 * @author Roland Haeder <webmaster@shipsimu.org>
15 <<<<<<< HEAD:framework/main/interfaces/template/class_CompileableTemplate.php
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
19 >>>>>>> Some updates::inc/main/interfaces/template/class_CompileableTemplate.php
20 * @license GNU GPL 3.0 or any newer version
21 * @link http://www.shipsimu.org
23 * This program is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 interface CompileableTemplate extends FrameworkInterface {
38 * Assign variables for templates
40 * @param $variableName The "variable" we want to assign
41 * @param $value The value we want to store in the variable
44 function assignVariable ($variableName, $value);
47 * Load a specified HTML template into the engine
49 * @param $template The web template we shall load which is located in
53 function loadHtmlTemplate ($template);
56 * Load a specified code template into the engine for later compilation
57 * with other code/web/email templates.
59 * @param $template The code template we shall load which is
60 * located in "html" by default
63 function loadCodeTemplate ($template);
66 * Load a specified email template into the engine for later compilation
67 * with other code/web/email templates.
69 * @param $template The email template we shall load which is
70 * located in "html" by default
73 function loadEmailTemplate ($template);
76 * Compile all variables by inserting their respective values
80 function compileVariables ();
84 * Compile all required code/web/email-templates into the current one
88 function compileTemplate ();
91 * Adds a variable to current group
93 * @param $variableName Variable to set
94 * @param $value Value to store in variable
97 function addGroupVariable ($variableName, $value);
100 * Removes a given variable
102 * @param $variableName The variable we are looking for
103 * @param $variableGroup Name of variable group (default: 'general')
106 function removeVariable ($variableName, $variableGroup = 'general');
109 * Assign a given congfiguration variable with a value
111 * @param $variableName The configuration variable we want to assign
114 function assignConfigVariable ($variableName);
117 * Compiles configuration place-holders in all variables. This 'walks'
118 * through the variable stack 'general'. It interprets all values from that
119 * variables as configuration entries after compiling them.
123 function compileConfigInVariables ();
126 * Assigns the last loaded raw template content with a given variable
128 * @param $templateName Name of the template we want to assign
129 * @param $variableName Name of the variable we want to assign
132 function assignTemplateWithVariable ($templateName, $variableName);
135 * Transfers the content of this template engine to a given response instance
137 * @param $responseInstance An instance of a Responseable class
140 function transferToResponse (Responseable $responseInstance);
143 * Assigns all the application data with template variables
145 * @param $applicationInstance A manageable application instance
148 function assignApplicationData (ManageableApplication $applicationInstance);
151 * "Compiles" a variable by replacing {?var?} with it's content
153 * @param $rawCode Raw code to compile
154 * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: false)
155 * @return $rawCode Compile code with inserted variable value
157 function compileRawCode ($rawCode, $setMatchAsCode = false);
160 * Renames a variable in code and in stack
162 * @param $oldName Old name of variable
163 * @param $newName New name of variable
166 function renameVariable ($oldName, $newName);
169 * Renders the given XML content
171 * @param $content Valid XML content or if not set the current loaded raw content
173 * @throws XmlParserException If an XML error was found
175 function renderXmlContent ($content = NULL);
178 * Enables or disables language support
180 * @param $languageSupport New language support setting
183 function enableLanguageSupport ($languageSupport = true);
186 * Checks whether language support is enabled
188 * @return $languageSupport Whether language support is enabled or disabled
190 function isLanguageSupportEnabled ();
193 * Enables or disables XML compacting
195 * @param $xmlCompacting New XML compacting setting
198 function enableXmlCompacting ($xmlCompacting = true);
201 * Checks whether XML compacting is enabled
203 * @return $xmlCompacting Whether XML compacting is enabled or disabled
205 function isXmlCompactingEnabled ();
208 * Removes all comments, tabs and new-line charcters to compact the content
210 * @param $uncompactedContent The uncompacted content
211 * @return $compactedContent The compacted content
213 function compactContent ($uncompactedContent);
216 * Getter for given variable group
218 * @param $variableGroup Variable group to check
219 * @return $varStack Found variable group
221 function getVarStack ($variableGroup);
224 * Settter for variable group
226 * @param $groupName Name of variable group
227 * @param $add Whether add this group
230 function setVariableGroup ($groupName, $add = true);
233 * Getter for template type
235 * @return $templateType The current template's type
237 function getTemplateType ();
240 * Getter for base path
242 * @return $templateBasePath The relative base path for all templates
244 function getTemplateBasePath ();
247 * Getter for generic base path
249 * @return $templateBasePath The relative base path for all templates
251 function getGenericBasePath ();
254 * Getter for template extension
256 * @return $templateExtension The file extension for all uncompiled
259 function getRawTemplateExtension ();
262 * Getter for code-template extension
264 * @return $codeExtension The file extension for all code-
267 function getCodeTemplateExtension ();
270 * Getter for raw template data
272 * @return $rawTemplateData The raw data from the template
274 function getRawTemplateData ();
277 * Assigns a lot variables into the stack of currently loaded template.
278 * This method should only be used in very rare circumstances, e.g. when
279 * you have to copy a whole set of variables into the template engine.
280 * Before you use this method, please make sure you have considered all
281 * other possiblities.
283 * @param $variables An array with variables to be assigned
286 function assignMultipleVariables (array $variables);
289 * Getter for variable group array
291 * @return $variableGroups All variable groups
293 function getVariableGroups ();