Passed
Push — master ( 7ac6ee...bf39ad )
by Roeland
13:54 queued 15s
created
lib/private/Search/Provider/File.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -38,63 +38,63 @@
 block discarded – undo
38 38
  */
39 39
 class File extends PagedProvider {
40 40
 
41
-	/**
42
-	 * Search for files and folders matching the given query
43
-	 *
44
-	 * @param string $query
45
-	 * @param int|null $limit
46
-	 * @param int|null $offset
47
-	 * @return \OCP\Search\Result[]
48
-	 * @deprecated 20.0.0
49
-	 */
50
-	public function search($query, int $limit = null, int $offset = null) {
51
-		if ($offset === null) {
52
-			$offset = 0;
53
-		}
54
-		\OC_Util::setupFS();
55
-		$files = Filesystem::search($query);
56
-		$results = [];
57
-		if ($limit !== null) {
58
-			$files = array_slice($files, $offset, $offset + $limit);
59
-		}
60
-		// edit results
61
-		foreach ($files as $fileData) {
62
-			// skip versions
63
-			if (strpos($fileData['path'], '_versions') === 0) {
64
-				continue;
65
-			}
66
-			// skip top-level folder
67
-			if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
68
-				continue;
69
-			}
70
-			// create audio result
71
-			if ($fileData['mimepart'] === 'audio') {
72
-				$result = new \OC\Search\Result\Audio($fileData);
73
-			}
74
-			// create image result
75
-			elseif ($fileData['mimepart'] === 'image') {
76
-				$result = new \OC\Search\Result\Image($fileData);
77
-			}
78
-			// create folder result
79
-			elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
80
-				$result = new \OC\Search\Result\Folder($fileData);
81
-			}
82
-			// or create file result
83
-			else {
84
-				$result = new \OC\Search\Result\File($fileData);
85
-			}
86
-			// add to results
87
-			$results[] = $result;
88
-		}
89
-		// return
90
-		return $results;
91
-	}
41
+    /**
42
+     * Search for files and folders matching the given query
43
+     *
44
+     * @param string $query
45
+     * @param int|null $limit
46
+     * @param int|null $offset
47
+     * @return \OCP\Search\Result[]
48
+     * @deprecated 20.0.0
49
+     */
50
+    public function search($query, int $limit = null, int $offset = null) {
51
+        if ($offset === null) {
52
+            $offset = 0;
53
+        }
54
+        \OC_Util::setupFS();
55
+        $files = Filesystem::search($query);
56
+        $results = [];
57
+        if ($limit !== null) {
58
+            $files = array_slice($files, $offset, $offset + $limit);
59
+        }
60
+        // edit results
61
+        foreach ($files as $fileData) {
62
+            // skip versions
63
+            if (strpos($fileData['path'], '_versions') === 0) {
64
+                continue;
65
+            }
66
+            // skip top-level folder
67
+            if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
68
+                continue;
69
+            }
70
+            // create audio result
71
+            if ($fileData['mimepart'] === 'audio') {
72
+                $result = new \OC\Search\Result\Audio($fileData);
73
+            }
74
+            // create image result
75
+            elseif ($fileData['mimepart'] === 'image') {
76
+                $result = new \OC\Search\Result\Image($fileData);
77
+            }
78
+            // create folder result
79
+            elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
80
+                $result = new \OC\Search\Result\Folder($fileData);
81
+            }
82
+            // or create file result
83
+            else {
84
+                $result = new \OC\Search\Result\File($fileData);
85
+            }
86
+            // add to results
87
+            $results[] = $result;
88
+        }
89
+        // return
90
+        return $results;
91
+    }
92 92
 
93
-	public function searchPaged($query, $page, $size) {
94
-		if ($size === 0) {
95
-			return $this->search($query);
96
-		} else {
97
-			return $this->search($query, $size, ($page - 1) * $size);
98
-		}
99
-	}
93
+    public function searchPaged($query, $page, $size) {
94
+        if ($size === 0) {
95
+            return $this->search($query);
96
+        } else {
97
+            return $this->search($query, $size, ($page - 1) * $size);
98
+        }
99
+    }
100 100
 }
Please login to merge, or discard this patch.
apps/files/lib/Search/FilesSearchProvider.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -43,102 +43,102 @@
 block discarded – undo
