Completed
Pull Request — master (#5305)
by Jan-Christoph
15:51
created
apps/files/lib/Controller/ViewController.php 1 patch
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -48,218 +48,218 @@
 block discarded – undo
48 48
  * @package OCA\Files\Controller
49 49
  */
50 50
 class ViewController extends Controller {
51
-	/** @var string */
52
-	protected $appName;
53
-	/** @var IRequest */
54
-	protected $request;
55
-	/** @var IURLGenerator */
56
-	protected $urlGenerator;
57
-	/** @var IL10N */
58
-	protected $l10n;
59
-	/** @var IConfig */
60
-	protected $config;
61
-	/** @var EventDispatcherInterface */
62
-	protected $eventDispatcher;
63
-	/** @var IUserSession */
64
-	protected $userSession;
65
-	/** @var IAppManager */
66
-	protected $appManager;
67
-	/** @var IRootFolder */
68
-	protected $rootFolder;
51
+    /** @var string */
52
+    protected $appName;
53
+    /** @var IRequest */
54
+    protected $request;
55
+    /** @var IURLGenerator */
56
+    protected $urlGenerator;
57
+    /** @var IL10N */
58
+    protected $l10n;
59
+    /** @var IConfig */
60
+    protected $config;
61
+    /** @var EventDispatcherInterface */
62
+    protected $eventDispatcher;
63
+    /** @var IUserSession */
64
+    protected $userSession;
65
+    /** @var IAppManager */
66
+    protected $appManager;
67
+    /** @var IRootFolder */
68
+    protected $rootFolder;
69 69
 
70
-	/**
71
-	 * @param string $appName
72
-	 * @param IRequest $request
73
-	 * @param IURLGenerator $urlGenerator
74
-	 * @param IL10N $l10n
75
-	 * @param IConfig $config
76
-	 * @param EventDispatcherInterface $eventDispatcherInterface
77
-	 * @param IUserSession $userSession
78
-	 * @param IAppManager $appManager
79
-	 * @param IRootFolder $rootFolder
80
-	 */
81
-	public function __construct($appName,
82
-								IRequest $request,
83
-								IURLGenerator $urlGenerator,
84
-								IL10N $l10n,
85
-								IConfig $config,
86
-								EventDispatcherInterface $eventDispatcherInterface,
87
-								IUserSession $userSession,
88
-								IAppManager $appManager,
89
-								IRootFolder $rootFolder
90
-	) {
91
-		parent::__construct($appName, $request);
92
-		$this->appName = $appName;
93
-		$this->request = $request;
94
-		$this->urlGenerator = $urlGenerator;
95
-		$this->l10n = $l10n;
96
-		$this->config = $config;
97
-		$this->eventDispatcher = $eventDispatcherInterface;
98
-		$this->userSession = $userSession;
99
-		$this->appManager = $appManager;
100
-		$this->rootFolder = $rootFolder;
101
-	}
70
+    /**
71
+     * @param string $appName
72
+     * @param IRequest $request
73
+     * @param IURLGenerator $urlGenerator
74
+     * @param IL10N $l10n
75
+     * @param IConfig $config
76
+     * @param EventDispatcherInterface $eventDispatcherInterface
77
+     * @param IUserSession $userSession
78
+     * @param IAppManager $appManager
79
+     * @param IRootFolder $rootFolder
80
+     */
81
+    public function __construct($appName,
82
+                                IRequest $request,
83
+                                IURLGenerator $urlGenerator,
84
+                                IL10N $l10n,
85
+                                IConfig $config,
86
+                                EventDispatcherInterface $eventDispatcherInterface,
87
+                                IUserSession $userSession,
88
+                                IAppManager $appManager,
89
+                                IRootFolder $rootFolder
90
+    ) {
91
+        parent::__construct($appName, $request);
92
+        $this->appName = $appName;
93
+        $this->request = $request;
94
+        $this->urlGenerator = $urlGenerator;
95
+        $this->l10n = $l10n;
96
+        $this->config = $config;
97
+        $this->eventDispatcher = $eventDispatcherInterface;
98
+        $this->userSession = $userSession;
99
+        $this->appManager = $appManager;
100
+        $this->rootFolder = $rootFolder;
101
+    }
102 102
 
103
-	/**
104
-	 * @param string $appName
105
-	 * @param string $scriptName
106
-	 * @return string
107
-	 */
108
-	protected function renderScript($appName, $scriptName) {
109
-		$content = '';
110
-		$appPath = \OC_App::getAppPath($appName);
111
-		$scriptPath = $appPath . '/' . $scriptName;
112
-		if (file_exists($scriptPath)) {
113
-			// TODO: sanitize path / script name ?
114
-			ob_start();
115
-			include $scriptPath;
116
-			$content = ob_get_contents();
117
-			@ob_end_clean();
118
-		}
119
-		return $content;
120
-	}
103
+    /**
104
+     * @param string $appName
105
+     * @param string $scriptName
106
+     * @return string
107
+     */
108
+    protected function renderScript($appName, $scriptName) {
109
+        $content = '';
110
+        $appPath = \OC_App::getAppPath($appName);
111
+        $scriptPath = $appPath . '/' . $scriptName;
112
+        if (file_exists($scriptPath)) {
113
+            // TODO: sanitize path / script name ?
114
+            ob_start();
115
+            include $scriptPath;
116
+            $content = ob_get_contents();
117
+            @ob_end_clean();
118
+        }
119
+        return $content;
120
+    }
121 121
 
122
-	/**
123
-	 * FIXME: Replace with non static code
124
-	 *
125
-	 * @return array
126
-	 * @throws \OCP\Files\NotFoundException
127
-	 */
128
-	protected function getStorageInfo() {
129
-		$dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
130
-		return \OC_Helper::getStorageInfo('/', $dirInfo);
131
-	}
122
+    /**
123
+     * FIXME: Replace with non static code
124
+     *
125
+     * @return array
126
+     * @throws \OCP\Files\NotFoundException
127
+     */
128
+    protected function getStorageInfo() {
129
+        $dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
130
+        return \OC_Helper::getStorageInfo('/', $dirInfo);
131
+    }
132 132
 
133
-	/**
134
-	 * @NoCSRFRequired
135
-	 * @NoAdminRequired
136
-	 *
137
-	 * @param string $dir
138
-	 * @param string $view
139
-	 * @param string $fileid
140
-	 * @return TemplateResponse|RedirectResponse
141
-	 */
142
-	public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
143
-		if ($fileid !== null) {
144
-			try {
145
-				return $this->showFile($fileid);
146
-			} catch (NotFoundException $e) {
147
-				return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
148
-			}
149
-		}
133
+    /**
134
+     * @NoCSRFRequired
135
+     * @NoAdminRequired
136
+     *
137
+     * @param string $dir
138
+     * @param string $view
139
+     * @param string $fileid
140
+     * @return TemplateResponse|RedirectResponse
141
+     */
142
+    public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) {
143
+        if ($fileid !== null) {
144
+            try {
145
+                return $this->showFile($fileid);
146
+            } catch (NotFoundException $e) {
147
+                return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
148
+            }
149
+        }
150 150
 
151
-		$nav = new \OCP\Template('files', 'appnavigation', '');
151
+        $nav = new \OCP\Template('files', 'appnavigation', '');
152 152
 
153
-		// Load the files we need
154
-		\OCP\Util::addStyle('files', 'merged');
155
-		\OCP\Util::addScript('files', 'merged-index');
153
+        // Load the files we need
154
+        \OCP\Util::addStyle('files', 'merged');
155
+        \OCP\Util::addScript('files', 'merged-index');
156 156
 
157
-		// mostly for the home storage's free space
158
-		// FIXME: Make non static
159
-		$storageInfo = $this->getStorageInfo();
157
+        // mostly for the home storage's free space
158
+        // FIXME: Make non static
159
+        $storageInfo = $this->getStorageInfo();
160 160
 
161
-		\OCA\Files\App::getNavigationManager()->add(
162
-			[
163
-				'id' => 'favorites',
164
-				'appname' => 'files',
165
-				'script' => 'simplelist.php',
166
-				'order' => 5,
167
-				'name' => $this->l10n->t('Favorites')
168
-			]
169
-		);
161
+        \OCA\Files\App::getNavigationManager()->add(
162
+            [
163
+                'id' => 'favorites',
164
+                'appname' => 'files',
165
+                'script' => 'simplelist.php',
166
+                'order' => 5,
167
+                'name' => $this->l10n->t('Favorites')
168
+            ]
169
+        );
170 170
 
171
-		$navItems = \OCA\Files\App::getNavigationManager()->getAll();
172
-		usort($navItems, function($item1, $item2) {
173
-			return $item1['order'] - $item2['order'];
174
-		});
175
-		$nav->assign('navigationItems', $navItems);
171
+        $navItems = \OCA\Files\App::getNavigationManager()->getAll();
172
+        usort($navItems, function($item1, $item2) {
173
+            return $item1['order'] - $item2['order'];
174
+        });
175
+        $nav->assign('navigationItems', $navItems);
176 176
 
177 177
 
178
-		$nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used']));
179
-		if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
180
-			$totalSpace = $this->l10n->t('Unlimited');
181
-		} else {
182
-			$totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
183
-		}
184
-		$nav->assign('total_space', $totalSpace);
185
-		$nav->assign('quota', $storageInfo['quota']);
186
-		$nav->assign('usage_relative', $storageInfo['relative']);
178
+        $nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used']));
179
+        if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
180
+            $totalSpace = $this->l10n->t('Unlimited');
181
+        } else {
182
+            $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']);
183
+        }
184
+        $nav->assign('total_space', $totalSpace);
185
+        $nav->assign('quota', $storageInfo['quota']);
186
+        $nav->assign('usage_relative', $storageInfo['relative']);
187 187
 
