1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* ***************************************************************************** |
4
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
5
|
|
|
* project that has received funding from the European Union’s Framework |
6
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
7
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
8
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
9
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
10
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
11
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
12
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
13
|
|
|
* UK as a branch of GÉANT Vereniging. |
14
|
|
|
* |
15
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
16
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
17
|
|
|
* |
18
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
19
|
|
|
* <base_url>/copyright.php after deploying the software |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* This file contains a class for handling switching between skin frontends. |
24
|
|
|
* |
25
|
|
|
* @package Developer |
26
|
|
|
*/ |
27
|
|
|
/** |
28
|
|
|
* |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
namespace web\lib\user; |
32
|
|
|
|
33
|
|
|
use \Exception; |
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* This class handles user UI skin handling. |
37
|
|
|
* |
38
|
|
|
* @author Stefan Winter <[email protected]> |
39
|
|
|
*/ |
40
|
|
|
class Skinjob { |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The skin that was selected |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
public $skin; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Initialise the skin. |
51
|
|
|
* |
52
|
|
|
* @param string $selectedSkin the name of the skin to use |
53
|
|
|
*/ |
54
|
|
|
public function __construct($selectedSkin = NULL) { |
55
|
|
|
// input may have been rubbish. Sanity-check and fall back to default skin if needed |
56
|
|
|
$actualSkin = \config\Master::APPEARANCE['skins'][0]; |
57
|
|
|
if (in_array($selectedSkin, \config\Master::APPEARANCE['skins'])) { |
58
|
|
|
$correctIndex = array_search($selectedSkin, \config\Master::APPEARANCE['skins']); |
59
|
|
|
$actualSkin = \config\Master::APPEARANCE['skins'][$correctIndex]; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$this->skin = $actualSkin; |
63
|
|
|
$_SESSION['skin'] = $actualSkin; |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* constructs a URL to the main resources directories. Searches for the file |
69
|
|
|
* first in the current skin's resource dir, then falls back to the global |
70
|
|
|
* resources dir, or returns FALSE if the requested file could not be found |
71
|
|
|
* at either location. |
72
|
|
|
* |
73
|
|
|
* @param string $resourcetype which type of resource do we need a URL for? |
74
|
|
|
* @param string $filename the name of the file being searched. |
75
|
|
|
* @param string $submodule an area (diag, admin, ...) where to look |
76
|
|
|
* @return string|boolean the URL to the resource, or FALSE if this file does not exist |
77
|
|
|
* @throws Exception if something went wrong during the URL construction |
78
|
|
|
*/ |
79
|
|
|
public function findResourceUrl($resourcetype, $filename, $submodule = '') { |
80
|
|
|
switch ($resourcetype) { |
81
|
|
|
case "CSS": |
82
|
|
|
$path = "/resources/css/"; |
83
|
|
|
break; |
84
|
|
|
case "IMAGES": |
85
|
|
|
$path = "/resources/images/"; |
86
|
|
|
break; |
87
|
|
|
case "BASE": |
88
|
|
|
$path = "/"; |
89
|
|
|
break; |
90
|
|
|
case "EXTERNAL": |
91
|
|
|
$path = "/external/"; |
92
|
|
|
break; |
93
|
|
|
default: |
94
|
|
|
throw new Exception("findResourceUrl: unknown type of resource requested"); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
// does the file exist in the current skin's directory? Has precedence |
98
|
|
|
if ($submodule !== '' && file_exists(__DIR__ . "/../../skins/" . $this->skin . "/" . $submodule . $path . $filename)) { |
99
|
|
|
$extrapath = "/skins/" . $this->skin . "/" . $submodule; |
100
|
|
|
} |
101
|
|
|
elseif (file_exists(__DIR__ . "/../../skins/" . $this->skin . $path . $filename)) { |
102
|
|
|
$extrapath = "/skins/" . $this->skin; |
103
|
|
|
} elseif (file_exists(__DIR__ . "/../../" . $path . $filename)) { |
104
|
|
|
$extrapath = ""; |
105
|
|
|
} else { |
106
|
|
|
return FALSE; |
107
|
|
|
} |
108
|
|
|
return htmlspecialchars(\core\CAT::getRootUrlPath() . $extrapath . $path . $filename, ENT_QUOTES); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths