3 * An interface for template engines
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 interface CompileableTemplate extends FrameworkInterface {
26 * Assign variables for templates
28 * @param $variableName The "variable" we want to assign
29 * @param $value The value we want to store in the variable
32 function assignVariable ($variableName, $value);
35 * Load a specified HTML template into the engine
37 * @param $template The web template we shall load which is located in
41 function loadHtmlTemplate ($template);
44 * Load a specified code template into the engine for later compilation
45 * with other code/web/email templates.
47 * @param $template The code template we shall load which is
48 * located in "html" by default
51 function loadCodeTemplate ($template);
54 * Load a specified email template into the engine for later compilation
55 * with other code/web/email templates.
57 * @param $template The email template we shall load which is
58 * located in "html" by default
61 function loadEmailTemplate ($template);
64 * Compile all variables by inserting their respective values
68 function compileVariables ();
72 * Compile all required code/web/email-templates into the current one
76 function compileTemplate ();
79 * Adds a variable to current group
81 * @param $variableName Variable to set
82 * @param $value Value to store in variable
85 function addGroupVariable ($variableName, $value);
88 * Removes a given variable
90 * @param $variableName The variable we are looking for
91 * @param $variableGroup Name of variable group (default: 'general')
94 function removeVariable ($variableName, $variableGroup = 'general');
97 * Assign a given congfiguration variable with a value
99 * @param $variableName The configuration variable we want to assign
102 function assignConfigVariable ($variableName);
105 * Compiles configuration place-holders in all variables. This 'walks'
106 * through the variable stack 'general'. It interprets all values from that
107 * variables as configuration entries after compiling them.
111 function compileConfigInVariables ();
114 * Assigns the last loaded raw template content with a given variable
116 * @param $templateName Name of the template we want to assign
117 * @param $variableName Name of the variable we want to assign
120 function assignTemplateWithVariable ($templateName, $variableName);
123 * Transfers the content of this template engine to a given response instance
125 * @param $responseInstance An instance of a response class
128 function transferToResponse (Responseable $responseInstance);
131 * Assigns all the application data with template variables
133 * @param $applicationInstance A manageable application instance
136 function assignApplicationData (ManageableApplication $applicationInstance);
139 * "Compiles" a variable by replacing {?var?} with it's content
141 * @param $rawCode Raw code to compile
142 * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: FALSE)
143 * @return $rawCode Compile code with inserted variable value
145 function compileRawCode ($rawCode, $setMatchAsCode = FALSE);
148 * Renames a variable in code and in stack
150 * @param $oldName Old name of variable
151 * @param $newName New name of variable
154 function renameVariable ($oldName, $newName);
157 * Renders the given XML content
159 * @param $content Valid XML content or if not set the current loaded raw content
161 * @throws XmlParserException If an XML error was found
163 function renderXmlContent ($content = NULL);
166 * Enables or disables language support
168 * @param $languageSupport New language support setting
171 function enableLanguageSupport ($languageSupport = TRUE);
174 * Checks whether language support is enabled
176 * @return $languageSupport Whether language support is enabled or disabled
178 function isLanguageSupportEnabled ();
181 * Enables or disables XML compacting
183 * @param $xmlCompacting New XML compacting setting
186 function enableXmlCompacting ($xmlCompacting = TRUE);
189 * Checks whether XML compacting is enabled
191 * @return $xmlCompacting Whether XML compacting is enabled or disabled
193 function isXmlCompactingEnabled ();
196 * Removes all comments, tabs and new-line charcters to compact the content
198 * @param $uncompactedContent The uncompacted content
199 * @return $compactedContent The compacted content
201 function compactContent ($uncompactedContent);
204 * Getter for given variable group
206 * @param $variableGroup Variable group to check
207 * @return $varStack Found variable group
209 function getVarStack ($variableGroup);
212 * Settter for variable group
214 * @param $groupName Name of variable group
215 * @param $add Whether add this group
218 function setVariableGroup ($groupName, $add = TRUE);
221 * Getter for template type
223 * @return $templateType The current template's type
225 function getTemplateType ();
228 * Getter for base path
230 * @return $templateBasePath The relative base path for all templates
232 function getTemplateBasePath ();
235 * Getter for generic base path
237 * @return $templateBasePath The relative base path for all templates
239 function getGenericBasePath ();
242 * Getter for template extension
244 * @return $templateExtension The file extension for all uncompiled
247 function getRawTemplateExtension ();
250 * Getter for code-template extension
252 * @return $codeExtension The file extension for all code-
255 function getCodeTemplateExtension ();
258 * Getter for raw template data
260 * @return $rawTemplateData The raw data from the template
262 function getRawTemplateData ();
265 * Assigns a lot variables into the stack of currently loaded template.
266 * This method should only be used in very rare circumstances, e.g. when
267 * you have to copy a whole set of variables into the template engine.
268 * Before you use this method, please make sure you have considered all
269 * other possiblities.
271 * @param $variables An array with variables to be assigned
274 function assignMultipleVariables (array $variables);
277 * Getter for variable group array
279 * @return $variableGroups All variable groups
281 function getVariableGroups ();