LEPTON CMS 7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
lepton_template.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25abstract class LEPTON_template
26{
32 public $language = array();
33
39 public $parents = array();
40
47
53 public $template_name = "";
54
60 public $template_function = "";
61
67 public $template_version = "";
68
74 public $template_platform = "";
75
81 public $template_author = "";
82
88 public $template_license = "";
89
96
103
109 public $template_guid = "";
110
116 public $block = [];
117
123 public $menu = [];
124
129 public static $instance;
130
135 public static function getInstance()
136 {
137 if (null === static::$instance)
138 {
139 static::$instance = new static();
140 static::$instance->getParents();
141 static::$instance->getTemplateInfo();
142 static::$instance->getLanguageFile();
143 static::$instance->initialize();
144 }
145 return static::$instance;
146 }
147
151 protected function getParents()
152 {
153 // First the class itself
154 static::$instance->parents[] = get_class(static::$instance);
155
156 // Now the parents
157 $aTempParents = class_parents( static::$instance, true );
158 foreach($aTempParents as $sParentname)
159 {
160 static::$instance->parents[] = $sParentname;
161 }
162 }
163
169 protected function getTemplateInfo()
170 {
171
172 foreach(static::$instance->parents as $sModuleDirectory)
173 {
174 // strip namespace
175 $aTemp = explode("\\", $sModuleDirectory);
176 $sModuleDirectory = array_pop($aTemp);
177
178 $sLookUpPath = __DIR__."/../../templates/".$sModuleDirectory."/info.php";
179 if( file_exists($sLookUpPath) )
180 {
181 require $sLookUpPath;
182 // [1.1]
183 if(isset($template_name))
184 {
185 static::$instance->template_name = $template_name;
186 }
187 // [1.2]
188 if(isset($template_directory))
189 {
190 static::$instance->template_directory = $template_directory;
191 }
192 // [1.3]
193 if(isset($template_function))
194 {
195 static::$instance->template_function = $template_function;
196 }
197 // [1.4]
198 if(isset($template_version))
199 {
200 static::$instance->template_version = $template_version;
201 }
202 // [1.5]
203 if(isset($template_platform))
204 {
205 static::$instance->template_platform = $template_platform;
206 }
207 // [1.6]
208 if(isset($template_author))
209 {
210 static::$instance->template_author = $template_author;
211 }
212 // [1.7]
213 if(isset($template_license))
214 {
215 static::$instance->template_license = $template_license;
216 }
217 // [1.8]
218 if(isset($template_license_terms))
219 {
220 static::$instance->template_license_terms = $template_license_terms;
221 }
222 // [1.9]
223 if(isset($template_description))
224 {
225 static::$instance->template_description = $template_description;
226 }
227 // [1.10]
228 if(isset($template_guid))
229 {
230 static::$instance->template_guid = $template_guid;
231 }
232 // [1.11]
233 if(isset($block))
234 {
235 static::$instance->block = $block;
236 }
237 // [1.12]
238 if(isset($menu))
239 {
240 static::$instance->menu = $menu;
241 }
242
243 break;
244 }
245 }
246 }
247
251 protected function getLanguageFile()
252 {
253 if (defined("LEPTON_PATH"))
254 {
255 $aLookUpFilenames = [
256 LANGUAGE."_add.php",
257 LANGUAGE."_custom.php",
258 LANGUAGE.".php",
259 "EN_custom.php",
260 "EN.php"
261 ];
262
263 foreach (static::$instance->parents as $sClassName)
264 {
265 // Strip the namespace
266 $aTemp = explode("\\", $sClassName);
267 $sClassName = array_pop($aTemp);
268
269 $lookUpPath = LEPTON_PATH."/templates/".$sClassName."/languages/";
270
271 $bFoundFile = false;
272
273 foreach ($aLookUpFilenames as $sTempFilename)
274 {
275 if (true === file_exists($lookUpPath.$sTempFilename))
276 {
277 if (isset($template_description))
278 {
280 }
281 require $lookUpPath.$sTempFilename;
282 $bFoundFile = true;
283 break;
284 }
285 }
286
287 if (false === $bFoundFile)
288 {
289 continue;
290 }
291
292 $tempName = (static::$instance->template_function == "theme"
293 ? "THEME"
294 : "TEMPLATE_".strtoupper($sClassName)
295 );
296
297 if (isset(${$tempName}))
298 {
299 static::$instance->language = ${$tempName};
300
304 if (isset($template_description))
305 {
306 $this->template_description = $template_description;
307 }
308 break;
309 }
310 }
311 }
312 }
313
317 abstract protected function initialize();
318}