3 namespace CoreFramework\Template;
5 // Import framework stuff
6 use CoreFramework\Generic\FrameworkInterface;
7 use CoreFramework\Manager\ManageableApplication;
8 use CoreFramework\Response\Responseable;
11 * An interface for template engines
13 * @author Roland Haeder <webmaster@shipsimu.org>
15 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16 * @license GNU GPL 3.0 or any newer version
17 * @link http://www.shipsimu.org
19 * This program is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 interface CompileableTemplate extends FrameworkInterface {
34 * Assign variables for templates
36 * @param $variableName The "variable" we want to assign
37 * @param $value The value we want to store in the variable
40 function assignVariable ($variableName, $value);
43 * Load a specified HTML template into the engine
45 * @param $template The web template we shall load which is located in
49 function loadHtmlTemplate ($template);
52 * Load a specified code template into the engine for later compilation
53 * with other code/web/email templates.
55 * @param $template The code template we shall load which is
56 * located in "html" by default
59 function loadCodeTemplate ($template);
62 * Load a specified email template into the engine for later compilation
63 * with other code/web/email templates.
65 * @param $template The email template we shall load which is
66 * located in "html" by default
69 function loadEmailTemplate ($template);
72 * Compile all variables by inserting their respective values
76 function compileVariables ();
80 * Compile all required code/web/email-templates into the current one
84 function compileTemplate ();
87 * Adds a variable to current group
89 * @param $variableName Variable to set
90 * @param $value Value to store in variable
93 function addGroupVariable ($variableName, $value);
96 * Removes a given variable
98 * @param $variableName The variable we are looking for
99 * @param $variableGroup Name of variable group (default: 'general')
102 function removeVariable ($variableName, $variableGroup = 'general');
105 * Assign a given congfiguration variable with a value
107 * @param $variableName The configuration variable we want to assign
110 function assignConfigVariable ($variableName);
113 * Compiles configuration place-holders in all variables. This 'walks'
114 * through the variable stack 'general'. It interprets all values from that
115 * variables as configuration entries after compiling them.
119 function compileConfigInVariables ();
122 * Assigns the last loaded raw template content with a given variable
124 * @param $templateName Name of the template we want to assign
125 * @param $variableName Name of the variable we want to assign
128 function assignTemplateWithVariable ($templateName, $variableName);
131 * Transfers the content of this template engine to a given response instance
133 * @param $responseInstance An instance of a Responseable class
136 function transferToResponse (Responseable $responseInstance);
139 * Assigns all the application data with template variables
141 * @param $applicationInstance A manageable application instance
144 function assignApplicationData (ManageableApplication $applicationInstance);
147 * "Compiles" a variable by replacing {?var?} with it's content
149 * @param $rawCode Raw code to compile
150 * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: FALSE)
151 * @return $rawCode Compile code with inserted variable value
153 function compileRawCode ($rawCode, $setMatchAsCode = FALSE);
156 * Renames a variable in code and in stack
158 * @param $oldName Old name of variable
159 * @param $newName New name of variable
162 function renameVariable ($oldName, $newName);
165 * Renders the given XML content
167 * @param $content Valid XML content or if not set the current loaded raw content
169 * @throws XmlParserException If an XML error was found
171 function renderXmlContent ($content = NULL);
174 * Enables or disables language support
176 * @param $languageSupport New language support setting
179 function enableLanguageSupport ($languageSupport = TRUE);
182 * Checks whether language support is enabled
184 * @return $languageSupport Whether language support is enabled or disabled
186 function isLanguageSupportEnabled ();
189 * Enables or disables XML compacting
191 * @param $xmlCompacting New XML compacting setting
194 function enableXmlCompacting ($xmlCompacting = TRUE);
197 * Checks whether XML compacting is enabled
199 * @return $xmlCompacting Whether XML compacting is enabled or disabled
201 function isXmlCompactingEnabled ();
204 * Removes all comments, tabs and new-line charcters to compact the content
206 * @param $uncompactedContent The uncompacted content
207 * @return $compactedContent The compacted content
209 function compactContent ($uncompactedContent);
212 * Getter for given variable group
214 * @param $variableGroup Variable group to check
215 * @return $varStack Found variable group
217 function getVarStack ($variableGroup);
220 * Settter for variable group
222 * @param $groupName Name of variable group
223 * @param $add Whether add this group
226 function setVariableGroup ($groupName, $add = TRUE);
229 * Getter for template type
231 * @return $templateType The current template's type
233 function getTemplateType ();
236 * Getter for base path
238 * @return $templateBasePath The relative base path for all templates
240 function getTemplateBasePath ();
243 * Getter for generic base path
245 * @return $templateBasePath The relative base path for all templates
247 function getGenericBasePath ();
250 * Getter for template extension
252 * @return $templateExtension The file extension for all uncompiled
255 function getRawTemplateExtension ();
258 * Getter for code-template extension
260 * @return $codeExtension The file extension for all code-
263 function getCodeTemplateExtension ();
266 * Getter for raw template data
268 * @return $rawTemplateData The raw data from the template
270 function getRawTemplateData ();
273 * Assigns a lot variables into the stack of currently loaded template.
274 * This method should only be used in very rare circumstances, e.g. when
275 * you have to copy a whole set of variables into the template engine.
276 * Before you use this method, please make sure you have considered all
277 * other possiblities.
279 * @param $variables An array with variables to be assigned
282 function assignMultipleVariables (array $variables);
285 * Getter for variable group array
287 * @return $variableGroups All variable groups
289 function getVariableGroups ();