188
-		$contentItems = [];
188
+        $contentItems = [];
189 189
 
190
-		// render the container content for every navigation item
191
-		foreach ($navItems as $item) {
192
-			$content = '';
193
-			if (isset($item['script'])) {
194
-				$content = $this->renderScript($item['appname'], $item['script']);
195
-			}
196
-			$contentItem = [];
197
-			$contentItem['id'] = $item['id'];
198
-			$contentItem['content'] = $content;
199
-			$contentItems[] = $contentItem;
200
-		}
190
+        // render the container content for every navigation item
191
+        foreach ($navItems as $item) {
192
+            $content = '';
193
+            if (isset($item['script'])) {
194
+                $content = $this->renderScript($item['appname'], $item['script']);
195
+            }
196
+            $contentItem = [];
197
+            $contentItem['id'] = $item['id'];
198
+            $contentItem['content'] = $content;
199
+            $contentItems[] = $contentItem;
200
+        }
201 201
 
202
-		$this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts');
202
+        $this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts');
203 203
 
204
-		$params = [];
205
-		$params['usedSpacePercent'] = (int)$storageInfo['relative'];
206
-		$params['owner'] = $storageInfo['owner'];
207
-		$params['ownerDisplayName'] = $storageInfo['ownerDisplayName'];
208
-		$params['isPublic'] = false;
209
-		$params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
210
-		$user = $this->userSession->getUser()->getUID();
211
-		$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
212
-		$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
213
-		$showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
214
-		$params['showHiddenFiles'] = $showHidden ? 1 : 0;
215
-		$params['fileNotFound'] = $fileNotFound ? 1 : 0;
216
-		$params['appNavigation'] = $nav;
217
-		$params['appContents'] = $contentItems;
204
+        $params = [];
205
+        $params['usedSpacePercent'] = (int)$storageInfo['relative'];
206
+        $params['owner'] = $storageInfo['owner'];
207
+        $params['ownerDisplayName'] = $storageInfo['ownerDisplayName'];
208
+        $params['isPublic'] = false;
209
+        $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
210
+        $user = $this->userSession->getUser()->getUID();
211
+        $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
212
+        $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
213
+        $showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
214
+        $params['showHiddenFiles'] = $showHidden ? 1 : 0;
215
+        $params['fileNotFound'] = $fileNotFound ? 1 : 0;
216
+        $params['appNavigation'] = $nav;
217
+        $params['appContents'] = $contentItems;
218 218
 
