Renamed classes/main/ to main/classes/ + added FuseFeature, an upcoming feature
[core.git] / inc / main / interfaces / template / class_CompileableTemplate.php
1 <?php
2 /**
3  * An interface for template engines
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
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
10  *
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.
15  *
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.
20  *
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/>.
23  */
24 interface CompileableTemplate extends FrameworkInterface {
25         /**
26          * Assign variables for templates
27          *
28          * @param       $variableName   The "variable" we want to assign
29          * @param       $value                  The value we want to store in the variable
30          * @return      void
31          */
32         function assignVariable ($variableName, $value);
33
34         /**
35          * Load a specified HTML template into the engine
36          *
37          * @param       $template       The web template we shall load which is located in
38          *                                              "html" by default
39          * @return      void
40          */
41         function loadHtmlTemplate ($template);
42
43         /**
44          * Load a specified code template into the engine for later compilation
45          * with other code/web/email templates.
46          *
47          * @param       $template       The code template we shall load which is
48          *                                              located in "html" by default
49          * @return      void
50          */
51         function loadCodeTemplate ($template);
52
53         /**
54          * Load a specified email template into the engine for later compilation
55          * with other code/web/email templates.
56          *
57          * @param       $template       The email template we shall load which is
58          *                                              located in "html" by default
59          * @return      void
60          */
61         function loadEmailTemplate ($template);
62
63         /**
64          * Compile all variables by inserting their respective values
65          *
66          * @return      void
67          */
68         function compileVariables ();
69
70
71         /**
72          * Compile all required code/web/email-templates into the current one
73          *
74          * @return      void
75          */
76         function compileTemplate ();
77
78         /**
79          * Adds a variable to current group
80          *
81          * @param       $variableName   Variable to set
82          * @param       $value                  Value to store in variable
83          * @return      void
84          */
85         function addGroupVariable ($variableName, $value);
86
87         /**
88          * Removes a given variable
89          *
90          * @param       $variableName   The variable we are looking for
91          * @param       $variableGroup  Name of variable group (default: 'general')
92          * @return      void
93          */
94         function removeVariable ($variableName, $variableGroup = 'general');
95
96         /**
97          * Assign a given congfiguration variable with a value
98          *
99          * @param       $variableName   The configuration variable we want to assign
100          * @return      void
101          */
102         function assignConfigVariable ($variableName);
103
104         /**
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.
108          *
109          * @return      void
110          */
111         function compileConfigInVariables ();
112
113         /**
114          * Assigns the last loaded raw template content with a given variable
115          *
116          * @param       $templateName   Name of the template we want to assign
117          * @param       $variableName   Name of the variable we want to assign
118          * @return      void
119          */
120         function assignTemplateWithVariable ($templateName, $variableName);
121
122         /**
123          * Transfers the content of this template engine to a given response instance
124          *
125          * @param       $responseInstance       An instance of a response class
126          * @return      void
127          */
128         function transferToResponse (Responseable $responseInstance);
129
130         /**
131          * Assigns all the application data with template variables
132          *
133          * @param       $applicationInstance    A manageable application instance
134          * @return      void
135          */
136         function assignApplicationData (ManageableApplication $applicationInstance);
137
138         /**
139          * "Compiles" a variable by replacing {?var?} with it's content
140          *
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
144          */
145         function compileRawCode ($rawCode, $setMatchAsCode = FALSE);
146
147         /**
148          * Renames a variable in code and in stack
149          *
150          * @param       $oldName        Old name of variable
151          * @param       $newName        New name of variable
152          * @return      void
153          */
154         function renameVariable ($oldName, $newName);
155
156         /**
157          * Renders the given XML content
158          *
159          * @param       $content        Valid XML content or if not set the current loaded raw content
160          * @return      void
161          * @throws      XmlParserException      If an XML error was found
162          */
163         function renderXmlContent ($content = NULL);
164
165         /**
166          * Enables or disables language support
167          *
168          * @param       $languageSupport        New language support setting
169          * @return      void
170          */
171         function enableLanguageSupport ($languageSupport = TRUE);
172
173         /**
174          * Checks whether language support is enabled
175          *
176          * @return      $languageSupport        Whether language support is enabled or disabled
177          */
178         function isLanguageSupportEnabled ();
179
180         /**
181          * Enables or disables XML compacting
182          *
183          * @param       $xmlCompacting  New XML compacting setting
184          * @return      void
185          */
186         function enableXmlCompacting ($xmlCompacting = TRUE);
187
188         /**
189          * Checks whether XML compacting is enabled
190          *
191          * @return      $xmlCompacting  Whether XML compacting is enabled or disabled
192          */
193         function isXmlCompactingEnabled ();
194
195         /**
196          * Removes all comments, tabs and new-line charcters to compact the content
197          *
198          * @param       $uncompactedContent             The uncompacted content
199          * @return      $compactedContent               The compacted content
200          */
201         function compactContent ($uncompactedContent);
202
203         /**
204          * Getter for given variable group
205          *
206          * @param       $variableGroup  Variable group to check
207          * @return      $varStack               Found variable group
208          */
209         function getVarStack ($variableGroup);
210
211         /**
212          * Settter for variable group
213          *
214          * @param       $groupName      Name of variable group
215          * @param       $add            Whether add this group
216          * @return      void
217          */
218         function setVariableGroup ($groupName, $add = TRUE);
219
220         /**
221          * Getter for template type
222          *
223          * @return      $templateType   The current template's type
224          */
225         function getTemplateType ();
226
227         /**
228          * Getter for base path
229          *
230          * @return      $templateBasePath       The relative base path for all templates
231          */
232         function getTemplateBasePath ();
233
234         /**
235          * Getter for generic base path
236          *
237          * @return      $templateBasePath       The relative base path for all templates
238          */
239         function getGenericBasePath ();
240
241         /**
242          * Getter for template extension
243          *
244          * @return      $templateExtension      The file extension for all uncompiled
245          *                                                      templates
246          */
247         function getRawTemplateExtension ();
248
249         /**
250          * Getter for code-template extension
251          *
252          * @return      $codeExtension          The file extension for all code-
253          *                                                      templates
254          */
255         function getCodeTemplateExtension ();
256
257         /**
258          * Getter for raw template data
259          *
260          * @return      $rawTemplateData        The raw data from the template
261          */
262         function getRawTemplateData ();
263
264         /**
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.
270          *
271          * @param       $variables      An array with variables to be assigned
272          * @return      void
273          */
274         function assignMultipleVariables (array $variables);
275
276         /**
277          * Getter for variable group array
278          *
279          * @return      $variableGroups All variable groups
280          */
281         function getVariableGroups ();
282 }
283
284 // [EOF]
285 ?>