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 - 2023 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 (string $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 (string $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 (string $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 (string $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 (string $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 (string $variableName, string $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 (string $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 (string $templateName, string $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 (string $rawCode, bool $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 (string $oldName, string $newName);
161
162         /**
163          * Enables or disables language support
164          *
165          * @param       $languageSupport        New language support setting
166          * @return      void
167          */
168         function enableLanguageSupport (bool $languageSupport = true);
169
170         /**
171          * Checks whether language support is enabled
172          *
173          * @return      $languageSupport        Whether language support is enabled or disabled
174          */
175         function isLanguageSupportEnabled ();
176
177         /**
178          * Getter for given variable group
179          *
180          * @param       $variableGroup  Variable group to check
181          * @return      $varStack               Found variable group
182          */
183         function getVarStack (string $variableGroup);
184
185         /**
186          * Settter for variable group
187          *
188          * @param       $groupName      Name of variable group
189          * @param       $add            Whether add this group
190          * @return      void
191          */
192         function setVariableGroup (string $groupName, bool $add = true);
193
194         /**
195          * Getter for template type
196          *
197          * @return      $templateType   The current template's type
198          */
199         function getTemplateType ();
200
201         /**
202          * Getter for base path
203          *
204          * @return      $templateBasePath       The relative base path for all templates
205          */
206         function getTemplateBasePath ();
207
208         /**
209          * Getter for generic base path
210          *
211          * @return      $templateBasePath       The relative base path for all templates
212          */
213         function getGenericBasePath ();
214
215         /**
216          * Getter for template extension
217          *
218          * @return      $templateExtension      The file extension for all uncompiled
219          *                                                      templates
220          */
221         function getRawTemplateExtension ();
222
223         /**
224          * Getter for code-template extension
225          *
226          * @return      $codeExtension          The file extension for all code-
227          *                                                      templates
228          */
229         function getCodeTemplateExtension ();
230
231         /**
232          * Getter for raw template data
233          *
234          * @return      $rawTemplateData        The raw data from the template
235          */
236         function getRawTemplateData ();
237
238         /**
239          * Assigns a lot variables into the stack of currently loaded template.
240          * This method should only be used in very rare circumstances, e.g. when
241          * you have to copy a whole set of variables into the template engine.
242          * Before you use this method, please make sure you have considered all
243          * other possiblities.
244          *
245          * @param       $variables      An array with variables to be assigned
246          * @return      void
247          */
248         function assignMultipleVariables (array $variables);
249
250         /**
251          * Getter for variable group array
252          *
253          * @return      $variableGroups All variable groups
254          */
255         function getVariableGroups ();
256
257 }