Introduced namespaces:
[core.git] / inc / main / interfaces / template / class_CompileableTemplate.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Template;
4
5 // Load framework stuff
6 use CoreFramework\Generic\FrameworkInterface;
7
8 /**
9  * An interface for template engines
10  *
11  * @author              Roland Haeder <webmaster@shipsimu.org>
12  * @version             0.0.0
13  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
14  * @license             GNU GPL 3.0 or any newer version
15  * @link                http://www.shipsimu.org
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  */
30 interface CompileableTemplate extends FrameworkInterface {
31         /**
32          * Assign variables for templates
33          *
34          * @param       $variableName   The "variable" we want to assign
35          * @param       $value                  The value we want to store in the variable
36          * @return      void
37          */
38         function assignVariable ($variableName, $value);
39
40         /**
41          * Load a specified HTML template into the engine
42          *
43          * @param       $template       The web template we shall load which is located in
44          *                                              "html" by default
45          * @return      void
46          */
47         function loadHtmlTemplate ($template);
48
49         /**
50          * Load a specified code template into the engine for later compilation
51          * with other code/web/email templates.
52          *
53          * @param       $template       The code template we shall load which is
54          *                                              located in "html" by default
55          * @return      void
56          */
57         function loadCodeTemplate ($template);
58
59         /**
60          * Load a specified email template into the engine for later compilation
61          * with other code/web/email templates.
62          *
63          * @param       $template       The email template we shall load which is
64          *                                              located in "html" by default
65          * @return      void
66          */
67         function loadEmailTemplate ($template);
68
69         /**
70          * Compile all variables by inserting their respective values
71          *
72          * @return      void
73          */
74         function compileVariables ();
75
76
77         /**
78          * Compile all required code/web/email-templates into the current one
79          *
80          * @return      void
81          */
82         function compileTemplate ();
83
84         /**
85          * Adds a variable to current group
86          *
87          * @param       $variableName   Variable to set
88          * @param       $value                  Value to store in variable
89          * @return      void
90          */
91         function addGroupVariable ($variableName, $value);
92
93         /**
94          * Removes a given variable
95          *
96          * @param       $variableName   The variable we are looking for
97          * @param       $variableGroup  Name of variable group (default: 'general')
98          * @return      void
99          */
100         function removeVariable ($variableName, $variableGroup = 'general');
101
102         /**
103          * Assign a given congfiguration variable with a value
104          *
105          * @param       $variableName   The configuration variable we want to assign
106          * @return      void
107          */
108         function assignConfigVariable ($variableName);
109
110         /**
111          * Compiles configuration place-holders in all variables. This 'walks'
112          * through the variable stack 'general'. It interprets all values from that
113          * variables as configuration entries after compiling them.
114          *
115          * @return      void
116          */
117         function compileConfigInVariables ();
118
119         /**
120          * Assigns the last loaded raw template content with a given variable
121          *
122          * @param       $templateName   Name of the template we want to assign
123          * @param       $variableName   Name of the variable we want to assign
124          * @return      void
125          */
126         function assignTemplateWithVariable ($templateName, $variableName);
127
128         /**
129          * Transfers the content of this template engine to a given response instance
130          *
131          * @param       $responseInstance       An instance of a response class
132          * @return      void
133          */
134         function transferToResponse (Responseable $responseInstance);
135
136         /**
137          * Assigns all the application data with template variables
138          *
139          * @param       $applicationInstance    A manageable application instance
140          * @return      void
141          */
142         function assignApplicationData (ManageableApplication $applicationInstance);
143
144         /**
145          * "Compiles" a variable by replacing {?var?} with it's content
146          *
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
150          */
151         function compileRawCode ($rawCode, $setMatchAsCode = FALSE);
152
153         /**
154          * Renames a variable in code and in stack
155          *
156          * @param       $oldName        Old name of variable
157          * @param       $newName        New name of variable
158          * @return      void
159          */
160         function renameVariable ($oldName, $newName);
161
162         /**
163          * Renders the given XML content
164          *
165          * @param       $content        Valid XML content or if not set the current loaded raw content
166          * @return      void
167          * @throws      XmlParserException      If an XML error was found
168          */
169         function renderXmlContent ($content = NULL);
170
171         /**
172          * Enables or disables language support
173          *
174          * @param       $languageSupport        New language support setting
175          * @return      void
176          */
177         function enableLanguageSupport ($languageSupport = TRUE);
178
179         /**
180          * Checks whether language support is enabled
181          *
182          * @return      $languageSupport        Whether language support is enabled or disabled
183          */
184         function isLanguageSupportEnabled ();
185
186         /**
187          * Enables or disables XML compacting
188          *
189          * @param       $xmlCompacting  New XML compacting setting
190          * @return      void
191          */
192         function enableXmlCompacting ($xmlCompacting = TRUE);
193
194         /**
195          * Checks whether XML compacting is enabled
196          *
197          * @return      $xmlCompacting  Whether XML compacting is enabled or disabled
198          */
199         function isXmlCompactingEnabled ();
200
201         /**
202          * Removes all comments, tabs and new-line charcters to compact the content
203          *
204          * @param       $uncompactedContent             The uncompacted content
205          * @return      $compactedContent               The compacted content
206          */
207         function compactContent ($uncompactedContent);
208
209         /**
210          * Getter for given variable group
211          *
212          * @param       $variableGroup  Variable group to check
213          * @return      $varStack               Found variable group
214          */
215         function getVarStack ($variableGroup);
216
217         /**
218          * Settter for variable group
219          *
220          * @param       $groupName      Name of variable group
221          * @param       $add            Whether add this group
222          * @return      void
223          */
224         function setVariableGroup ($groupName, $add = TRUE);
225
226         /**
227          * Getter for template type
228          *
229          * @return      $templateType   The current template's type
230          */
231         function getTemplateType ();
232
233         /**
234          * Getter for base path
235          *
236          * @return      $templateBasePath       The relative base path for all templates
237          */
238         function getTemplateBasePath ();
239
240         /**
241          * Getter for generic base path
242          *
243          * @return      $templateBasePath       The relative base path for all templates
244          */
245         function getGenericBasePath ();
246
247         /**
248          * Getter for template extension
249          *
250          * @return      $templateExtension      The file extension for all uncompiled
251          *                                                      templates
252          */
253         function getRawTemplateExtension ();
254
255         /**
256          * Getter for code-template extension
257          *
258          * @return      $codeExtension          The file extension for all code-
259          *                                                      templates
260          */
261         function getCodeTemplateExtension ();
262
263         /**
264          * Getter for raw template data
265          *
266          * @return      $rawTemplateData        The raw data from the template
267          */
268         function getRawTemplateData ();
269
270         /**
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.
276          *
277          * @param       $variables      An array with variables to be assigned
278          * @return      void
279          */
280         function assignMultipleVariables (array $variables);
281
282         /**
283          * Getter for variable group array
284          *
285          * @return      $variableGroups All variable groups
286          */
287         function getVariableGroups ();
288
289 }