XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
LegacyTheme.class.php
1<?php
2
3if (!defined('XOOPS_ROOT_PATH')) {
4 exit();
5}
6
8{
9 public $mDirName=null;
10 public $mFileName=null;
11 public $ScreenShot=null;
12 public $mManifesto=null;
13
14 public function __construct($dirName, $manifesto=null)
15 {
16 $this->mDirName=$dirName;
17 if (null !== $manifesto) {
18 $this->initializeByManifesto($manifesto);
19 }
20 }
21
22 public function initializeByManifesto($manifesto)
23 {
24 //
25 // Manifesto sanitized to prevent that an attacker triggers javascript with a fake theme.
26 //
27 $this->mManifesto=$manifesto;
28 $this->ScreenShot=$manifesto['Theme']['ScreenShot'];
29 }
30}
31
33{
34 public $_mThemeList = [];
35
36 public function __construct()
37 {
38 if ($handler=opendir(XOOPS_THEME_PATH)) {
39 while (false !== ($dir=readdir($handler))) {
40 if ('.' === $dir || '..' === $dir) {
41 continue;
42 }
43
44 $themeDir= XOOPS_THEME_PATH . '/' . $dir;
45 if (is_dir($themeDir)) {
46 $manifesto = [];
47 if (file_exists($mnfFile = $themeDir . '/manifesto.ini.php')) {
48 $iniHandler = new XCube_IniHandler($mnfFile, true);
49 $manifesto = $iniHandler->getAllConfig();
50 }
51
52 if ((is_countable($manifesto) ? count($manifesto) : 0) > 0) {
53 //
54 // If this system can use this theme, add this to list.
55 //
56 // @gigamaster merged isset and applied strict ( === )
57 if (isset($manifesto['Manifesto']) && isset($manifesto['Manifesto']['Depends']) && 'Legacy_RenderSystem' == $manifesto['Manifesto']['Depends']) {
58 $this->_mThemeList[]=new LegacyTheme($dir, $manifesto);
59 }
60 } else {
61 $file= $themeDir . '/theme.html';
62 if (file_exists($file)) {
63 $this->_mThemeList[]=new LegacyTheme($dir);
64 }
65 }
66 }
67 }
68 closedir($handler);
69 }
70 }
71
72 public function &enumAll()
73 {
74 return $this->_mThemeList;
75 }
76}