Passed
Push — master ( 61d22f...88b2d8 )
by Roeland
08:51 queued 11s
created
apps/comments/lib/Listener/LoadAdditionalScripts.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
 use OCP\Util;
31 31
 
32 32
 class LoadAdditionalScripts implements IEventListener {
33
-	public function handle(Event $event): void {
34
-		if (!($event instanceof LoadAdditionalScriptsEvent)) {
35
-			return;
36
-		}
33
+    public function handle(Event $event): void {
34
+        if (!($event instanceof LoadAdditionalScriptsEvent)) {
35
+            return;
36
+        }
37 37
 
38
-		Util::addScript('comments', 'comments');
39
-	}
38
+        Util::addScript('comments', 'comments');
39
+    }
40 40
 
41 41
 }
Please login to merge, or discard this patch.
apps/comments/lib/AppInfo/Application.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -38,49 +38,49 @@
 block discarded – undo
38 38
 
39 39
 class Application extends App {
40 40
 
41
-	public function __construct (array $urlParams = array()) {
42
-		parent::__construct('comments', $urlParams);
43
-		$container = $this->getContainer();
41
+    public function __construct (array $urlParams = array()) {
42
+        parent::__construct('comments', $urlParams);
43
+        $container = $this->getContainer();
44 44
 
45
-		$container->registerAlias('NotificationsController', Notifications::class);
45
+        $container->registerAlias('NotificationsController', Notifications::class);
46 46
 
47
-		$jsSettingsHelper = new JSSettingsHelper($container->getServer());
48
-		Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
49
-	}
47
+        $jsSettingsHelper = new JSSettingsHelper($container->getServer());
48
+        Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
49
+    }
50 50
 
51
-	public function register() {
52
-		$server = $this->getContainer()->getServer();
51
+    public function register() {
52
+        $server = $this->getContainer()->getServer();
53 53
 
54
-		/** @var IEventDispatcher $newDispatcher */
55
-		$dispatcher = $server->query(IEventDispatcher::class);
56
-		$this->registerSidebarScripts($dispatcher);
57
-		$this->registerDavEntity($dispatcher);
58
-		$this->registerNotifier();
59
-		$this->registerCommentsEventHandler();
54
+        /** @var IEventDispatcher $newDispatcher */
55
+        $dispatcher = $server->query(IEventDispatcher::class);
56
+        $this->registerSidebarScripts($dispatcher);
57
+        $this->registerDavEntity($dispatcher);
58
+        $this->registerNotifier();
59
+        $this->registerCommentsEventHandler();
60 60
 
61
-		$server->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
62
-	}
61
+        $server->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
62
+    }
63 63
 
64
-	protected function registerSidebarScripts(IEventDispatcher $dispatcher) {
65
-		$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
66
-	}
64
+    protected function registerSidebarScripts(IEventDispatcher $dispatcher) {
65
+        $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
66
+    }
67 67
 
68
-	protected function registerDavEntity(IEventDispatcher $dispatcher) {
69
-		$dispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
70
-			$event->addEntityCollection('files', function($name) {
71
-				$nodes = \OC::$server->getUserFolder()->getById((int)$name);
72
-				return !empty($nodes);
73
-			});
74
-		});
75
-	}
68
+    protected function registerDavEntity(IEventDispatcher $dispatcher) {
69
+        $dispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
70
+            $event->addEntityCollection('files', function($name) {
71
+                $nodes = \OC::$server->getUserFolder()->getById((int)$name);
72
+                return !empty($nodes);
73
+            });
74
+        });
75
+    }
76 76
 
77
-	protected function registerNotifier() {
78
-		$this->getContainer()->getServer()->getNotificationManager()->registerNotifierService(Notifier::class);
79
-	}
77
+    protected function registerNotifier() {
78
+        $this->getContainer()->getServer()->getNotificationManager()->registerNotifierService(Notifier::class);
79
+    }
80 80
 
