This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | /* global Gallery */ |
||
2 | (function ($, Gallery) { |
||
3 | "use strict"; |
||
4 | /** |
||
5 | * Stores the gallery configuration |
||
6 | * |
||
7 | * @param {{features: string[], mediatypes: string[]}} config |
||
8 | * @constructor |
||
9 | */ |
||
10 | var Config = function (config) { |
||
11 | this.galleryFeatures = this._setGalleryFeatures(config.features); |
||
12 | this.mediaTypes = this._setMediaTypes(config.mediatypes); |
||
13 | }; |
||
14 | |||
15 | Config.prototype = { |
||
16 | galleryFeatures: [], |
||
17 | cachedFeaturesString: '', |
||
18 | mediaTypes: [], |
||
19 | cachedMediaTypesString: '', |
||
20 | albumInfo: null, |
||
21 | albumSorting: null, |
||
22 | albumDesign: null, |
||
23 | albumError: false, |
||
24 | infoLoaded: false, |
||
25 | |||
26 | /** |
||
27 | * Returns the list of supported features in a string |
||
28 | * |
||
29 | * @returns {string} |
||
30 | */ |
||
31 | getFeatures: function () { |
||
32 | return this.cachedFeaturesString; |
||
33 | }, |
||
34 | |||
35 | /** |
||
36 | * Returns the list of supported media types in a string |
||
37 | * |
||
38 | * @returns {string} |
||
39 | */ |
||
40 | getMediaTypes: function () { |
||
41 | return this.cachedMediaTypesString; |
||
42 | }, |
||
43 | |||
44 | /** |
||
45 | * Stores the configuration about the current album |
||
46 | * |
||
47 | * @param {{ |
||
48 | * design, |
||
49 | * information, |
||
50 | * sorting, |
||
51 | * error: string |
||
52 | * }} albumConfig |
||
53 | * @param albumPath |
||
54 | */ |
||
55 | setAlbumConfig: function (albumConfig, albumPath) { |
||
56 | this.albumInfo = this._setAlbumInfo(albumConfig, albumPath); |
||
57 | this.albumSorting = this._setAlbumSorting(albumConfig); |
||
58 | this.albumDesign = this._setAlbumDesign(albumConfig); |
||
59 | this.albumError = albumConfig.error; |
||
60 | }, |
||
61 | |||
62 | /** |
||
63 | * Updates the sorting order |
||
64 | */ |
||
65 | updateAlbumSorting: function (sortConfig) { |
||
66 | this.albumSorting = { |
||
67 | type: sortConfig.type, |
||
68 | order: sortConfig.order, |
||
69 | albumOrder: sortConfig.albumOrder |
||
70 | }; |
||
71 | }, |
||
72 | |||
73 | /** |
||
74 | * Saves the list of features which have been enabled in the app |
||
75 | * |
||
76 | * @param {string[]} configFeatures |
||
77 | * |
||
78 | * @returns {Array} |
||
79 | * @private |
||
80 | */ |
||
81 | _setGalleryFeatures: function (configFeatures) { |
||
82 | var features = []; |
||
83 | var feature = null; |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
84 | var i, configFeaturesLength = configFeatures.length; |
||
85 | if (configFeaturesLength) { |
||
86 | for (i = 0; i < configFeaturesLength; i++) { |
||
87 | feature = configFeatures[i]; |
||
88 | if (this._worksInCurrentBrowser(feature, 'native_svg')) { |
||
89 | features.push(feature); |
||
90 | Gallery.utility.addDomPurifyHooks(); |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 | this.cachedFeaturesString = features.join(';'); |
||
95 | |||
96 | return features; |
||
97 | }, |
||
98 | |||
99 | /** |
||
100 | * Saves the list of supported media types |
||
101 | * |
||
102 | * @param {string[]} mediaTypes |
||
103 | * |
||
104 | * @returns {Array} |
||
105 | * @private |
||
106 | */ |
||
107 | _setMediaTypes: function (mediaTypes) { |
||
108 | var supportedMediaTypes = []; |
||
109 | var mediaType = null; |
||
0 ignored issues
–
show
|
|||
110 | var i, mediaTypesLength = mediaTypes.length; |
||
111 | if (mediaTypesLength) { |
||
112 | for (i = 0; i < mediaTypesLength; i++) { |
||
113 | mediaType = mediaTypes[i]; |
||
114 | if (this._worksInCurrentBrowser(mediaType, 'image/svg+xml')) { |
||
115 | supportedMediaTypes.push(mediaType); |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | this.cachedMediaTypesString = supportedMediaTypes.join(';'); |
||
120 | |||
121 | return supportedMediaTypes; |
||
122 | }, |
||
123 | |||
124 | /** |
||
125 | * Determines if we can accept a specific config element in Internet Explorer |
||
126 | * |
||
127 | * @param {string} feature |
||
128 | * @param {string} validationRule |
||
129 | * |
||
130 | * @returns {boolean} |
||
131 | * @private |
||
132 | */ |
||
133 | _worksInCurrentBrowser: function (feature, validationRule) { |
||
134 | var isAcceptable = true; |
||
135 | if (feature === validationRule && |
||
136 | (Gallery.ieVersion !== false && Gallery.ieVersion !== 'edge')) { |
||
137 | isAcceptable = false; |
||
138 | } |
||
139 | |||
140 | return isAcceptable; |
||
141 | }, |
||
142 | |||
143 | /** |
||
144 | * Saves the description and copyright information for the current album |
||
145 | * |
||
146 | * @param {{ |
||
147 | * design, |
||
148 | * information, |
||
149 | * sorting, |
||
150 | * error: string |
||
151 | * }} albumConfig |
||
152 | * @param albumPath |
||
153 | * |
||
154 | * @returns {null||{ |
||
155 | * description: string, |
||
156 | * descriptionLink: string, |
||
157 | * copyright: string, |
||
158 | * copyrightLink: string, |
||
159 | * filePath: string, |
||
160 | * inherit: bool, |
||
161 | * level: number |
||
162 | * }} |
||
163 | * @private |
||
164 | */ |
||
165 | _setAlbumInfo: function (albumConfig, albumPath) { |
||
166 | /**@type {{ |
||
167 | * description: string, |
||
168 | * description_link: string, |
||
169 | * copyright: string, |
||
170 | * copyright_link: string, |
||
171 | * inherit: bool, |
||
172 | * level: number |
||
173 | * }} |
||
174 | */ |
||
175 | var albumInfo = albumConfig.information; |
||
176 | var params = null; |
||
177 | if (!$.isEmptyObject(albumInfo)) { |
||
178 | var docPath = albumPath; |
||
179 | var level = albumInfo.level; |
||
180 | if (level > 0) { |
||
181 | if (docPath.indexOf('/') !== -1) { |
||
182 | var folders = docPath.split('/'); |
||
183 | folders = folders.slice(-0, -level); |
||
184 | docPath = folders.join('/') + '/'; |
||
185 | } else { |
||
186 | docPath = ''; |
||
187 | } |
||
188 | } |
||
189 | |||
190 | /* jshint camelcase: false */ |
||
191 | params = { |
||
192 | description: albumInfo.description, |
||
193 | descriptionLink: albumInfo.description_link, |
||
194 | copyright: albumInfo.copyright, |
||
195 | copyrightLink: albumInfo.copyright_link, |
||
196 | filePath: docPath, |
||
197 | inherit: albumInfo.inherit, |
||
198 | level: level |
||
199 | }; |
||
200 | } |
||
201 | |||
202 | return params; |
||
203 | }, |
||
204 | |||
205 | /** |
||
206 | * Saves the description and copyright information for the current album |
||
207 | * |
||
208 | * @param {{ |
||
209 | * design, |
||
210 | * information, |
||
211 | * sorting, |
||
212 | * error: string |
||
213 | * }} albumConfig |
||
214 | * |
||
215 | * @returns {null||{ |
||
216 | * background: string, |
||
217 | * inherit: bool, |
||
218 | * level: number |
||
219 | * }} |
||
220 | * @private |
||
221 | */ |
||
222 | _setAlbumDesign: function (albumConfig) { |
||
223 | /**@type {{ |
||
224 | * background: string, |
||
225 | * inherit: bool, |
||
226 | * level: number |
||
227 | * }} |
||
228 | */ |
||
229 | var albumDesign = albumConfig.design; |
||
230 | var params = null; |
||
231 | if (!$.isEmptyObject(albumDesign)) { |
||
232 | params = { |
||
233 | background: albumDesign.background, |
||
234 | inherit: albumDesign.inherit, |
||
235 | level: albumDesign.level |
||
236 | }; |
||
237 | } |
||
238 | |||
239 | return params; |
||
240 | }, |
||
241 | |||
242 | /** |
||
243 | * Saves the sorting configuration for the current album |
||
244 | * |
||
245 | * @param {{ |
||
246 | * design, |
||
247 | * information, |
||
248 | * sorting, |
||
249 | * error: string |
||
250 | * }} albumConfig |
||
251 | * |
||
252 | * @returns {{type: string, order: string, albumOrder: string}} |
||
253 | * @private |
||
254 | */ |
||
255 | _setAlbumSorting: function (albumConfig) { |
||
256 | var sortType = 'name'; |
||
257 | var sortOrder = 'asc'; |
||
258 | var albumSortOrder = 'asc'; |
||
259 | if (!$.isEmptyObject(albumConfig.sorting)) { |
||
260 | if (!$.isEmptyObject(albumConfig.sorting.type)) { |
||
261 | sortType = albumConfig.sorting.type; |
||
262 | } |
||
263 | if (!$.isEmptyObject(albumConfig.sorting.order)) { |
||
264 | sortOrder = albumConfig.sorting.order; |
||
265 | if (sortType === 'name') { |
||
266 | albumSortOrder = sortOrder; |
||
267 | } |
||
268 | } |
||
269 | } |
||
270 | |||
271 | return { |
||
272 | type: sortType, |
||
273 | order: sortOrder, |
||
274 | albumOrder: albumSortOrder |
||
275 | }; |
||
276 | } |
||
277 | }; |
||
278 | |||
279 | Gallery.Config = Config; |
||
280 | })(jQuery, Gallery); |
||
281 |