219
-		$response = new TemplateResponse(
220
-			$this->appName,
221
-			'index',
222
-			$params
223
-		);
224
-		$policy = new ContentSecurityPolicy();
225
-		$policy->addAllowedFrameDomain('\'self\'');
226
-		$response->setContentSecurityPolicy($policy);
219
+        $response = new TemplateResponse(
220
+            $this->appName,
221
+            'index',
222
+            $params
223
+        );
224
+        $policy = new ContentSecurityPolicy();
225
+        $policy->addAllowedFrameDomain('\'self\'');
226
+        $response->setContentSecurityPolicy($policy);
227 227
 
228
-		return $response;
229
-	}
228
+        return $response;
229
+    }
230 230
 
231
-	/**
232
-	 * Redirects to the file list and highlight the given file id
233
-	 *
234
-	 * @param string $fileId file id to show
235
-	 * @return RedirectResponse redirect response or not found response
236
-	 * @throws \OCP\Files\NotFoundException
237
-	 */
238
-	private function showFile($fileId) {
239
-		$uid = $this->userSession->getUser()->getUID();
240
-		$baseFolder = $this->rootFolder->getUserFolder($uid);
241
-		$files = $baseFolder->getById($fileId);
242
-		$params = [];
231
+    /**
232
+     * Redirects to the file list and highlight the given file id
233
+     *
234
+     * @param string $fileId file id to show
235
+     * @return RedirectResponse redirect response or not found response
236
+     * @throws \OCP\Files\NotFoundException
237
+     */
238
+    private function showFile($fileId) {
239
+        $uid = $this->userSession->getUser()->getUID();
240
+        $baseFolder = $this->rootFolder->getUserFolder($uid);
241
+        $files = $baseFolder->getById($fileId);
242
+        $params = [];
243 243
 
244
-		if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
245
-			$baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
246
-			$files = $baseFolder->getById($fileId);
247
-			$params['view'] = 'trashbin';
248
-		}
244
+        if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
245
+            $baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
246
+            $files = $baseFolder->getById($fileId);
247
+            $params['view'] = 'trashbin';
248
+        }
249 249
 