81
-	protected function registerCommentsEventHandler() {
82
-		$this->getContainer()->getServer()->getCommentsManager()->registerEventHandler(function () {
83
-			return $this->getContainer()->query(EventHandler::class);
84
-		});
85
-	}
81
+    protected function registerCommentsEventHandler() {
82
+        $this->getContainer()->getServer()->getCommentsManager()->registerEventHandler(function () {
83
+            return $this->getContainer()->query(EventHandler::class);
84
+        });
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/files/lib/Controller/ViewController.php 1 patch
Indentation   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -52,285 +52,285 @@
 block discarded – undo
52 52
  * @package OCA\Files\Controller
53 53
  */
54 54
 class ViewController extends Controller {
55
-	/** @var string */
56
-	protected $appName;
57
-	/** @var IRequest */
58
-	protected $request;
59
-	/** @var IURLGenerator */
60
-	protected $urlGenerator;
61
-	/** @var IL10N */
62
-	protected $l10n;
63
-	/** @var IConfig */
64
-	protected $config;
65
-	/** @var IEventDispatcher */
66
-	protected $eventDispatcher;
67
-	/** @var IUserSession */
68
-	protected $userSession;
69
-	/** @var IAppManager */
70
-	protected $appManager;
71
-	/** @var IRootFolder */
72
-	protected $rootFolder;
73
-	/** @var Helper */
74
-	protected $activityHelper;
75
-
76
-	public function __construct(string $appName,
77
-		IRequest $request,
78
-		IURLGenerator $urlGenerator,
79
-		IL10N $l10n,
80
-		IConfig $config,
81
-		IEventDispatcher $eventDispatcher,
82
-		IUserSession $userSession,
83
-		IAppManager $appManager,
84
-		IRootFolder $rootFolder,
85
-		Helper $activityHelper
86
-	) {
87
-		parent::__construct($appName, $request);
88
-		$this->appName         = $appName;
89
-		$this->request         = $request;
90
-		$this->urlGenerator    = $urlGenerator;
91
-		$this->l10n            = $l10n;
92
-		$this->config          = $config;
93
-		$this->eventDispatcher = $eventDispatcher;
94
-		$this->userSession     = $userSession;
95
-		$this->appManager      = $appManager;
96
-		$this->rootFolder      = $rootFolder;
97
-		$this->activityHelper  = $activityHelper;
98
-	}
99
-
100
-	/**
101
-	 * @param string $appName
102
-	 * @param string $scriptName
103
-	 * @return string
104
-	 */
105
-	protected function renderScript($appName, $scriptName) {
106
-		$content    = '';
107
-		$appPath    = \OC_App::getAppPath($appName);
108
-		$scriptPath = $appPath . '/' . $scriptName;
109
-		if (file_exists($scriptPath)) {
110
-			// TODO: sanitize path / script name ?
111
-			ob_start();
112
-			include $scriptPath;
113
-			$content = ob_get_contents();
114
-			@ob_end_clean();
115
-		}
116
-
117
-		return $content;
118
-	}
119
-
120
-	/**
121
-	 * FIXME: Replace with non static code
122
-	 *
123
-	 * @return array
124
-	 * @throws \OCP\Files\NotFoundException
125
-	 */
126
-	protected function getStorageInfo() {
127
-		$dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
128
-
129
-		return \OC_Helper::getStorageInfo('/', $dirInfo);
130
-	}
131
-
132
-	/**
133
-	 * @NoCSRFRequired
134
-	 * @NoAdminRequired
135
-	 *
136
-	 * @param string $fileid
137
-	 * @return TemplateResponse|RedirectResponse
138
-	 * @throws NotFoundException
139
-	 */
140
-	public function showFile(string $fileid = null): Response {
141
-		// This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
142
-		try {
143
-			return $this->redirectToFile($fileid);
144
-		} catch (NotFoundException $e) {
145
-			return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
146
-		}
147
-	}
148
-
149
-	/**
150
-	 * @NoCSRFRequired
151
-	 * @NoAdminRequired
152
-	 *
153
-	 * @param string $dir
154
-	 * @param string $view
155
-	 * @param string $fileid
156
-	 * @param bool $fileNotFound
157
-	 * @return TemplateResponse|RedirectResponse
158
-	 * @throws NotFoundException
159
-	 */
160
-	public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
161
-		if ($fileid !== null) {
162
-			try {
163
-				return $this->redirectToFile($fileid);
164
-			} catch (NotFoundException $e) {
165
-				return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
166
-			}
167
-		}
168
-
169
-		$nav = new \OCP\Template('files', 'appnavigation', '');
170
-
171
-		// Load the files we need
172
-		\OCP\Util::addStyle('files', 'merged');
173
-		\OCP\Util::addScript('files', 'merged-index');
174
-
175
-		// mostly for the home storage's free space
176
-		// FIXME: Make non static
177
-		$storageInfo = $this->getStorageInfo();
178
-
179
-		$user = $this->userSession->getUser()->getUID();
180
-
181
-		// Get all the user favorites to create a submenu
182
-		try {
183
-			$favElements = $this->activityHelper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
184
-		} catch (\RuntimeException $e) {
185
-			$favElements['folders'] = [];
186
-		}
187
-
188
-		$collapseClasses = '';
189
-		if (count($favElements['folders']) > 0) {
190
-			$collapseClasses = 'collapsible';
191
-		}
192
-
193
-		$favoritesSublistArray = Array();
194
-
195
-		$navBarPositionPosition = 6;
196
-		$currentCount           = 0;
197
-		foreach ($favElements['folders'] as $dir) {
198
-
199
-			$link         = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']);
200
-			$sortingValue = ++$currentCount;
201
-			$element      = [
202
-				'id'                 => str_replace('/', '-', $dir),
203
-				'view'               => 'files',
204
-				'href'               => $link,
205
-				'dir'                => $dir,
206
-				'order'              => $navBarPositionPosition,
207
-				'folderPosition'     => $sortingValue,
208
-				'name'               => basename($dir),
209
-				'icon'               => 'files',
210
-				'quickaccesselement' => 'true'
211
-			];
212
-
213
-			array_push($favoritesSublistArray, $element);
214
-			$navBarPositionPosition++;
215
-		}
216
-
217
-		$navItems = \OCA\Files\App::getNavigationManager()->getAll();
218
-
219
-		// add the favorites entry in menu
220
-		$navItems['favorites']['sublist'] = $favoritesSublistArray;
221
-		$navItems['favorites']['classes'] = $collapseClasses;
222
-
223
-		// parse every menu and add the expandedState user value
224
-		foreach ($navItems as $key => $item) {
225
-			if (isset($item['expandedState'])) {
226
-				$navItems[$key]['defaultExpandedState'] = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', $item['expandedState'], '0') === '1';
227
-			}
228
-		}
229
-
230
-		$nav->assign('navigationItems', $navItems);
231
-
232
-		$nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used']));
233
-		if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
234
-			$totalSpace = $this->l10n->t('Unlimited');
235
-		} else {
236
-			$totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
237
-		}
238
-		$nav->assign('total_space', $totalSpace);
239
-		$nav->assign('quota', $storageInfo['quota']);
240
-		$nav->assign('usage_relative', $storageInfo['relative']);
241
-
242
-		$contentItems = [];
243
-
244
-		// render the container content for every navigation item
245
-		foreach ($navItems as $item) {
246
-			$content = '';
247
-			if (isset($item['script'])) {
248
-				$content = $this->renderScript($item['appname'], $item['script']);
249
-			}
250
-			// parse submenus
251
-			if (isset($item['sublist'])) {
252
-				foreach ($item['sublist'] as $subitem) {
253
-					$subcontent = '';
254
-					if (isset($subitem['script'])) {
255
-						$subcontent = $this->renderScript($subitem['appname'], $subitem['script']);
256
-					}
257
-					$contentItems[$subitem['id']] = [
258
-						'id'      => $subitem['id'],
259
-						'content' => $subcontent
260
-					];
261
-				}
262
-			}
263
-			$contentItems[$item['id']] = [
264
-				'id'      => $item['id'],
265
-				'content' => $content
266
-			];
267
-		}
268
-
269
-		$event = new LoadAdditionalScriptsEvent();
270
-		$this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);
271
-
272
-		$params                                = [];
273
-		$params['usedSpacePercent']            = (int) $storageInfo['relative'];
274
-		$params['owner']                       = $storageInfo['owner'];
275
-		$params['ownerDisplayName']            = $storageInfo['ownerDisplayName'];
276
-		$params['isPublic']                    = false;
277
-		$params['allowShareWithLink']          = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
278
-		$params['defaultFileSorting']          = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
279
-		$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
280
-		$params['showgridview']				   = $this->config->getUserValue($user, 'files', 'show_grid', false);
281
-		$params['isIE']						   = \OCP\Util::isIE();
282
-		$showHidden                            = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
283
-		$params['showHiddenFiles']             = $showHidden ? 1 : 0;
284
-		$params['fileNotFound']                = $fileNotFound ? 1 : 0;
285
-		$params['appNavigation']               = $nav;
286
-		$params['appContents']                 = $contentItems;
287
-		$params['hiddenFields']                = $event->getHiddenFields();
288
-
289
-		$response = new TemplateResponse(
290
-			$this->appName,
291
-			'index',
292
-			$params
293
-		);
294
-		$policy = new ContentSecurityPolicy();
295
-		$policy->addAllowedFrameDomain('\'self\'');
296
-		$response->setContentSecurityPolicy($policy);
297
-
298
-		return $response;
299
-	}
300
-
301
-	/**
302
-	 * Redirects to the file list and highlight the given file id
303
-	 *
304
-	 * @param string $fileId file id to show
305
-	 * @return RedirectResponse redirect response or not found response
306
-	 * @throws \OCP\Files\NotFoundException
307
-	 */
308
-	private function redirectToFile($fileId) {
309
-		$uid        = $this->userSession->getUser()->getUID();
310
-		$baseFolder = $this->rootFolder->getUserFolder($uid);
311
-		$files      = $baseFolder->getById($fileId);
312
-		$params     = [];
313
-
314
-		if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
315
-			$baseFolder     = $this->rootFolder->get($uid . '/files_trashbin/files/');
316
-			$files          = $baseFolder->getById($fileId);
317
-			$params['view'] = 'trashbin';
318
-		}
319
-
320
-		if (!empty($files)) {
321
-			$file = current($files);
322
-			if ($file instanceof Folder) {
323
-				// set the full path to enter the folder
324
-				$params['dir'] = $baseFolder->getRelativePath($file->getPath());
325
-			} else {
326
-				// set parent path as dir
327
-				$params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
328
-				// and scroll to the entry
329
-				$params['scrollto'] = $file->getName();
330
-			}
331
-
332
-			return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
333
-		}
334
-		throw new \OCP\Files\NotFoundException();
335
-	}
55
+    /** @var string */
56
+    protected $appName;
57
+    /** @var IRequest */
58
+    protected $request;
59
+    /** @var IURLGenerator */
60
+    protected $urlGenerator;
61
+    /** @var IL10N */
62
+    protected $l10n;
63
+    /** @var IConfig */
64
+    protected $config;
65
+    /** @var IEventDispatcher */
66
+    protected $eventDispatcher;
67
+    /** @var IUserSession */
68
+    protected $userSession;
69
+    /** @var IAppManager */
70
+    protected $appManager;
71
+    /** @var IRootFolder */
72
+    protected $rootFolder;
73
+    /** @var Helper */
74
+    protected $activityHelper;
75
+
76
+    public function __construct(string $appName,
77
+        IRequest $request,
78
+        IURLGenerator $urlGenerator,
79
+        IL10N $l10n,
80
+        IConfig $config,
81
+        IEventDispatcher $eventDispatcher,
82
+        IUserSession $userSession,
83
+        IAppManager $appManager,
84
+        IRootFolder $rootFolder,
85
+        Helper $activityHelper
86
+    ) {
87
+        parent::__construct($appName, $request);
88
+        $this->appName         = $appName;
89
+        $this->request         = $request;
90
+        $this->urlGenerator    = $urlGenerator;
91
+        $this->l10n            = $l10n;
92
+        $this->config          = $config;
93
+        $this->eventDispatcher = $eventDispatcher;
94
+        $this->userSession     = $userSession;
95
+        $this->appManager      = $appManager;
96
+        $this->rootFolder      = $rootFolder;
97
+        $this->activityHelper  = $activityHelper;
98
+    }
99
+
100
+    /**
101
+     * @param string $appName
102
+     * @param string $scriptName
103
+     * @return string
104
+     */
105
+    protected function renderScript($appName, $scriptName) {
106
+        $content    = '';
107
+        $appPath    = \OC_App::getAppPath($appName);
108
+        $scriptPath = $appPath . '/' . $scriptName;
109
+        if (file_exists($scriptPath)) {
110
+            // TODO: sanitize path / script name ?
111
+            ob_start();
112
+            include $scriptPath;
113
+            $content = ob_get_contents();
114
+            @ob_end_clean();
115
+        }
116
+
117
+        return $content;
118
+    }
119
+
120
+    /**
121
+     * FIXME: Replace with non static code
122
+     *
123
+     * @return array
124
+     * @throws \OCP\Files\NotFoundException
125
+     */
126
+    protected function getStorageInfo() {
127
+        $dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
128
+
129
+        return \OC_Helper::getStorageInfo('/', $dirInfo);
130
+    }
131
+
132
+    /**
133
+     * @NoCSRFRequired
134
+     * @NoAdminRequired
135
+     *
136
+     * @param string $fileid
137
+     * @return TemplateResponse|RedirectResponse
138
+     * @throws NotFoundException
139
+     */
140
+    public function showFile(string $fileid = null): Response {
141
+        // This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
142
+        try {
143
+            return $this->redirectToFile($fileid);
144
+        } catch (NotFoundException $e) {
145
+            return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
146
+        }
147
+    }
148
+
149
+    /**
150
+     * @NoCSRFRequired
151
+     * @NoAdminRequired
152
+     *
153
+     * @param string $dir
154
+     * @param string $view
155
+     * @param string $fileid
156
+     * @param bool $fileNotFound
157
+     * @return TemplateResponse|RedirectResponse
158
+     * @throws NotFoundException
159
+     */
160
+    public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
161
+        if ($fileid !== null) {
162
+            try {
163
+                return $this->redirectToFile($fileid);
164
+            } catch (NotFoundException $e) {
165
+                return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
166
+            }
167
+        }
168
+
169
+        $nav = new \OCP\Template('files', 'appnavigation', '');
170
+
171
+        // Load the files we need
172
+        \OCP\Util::addStyle('files', 'merged');
173
+        \OCP\Util::addScript('files', 'merged-index');
174
+
175
+        // mostly for the home storage's free space
176
+        // FIXME: Make non static
177
+        $storageInfo = $this->getStorageInfo();
178
+
179
+        $user = $this->userSession->getUser()->getUID();
180
+
181
+        // Get all the user favorites to create a submenu
182
+        try {
183
+            $favElements = $this->activityHelper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
184
+        } catch (\RuntimeException $e) {
185
+            $favElements['folders'] = [];
186
+        }
187
+
188
+        $collapseClasses = '';
189
+        if (count($favElements['folders']) > 0) {
190
+            $collapseClasses = 'collapsible';
191
+        }
192
+
193
+        $favoritesSublistArray = Array();
194
+
195
+        $navBarPositionPosition = 6;
196
+        $currentCount           = 0;
197
+        foreach ($favElements['folders'] as $dir) {
198
+
199
+            $link         = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']);
200
+            $sortingValue = ++$currentCount;
201
+            $element      = [
202
+                'id'                 => str_replace('/', '-', $dir),
203
+                'view'               => 'files',
204
+                'href'               => $link,
205
+                'dir'                => $dir,
206
+                'order'              => $navBarPositionPosition,
207
+                'folderPosition'     => $sortingValue,
208
+                'name'               => basename($dir),
209
+                'icon'               => 'files',
210
+                'quickaccesselement' => 'true'
211
+            ];
212
+
213
+            array_push($favoritesSublistArray, $element);
214
+            $navBarPositionPosition++;
215
+        }
216
+
217
+        $navItems = \OCA\Files\App::getNavigationManager()->getAll();
218
+
219
+        // add the favorites entry in menu
220
+        $navItems['favorites']['sublist'] = $favoritesSublistArray;
221
+        $navItems['favorites']['classes'] = $collapseClasses;
222
+
223
+        // parse every menu and add the expandedState user value
224
+        foreach ($navItems as $key => $item) {
225
+            if (isset($item['expandedState'])) {
226
+                $navItems[$key]['defaultExpandedState'] = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', $item['expandedState'], '0') === '1';
227
+            }
228
+        }
229
+
230
+        $nav->assign('navigationItems', $navItems);
231
+
232
+        $nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used']));
233
+        if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
234
+            $totalSpace = $this->l10n->t('Unlimited');
235
+        } else {
236
+            $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
237
+        }
238
+        $nav->assign('total_space', $totalSpace);
239
+        $nav->assign('quota', $storageInfo['quota']);
240
+        $nav->assign('usage_relative', $storageInfo['relative']);
241
+
242
+        $contentItems = [];
243
+
244
+        // render the container content for every navigation item
245
+        foreach ($navItems as $item) {
246
+            $content = '';
247
+            if (isset($item['script'])) {
248
+                $content = $this->renderScript($item['appname'], $item['script']);
249
+            }
250
+            // parse submenus
251
+            if (isset($item['sublist'])) {
252
+                foreach ($item['sublist'] as $subitem) {
253
+                    $subcontent = '';
254
+                    if (isset($subitem['script'])) {
255
+                        $subcontent = $this->renderScript($subitem['appname'], $subitem['script']);
256
+                    }
257
+                    $contentItems[$subitem['id']] = [
258
+                        'id'      => $subitem['id'],
259
+                        'content' => $subcontent
260
+                    ];
261
+                }
262
+            }
263
+            $contentItems[$item['id']] = [
264
+                'id'      => $item['id'],
265
+                'content' => $content
266
+            ];
267
+        }
268
+
269
+        $event = new LoadAdditionalScriptsEvent();
270
+        $this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);
271
+
272
+        $params                                = [];
273
+        $params['usedSpacePercent']            = (int) $storageInfo['relative'];
274
+        $params['owner']                       = $storageInfo['owner'];
275
+        $params['ownerDisplayName']            = $storageInfo['ownerDisplayName'];
276
+        $params['isPublic']                    = false;
277
+        $params['allowShareWithLink']          = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
278
+        $params['defaultFileSorting']          = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
279
+        $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
280
+        $params['showgridview']				   = $this->config->getUserValue($user, 'files', 'show_grid', false);
281
+        $params['isIE']						   = \OCP\Util::isIE();
282
+        $showHidden                            = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
283
+        $params['showHiddenFiles']             = $showHidden ? 1 : 0;
284
+        $params['fileNotFound']                = $fileNotFound ? 1 : 0;
285
+        $params['appNavigation']               = $nav;
286
+        $params['appContents']                 = $contentItems;
287
+        $params['hiddenFields']                = $event->getHiddenFields();
288
+
289
+        $response = new TemplateResponse(
290
+            $this->appName,
291
+            'index',
292
+            $params
293
+        );
294
+        $policy = new ContentSecurityPolicy();
295
+        $policy->addAllowedFrameDomain('\'self\'');
296
+        $response->setContentSecurityPolicy($policy);
297
+
298
+        return $response;
299
+    }
300
+
301
+    /**
302
+     * Redirects to the file list and highlight the given file id
303
+     *
304
+     * @param string $fileId file id to show
305
+     * @return RedirectResponse redirect response or not found response
306
+     * @throws \OCP\Files\NotFoundException
307
+     */
308
+    private function redirectToFile($fileId) {
309
+        $uid        = $this->userSession->getUser()->getUID();
310
+        $baseFolder = $this->rootFolder->getUserFolder($uid);
311
+        $files      = $baseFolder->getById($fileId);
312
+        $params     = [];
313
+
314
+        if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
315
+            $baseFolder     = $this->rootFolder->get($uid . '/files_trashbin/files/');
316
+            $files          = $baseFolder->getById($fileId);
317
+            $params['view'] = 'trashbin';
318
+        }
319
+
320
+        if (!empty($files)) {
321
+            $file = current($files);
322
+            if ($file instanceof Folder) {
323
+                // set the full path to enter the folder
324
+                $params['dir'] = $baseFolder->getRelativePath($file->getPath());
325
+            } else {
326
+                // set parent path as dir
327
+                $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
328
+                // and scroll to the entry
329
+                $params['scrollto'] = $file->getName();
330
+            }
331
+
332
+            return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
333
+        }
334
+        throw new \OCP\Files\NotFoundException();
335
+    }
336 336
 }