43 43
 
44 44
 class FilesSearchProvider implements IProvider {
45 45
 
46
-	/** @var File */
47
-	private $fileSearch;
48
-
49
-	/** @var IL10N */
50
-	private $l10n;
51
-
52
-	/** @var IURLGenerator */
53
-	private $urlGenerator;
54
-
55
-	/** @var IMimeTypeDetector */
56
-	private $mimeTypeDetector;
57
-
58
-	/** @var IRootFolder */
59
-	private $rootFolder;
60
-
61
-	public function __construct(File $fileSearch,
62
-								IL10N $l10n,
63
-								IURLGenerator $urlGenerator,
64
-								IMimeTypeDetector $mimeTypeDetector,
65
-								IRootFolder $rootFolder) {
66
-		$this->l10n = $l10n;
67
-		$this->fileSearch = $fileSearch;
68
-		$this->urlGenerator = $urlGenerator;
69
-		$this->mimeTypeDetector = $mimeTypeDetector;
70
-		$this->rootFolder = $rootFolder;
71
-	}
72
-
73
-	/**
74
-	 * @inheritDoc
75
-	 */
76
-	public function getId(): string {
77
-		return 'files';
78
-	}
79
-
80
-	/**
81
-	 * @inheritDoc
82
-	 */
83
-	public function getName(): string {
84
-		return $this->l10n->t('Files');
85
-	}
86
-
87
-	/**
88
-	 * @inheritDoc
89
-	 */
90
-	public function getOrder(string $route, array $routeParameters): int {
91
-		if ($route === 'files.View.index') {
92
-			// Before comments
93
-			return -5;
94
-		}
95
-		return 5;
96
-	}
97
-
98
-	/**
99
-	 * @inheritDoc
100
-	 */
101
-	public function search(IUser $user, ISearchQuery $query): SearchResult {
102
-
103
-		// Make sure we setup the users filesystem
104
-		$this->rootFolder->getUserFolder($user->getUID());
105
-
106
-		return SearchResult::paginated(
107
-			$this->l10n->t('Files'),
108
-			array_map(function (FileResult $result) {
109
-				// Generate thumbnail url
110
-				$thumbnailUrl = $result->has_preview
111
-					? $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id])
112
-					: '';
113
-
114
-				$searchResultEntry = new SearchResultEntry(
115
-					$thumbnailUrl,
116
-					$result->name,
117
-					$this->formatSubline($result),
118
-					$this->urlGenerator->getAbsoluteURL($result->link),
119
-					$result->type === 'folder' ? 'icon-folder' : $this->mimeTypeDetector->mimeTypeIcon($result->mime_type)
120
-				);
121
-				$searchResultEntry->addAttribute('fileId', (string)$result->id);
122
-				$searchResultEntry->addAttribute('path', $result->path);
123
-				return $searchResultEntry;
124
-			}, $this->fileSearch->search($query->getTerm(), $query->getLimit(), (int)$query->getCursor())),
125
-			$query->getCursor() + $query->getLimit()
126
-		);
127
-	}
128
-
129
-	/**
130
-	 * Format subline for files
131
-	 *
132
-	 * @param FileResult $result
133
-	 * @return string
134
-	 */
135
-	private function formatSubline($result): string {
136
-		// Do not show the location if the file is in root
137
-		if ($result->path === '/' . $result->name) {
138
-			return '';
139
-		}
140
-
141
-		$path = ltrim(dirname($result->path), '/');
142
-		return $this->l10n->t('in %s', [$path]);
143
-	}
46
+    /** @var File */
47
+    private $fileSearch;
48
+
49
+    /** @var IL10N */
50
+    private $l10n;
51
+
52
+    /** @var IURLGenerator */
53
+    private $urlGenerator;
54
+
55
+    /** @var IMimeTypeDetector */
56
+    private $mimeTypeDetector;
57
+
58
+    /** @var IRootFolder */
59
+    private $rootFolder;
60
+
61
+    public function __construct(File $fileSearch,
62
+                                IL10N $l10n,
63
+                                IURLGenerator $urlGenerator,
64
+                                IMimeTypeDetector $mimeTypeDetector,
65
+                                IRootFolder $rootFolder) {
66
+        $this->l10n = $l10n;
67
+        $this->fileSearch = $fileSearch;
68
+        $this->urlGenerator = $urlGenerator;
69
+        $this->mimeTypeDetector = $mimeTypeDetector;
70
+        $this->rootFolder = $rootFolder;
71
+    }
72
+
73
+    /**
74
+     * @inheritDoc
75
+     */
76
+    public function getId(): string {
77
+        return 'files';
78
+    }
79
+
80
+    /**
81
+     * @inheritDoc
82
+     */
83
+    public function getName(): string {
84
+        return $this->l10n->t('Files');
85
+    }
86
+
87
+    /**
88
+     * @inheritDoc
89
+     */
90
+    public function getOrder(string $route, array $routeParameters): int {
91
+        if ($route === 'files.View.index') {
92
+            // Before comments
93
+            return -5;
94
+        }
95
+        return 5;
96
+    }
97
+
98
+    /**
99
+     * @inheritDoc
100
+     */
101
+    public function search(IUser $user, ISearchQuery $query): SearchResult {
102
+
103
+        // Make sure we setup the users filesystem
104
+        $this->rootFolder->getUserFolder($user->getUID());
105
+
106
+        return SearchResult::paginated(
107
+            $this->l10n->t('Files'),
108
+            array_map(function (FileResult $result) {
109
+                // Generate thumbnail url
110
+                $thumbnailUrl = $result->has_preview
111
+                    ? $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id])
112
+                    : '';
113
+
114
+                $searchResultEntry = new SearchResultEntry(
115
+                    $thumbnailUrl,
116
+                    $result->name,
117
+                    $this->formatSubline($result),
118
+                    $this->urlGenerator->getAbsoluteURL($result->link),
119
+                    $result->type === 'folder' ? 'icon-folder' : $this->mimeTypeDetector->mimeTypeIcon($result->mime_type)
120
+                );
121
+                $searchResultEntry->addAttribute('fileId', (string)$result->id);
122
+                $searchResultEntry->addAttribute('path', $result->path);
123
+                return $searchResultEntry;
124
+            }, $this->fileSearch->search($query->getTerm(), $query->getLimit(), (int)$query->getCursor())),
125
+            $query->getCursor() + $query->getLimit()
126
+        );
127
+    }
128
+
129
+    /**
130
+     * Format subline for files
131
+     *
132
+     * @param FileResult $result
133
+     * @return string
134
+     */
135
+    private function formatSubline($result): string {
136
+        // Do not show the location if the file is in root
137
+        if ($result->path === '/' . $result->name) {
138
+            return '';
139
+        }
140
+
141
+        $path = ltrim(dirname($result->path), '/');
142
+        return $this->l10n->t('in %s', [$path]);
143
+    }
144 144
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 		return SearchResult::paginated(
107 107
 			$this->l10n->t('Files'),
108
-			array_map(function (FileResult $result) {
108
+			array_map(function(FileResult $result) {
109 109
 				// Generate thumbnail url
110 110
 				$thumbnailUrl = $result->has_preview
111 111
 					? $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id])
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 					$this->urlGenerator->getAbsoluteURL($result->link),
119 119
 					$result->type === 'folder' ? 'icon-folder' : $this->mimeTypeDetector->mimeTypeIcon($result->mime_type)
120 120
 				);
121
-				$searchResultEntry->addAttribute('fileId', (string)$result->id);
121
+				$searchResultEntry->addAttribute('fileId', (string) $result->id);
122 122
 				$searchResultEntry->addAttribute('path', $result->path);
123 123
 				return $searchResultEntry;
124
-			}, $this->fileSearch->search($query->getTerm(), $query->getLimit(), (int)$query->getCursor())),
124
+			}, $this->fileSearch->search($query->getTerm(), $query->getLimit(), (int) $query->getCursor())),
125 125
 			$query->getCursor() + $query->getLimit()
126 126
 		);
127 127
 	}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	private function formatSubline($result): string {
136 136
 		// Do not show the location if the file is in root
137
-		if ($result->path === '/' . $result->name) {
137
+		if ($result->path === '/'.$result->name) {
138 138
 			return '';
139 139
 		}
140 140
 
Please login to merge, or discard this patch.