LEPTON CMS 7.0.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->getLanguageFile();
142 static::$instance->getTemplateInfo();
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."_custom.php",
257 LANGUAGE.".php",
258 "EN_custom.php",
259 "EN.php"
260 ];
261
262 foreach( static::$instance->parents as $sClassName)
263 {
264 // Strip the namespace
265 $aTemp = explode("\\", $sClassName);
266 $sClassName = array_pop($aTemp);
267
268 $lookUpPath = LEPTON_PATH."/templates/".$sClassName."/languages/";
269
270 $bFoundFile = false;
271
272 foreach( $aLookUpFilenames as $sTempFilename )
273 {
274 if(true === file_exists( $lookUpPath.$sTempFilename ) )
275 {
276 if(isset($template_description))
277 {
279 }
280 require $lookUpPath.$sTempFilename;
281 $bFoundFile = true;
282 break;
283 }
284 }
285
286 if(false === $bFoundFile)
287 {
288 continue;
289 }
290
291 $tempName = (static::$instance->template_function == "theme"
292 ? "THEME"
293 : "TEMPLATE_".strtoupper($sClassName)
294 );
295
296 if(isset(${$tempName}))
297 {
298 static::$instance->language = ${$tempName};
299
303 if(isset($template_description))
304 {
305 $this->template_description = $template_description;
306 }
307 break;
308 }
309 }
310 }
311 }
312
316 abstract protected function initialize();
317}