Please login to merge, or discard this patch.
apps/files/lib/Listener/LegacyLoadAdditionalScriptsAdapter.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@
 block discarded – undo
32 32
 
33 33
 class LegacyLoadAdditionalScriptsAdapter implements IEventListener {
34 34
 
35
-	/** @var SymfonyAdapter */
36
-	private $dispatcher;
37
-
38
-	public function __construct(SymfonyAdapter $dispatcher) {
39
-		$this->dispatcher = $dispatcher;
40
-	}
41
-
42
-	public function handle(Event $event): void {
43
-		if (!($event instanceof LoadAdditionalScriptsEvent)) {
44
-			return;
45
-		}
46
-
47
-		$legacyEvent = new GenericEvent(null, ['hiddenFields' => []]);
48
-		$this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent);
49
-
50
-		$hiddenFields = $legacyEvent->getArgument('hiddenFields');
51
-		foreach ($hiddenFields as $name => $value) {
52
-			$event->addHiddenField($name, $value);
53
-		}
54
-	}
35
+    /** @var SymfonyAdapter */
36
+    private $dispatcher;
37
+
38
+    public function __construct(SymfonyAdapter $dispatcher) {
39
+        $this->dispatcher = $dispatcher;
40
+    }
41
+
42
+    public function handle(Event $event): void {
43
+        if (!($event instanceof LoadAdditionalScriptsEvent)) {
44
+            return;
45
+        }
46
+
47
+        $legacyEvent = new GenericEvent(null, ['hiddenFields' => []]);
48
+        $this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent);
49
+
50
+        $hiddenFields = $legacyEvent->getArgument('hiddenFields');
51
+        foreach ($hiddenFields as $name => $value) {
52
+            $event->addHiddenField($name, $value);
53
+        }
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
apps/files/lib/AppInfo/Application.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -41,56 +41,56 @@
 block discarded – undo
