Continued:
[core.git] / framework / main / interfaces / template / class_CompileableTemplate.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Template;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7 use Org\Mxchange\CoreFramework\Response\Responseable;
8
9 /**
10  * An interface for template engines
11  *
12  * @author              Roland Haeder <webmaster@shipsimu.org>
13  * @version             0.0.0
14  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
15  * @license             GNU GPL 3.0 or any newer version
16  * @link                http://www.shipsimu.org
17  *
18  * This program is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program. If not, see <http://www.gnu.org/licenses/>.
30  */
31 interface CompileableTemplate extends FrameworkInterface {
32         /**
33          * Assign variables for templates
34          *
35          * @param       $variableName   The "variable" we want to assign
36          * @param       $value                  The value we want to store in the variable
37          * @return      void
38          */
39         function assignVariable ($variableName, $value);
40
41         /**
42          * Load a specified HTML template into the engine
43          *
44          * @param       $template       The web template we shall load which is located in
45          *                                              "html" by default
46          * @return      void
47          */
48         function loadHtmlTemplate ($template);
49
50         /**
51          * Load a specified code template into the engine for later compilation
52          * with other code/web/email templates.
53          *
54          * @param       $template       The code template we shall load which is
55          *                                              located in "html" by default
56          * @return      void
57          */
58         function loadCodeTemplate ($template);
59
60         /**
61          * Load a specified email template into the engine for later compilation
62          * with other code/web/email templates.
63          *
64          * @param       $template       The email template we shall load which is
65          *                                              located in "html" by default
66          * @return      void
67          */
68         function loadEmailTemplate ($template);
69
70         /**
71          * Compile all variables by inserting their respective values
72          *
73          * @return      void
74          */
75         function compileVariables ();
76
77
78         /**
79          * Compile all required code/web/email-templates into the current one
80          *
81          * @return      void
82          */
83         function compileTemplate ();
84
85         /**
86          * Adds a variable to current group
87          *
88          * @param       $variableName   Variable to set
89          * @param       $value                  Value to store in variable
90          * @return      void
91          */
92         function addGroupVariable ($variableName, $value);
93
94         /**
95          * Removes a given variable
96          *
97          * @param       $variableName   The variable we are looking for
98          * @param       $variableGroup  Name of variable group (default: 'general')
99          * @return      void
100          */
101         function removeVariable ($variableName, $variableGroup = 'general');
102
103         /**
104          * Assign a given congfiguration variable with a value
105          *
106          * @param       $variableName   The configuration variable we want to assign
107          * @return      void
108          */
109         function assignConfigVariable ($variableName);
110
111         /**
112          * Compiles configuration place-holders in all variables. This 'walks'
113          * through the variable stack 'general'. It interprets all values from that
114          * variables as configuration entries after compiling them.
115          *
116          * @return      void
117          */
118         function compileConfigInVariables ();
119
120         /**
121          * Assigns the last loaded raw template content with a given variable
122          *
123          * @param       $templateName   Name of the template we want to assign
124          * @param       $variableName   Name of the variable we want to assign
125          * @return      void
126          */
127         function assignTemplateWithVariable ($templateName, $variableName);
128
129         /**
130          * Transfers the content of this template engine to a given response instance
131          *
132          * @param       $responseInstance       An instance of a Responseable class
133          * @return      void
134          */
135         function transferToResponse (Responseable $responseInstance);
136
137         /**
138          * Assigns all the application data with template variables
139          *
140          * @return      void
141          */
142         function assignApplicationData ();
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 }