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