Completed
Push — develop ( 047ab8...b0109b )
by Jöran
15:06
created
Classes/Service/FileCollectionService.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
             // Load all image and sort them by folder_hash
204 204
             foreach ($collection->getItems() as $item) {
205
-                if($item->getProperty('folder_hash') === $galleryFolderHash) {
205
+                if ($item->getProperty('folder_hash') === $galleryFolderHash) {
206 206
                     if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
207 207
                         array_push($allItems, $this->getFileObjectFromFileReference($item));
208 208
                     } else {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function sortFileObjectsByName(&$items, $direction)
272 272
     {
273
-        $lowercaseNames = array_map(function ($n) {
273
+        $lowercaseNames = array_map(function($n) {
274 274
             return strtolower($n->getName());
275 275
         }, $items);
276 276
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     protected function sortFileObjectsByDate(&$items, $direction)
286 286
     {
287
-        $dates = array_map(function ($n) {
287
+        $dates = array_map(function($n) {
288 288
             return strtolower($n->getCreationTime());
289 289
         }, $items);
290 290
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      */
299 299
     protected function sortFileObjectsByFolderHash(&$items, $direction)
300 300
     {
301
-        $folderhashes = array_map(function ($n) {
301
+        $folderhashes = array_map(function($n) {
302 302
             return strtolower($n->getProperty('folder_hash'));
303 303
         }, $items);
304 304
 
Please login to merge, or discard this patch.
Indentation   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -26,334 +26,334 @@
 block discarded – undo
26 26
 class FileCollectionService
27 27
 {
28 28
 
29
-    /**
30
-     * Collection Repository
31
-     *
32
-     * @var \TYPO3\CMS\Core\Resource\FileCollectionRepository
33
-     */
34
-    protected $fileCollectionRepository;
29
+	/**
30
+	 * Collection Repository
31
+	 *
32
+	 * @var \TYPO3\CMS\Core\Resource\FileCollectionRepository
33
+	 */
34
+	protected $fileCollectionRepository;
35 35
 
36
-    /**
37
-     * The Frontend Configuration
38
-     *
39
-     * @var \TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager
40
-     */
41
-    protected $frontendConfigurationManager;
36
+	/**
37
+	 * The Frontend Configuration
38
+	 *
39
+	 * @var \TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager
40
+	 */
41
+	protected $frontendConfigurationManager;
42 42
 
43
-    /**
44
-     * Inject the fileCollection repository
45
-     *
46
-     * @param \TYPO3\CMS\Core\Resource\FileCollectionRepository $fileCollectionRepository
47
-     *
48
-     * @return void
49
-     */
50
-    public function injectFileCollectionRepository(FileCollectionRepository $fileCollectionRepository)
51
-    {
52
-        $this->fileCollectionRepository = $fileCollectionRepository;
53
-    }
43
+	/**
44
+	 * Inject the fileCollection repository
45
+	 *
46
+	 * @param \TYPO3\CMS\Core\Resource\FileCollectionRepository $fileCollectionRepository
47
+	 *
48
+	 * @return void
49
+	 */
50
+	public function injectFileCollectionRepository(FileCollectionRepository $fileCollectionRepository)
51
+	{
52
+		$this->fileCollectionRepository = $fileCollectionRepository;
53
+	}
54 54
 
55
-    /**
56
-     * Inject the Frontend Configuration Manager.
57
-     *
58
-     * @param \TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager $frontendConfigurationManager
59
-     *
60
-     * @return void
61
-     */
62
-    public function injectFrontendConfigurationManager(FrontendConfigurationManager $frontendConfigurationManager)
63
-    {
64
-        $this->frontendConfigurationManager = $frontendConfigurationManager;
65
-    }
55
+	/**
56
+	 * Inject the Frontend Configuration Manager.
57
+	 *
58
+	 * @param \TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager $frontendConfigurationManager
59
+	 *
60
+	 * @return void
61
+	 */
62
+	public function injectFrontendConfigurationManager(FrontendConfigurationManager $frontendConfigurationManager)
63
+	{
64
+		$this->frontendConfigurationManager = $frontendConfigurationManager;
65
+	}
66 66
 
67
-    /**
68
-     * Returns an array of file objects for the given UIDs of fileCollections
69
-     *
70
-     * @param array $collectionUids The uids
71
-     *
72
-     * @return array
73
-     */
74
-    public function getFileObjectsFromCollection(array $collectionUids)
75
-    {
76
-        $imageItems = array();
77
-        foreach ($collectionUids as $collectionUid) {
78
-            $collection = $this->fileCollectionRepository->findByUid($collectionUid);
79
-            $collection->loadContents();
80
-            foreach ($collection->getItems() as $item) {
81
-                if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
82
-                    array_push($imageItems, $this->getFileObjectFromFileReference($item));
83
-                } else {
84
-                    array_push($imageItems, $item);
85
-                }
86
-            }
87
-        }
88
-        return $this->sortFileObjects($imageItems);
89
-    }
67
+	/**
68
+	 * Returns an array of file objects for the given UIDs of fileCollections
69
+	 *
70
+	 * @param array $collectionUids The uids
71
+	 *
72
+	 * @return array
73
+	 */
74
+	public function getFileObjectsFromCollection(array $collectionUids)
75
+	{
76
+		$imageItems = array();
77
+		foreach ($collectionUids as $collectionUid) {
78
+			$collection = $this->fileCollectionRepository->findByUid($collectionUid);
79
+			$collection->loadContents();
80
+			foreach ($collection->getItems() as $item) {
81
+				if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
82
+					array_push($imageItems, $this->getFileObjectFromFileReference($item));
83
+				} else {
84
+					array_push($imageItems, $item);
85
+				}
86
+			}
87
+		}
88
+		return $this->sortFileObjects($imageItems);
89
+	}
90 90
 
91
-    /**
92
-     * Returns an array of gallery covers for the given UIDs of fileCollections
93
-     *
94
-     * @param $collectionUids
95
-     * @return array
96
-     */
97
-    public function getGalleryCoversFromCollections($collectionUids)
98
-    {
99
-        $imageItems = array();
100
-        foreach ($collectionUids as $collectionUid) {
101
-            $collection = $this->fileCollectionRepository->findByUid($collectionUid);
102
-            $collection->loadContents();
103
-            $galleryCover = array();
104
-            foreach ($collection->getItems() as $item) {
105
-                if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
106
-                    array_push($galleryCover, $this->getFileObjectFromFileReference($item));
107
-                } else {
108
-                    array_push($galleryCover, $item);
109
-                }
110
-            }
111
-            $galleryCover = $this->sortFileObjects($galleryCover);
91
+	/**
92
+	 * Returns an array of gallery covers for the given UIDs of fileCollections
93
+	 *
94
+	 * @param $collectionUids
95
+	 * @return array
96
+	 */
97
+	public function getGalleryCoversFromCollections($collectionUids)
98
+	{
99
+		$imageItems = array();
100
+		foreach ($collectionUids as $collectionUid) {
101
+			$collection = $this->fileCollectionRepository->findByUid($collectionUid);
102
+			$collection->loadContents();
103
+			$galleryCover = array();
104
+			foreach ($collection->getItems() as $item) {
105
+				if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
106
+					array_push($galleryCover, $this->getFileObjectFromFileReference($item));
107
+				} else {
108
+					array_push($galleryCover, $item);
109
+				}
110
+			}
111
+			$galleryCover = $this->sortFileObjects($galleryCover);
112 112
 
113
-            $galleryCover[0]->galleryUID = $collectionUid;
114
-            $galleryCover[0]->galleryTitle = $collection->getTitle();
115
-            $galleryCover[0]->galleryDescription = $collection->getDescription();
116
-            $galleryCover[0]->gallerySize = sizeof($galleryCover);
113
+			$galleryCover[0]->galleryUID = $collectionUid;
114
+			$galleryCover[0]->galleryTitle = $collection->getTitle();
115
+			$galleryCover[0]->galleryDescription = $collection->getDescription();
116
+			$galleryCover[0]->gallerySize = sizeof($galleryCover);
117 117
 
118
-            array_push($imageItems, $galleryCover[0]);
119
-        }
120
-        return $this->sortFileObjects($imageItems);
121
-    }
118
+			array_push($imageItems, $galleryCover[0]);
119
+		}
120
+		return $this->sortFileObjects($imageItems);
121
+	}
122 122
 
123
-    /**
124
-     * Returns an array of gallery covers for the given UIDs of fileCollections
125
-     * Use if you have recursive folder collection.
126
-     *
127
-     * @param $collectionUids
128
-     * @return array
129
-     */
130
-    public function getGalleryCoversFromNestedFoldersCollection($collectionUids)
131
-    {
132
-        $configuration = $this->frontendConfigurationManager->getConfiguration();
133
-        $imageItems = array();
123
+	/**
124
+	 * Returns an array of gallery covers for the given UIDs of fileCollections
125
+	 * Use if you have recursive folder collection.
126
+	 *
127
+	 * @param $collectionUids
128
+	 * @return array
129
+	 */
130
+	public function getGalleryCoversFromNestedFoldersCollection($collectionUids)
131
+	{
132
+		$configuration = $this->frontendConfigurationManager->getConfiguration();
133
+		$imageItems = array();
134 134
 
135
-        // Load all images from collection
136
-        foreach ($collectionUids as $collectionUid) {
137
-            $collection = $this->fileCollectionRepository->findByUid($collectionUid);
138
-            $collection->loadContents();
139
-            $galleryCover = array();
135
+		// Load all images from collection
136
+		foreach ($collectionUids as $collectionUid) {
137
+			$collection = $this->fileCollectionRepository->findByUid($collectionUid);
138
+			$collection->loadContents();
139
+			$galleryCover = array();
140 140
 
141
-            // Load all image and sort them by folder_hash
142
-            foreach ($collection->getItems() as $item) {
143
-                if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
144
-                    array_push($galleryCover, $this->getFileObjectFromFileReference($item));
145
-                } else {
146
-                    array_push($galleryCover, $item);
147
-                }
148
-            }
149
-            $this->sortFileObjectsByFolderHash($galleryCover, SORT_ASC);
141
+			// Load all image and sort them by folder_hash
142
+			foreach ($collection->getItems() as $item) {
143
+				if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
144
+					array_push($galleryCover, $this->getFileObjectFromFileReference($item));
145
+				} else {
146
+					array_push($galleryCover, $item);
147
+				}
148
+			}
149
+			$this->sortFileObjectsByFolderHash($galleryCover, SORT_ASC);
150 150
 
151
-            // Split all images in separate arrays
152
-            $folderHashedGalleryCovers = array();
153
-            $oldFolderHash = '';
154
-            foreach ($galleryCover as $item) {
155
-                $getFolderPath = explode(strrchr($item->getIdentifier(), "/"), $item->getIdentifier());
156
-                $itemIdentificatorWithoutFilename = $getFolderPath[0];
157
-                if ($item->getProperty('folder_hash') !== $oldFolderHash) {
158
-                    $oldFolderHash = $item->getProperty('folder_hash');
159
-                    $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename] = array();
160
-                    array_push($folderHashedGalleryCovers[$itemIdentificatorWithoutFilename], $item);
161
-                } else {
162
-                    array_push($folderHashedGalleryCovers[$itemIdentificatorWithoutFilename], $item);
163
-                }
164
-            }
151
+			// Split all images in separate arrays
152
+			$folderHashedGalleryCovers = array();
153
+			$oldFolderHash = '';
154
+			foreach ($galleryCover as $item) {
155
+				$getFolderPath = explode(strrchr($item->getIdentifier(), "/"), $item->getIdentifier());
156
+				$itemIdentificatorWithoutFilename = $getFolderPath[0];
157
+				if ($item->getProperty('folder_hash') !== $oldFolderHash) {
158
+					$oldFolderHash = $item->getProperty('folder_hash');
159
+					$folderHashedGalleryCovers[$itemIdentificatorWithoutFilename] = array();
160
+					array_push($folderHashedGalleryCovers[$itemIdentificatorWithoutFilename], $item);
161
+				} else {
162
+					array_push($folderHashedGalleryCovers[$itemIdentificatorWithoutFilename], $item);
163
+				}
164
+			}
165 165
 
166
-            // Sort the array by key => $itemIdentificatorWithoutFilename
167
-            if ($configuration['settings']['orderNestedFolder'] == "asc") {
168
-                ksort($folderHashedGalleryCovers);
169
-            } else {
170
-                krsort($folderHashedGalleryCovers);
171
-            }
166
+			// Sort the array by key => $itemIdentificatorWithoutFilename
167
+			if ($configuration['settings']['orderNestedFolder'] == "asc") {
168
+				ksort($folderHashedGalleryCovers);
169
+			} else {
170
+				krsort($folderHashedGalleryCovers);
171
+			}
172 172
 
173
-            // Sort all subarrays depending on the current settings
174
-            foreach ($folderHashedGalleryCovers as $itemIdentificatorWithoutFilename => $folderHashedGalleryCoversArray) {
175
-                $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename] = $this->sortFileObjects($folderHashedGalleryCoversArray);
176
-                $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->galleryFolder = $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->getProperty('folder_hash');
173
+			// Sort all subarrays depending on the current settings
174
+			foreach ($folderHashedGalleryCovers as $itemIdentificatorWithoutFilename => $folderHashedGalleryCoversArray) {
175
+				$folderHashedGalleryCovers[$itemIdentificatorWithoutFilename] = $this->sortFileObjects($folderHashedGalleryCoversArray);
176
+				$folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->galleryFolder = $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->getProperty('folder_hash');
177 177
 
178
-                $getFolderPath = explode("/", $itemIdentificatorWithoutFilename);
179
-                $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->galleryFolderName = end($getFolderPath);
180
-                $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->galleryUID = $collectionUid;
181
-                $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->gallerySize = sizeof($folderHashedGalleryCovers[$itemIdentificatorWithoutFilename]);
182
-                array_push($imageItems, $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]);
183
-            }
184
-        }
185
-        return $imageItems;
186
-    }
178
+				$getFolderPath = explode("/", $itemIdentificatorWithoutFilename);
179
+				$folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->galleryFolderName = end($getFolderPath);
180
+				$folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->galleryUID = $collectionUid;
181
+				$folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]->gallerySize = sizeof($folderHashedGalleryCovers[$itemIdentificatorWithoutFilename]);
182
+				array_push($imageItems, $folderHashedGalleryCovers[$itemIdentificatorWithoutFilename][0]);
183
+			}
184
+		}
185
+		return $imageItems;
186
+	}
187 187
 
188
-    /**
189
-     * Returns an array of gallery covers for the given UIDs of fileCollections
190
-     * Use if you have recursive folder collection.
191
-     *
192
-     * @param $collectionUids
193
-     * @param $galleryFolder
194
-     * @return array
195
-     */
196
-    public function getGalleryItemsByFolderHash($collectionUids, $galleryFolderHash)
197
-    {
198
-        $imageItems = array();
188
+	/**
189
+	 * Returns an array of gallery covers for the given UIDs of fileCollections
190
+	 * Use if you have recursive folder collection.
191
+	 *
192
+	 * @param $collectionUids
193
+	 * @param $galleryFolder
194
+	 * @return array
195
+	 */
196
+	public function getGalleryItemsByFolderHash($collectionUids, $galleryFolderHash)
197
+	{
198
+		$imageItems = array();
199 199
 
200
-        // Load all images from collection
201
-        foreach ($collectionUids as $collectionUid) {
202
-            $collection = $this->fileCollectionRepository->findByUid($collectionUid);
203
-            $collection->loadContents();
204
-            $allItems = array();
200
+		// Load all images from collection
201
+		foreach ($collectionUids as $collectionUid) {
202
+			$collection = $this->fileCollectionRepository->findByUid($collectionUid);
203
+			$collection->loadContents();
204
+			$allItems = array();
205 205
 
206
-            // Load all image and sort them by folder_hash
207
-            foreach ($collection->getItems() as $item) {
208
-                if($item->getProperty('folder_hash') === $galleryFolderHash) {
209
-                    if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
210
-                        array_push($allItems, $this->getFileObjectFromFileReference($item));
211
-                    } else {
212
-                        array_push($allItems, $item);
213
-                    }
214
-                }
215
-            }
216
-            $imageItems = $this->sortFileObjects($allItems);
217
-        }
218
-        return $imageItems;
219
-    }
206
+			// Load all image and sort them by folder_hash
207
+			foreach ($collection->getItems() as $item) {
208
+				if($item->getProperty('folder_hash') === $galleryFolderHash) {
209
+					if (get_class($item) === 'TYPO3\CMS\Core\Resource\FileReference') {
210
+						array_push($allItems, $this->getFileObjectFromFileReference($item));
211
+					} else {
212
+						array_push($allItems, $item);
213
+					}
214
+				}
215
+			}
216
+			$imageItems = $this->sortFileObjects($allItems);
217
+		}
218
+		return $imageItems;
219
+	}
220 220
 
221
-    /**
222
-     * Returns the array including pagination settings
223
-     *
224
-     * @param array $settings The current settings
225
-     * @return array
226
-     */
227
-    public function buildPaginationArray($settings)
228
-    {
229
-        $paginationArray = array();
230
-        if (!empty($settings)) {
231
-            $paginationArray = array(
232
-                'itemsPerPage' => $settings['imagesPerPage'],
233
-                'maximumVisiblePages' => $settings['numberOfPages'],
234
-                'insertAbove' => $settings['insertAbove'],
235
-                'insertBelow' => $settings['insertBelow']
236
-            );
237
-        }
238
-        return $paginationArray;
239
-    }
221
+	/**
222
+	 * Returns the array including pagination settings
223
+	 *
224
+	 * @param array $settings The current settings
225
+	 * @return array
226
+	 */
227
+	public function buildPaginationArray($settings)
228
+	{
229
+		$paginationArray = array();
230
+		if (!empty($settings)) {
231
+			$paginationArray = array(
232
+				'itemsPerPage' => $settings['imagesPerPage'],
233
+				'maximumVisiblePages' => $settings['numberOfPages'],
234
+				'insertAbove' => $settings['insertAbove'],
235
+				'insertBelow' => $settings['insertBelow']
236
+			);
237
+		}
238
+		return $paginationArray;
239
+	}
240 240
 
241
-    /**
242
-     * Returns the array for assign to view in controller
243
-     *
244
-     * @param array $imageItems The imageItems to show
245
-     * @param int $offset The offset in gallery
246
-     * @param array $paginationConfiguration The pagination config
247
-     * @param array $settings The settings array
248
-     * @param int $currentUid The current uid
249
-     * @param int $columnPosition The column position
250
-     * @param bool $showBackToGallerySelectionLink If back link should be shown
251
-     *
252
-     * @return array
253
-     */
254
-    public function buildArrayForAssignToView($imageItems, $offset, $paginationConfiguration, $settings,
255
-                                              $currentUid, $columnPosition, $showBackToGallerySelectionLink)
256
-    {
257
-        $assign = array(
258
-            'imageItems' => $imageItems,
259
-            'offset' => $offset,
260
-            'paginationConfiguration' => $paginationConfiguration,
261
-            'settings' => $settings,
262
-            'currentUid' => $currentUid,
263
-            'columnPosition' => $columnPosition,
264
-            'showBackToGallerySelectionLink' => $showBackToGallerySelectionLink
265
-        );
266
-        return $assign;
267
-    }
241
+	/**
242
+	 * Returns the array for assign to view in controller
243
+	 *
244
+	 * @param array $imageItems The imageItems to show
245
+	 * @param int $offset The offset in gallery
246
+	 * @param array $paginationConfiguration The pagination config
247
+	 * @param array $settings The settings array
248
+	 * @param int $currentUid The current uid
249
+	 * @param int $columnPosition The column position
250
+	 * @param bool $showBackToGallerySelectionLink If back link should be shown
251
+	 *
252
+	 * @return array
253
+	 */
254
+	public function buildArrayForAssignToView($imageItems, $offset, $paginationConfiguration, $settings,
255
+											  $currentUid, $columnPosition, $showBackToGallerySelectionLink)
256
+	{
257
+		$assign = array(
258
+			'imageItems' => $imageItems,
259
+			'offset' => $offset,
260
+			'paginationConfiguration' => $paginationConfiguration,
261
+			'settings' => $settings,
262
+			'currentUid' => $currentUid,
263
+			'columnPosition' => $columnPosition,
264
+			'showBackToGallerySelectionLink' => $showBackToGallerySelectionLink
265
+		);
266
+		return $assign;
267
+	}
268 268
 
269
-    /**
270
-     * @param array $items The items to sort
271
-     * @param $direction the direction. SORT_DESC or SORT_ASC
272
-     * @return bool
273
-     */
274
-    protected function sortFileObjectsByName(&$items, $direction)
275
-    {
276
-        $lowercaseNames = array_map(function ($n) {
277
-            return strtolower($n->getName());
278
-        }, $items);
269
+	/**
270
+	 * @param array $items The items to sort
271
+	 * @param $direction the direction. SORT_DESC or SORT_ASC
272
+	 * @return bool
273
+	 */
274
+	protected function sortFileObjectsByName(&$items, $direction)
275
+	{
276
+		$lowercaseNames = array_map(function ($n) {
277
+			return strtolower($n->getName());
278
+		}, $items);
279 279
 
280
-        array_multisort($lowercaseNames, $direction, SORT_STRING, $items);
281
-    }
280
+		array_multisort($lowercaseNames, $direction, SORT_STRING, $items);
281
+	}
282 282
 
283
-    /**
284
-     * @param array $items The items to sort
285
-     * @param $direction the direction. SORT_DESC or SORT_ASC
286
-     * @return bool
287
-     */
288
-    protected function sortFileObjectsByDate(&$items, $direction)
289
-    {
290
-        $dates = array_map(function ($n) {
291
-            return strtolower($n->getCreationTime());
292
-        }, $items);
283
+	/**
284
+	 * @param array $items The items to sort
285
+	 * @param $direction the direction. SORT_DESC or SORT_ASC
286
+	 * @return bool
287
+	 */
288
+	protected function sortFileObjectsByDate(&$items, $direction)
289
+	{
290
+		$dates = array_map(function ($n) {
291
+			return strtolower($n->getCreationTime());
292
+		}, $items);
293 293
 
294
-        array_multisort($dates, $direction, SORT_NUMERIC, $items);
295
-    }
294
+		array_multisort($dates, $direction, SORT_NUMERIC, $items);
295
+	}
296 296
 
297
-    /**
298
-     * @param array $items The items to sort
299
-     * @param $direction the direction. SORT_DESC or SORT_ASC
300
-     * @return bool
301
-     */
302
-    protected function sortFileObjectsByFolderHash(&$items, $direction)
303
-    {
304
-        $folderhashes = array_map(function ($n) {
305
-            return strtolower($n->getProperty('folder_hash'));
306
-        }, $items);
297
+	/**
298
+	 * @param array $items The items to sort
299
+	 * @param $direction the direction. SORT_DESC or SORT_ASC
300
+	 * @return bool
301
+	 */
302
+	protected function sortFileObjectsByFolderHash(&$items, $direction)
303
+	{
304
+		$folderhashes = array_map(function ($n) {
305
+			return strtolower($n->getProperty('folder_hash'));
306
+		}, $items);
307 307
 
308
-        array_multisort($folderhashes, $direction, SORT_NUMERIC, $items);
309
-    }
308
+		array_multisort($folderhashes, $direction, SORT_NUMERIC, $items);
309
+	}
310 310
 
311
-    /**
312
-     * Sorts the Result Array according to the Flexform Settings
313
-     *
314
-     * @param array $imageItems The image items
315
-     *
316
-     * @return array
317
-     */
318
-    protected function sortFileObjects($imageItems)
319
-    {
320
-        $configuration = $this->frontendConfigurationManager->getConfiguration();
321
-        switch ($configuration['settings']['order']) {
322
-            case 'desc':
323
-                $this->sortFileObjectsByName($imageItems, SORT_DESC);
324
-                break;
325
-            case 'date-desc':
326
-                $this->sortFileObjectsByDate($imageItems, SORT_DESC);
327
-                break;
328
-            case 'date-asc':
329
-                $this->sortFileObjectsByDate($imageItems, SORT_ASC);
330
-                break;
331
-            case 'manual':
332
-                // Do not sort. This could be default, but could be breaking, since default was ASC before.
333
-                break;
334
-            default:
335
-                $this->sortFileObjectsByName($imageItems, SORT_ASC);
336
-                break;
337
-        }
338
-        return $imageItems;
339
-    }
311
+	/**
312
+	 * Sorts the Result Array according to the Flexform Settings
313
+	 *
314
+	 * @param array $imageItems The image items
315
+	 *
316
+	 * @return array
317
+	 */
318
+	protected function sortFileObjects($imageItems)
319
+	{
320
+		$configuration = $this->frontendConfigurationManager->getConfiguration();
321
+		switch ($configuration['settings']['order']) {
322
+			case 'desc':
323
+				$this->sortFileObjectsByName($imageItems, SORT_DESC);
324
+				break;
325
+			case 'date-desc':
326
+				$this->sortFileObjectsByDate($imageItems, SORT_DESC);
327
+				break;
328
+			case 'date-asc':
329
+				$this->sortFileObjectsByDate($imageItems, SORT_ASC);
330
+				break;
331
+			case 'manual':
332
+				// Do not sort. This could be default, but could be breaking, since default was ASC before.
333
+				break;
334
+			default:
335
+				$this->sortFileObjectsByName($imageItems, SORT_ASC);
336
+				break;
337
+		}
338
+		return $imageItems;
339
+	}
340 340
 
341
-    /**
342
-     * Returns an FileObject from a given FileReference
343
-     *
344
-     * @param \TYPO3\CMS\Core\Resource\FileReference $item The item
345
-     *
346
-     * @return \TYPO3\CMS\Core\Resource\File
347
-     */
348
-    protected function getFileObjectFromFileReference(FileReference $item)
349
-    {
350
-        /**
351
-         * The item to return
352
-         *
353
-         * @var \TYPO3\CMS\Core\Resource\File $returnItem
354
-         */
355
-        $returnItem = $item->getOriginalFile();
356
-        $returnItem->updateProperties($item->getProperties());
357
-        return $returnItem;
358
-    }
341
+	/**
342
+	 * Returns an FileObject from a given FileReference
343
+	 *
344
+	 * @param \TYPO3\CMS\Core\Resource\FileReference $item The item
345
+	 *
346
+	 * @return \TYPO3\CMS\Core\Resource\File
347
+	 */
348
+	protected function getFileObjectFromFileReference(FileReference $item)
349
+	{
350
+		/**
351
+		 * The item to return
352
+		 *
353
+		 * @var \TYPO3\CMS\Core\Resource\File $returnItem
354
+		 */
355
+		$returnItem = $item->getOriginalFile();
356
+		$returnItem->updateProperties($item->getProperties());
357
+		return $returnItem;
358
+	}
359 359
 }
Please login to merge, or discard this patch.
Classes/Controller/GalleryController.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -24,148 +24,148 @@
 block discarded – undo
24 24
 class GalleryController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
25 25
 {
26 26
 
27
-    /**
28
-     * File Collection Service
29
-     *
30
-     * @var \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService
31
-     */
32
-    protected $fileCollectionService;
33
-
34
-    /**
35
-     * Inject the FileCollectionService
36
-     *
37
-     * @param \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService $fileCollectionService The service
38
-     *
39
-     * @return void
40
-     */
41
-    public function injectFileCollectionService(FileCollectionService $fileCollectionService)
42
-    {
43
-        $this->fileCollectionService = $fileCollectionService;
44
-    }
45
-
46
-    /**
47
-     * Initializes the view before invoking an action method.
48
-     * Override this method to solve assign variables common for all actions
49
-     * or prepare the view in another way before the action is called.
50
-     *
51
-     * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
52
-     * @return void
53
-     */
54
-    protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
55
-    {
56
-        $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
57
-    }
58
-
59
-    /**
60
-     * List action
61
-     *
62
-     * @param int $offset The offset
63
-     *
64
-     * @return void
65
-     */
66
-    public function listAction($offset = 0)
67
-    {
68
-        if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
69
-            $collectionUids = explode(',', $this->settings['fileCollection']);
70
-            $cObj = $this->configurationManager->getContentObject();
71
-            $currentUid = $cObj->data['uid'];
72
-            $columnPosition = $cObj->data['colPos'];
73
-
74
-            $showBackToGallerySelectionLink = FALSE;
75
-            //if a special gallery is requested
76
-            if ($this->request->hasArgument('galleryUID')) {
77
-                $gallery = array($this->request->getArgument('galleryUID'));
78
-                $imageItems = $this->fileCollectionService->getFileObjectsFromCollection($gallery);
79
-                $showBackToGallerySelectionLink = TRUE;
80
-            } else {
81
-                $imageItems = $this->fileCollectionService->getFileObjectsFromCollection($collectionUids);
82
-            }
83
-            $this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
84
-                $imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
85
-                $this->settings, $currentUid, $columnPosition, $showBackToGallerySelectionLink
86
-            ));
87
-        }
88
-    }
89
-
90
-
91
-    /**
92
-     * List from folder action
93
-     *
94
-     * @param int $offset The offset
95
-     *
96
-     * @return void
97
-     */
98
-    public function listFromFolderAction($offset = 0)
99
-    {
100
-        if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
101
-            $cObj = $this->configurationManager->getContentObject();
102
-            $currentUid = $cObj->data['uid'];
103
-            $columnPosition = $cObj->data['colPos'];
104
-
105
-            $showBackToGallerySelectionLink = FALSE;
106
-            $imageItems = array();
107
-            //if a special gallery is requested
108
-            if ($this->request->hasArgument('galleryFolder') && $this->request->hasArgument('galleryUID')) {
109
-                $galleryFolderHash = $this->request->getArgument('galleryFolder');
110
-                $galleryUid = array($this->request->getArgument('galleryUID'));
111
-                $imageItems = $this->fileCollectionService->getGalleryItemsByFolderHash($galleryUid, $galleryFolderHash);
112
-                $showBackToGallerySelectionLink = TRUE;
113
-            }
114
-
115
-            $this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
116
-                $imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
117
-                $this->settings, $currentUid, $columnPosition, $showBackToGallerySelectionLink
118
-            ));
119
-        }
120
-    }
121
-
122
-    /**
123
-     * Nested action
124
-     *
125
-     * @param int $offset The offset
126
-     *
127
-     * @return void
128
-     */
129
-    public function nestedAction($offset = 0)
130
-    {
131
-        if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
132
-            $cObj = $this->configurationManager->getContentObject();
133
-            $currentUid = $cObj->data['uid'];
134
-            $columnPosition = $cObj->data['colPos'];
135
-
136
-            $collectionUids = explode(',', $this->settings['fileCollection']);
137
-
138
-            $imageItems = $this->fileCollectionService->getGalleryCoversFromCollections($collectionUids);
139
-
140
-            $this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
141
-                $imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
142
-                $this->settings, $currentUid, $columnPosition, FALSE
143
-            ));
144
-        }
145
-    }
146
-
147
-    /**
148
-     * Nested action
149
-     *
150
-     * @param int $offset The offset
151
-     *
152
-     * @return void
153
-     */
154
-    public function nestedFromFolderAction($offset = 0)
155
-    {
156
-        if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
157
-            $cObj = $this->configurationManager->getContentObject();
158
-            $currentUid = $cObj->data['uid'];
159
-            $columnPosition = $cObj->data['colPos'];
160
-
161
-            $collectionUids = explode(',', $this->settings['fileCollection']);
162
-
163
-            $imageItems = $this->fileCollectionService->getGalleryCoversFromNestedFoldersCollection($collectionUids);
164
-
165
-            $this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
166
-                $imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
167
-                $this->settings, $currentUid, $columnPosition, FALSE
168
-            ));
169
-        }
170
-    }
27
+	/**
28
+	 * File Collection Service
29
+	 *
30
+	 * @var \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService
31
+	 */
32
+	protected $fileCollectionService;
33
+
34
+	/**
35
+	 * Inject the FileCollectionService
36
+	 *
37
+	 * @param \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService $fileCollectionService The service
38
+	 *
39
+	 * @return void
40
+	 */
41
+	public function injectFileCollectionService(FileCollectionService $fileCollectionService)
42
+	{
43
+		$this->fileCollectionService = $fileCollectionService;
44
+	}
45
+
46
+	/**
47
+	 * Initializes the view before invoking an action method.
48
+	 * Override this method to solve assign variables common for all actions
49
+	 * or prepare the view in another way before the action is called.
50
+	 *
51
+	 * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
52
+	 * @return void
53
+	 */
54
+	protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
55
+	{
56
+		$view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
57
+	}
58
+
59
+	/**
60
+	 * List action
61
+	 *
62
+	 * @param int $offset The offset
63
+	 *
64
+	 * @return void
65
+	 */
66
+	public function listAction($offset = 0)
67
+	{
68
+		if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
69
+			$collectionUids = explode(',', $this->settings['fileCollection']);
70
+			$cObj = $this->configurationManager->getContentObject();
71
+			$currentUid = $cObj->data['uid'];
72
+			$columnPosition = $cObj->data['colPos'];
73
+
74
+			$showBackToGallerySelectionLink = FALSE;
75
+			//if a special gallery is requested
76
+			if ($this->request->hasArgument('galleryUID')) {
77
+				$gallery = array($this->request->getArgument('galleryUID'));
78
+				$imageItems = $this->fileCollectionService->getFileObjectsFromCollection($gallery);
79
+				$showBackToGallerySelectionLink = TRUE;
80
+			} else {
81
+				$imageItems = $this->fileCollectionService->getFileObjectsFromCollection($collectionUids);
82
+			}
83
+			$this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
84
+				$imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
85
+				$this->settings, $currentUid, $columnPosition, $showBackToGallerySelectionLink
86
+			));
87
+		}
88
+	}
89
+
90
+
91
+	/**
92
+	 * List from folder action
93
+	 *
94
+	 * @param int $offset The offset
95
+	 *
96
+	 * @return void
97
+	 */
98
+	public function listFromFolderAction($offset = 0)
99
+	{
100
+		if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
101
+			$cObj = $this->configurationManager->getContentObject();
102
+			$currentUid = $cObj->data['uid'];
103
+			$columnPosition = $cObj->data['colPos'];
104
+
105
+			$showBackToGallerySelectionLink = FALSE;
106
+			$imageItems = array();
107
+			//if a special gallery is requested
108
+			if ($this->request->hasArgument('galleryFolder') && $this->request->hasArgument('galleryUID')) {
109
+				$galleryFolderHash = $this->request->getArgument('galleryFolder');
110
+				$galleryUid = array($this->request->getArgument('galleryUID'));
111
+				$imageItems = $this->fileCollectionService->getGalleryItemsByFolderHash($galleryUid, $galleryFolderHash);
112
+				$showBackToGallerySelectionLink = TRUE;
113
+			}
114
+
115
+			$this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
116
+				$imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
117
+				$this->settings, $currentUid, $columnPosition, $showBackToGallerySelectionLink
118
+			));
119
+		}
120
+	}
121
+
122
+	/**
123
+	 * Nested action
124
+	 *
125
+	 * @param int $offset The offset
126
+	 *
127
+	 * @return void
128
+	 */
129
+	public function nestedAction($offset = 0)
130
+	{
131
+		if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
132
+			$cObj = $this->configurationManager->getContentObject();
133
+			$currentUid = $cObj->data['uid'];
134
+			$columnPosition = $cObj->data['colPos'];
135
+
136
+			$collectionUids = explode(',', $this->settings['fileCollection']);
137
+
138
+			$imageItems = $this->fileCollectionService->getGalleryCoversFromCollections($collectionUids);
139
+
140
+			$this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
141
+				$imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
142
+				$this->settings, $currentUid, $columnPosition, FALSE
143
+			));
144
+		}
145
+	}
146
+
147
+	/**
148
+	 * Nested action
149
+	 *
150
+	 * @param int $offset The offset
151
+	 *
152
+	 * @return void
153
+	 */
154
+	public function nestedFromFolderAction($offset = 0)
155
+	{
156
+		if ($this->settings['fileCollection'] !== '' && $this->settings['fileCollection']) {
157
+			$cObj = $this->configurationManager->getContentObject();
158
+			$currentUid = $cObj->data['uid'];
159
+			$columnPosition = $cObj->data['colPos'];
160
+
161
+			$collectionUids = explode(',', $this->settings['fileCollection']);
162
+
163
+			$imageItems = $this->fileCollectionService->getGalleryCoversFromNestedFoldersCollection($collectionUids);
164
+
165
+			$this->view->assignMultiple($this->fileCollectionService->buildArrayForAssignToView(
166
+				$imageItems, $offset, $this->fileCollectionService->buildPaginationArray($this->settings),
167
+				$this->settings, $currentUid, $columnPosition, FALSE
168
+			));
169
+		}
170
+	}
171 171
 }
Please login to merge, or discard this patch.