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 Handlebars, Gallery */ |
||
2 | (function ($, OC, t, Gallery) { |
||
3 | "use strict"; |
||
4 | |||
5 | var TEMPLATE = |
||
6 | '{{#each crumbs}}' + |
||
7 | ' <div class="crumb {{cssClass}}" data-dir="{{dir}}">' + |
||
8 | ' {{#if link}}' + |
||
9 | ' <a href="{{link}}">' + |
||
10 | ' {{#if img}}' + |
||
11 | ' {{#with img}}' + |
||
12 | ' <img title="{{title}}" src="{{imageSrc}}">' + |
||
13 | ' {{/with}}' + |
||
14 | ' {{else}}' + |
||
15 | ' {{name}}' + |
||
16 | ' {{/if}}' + |
||
17 | ' </a>' + |
||
18 | ' {{else}}' + |
||
19 | ' <span>{{name}}</span>' + |
||
20 | ' {{/if}}' + |
||
21 | ' </div>' + |
||
22 | '{{/each}}'; |
||
23 | |||
24 | /** |
||
25 | * Breadcrumbs that represent the path to the current album |
||
26 | * |
||
27 | * @constructor |
||
28 | */ |
||
29 | var Breadcrumb = function () { |
||
30 | this.breadcrumbsElement = $('#breadcrumbs'); |
||
31 | }; |
||
32 | |||
33 | Breadcrumb.prototype = { |
||
34 | breadcrumbs: [], |
||
35 | breadcrumbsElement: null, |
||
36 | ellipsis: null, |
||
37 | albumPath: null, |
||
38 | availableWidth: 0, |
||
39 | onClick: null, |
||
40 | droppableOptions: { |
||
41 | accept: "#gallery > .row > a", |
||
42 | activeClass: 'breadcrumbs-droppable', |
||
43 | hoverClass: 'breadcrumbs-droppable-hover', |
||
44 | tolerance: 'pointer' |
||
45 | }, |
||
46 | |||
47 | /** |
||
48 | * Initialises the breadcrumbs for the current album |
||
49 | * |
||
50 | * @param {string} albumPath |
||
51 | * @param {int} availableWidth |
||
52 | */ |
||
53 | init: function (albumPath, availableWidth) { |
||
54 | this.albumPath = albumPath; |
||
55 | this.availableWidth = availableWidth; |
||
56 | this.breadcrumbs = []; |
||
57 | if (!this._template) { |
||
58 | this._template = Handlebars.compile(TEMPLATE); |
||
59 | } |
||
60 | this._build(); |
||
61 | this._resize(this.availableWidth); |
||
62 | }, |
||
63 | |||
64 | /** |
||
65 | * Defines the maximum available width in which we can build the breadcrumb and resizes it |
||
66 | * |
||
67 | * @param {int} availableWidth |
||
68 | */ |
||
69 | setMaxWidth: function (availableWidth) { |
||
70 | if (this.availableWidth > availableWidth || this.ellipsis.is(":visible")) { |
||
71 | this.availableWidth = availableWidth; |
||
72 | this._resize(this.availableWidth); |
||
73 | } |
||
74 | }, |
||
75 | |||
76 | /** |
||
77 | * Processes UI elements dropped on the breadcrumbs |
||
78 | * |
||
79 | * @param event |
||
80 | * @param ui |
||
81 | */ |
||
82 | onDrop: function (event, ui) { |
||
83 | var $item = ui.draggable; |
||
84 | var $clone = ui.helper; |
||
85 | var $target = $(event.target); |
||
86 | if (!$target.is('.crumb')) { |
||
87 | $target = $target.closest('.crumb'); |
||
88 | } |
||
89 | var targetPath = $(event.target).data('dir').toString(); |
||
90 | var dir = Gallery.currentAlbum; |
||
91 | |||
92 | while (dir.substr(0, 1) === '/') {//remove extra leading /'s |
||
93 | dir = dir.substr(1); |
||
94 | } |
||
95 | dir = '/' + dir; |
||
96 | if (dir.substr(-1, 1) !== '/') { |
||
97 | dir = dir + '/'; |
||
98 | } |
||
99 | // Do nothing if dragged on current dir |
||
100 | if (targetPath === dir || targetPath + '/' === dir) { |
||
101 | return; |
||
102 | } |
||
103 | var filePath = $item.data('path').toString(); |
||
104 | var fileName = OC.basename(filePath); |
||
105 | |||
106 | $clone.fadeOut("normal", function () { |
||
107 | Gallery.move($item, fileName, filePath, $target, targetPath); |
||
108 | }); |
||
109 | }, |
||
110 | |||
111 | /** |
||
112 | * Shows the dark spinner on the crumb |
||
113 | */ |
||
114 | showLoader: function () { |
||
115 | $(this).addClass("icon-loading-small-dark"); |
||
116 | }, |
||
117 | |||
118 | /** |
||
119 | * Builds the breadcrumbs array |
||
120 | * |
||
121 | * @private |
||
122 | */ |
||
123 | _build: function () { |
||
124 | var i, crumbs, name, path, currentAlbum; |
||
125 | var albumName = $('#content').data('albumname'); |
||
126 | if (!albumName) { |
||
127 | albumName = t('gallery', 'Gallery'); |
||
128 | } |
||
129 | path = ''; |
||
130 | name = ''; |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
131 | crumbs = this.albumPath.split('/'); |
||
132 | currentAlbum = crumbs.pop(); |
||
133 | |||
134 | // This adds the home button |
||
135 | this._addHome(albumName, currentAlbum); |
||
136 | // We always add a hidden ellipsis |
||
137 | this._pushCrumb('...', '', null, 'ellipsis'); |
||
138 | |||
139 | if (currentAlbum) { |
||
140 | // This builds the crumbs between home and the current folder |
||
141 | var crumbsLength = crumbs.length; |
||
142 | if (crumbsLength > 0) { |
||
143 | // We add all albums to the breadcrumbs array |
||
144 | for (i = 0; i < crumbsLength; i++) { |
||
145 | if (crumbs[i]) { |
||
146 | name = crumbs[i]; |
||
147 | if (path) { |
||
148 | path += '/' + crumbs[i]; |
||
149 | } else { |
||
150 | path += crumbs[i]; |
||
151 | } |
||
152 | this._pushCrumb(name, path, null, ''); |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | // We finally push the current folder |
||
157 | this._pushCrumb(currentAlbum, '', null, 'last'); |
||
158 | } |
||
159 | |||
160 | this._render(); |
||
161 | }, |
||
162 | |||
163 | /** |
||
164 | * Adds the Home button |
||
165 | * |
||
166 | * @param {string} albumName |
||
167 | * @param {string} currentAlbum |
||
168 | * @private |
||
169 | */ |
||
170 | _addHome: function (albumName, currentAlbum) { |
||
171 | var crumbImg = { |
||
172 | imageSrc: OC.imagePath('core', 'places/home'), |
||
173 | title: albumName |
||
174 | }; |
||
175 | var cssClass = 'home'; |
||
176 | if (!currentAlbum) { |
||
177 | cssClass += ' last'; |
||
178 | } |
||
179 | |||
180 | this._pushCrumb('', '', crumbImg, cssClass); |
||
181 | }, |
||
182 | |||
183 | /** |
||
184 | * Pushes crumb objects to the breadcrumbs array |
||
185 | * |
||
186 | * @param {string} name |
||
187 | * @param {string|boolean} link |
||
188 | * @param {Object} img |
||
189 | * @param {string} cssClass |
||
190 | * @private |
||
191 | */ |
||
192 | _pushCrumb: function (name, link, img, cssClass) { |
||
193 | var hash = ''; |
||
194 | |||
195 | // Prevent the last crumb from getting a link unless the last crumb is 'home'. |
||
196 | if ( cssClass.indexOf('last') === -1 || cssClass.indexOf('home') > -1 ) { |
||
197 | hash = '#' + encodeURIComponent(link); |
||
198 | } |
||
199 | |||
200 | this.breadcrumbs.push({ |
||
201 | name: name, |
||
202 | dir: link, |
||
203 | link: hash, |
||
204 | img: img, |
||
205 | cssClass: cssClass |
||
206 | }); |
||
207 | }, |
||
208 | |||
209 | /** |
||
210 | * Renders the full breadcrumb based on crumbs we have collected |
||
211 | * |
||
212 | * @private |
||
213 | */ |
||
214 | _render: function () { |
||
215 | this.breadcrumbsElement.children().remove(); |
||
216 | |||
217 | var breadcrumbs = this._template({ |
||
218 | crumbs: this.breadcrumbs |
||
219 | }); |
||
220 | |||
221 | this.breadcrumbsElement.append(breadcrumbs); |
||
222 | |||
223 | this.droppableOptions.drop = this.onDrop.bind(this); |
||
224 | this.breadcrumbsElement.find('.crumb:not(.last)').droppable(this.droppableOptions); |
||
225 | }, |
||
226 | |||
227 | /** |
||
228 | * Alters the breadcrumb to make it fit within the asked dimensions |
||
229 | * |
||
230 | * @param {int} availableWidth |
||
231 | * |
||
232 | * @private |
||
233 | */ |
||
234 | _resize: function (availableWidth) { |
||
235 | var crumbs = this.breadcrumbsElement.children(); |
||
236 | var shorten = false; |
||
237 | var ellipsisPath = ''; |
||
238 | var self = this; |
||
239 | |||
240 | // Hide everything first, so that we can check the width after adding each crumb |
||
241 | crumbs.hide(); |
||
242 | |||
243 | // We go through the array in reverse order |
||
244 | var crumbsElement = crumbs.get().reverse(); |
||
245 | $(crumbsElement).each(function () { |
||
246 | if ($(this).hasClass('home')) { |
||
247 | $(this).show(); |
||
248 | if (self.breadcrumbs.length > 2) { |
||
249 | $(this).click(self.showLoader); |
||
250 | } |
||
251 | return; |
||
252 | } |
||
253 | // 1st sub-album has no-parent and the breadcrumbs contain home, ellipsis and last |
||
254 | if (self.breadcrumbs.length > 3) { |
||
255 | $(this).click(self.showLoader); |
||
256 | } |
||
257 | if ($(this).hasClass('ellipsis')) { |
||
258 | self.ellipsis = $(this); |
||
259 | return; |
||
260 | } |
||
261 | if (!shorten) { |
||
262 | $(this).show(); |
||
263 | } |
||
264 | |||
265 | // If we've reached the maximum width, we start hiding crumbs |
||
266 | if (self.breadcrumbsElement.width() > availableWidth) { |
||
267 | shorten = true; |
||
268 | $(this).hide(); |
||
269 | if (!ellipsisPath) { |
||
270 | ellipsisPath = $(this).data('dir'); |
||
271 | } |
||
272 | } |
||
273 | }); |
||
274 | |||
275 | // If we had to hide crumbs, we add a way to go to the parent folder |
||
276 | if (shorten) { |
||
277 | this.ellipsis.show(); |
||
278 | |||
279 | if (!ellipsisPath) { |
||
280 | ellipsisPath = OC.dirname(this.albumPath); |
||
281 | } |
||
282 | |||
283 | this.ellipsis.children('a').attr('href', '#' + encodeURIComponent(ellipsisPath)); |
||
284 | this.ellipsis.attr('data-original-title', ellipsisPath).tooltip({ |
||
285 | fade: true, |
||
286 | placement: 'bottom', |
||
287 | delay: { |
||
288 | hide: 5 |
||
289 | } |
||
290 | }); |
||
291 | } |
||
292 | } |
||
293 | }; |
||
294 | |||
295 | Gallery.Breadcrumb = Breadcrumb; |
||
296 | })(jQuery, OC, t, Gallery); |
||
297 |