41 41
 use OCA\Files\Capabilities;
42 42
 
43 43
 class Application extends App {
44
-	public function __construct(array $urlParams=array()) {
45
-		parent::__construct('files', $urlParams);
46
-		$container = $this->getContainer();
47
-		$server = $container->getServer();
44
+    public function __construct(array $urlParams=array()) {
45
+        parent::__construct('files', $urlParams);
46
+        $container = $this->getContainer();
47
+        $server = $container->getServer();
48 48
 
49
-		/**
50
-		 * Controllers
51
-		 */
52
-		$container->registerService('APIController', function (IContainer $c) use ($server) {
53
-			return new ApiController(
54
-				$c->query('AppName'),
55
-				$c->query('Request'),
56
-				$server->getUserSession(),
57
-				$c->query('TagService'),
58
-				$server->getPreviewManager(),
59
-				$server->getShareManager(),
60
-				$server->getConfig(),
61
-				$server->getUserFolder()
62
-			);
63
-		});
49
+        /**
50
+         * Controllers
51
+         */
52
+        $container->registerService('APIController', function (IContainer $c) use ($server) {
53
+            return new ApiController(
54
+                $c->query('AppName'),
55
+                $c->query('Request'),
56
+                $server->getUserSession(),
57
+                $c->query('TagService'),
58
+                $server->getPreviewManager(),
59
+                $server->getShareManager(),
60
+                $server->getConfig(),
61
+                $server->getUserFolder()
62
+            );
63
+        });
64 64
 
65
-		/**
66
-		 * Services
67
-		 */
68
-		$container->registerService('TagService', function(IContainer $c) use ($server) {
69
-			$homeFolder = $c->query('ServerContainer')->getUserFolder();
70
-			return new TagService(
71
-				$c->query('ServerContainer')->getUserSession(),
72
-				$c->query('ServerContainer')->getActivityManager(),
73
-				$c->query('ServerContainer')->getTagManager()->load('files'),
74
-				$homeFolder,
75
-				$server->getEventDispatcher()
76
-			);
77
-		});
65
+        /**
66
+         * Services
67
+         */
68
+        $container->registerService('TagService', function(IContainer $c) use ($server) {
69
+            $homeFolder = $c->query('ServerContainer')->getUserFolder();
70
+            return new TagService(
71
+                $c->query('ServerContainer')->getUserSession(),
72
+                $c->query('ServerContainer')->getActivityManager(),
73
+                $c->query('ServerContainer')->getTagManager()->load('files'),
74
+                $homeFolder,
75
+                $server->getEventDispatcher()
76
+            );
77
+        });
78 78
 
79
-		/*
79
+        /*
80 80
 		 * Register capabilities
81 81
 		 */
82
-		$container->registerCapability(Capabilities::class);
82
+        $container->registerCapability(Capabilities::class);
83 83
 
84
-		/**
85
-		 * Register Collaboration ResourceProvider
86
-		 */
87
-		/** @var IManager $resourceManager */
88
-		$resourceManager = $container->query(IManager::class);
89
-		$resourceManager->registerResourceProvider(ResourceProvider::class);
90
-		Listener::register($server->getEventDispatcher());
84
+        /**
85
+         * Register Collaboration ResourceProvider
86
+         */
87
+        /** @var IManager $resourceManager */
88
+        $resourceManager = $container->query(IManager::class);
89
+        $resourceManager->registerResourceProvider(ResourceProvider::class);
90
+        Listener::register($server->getEventDispatcher());
91 91
 
92
-		/** @var IEventDispatcher $dispatcher */
93
-		$dispatcher = $container->query(IEventDispatcher::class);
94
-		$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
95
-	}
92
+        /** @var IEventDispatcher $dispatcher */
93
+        $dispatcher = $container->query(IEventDispatcher::class);
94
+        $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
95
+    }
96 96
 }
Please login to merge, or discard this patch.
apps/files/lib/Event/LoadAdditionalScriptsEvent.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
 
29 29
 class LoadAdditionalScriptsEvent extends Event {
30 30
 
31
-	private $hiddenFields = [];
31
+    private $hiddenFields = [];
32 32
 
33
-	public function addHiddenField(string $name, string $value): void {
34
-		$this->hiddenFields[$name] = $value;
35
-	}
33
+    public function addHiddenField(string $name, string $value): void {
34
+        $this->hiddenFields[$name] = $value;
35
+    }
36 36
 
37
-	public function getHiddenFields(): array {
38
-		return $this->hiddenFields;
39
-	}
37
+    public function getHiddenFields(): array {
38
+        return $this->hiddenFields;
39
+    }
40 40
 }
Please login to merge, or discard this patch.