[BUGFIX] Unused TDParams in ColumnsContentObject()
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / Filter / FileNameFilter.php
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Filter;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Andreas Wolf <andreas.wolf@ikt-werk.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Utility methods for filtering filenames
31 *
32 * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
33 */
34 class FileNameFilter {
35
36 /**
37 * whether to also show the hidden files (don't show them by default)
38 *
39 * @var boolean
40 */
41 static protected $showHiddenFilesAndFolders = FALSE;
42
43 /**
44 * Filter method that checks if a file/folder name starts with a dot (e.g. .htaccess)
45 *
46 * We have to use -1 as the „don't include“ return value, as call_user_func() will return FALSE
47 * If calling the method succeeded and thus we can't use that as a return value.
48 *
49 * @param string $itemName
50 * @param string $itemIdentifier
51 * @param string $parentIdentifier
52 * @param array $additionalInformation Additional information (driver dependent) about the inspected item
53 * @param \TYPO3\CMS\Core\Resource\Driver\DriverInterface $driverInstance
54 * @return boolean|integer -1 if the file should not be included in a listing
55 */
56 static public function filterHiddenFilesAndFolders($itemName, $itemIdentifier, $parentIdentifier, array $additionalInformation, \TYPO3\CMS\Core\Resource\Driver\DriverInterface $driverInstance) {
57 // Only apply the filter if you want to hide the hidden files
58 if (self::$showHiddenFilesAndFolders === FALSE && substr($itemName, 0, 1) == '.') {
59 return -1;
60 } else {
61 return TRUE;
62 }
63 }
64
65 /**
66 * Gets the info whether the hidden files are also displayed currently
67 *
68 * @static
69 * @return boolean
70 */
71 static public function getShowHiddenFilesAndFolders() {
72 return self::$showHiddenFilesAndFolders;
73 }
74
75 /**
76 * set the flag to show (or hide) the hidden files
77 *
78 * @static
79 * @param boolean $showHiddenFilesAndFolders
80 * @return boolean
81 */
82 static public function setShowHiddenFilesAndFolders($showHiddenFilesAndFolders) {
83 return self::$showHiddenFilesAndFolders = (bool) $showHiddenFilesAndFolders;
84 }
85
86 }