250
-		if (!empty($files)) {
251
-			$file = current($files);
252
-			if ($file instanceof Folder) {
253
-				// set the full path to enter the folder
254
-				$params['dir'] = $baseFolder->getRelativePath($file->getPath());
255
-			} else {
256
-				// set parent path as dir
257
-				$params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
258
-				// and scroll to the entry
259
-				$params['scrollto'] = $file->getName();
260
-			}
261
-			return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
262
-		}
263
-		throw new \OCP\Files\NotFoundException();
264
-	}
250
+        if (!empty($files)) {
251
+            $file = current($files);
252
+            if ($file instanceof Folder) {
253
+                // set the full path to enter the folder
254
+                $params['dir'] = $baseFolder->getRelativePath($file->getPath());
255
+            } else {
256
+                // set parent path as dir
257
+                $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
258
+                // and scroll to the entry
259
+                $params['scrollto'] = $file->getName();
260
+            }
261
+            return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
262
+        }
263
+        throw new \OCP\Files\NotFoundException();
264
+    }
265 265
 }
Please login to merge, or discard this patch.
apps/files/templates/appnavigation.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <div id="app-navigation">
2 2
 	<ul class="with-icon">
3 3
 		<li id="quota" class="section <?php
4
-		if ($_['quota'] !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
5
-			?>has-tooltip" title="<?php
6
-			p($l->t('%s %%', [$_['usage_relative']]));
7
-		}
8
-		?>">
4
+        if ($_['quota'] !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
5
+            ?>has-tooltip" title="<?php
6
+            p($l->t('%s %%', [$_['usage_relative']]));
7
+        }
8
+        ?>">
9 9
 			<a href="#" class="nav-icon-quota svg">
10 10
 				<p id="quotatext"><?php p($l->t('%s of %s used', [$_['usage'], $_['total_space']])); ?></p>
11 11
 				<div class="quota-container">
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 			<a href="#" class="nav-icon-quota svg">
10 10
 				<p id="quotatext"><?php p($l->t('%s of %s used', [$_['usage'], $_['total_space']])); ?></p>
11 11
 				<div class="quota-container">
12
-					<div style="width:<?php p($_['usage_relative']);?>%"
13
-						 <?php if($_['usage_relative'] > 80): ?>class="quota-warning"<?php endif; ?>>
12
+					<div style="width:<?php p($_['usage_relative']); ?>%"
13
+						 <?php if ($_['usage_relative'] > 80): ?>class="quota-warning"<?php endif; ?>>
14 14
 					</div>
15 15
 				</div>
16 16
 				<p id="quotatext-additional"><?php p($l->t('Do you need more space?')); ?></p>
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		<li data-id="<?php p($item['id']) ?>" class="nav-<?php p($item['id']) ?>">
21 21
 			<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
22 22
 				class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg">
23
-				<?php p($item['name']);?>
23
+				<?php p($item['name']); ?>
24 24
 			</a>
25 25
 		</li>
26 26
 		<?php } ?>
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	<div id="app-settings">
29 29
 		<div id="app-settings-header">
30 30
 			<button class="settings-button" data-apps-slide-toggle="#app-settings-content">
31
-				<?php p($l->t('Settings'));?>
31
+				<?php p($l->t('Settings')); ?>
32 32
 			</button>
33 33
 		</div>
34 34
 		<div id="app-settings-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 				<input class="checkbox" id="showhiddenfilesToggle" checked="checked" type="checkbox">
37 37
 				<label for="showhiddenfilesToggle"><?php p($l->t('Show hidden files')); ?></label>
38 38
 			</div>
39
-			<label for="webdavurl"><?php p($l->t('WebDAV'));?></label>
39
+			<label for="webdavurl"><?php p($l->t('WebDAV')); ?></label>
40 40
 			<input id="webdavurl" type="text" readonly="readonly" value="<?php p(\OCP\Util::linkToRemote('webdav')); ?>" />
41
-			<em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer">access your Files via WebDAV</a>', array(link_to_docs('user-webdav'))));?></em>
41
+			<em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer">access your Files via WebDAV</a>', array(link_to_docs('user-webdav')))); ?></em>
42 42
 		</div>
43 43
 	</div>
44 44
 </div>
Please login to merge, or discard this patch.