@@ -18,92 +18,92 @@ |
||
18 | 18 | */ |
19 | 19 | class ImagePresetUtility implements SingletonInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $store = []; |
|
21 | + /** |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $store = []; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $currentPreset = ''; |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $currentPreset = ''; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Returns a class instance |
|
33 | - * |
|
34 | - * @return \Fab\Media\Utility\ImagePresetUtility|object |
|
35 | - */ |
|
36 | - public static function getInstance() |
|
37 | - { |
|
38 | - return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Returns a class instance |
|
33 | + * |
|
34 | + * @return \Fab\Media\Utility\ImagePresetUtility|object |
|
35 | + */ |
|
36 | + public static function getInstance() |
|
37 | + { |
|
38 | + return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Set the current preset value. Preset values come from the settings and can be: |
|
43 | - * image_thumbnail, image_mini, image_small, image_medium, image_large |
|
44 | - * |
|
45 | - * @throws EmptyValueException |
|
46 | - * @param string $preset image_thumbnail, image_mini, ... |
|
47 | - * @return \Fab\Media\Utility\ImagePresetUtility |
|
48 | - */ |
|
49 | - public function preset($preset) |
|
50 | - { |
|
51 | - $size = ConfigurationUtility::getInstance()->get($preset); |
|
52 | - if (is_null($size)) { |
|
53 | - throw new EmptyValueException('No value for preset: ' . $preset, 1362501066); |
|
54 | - } |
|
41 | + /** |
|
42 | + * Set the current preset value. Preset values come from the settings and can be: |
|
43 | + * image_thumbnail, image_mini, image_small, image_medium, image_large |
|
44 | + * |
|
45 | + * @throws EmptyValueException |
|
46 | + * @param string $preset image_thumbnail, image_mini, ... |
|
47 | + * @return \Fab\Media\Utility\ImagePresetUtility |
|
48 | + */ |
|
49 | + public function preset($preset) |
|
50 | + { |
|
51 | + $size = ConfigurationUtility::getInstance()->get($preset); |
|
52 | + if (is_null($size)) { |
|
53 | + throw new EmptyValueException('No value for preset: ' . $preset, 1362501066); |
|
54 | + } |
|
55 | 55 | |
56 | - $this->currentPreset = $preset; |
|
57 | - if (!isset($this->store[$this->currentPreset])) { |
|
58 | - // @todo use object Dimension instead |
|
59 | - $dimensions = GeneralUtility::trimExplode('x', $size); |
|
60 | - $this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0]; |
|
61 | - $this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1]; |
|
62 | - } |
|
63 | - return $this; |
|
64 | - } |
|
56 | + $this->currentPreset = $preset; |
|
57 | + if (!isset($this->store[$this->currentPreset])) { |
|
58 | + // @todo use object Dimension instead |
|
59 | + $dimensions = GeneralUtility::trimExplode('x', $size); |
|
60 | + $this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0]; |
|
61 | + $this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1]; |
|
62 | + } |
|
63 | + return $this; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - public function getStore() |
|
70 | - { |
|
71 | - return $this->store; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + public function getStore() |
|
70 | + { |
|
71 | + return $this->store; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param array $store |
|
76 | - */ |
|
77 | - public function setStore($store) |
|
78 | - { |
|
79 | - $this->store = $store; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @param array $store |
|
76 | + */ |
|
77 | + public function setStore($store) |
|
78 | + { |
|
79 | + $this->store = $store; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Returns width of the current preset. |
|
84 | - * |
|
85 | - * @throws InvalidKeyInArrayException |
|
86 | - * @return int |
|
87 | - */ |
|
88 | - public function getWidth() |
|
89 | - { |
|
90 | - if (empty($this->store[$this->currentPreset])) { |
|
91 | - throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853); |
|
92 | - } |
|
93 | - return (int)$this->store[$this->currentPreset]['width']; |
|
94 | - } |
|
82 | + /** |
|
83 | + * Returns width of the current preset. |
|
84 | + * |
|
85 | + * @throws InvalidKeyInArrayException |
|
86 | + * @return int |
|
87 | + */ |
|
88 | + public function getWidth() |
|
89 | + { |
|
90 | + if (empty($this->store[$this->currentPreset])) { |
|
91 | + throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853); |
|
92 | + } |
|
93 | + return (int)$this->store[$this->currentPreset]['width']; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Returns height of the current preset. |
|
98 | - * |
|
99 | - * @throws InvalidKeyInArrayException |
|
100 | - * @return int |
|
101 | - */ |
|
102 | - public function getHeight() |
|
103 | - { |
|
104 | - if (empty($this->store[$this->currentPreset])) { |
|
105 | - throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853); |
|
106 | - } |
|
107 | - return (int)$this->store[$this->currentPreset]['height']; |
|
108 | - } |
|
96 | + /** |
|
97 | + * Returns height of the current preset. |
|
98 | + * |
|
99 | + * @throws InvalidKeyInArrayException |
|
100 | + * @return int |
|
101 | + */ |
|
102 | + public function getHeight() |
|
103 | + { |
|
104 | + if (empty($this->store[$this->currentPreset])) { |
|
105 | + throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853); |
|
106 | + } |
|
107 | + return (int)$this->store[$this->currentPreset]['height']; |
|
108 | + } |
|
109 | 109 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | { |
51 | 51 | $size = ConfigurationUtility::getInstance()->get($preset); |
52 | 52 | if (is_null($size)) { |
53 | - throw new EmptyValueException('No value for preset: ' . $preset, 1362501066); |
|
53 | + throw new EmptyValueException('No value for preset: '.$preset, 1362501066); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->currentPreset = $preset; |
@@ -17,67 +17,67 @@ |
||
17 | 17 | */ |
18 | 18 | class ConfigurationUtility implements SingletonInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $extensionKey = 'media'; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $extensionKey = 'media'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - protected $configuration = []; |
|
25 | + /** |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + protected $configuration = []; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Returns a class instance. |
|
32 | - * |
|
33 | - * @return \Fab\Media\Utility\ConfigurationUtility|object |
|
34 | - */ |
|
35 | - public static function getInstance() |
|
36 | - { |
|
37 | - return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class); |
|
38 | - } |
|
30 | + /** |
|
31 | + * Returns a class instance. |
|
32 | + * |
|
33 | + * @return \Fab\Media\Utility\ConfigurationUtility|object |
|
34 | + */ |
|
35 | + public static function getInstance() |
|
36 | + { |
|
37 | + return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Constructor |
|
42 | - */ |
|
43 | - public function __construct() |
|
44 | - { |
|
45 | - $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media'); |
|
40 | + /** |
|
41 | + * Constructor |
|
42 | + */ |
|
43 | + public function __construct() |
|
44 | + { |
|
45 | + $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media'); |
|
46 | 46 | |
47 | - // Fill up configuration array with relevant values. |
|
48 | - foreach ($configuration as $key => $value) { |
|
49 | - $this->configuration[$key] = $value; |
|
50 | - } |
|
51 | - } |
|
47 | + // Fill up configuration array with relevant values. |
|
48 | + foreach ($configuration as $key => $value) { |
|
49 | + $this->configuration[$key] = $value; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Returns a setting key. |
|
55 | - * |
|
56 | - * @param string $key |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function get($key) |
|
60 | - { |
|
61 | - return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null; |
|
62 | - } |
|
53 | + /** |
|
54 | + * Returns a setting key. |
|
55 | + * |
|
56 | + * @param string $key |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function get($key) |
|
60 | + { |
|
61 | + return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Set a setting key. |
|
66 | - * |
|
67 | - * @param string $key |
|
68 | - * @param mixed $value |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - public function set($key, $value) |
|
72 | - { |
|
73 | - $this->configuration[$key] = $value; |
|
74 | - } |
|
64 | + /** |
|
65 | + * Set a setting key. |
|
66 | + * |
|
67 | + * @param string $key |
|
68 | + * @param mixed $value |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + public function set($key, $value) |
|
72 | + { |
|
73 | + $this->configuration[$key] = $value; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - public function getConfiguration() |
|
80 | - { |
|
81 | - return $this->configuration; |
|
82 | - } |
|
76 | + /** |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + public function getConfiguration() |
|
80 | + { |
|
81 | + return $this->configuration; |
|
82 | + } |
|
83 | 83 | } |
@@ -17,18 +17,18 @@ |
||
17 | 17 | */ |
18 | 18 | class Logger implements SingletonInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * Returns a logger class instance. |
|
22 | - * |
|
23 | - * @param mixed $instance |
|
24 | - * @return \TYPO3\CMS\Core\Log\Logger |
|
25 | - */ |
|
26 | - public static function getInstance($instance) |
|
27 | - { |
|
28 | - /** @var $loggerManager \TYPO3\CMS\Core\Log\LogManager */ |
|
29 | - $loggerManager = GeneralUtility::makeInstance(LogManager::class); |
|
20 | + /** |
|
21 | + * Returns a logger class instance. |
|
22 | + * |
|
23 | + * @param mixed $instance |
|
24 | + * @return \TYPO3\CMS\Core\Log\Logger |
|
25 | + */ |
|
26 | + public static function getInstance($instance) |
|
27 | + { |
|
28 | + /** @var $loggerManager \TYPO3\CMS\Core\Log\LogManager */ |
|
29 | + $loggerManager = GeneralUtility::makeInstance(LogManager::class); |
|
30 | 30 | |
31 | - /** @var $logger \TYPO3\CMS\Core\Log\Logger */ |
|
32 | - return $loggerManager->getLogger(get_class($instance)); |
|
33 | - } |
|
31 | + /** @var $logger \TYPO3\CMS\Core\Log\Logger */ |
|
32 | + return $loggerManager->getLogger(get_class($instance)); |
|
33 | + } |
|
34 | 34 | } |
@@ -18,77 +18,77 @@ |
||
18 | 18 | */ |
19 | 19 | class Path |
20 | 20 | { |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected static $extensionName = 'media'; |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected static $extensionName = 'media'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Return a public path pointing to a resource. |
|
28 | - * |
|
29 | - * @param string $resource |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public static function getRelativePath($resource) |
|
33 | - { |
|
34 | - // If file is not found, resolve the path |
|
35 | - if (!is_file(Environment::getPublicPath() . '/' . $resource)) { |
|
36 | - $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath() . '/')); |
|
37 | - } |
|
26 | + /** |
|
27 | + * Return a public path pointing to a resource. |
|
28 | + * |
|
29 | + * @param string $resource |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public static function getRelativePath($resource) |
|
33 | + { |
|
34 | + // If file is not found, resolve the path |
|
35 | + if (!is_file(Environment::getPublicPath() . '/' . $resource)) { |
|
36 | + $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath() . '/')); |
|
37 | + } |
|
38 | 38 | |
39 | - return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath() . '/' . $resource)) . PathUtility::basename($resource); |
|
40 | - } |
|
39 | + return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath() . '/' . $resource)) . PathUtility::basename($resource); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Resolves path e.g. EXT:media/Resources/Public/foo.png or ../../foo and returns an absolute path to the given resource. |
|
44 | - * |
|
45 | - * @param string $resource |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public static function resolvePath($resource) |
|
49 | - { |
|
50 | - $resource = self::canonicalPath($resource); |
|
51 | - if (!is_file(Environment::getPublicPath() . '/' . $resource)) { |
|
52 | - $resource = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName) . '/Resources/Public/' . $resource; |
|
53 | - } |
|
54 | - return GeneralUtility::getFileAbsFileName($resource); |
|
55 | - } |
|
42 | + /** |
|
43 | + * Resolves path e.g. EXT:media/Resources/Public/foo.png or ../../foo and returns an absolute path to the given resource. |
|
44 | + * |
|
45 | + * @param string $resource |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public static function resolvePath($resource) |
|
49 | + { |
|
50 | + $resource = self::canonicalPath($resource); |
|
51 | + if (!is_file(Environment::getPublicPath() . '/' . $resource)) { |
|
52 | + $resource = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName) . '/Resources/Public/' . $resource; |
|
53 | + } |
|
54 | + return GeneralUtility::getFileAbsFileName($resource); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Tell whether a resource exist. |
|
59 | - * |
|
60 | - * @param string $resource |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public static function exists($resource) |
|
64 | - { |
|
65 | - return is_file(self::resolvePath($resource)); |
|
66 | - } |
|
57 | + /** |
|
58 | + * Tell whether a resource exist. |
|
59 | + * |
|
60 | + * @param string $resource |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public static function exists($resource) |
|
64 | + { |
|
65 | + return is_file(self::resolvePath($resource)); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Tell whether a resource does not exist. |
|
70 | - * |
|
71 | - * @param string $resource |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public static function notExists($resource) |
|
75 | - { |
|
76 | - return !self::exists($resource); |
|
77 | - } |
|
68 | + /** |
|
69 | + * Tell whether a resource does not exist. |
|
70 | + * |
|
71 | + * @param string $resource |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public static function notExists($resource) |
|
75 | + { |
|
76 | + return !self::exists($resource); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Returns a canonical path by stripping relative segment ../foo/../bar will become foo/bar |
|
81 | - * |
|
82 | - * @param $resource |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public static function canonicalPath($resource) |
|
86 | - { |
|
87 | - $segments = explode('/', $resource); |
|
88 | - $keys = array_keys($segments, '..'); |
|
89 | - foreach ($keys as $key) { |
|
90 | - unset($segments[$key]); |
|
91 | - } |
|
92 | - return implode('/', $segments); |
|
93 | - } |
|
79 | + /** |
|
80 | + * Returns a canonical path by stripping relative segment ../foo/../bar will become foo/bar |
|
81 | + * |
|
82 | + * @param $resource |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public static function canonicalPath($resource) |
|
86 | + { |
|
87 | + $segments = explode('/', $resource); |
|
88 | + $keys = array_keys($segments, '..'); |
|
89 | + foreach ($keys as $key) { |
|
90 | + unset($segments[$key]); |
|
91 | + } |
|
92 | + return implode('/', $segments); |
|
93 | + } |
|
94 | 94 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | public static function getRelativePath($resource) |
33 | 33 | { |
34 | 34 | // If file is not found, resolve the path |
35 | - if (!is_file(Environment::getPublicPath() . '/' . $resource)) { |
|
36 | - $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath() . '/')); |
|
35 | + if (!is_file(Environment::getPublicPath().'/'.$resource)) { |
|
36 | + $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath().'/')); |
|
37 | 37 | } |
38 | 38 | |
39 | - return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath() . '/' . $resource)) . PathUtility::basename($resource); |
|
39 | + return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath().'/'.$resource)).PathUtility::basename($resource); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | public static function resolvePath($resource) |
49 | 49 | { |
50 | 50 | $resource = self::canonicalPath($resource); |
51 | - if (!is_file(Environment::getPublicPath() . '/' . $resource)) { |
|
52 | - $resource = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName) . '/Resources/Public/' . $resource; |
|
51 | + if (!is_file(Environment::getPublicPath().'/'.$resource)) { |
|
52 | + $resource = 'EXT:'.GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName).'/Resources/Public/'.$resource; |
|
53 | 53 | } |
54 | 54 | return GeneralUtility::getFileAbsFileName($resource); |
55 | 55 | } |
@@ -16,54 +16,54 @@ |
||
16 | 16 | */ |
17 | 17 | class DomElement implements SingletonInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns a class instance |
|
21 | - * |
|
22 | - * @return \Fab\Media\Utility\DomElement|object |
|
23 | - */ |
|
24 | - public static function getInstance() |
|
25 | - { |
|
26 | - return GeneralUtility::makeInstance(\Fab\Media\Utility\DomElement::class); |
|
27 | - } |
|
19 | + /** |
|
20 | + * Returns a class instance |
|
21 | + * |
|
22 | + * @return \Fab\Media\Utility\DomElement|object |
|
23 | + */ |
|
24 | + public static function getInstance() |
|
25 | + { |
|
26 | + return GeneralUtility::makeInstance(\Fab\Media\Utility\DomElement::class); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Format an id given an input string |
|
31 | - * |
|
32 | - * @param string $input |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function formatId($input) |
|
36 | - { |
|
37 | - // remove the capital letter from the id |
|
38 | - $segments = preg_split('/(?=[A-Z])/', $input); |
|
39 | - $segments = array_map('strtolower', $segments); |
|
40 | - if ($segments[0] == '') { |
|
41 | - array_shift($segments); |
|
42 | - } |
|
43 | - $result = implode('-', $segments); |
|
29 | + /** |
|
30 | + * Format an id given an input string |
|
31 | + * |
|
32 | + * @param string $input |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function formatId($input) |
|
36 | + { |
|
37 | + // remove the capital letter from the id |
|
38 | + $segments = preg_split('/(?=[A-Z])/', $input); |
|
39 | + $segments = array_map('strtolower', $segments); |
|
40 | + if ($segments[0] == '') { |
|
41 | + array_shift($segments); |
|
42 | + } |
|
43 | + $result = implode('-', $segments); |
|
44 | 44 | |
45 | - return $this->sanitizeId($result); |
|
46 | - } |
|
45 | + return $this->sanitizeId($result); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Sanitize an id |
|
50 | - * |
|
51 | - * @param string $input |
|
52 | - * @return mixed |
|
53 | - */ |
|
54 | - protected function sanitizeId($input) |
|
55 | - { |
|
56 | - // remove the track of possible namespace |
|
57 | - $searches[] = ' '; |
|
58 | - $searches[] = '_'; |
|
59 | - $searches[] = '--'; |
|
60 | - $searches[] = '['; |
|
61 | - $searches[] = ']'; |
|
62 | - $replaces[] = '-'; |
|
63 | - $replaces[] = '-'; |
|
64 | - $replaces[] = '-'; |
|
65 | - $replaces[] = '-'; |
|
66 | - $replaces[] = ''; |
|
67 | - return str_replace($searches, $replaces, strtolower($input)); |
|
68 | - } |
|
48 | + /** |
|
49 | + * Sanitize an id |
|
50 | + * |
|
51 | + * @param string $input |
|
52 | + * @return mixed |
|
53 | + */ |
|
54 | + protected function sanitizeId($input) |
|
55 | + { |
|
56 | + // remove the track of possible namespace |
|
57 | + $searches[] = ' '; |
|
58 | + $searches[] = '_'; |
|
59 | + $searches[] = '--'; |
|
60 | + $searches[] = '['; |
|
61 | + $searches[] = ']'; |
|
62 | + $replaces[] = '-'; |
|
63 | + $replaces[] = '-'; |
|
64 | + $replaces[] = '-'; |
|
65 | + $replaces[] = '-'; |
|
66 | + $replaces[] = ''; |
|
67 | + return str_replace($searches, $replaces, strtolower($input)); |
|
68 | + } |
|
69 | 69 | } |
@@ -20,72 +20,72 @@ |
||
20 | 20 | */ |
21 | 21 | class DeleteButton extends AbstractComponentView |
22 | 22 | { |
23 | - /** |
|
24 | - * Renders a "delete" button to be placed in the grid. |
|
25 | - * |
|
26 | - * @param Content $object |
|
27 | - * @return string |
|
28 | - * @throws \RuntimeException |
|
29 | - * @throws \InvalidArgumentException |
|
30 | - */ |
|
31 | - public function render(Content $object = null) |
|
32 | - { |
|
33 | - $button = ''; |
|
34 | - $file = $this->getFileConverter()->convert($object); |
|
23 | + /** |
|
24 | + * Renders a "delete" button to be placed in the grid. |
|
25 | + * |
|
26 | + * @param Content $object |
|
27 | + * @return string |
|
28 | + * @throws \RuntimeException |
|
29 | + * @throws \InvalidArgumentException |
|
30 | + */ |
|
31 | + public function render(Content $object = null) |
|
32 | + { |
|
33 | + $button = ''; |
|
34 | + $file = $this->getFileConverter()->convert($object); |
|
35 | 35 | |
36 | - // Only display the delete icon if the file has no reference. |
|
37 | - if ($this->getFileReferenceService()->countTotalReferences($object->getUid()) === 0 && $file->checkActionPermission('write')) { |
|
38 | - $button = $this->makeLinkButton() |
|
39 | - ->setHref($this->getDeleteUri($object)) |
|
40 | - ->setDataAttributes([ |
|
41 | - 'uid' => $object->getUid(), |
|
42 | - 'toggle' => 'tooltip', |
|
43 | - 'label' => $file->getProperty('title'), |
|
44 | - ]) |
|
45 | - ->setClasses('btn-delete') |
|
46 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:delete')) |
|
47 | - ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
48 | - ->render(); |
|
49 | - } |
|
36 | + // Only display the delete icon if the file has no reference. |
|
37 | + if ($this->getFileReferenceService()->countTotalReferences($object->getUid()) === 0 && $file->checkActionPermission('write')) { |
|
38 | + $button = $this->makeLinkButton() |
|
39 | + ->setHref($this->getDeleteUri($object)) |
|
40 | + ->setDataAttributes([ |
|
41 | + 'uid' => $object->getUid(), |
|
42 | + 'toggle' => 'tooltip', |
|
43 | + 'label' => $file->getProperty('title'), |
|
44 | + ]) |
|
45 | + ->setClasses('btn-delete') |
|
46 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:delete')) |
|
47 | + ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)) |
|
48 | + ->render(); |
|
49 | + } |
|
50 | 50 | |
51 | - return $button; |
|
52 | - } |
|
51 | + return $button; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param Content $object |
|
56 | - * @return string |
|
57 | - * @throws \InvalidArgumentException |
|
58 | - */ |
|
59 | - protected function getDeleteUri(Content $object) |
|
60 | - { |
|
61 | - $additionalParameters = array( |
|
62 | - $this->getModuleLoader()->getParameterPrefix() => array( |
|
63 | - 'controller' => 'Content', |
|
64 | - 'action' => 'delete', |
|
65 | - 'format' => 'json', |
|
66 | - 'matches' => array( |
|
67 | - 'uid' => $object->getUid(), |
|
68 | - ), |
|
69 | - ), |
|
70 | - ); |
|
71 | - return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
72 | - } |
|
54 | + /** |
|
55 | + * @param Content $object |
|
56 | + * @return string |
|
57 | + * @throws \InvalidArgumentException |
|
58 | + */ |
|
59 | + protected function getDeleteUri(Content $object) |
|
60 | + { |
|
61 | + $additionalParameters = array( |
|
62 | + $this->getModuleLoader()->getParameterPrefix() => array( |
|
63 | + 'controller' => 'Content', |
|
64 | + 'action' => 'delete', |
|
65 | + 'format' => 'json', |
|
66 | + 'matches' => array( |
|
67 | + 'uid' => $object->getUid(), |
|
68 | + ), |
|
69 | + ), |
|
70 | + ); |
|
71 | + return $this->getModuleLoader()->getModuleUrl($additionalParameters); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return FileReferenceService|object |
|
76 | - * @throws \InvalidArgumentException |
|
77 | - */ |
|
78 | - protected function getFileReferenceService() |
|
79 | - { |
|
80 | - return GeneralUtility::makeInstance(FileReferenceService::class); |
|
81 | - } |
|
74 | + /** |
|
75 | + * @return FileReferenceService|object |
|
76 | + * @throws \InvalidArgumentException |
|
77 | + */ |
|
78 | + protected function getFileReferenceService() |
|
79 | + { |
|
80 | + return GeneralUtility::makeInstance(FileReferenceService::class); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return ContentToFileConverter|object |
|
85 | - * @throws \InvalidArgumentException |
|
86 | - */ |
|
87 | - protected function getFileConverter() |
|
88 | - { |
|
89 | - return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
90 | - } |
|
83 | + /** |
|
84 | + * @return ContentToFileConverter|object |
|
85 | + * @throws \InvalidArgumentException |
|
86 | + */ |
|
87 | + protected function getFileConverter() |
|
88 | + { |
|
89 | + return GeneralUtility::makeInstance(ContentToFileConverter::class); |
|
90 | + } |
|
91 | 91 | } |
@@ -18,15 +18,15 @@ |
||
18 | 18 | */ |
19 | 19 | class UploadButton extends AbstractComponentView |
20 | 20 | { |
21 | - /** |
|
22 | - * Renders a button for uploading assets. |
|
23 | - * |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function render() |
|
27 | - { |
|
28 | - /** @var $fileUpload \Fab\Media\Form\FileUpload */ |
|
29 | - $fileUpload = GeneralUtility::makeInstance(FileUpload::class); |
|
30 | - return $fileUpload->setPrefix(MediaModule::getParameterPrefix())->render(); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Renders a button for uploading assets. |
|
23 | + * |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function render() |
|
27 | + { |
|
28 | + /** @var $fileUpload \Fab\Media\Form\FileUpload */ |
|
29 | + $fileUpload = GeneralUtility::makeInstance(FileUpload::class); |
|
30 | + return $fileUpload->setPrefix(MediaModule::getParameterPrefix())->render(); |
|
31 | + } |
|
32 | 32 | } |
@@ -21,98 +21,98 @@ |
||
21 | 21 | */ |
22 | 22 | class NewFolder extends AbstractComponentView |
23 | 23 | { |
24 | - /** |
|
25 | - * Renders a button to create a new folder. |
|
26 | - * |
|
27 | - * @param Content $object |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function render($object = null) |
|
31 | - { |
|
32 | - $output = ''; |
|
33 | - if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) { |
|
34 | - $button = $this->makeLinkButton() |
|
35 | - ->setHref($this->getNewFolderUri()) |
|
36 | - ->setTitle($this->getLabel()) |
|
37 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
38 | - ->render(); |
|
24 | + /** |
|
25 | + * Renders a button to create a new folder. |
|
26 | + * |
|
27 | + * @param Content $object |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function render($object = null) |
|
31 | + { |
|
32 | + $output = ''; |
|
33 | + if ($this->getMediaModule()->hasFolderTree() && !$this->getModuleLoader()->hasPlugin()) { |
|
34 | + $button = $this->makeLinkButton() |
|
35 | + ->setHref($this->getNewFolderUri()) |
|
36 | + ->setTitle($this->getLabel()) |
|
37 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
38 | + ->render(); |
|
39 | 39 | |
40 | - $output = '<div style="float: left;">' . $button . '</div>'; |
|
41 | - } |
|
42 | - return $output; |
|
43 | - } |
|
40 | + $output = '<div style="float: left;">' . $button . '</div>'; |
|
41 | + } |
|
42 | + return $output; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - protected function getLabel() |
|
49 | - { |
|
50 | - return $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.new'); |
|
51 | - } |
|
45 | + /** |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + protected function getLabel() |
|
49 | + { |
|
50 | + return $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.new'); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - protected function getNewFolderUri() |
|
57 | - { |
|
58 | - return BackendUtility::getModuleUrl( |
|
59 | - 'file_newfolder', |
|
60 | - array( |
|
61 | - 'target' => $this->getCombineIdentifier(), |
|
62 | - 'returnUrl' => $this->getReturnUrl(), |
|
63 | - ) |
|
64 | - ); |
|
65 | - } |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + protected function getNewFolderUri() |
|
57 | + { |
|
58 | + return BackendUtility::getModuleUrl( |
|
59 | + 'file_newfolder', |
|
60 | + array( |
|
61 | + 'target' => $this->getCombineIdentifier(), |
|
62 | + 'returnUrl' => $this->getReturnUrl(), |
|
63 | + ) |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - protected function getCombineIdentifier() |
|
72 | - { |
|
73 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
74 | - return $folder->getCombinedIdentifier(); |
|
75 | - } |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + protected function getCombineIdentifier() |
|
72 | + { |
|
73 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
74 | + return $folder->getCombinedIdentifier(); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - protected function getReturnUrl() |
|
81 | - { |
|
82 | - $returnUrl = BackendUtility::getModuleUrl( |
|
83 | - GeneralUtility::_GP('route'), |
|
84 | - $this->getAdditionalParameters() |
|
85 | - ); |
|
86 | - return $returnUrl; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + protected function getReturnUrl() |
|
81 | + { |
|
82 | + $returnUrl = BackendUtility::getModuleUrl( |
|
83 | + GeneralUtility::_GP('route'), |
|
84 | + $this->getAdditionalParameters() |
|
85 | + ); |
|
86 | + return $returnUrl; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - protected function getAdditionalParameters() |
|
93 | - { |
|
94 | - $additionalParameters = []; |
|
95 | - if (GeneralUtility::_GP('id')) { |
|
96 | - $additionalParameters = [ |
|
97 | - 'id' => urldecode(GeneralUtility::_GP('id')), |
|
98 | - ]; |
|
99 | - } |
|
100 | - return $additionalParameters; |
|
101 | - } |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + protected function getAdditionalParameters() |
|
93 | + { |
|
94 | + $additionalParameters = []; |
|
95 | + if (GeneralUtility::_GP('id')) { |
|
96 | + $additionalParameters = [ |
|
97 | + 'id' => urldecode(GeneralUtility::_GP('id')), |
|
98 | + ]; |
|
99 | + } |
|
100 | + return $additionalParameters; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @return MediaModule|object |
|
105 | - */ |
|
106 | - protected function getMediaModule() |
|
107 | - { |
|
108 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
109 | - } |
|
103 | + /** |
|
104 | + * @return MediaModule|object |
|
105 | + */ |
|
106 | + protected function getMediaModule() |
|
107 | + { |
|
108 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return LanguageService |
|
113 | - */ |
|
114 | - protected function getLanguageService() |
|
115 | - { |
|
116 | - return $GLOBALS['LANG']; |
|
117 | - } |
|
111 | + /** |
|
112 | + * @return LanguageService |
|
113 | + */ |
|
114 | + protected function getLanguageService() |
|
115 | + { |
|
116 | + return $GLOBALS['LANG']; |
|
117 | + } |
|
118 | 118 | } |
@@ -20,43 +20,43 @@ |
||
20 | 20 | */ |
21 | 21 | class DownloadButton extends AbstractComponentView |
22 | 22 | { |
23 | - /** |
|
24 | - * Renders a "download" button to be placed in the grid. |
|
25 | - * |
|
26 | - * @param Content $object |
|
27 | - * @return string |
|
28 | - * @throws \InvalidArgumentException |
|
29 | - */ |
|
30 | - public function render(Content $object = null) |
|
31 | - { |
|
32 | - $button = $this->makeLinkButton() |
|
33 | - ->setHref($this->getDownloadUri($object)) |
|
34 | - ->setDataAttributes([ |
|
35 | - 'uid' => $object->getUid(), |
|
36 | - 'toggle' => 'tooltip', |
|
37 | - ]) |
|
38 | - ->setClasses('btn-download') |
|
39 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:download')) |
|
40 | - ->setIcon($this->getIconFactory()->getIcon('actions-system-extension-download', Icon::SIZE_SMALL)) |
|
41 | - ->render(); |
|
23 | + /** |
|
24 | + * Renders a "download" button to be placed in the grid. |
|
25 | + * |
|
26 | + * @param Content $object |
|
27 | + * @return string |
|
28 | + * @throws \InvalidArgumentException |
|
29 | + */ |
|
30 | + public function render(Content $object = null) |
|
31 | + { |
|
32 | + $button = $this->makeLinkButton() |
|
33 | + ->setHref($this->getDownloadUri($object)) |
|
34 | + ->setDataAttributes([ |
|
35 | + 'uid' => $object->getUid(), |
|
36 | + 'toggle' => 'tooltip', |
|
37 | + ]) |
|
38 | + ->setClasses('btn-download') |
|
39 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:download')) |
|
40 | + ->setIcon($this->getIconFactory()->getIcon('actions-system-extension-download', Icon::SIZE_SMALL)) |
|
41 | + ->render(); |
|
42 | 42 | |
43 | - return $button; |
|
44 | - } |
|
43 | + return $button; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param Content $object |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - protected function getDownloadUri(Content $object) |
|
51 | - { |
|
52 | - $urlParameters = [ |
|
53 | - MediaModule::getParameterPrefix() => [ |
|
54 | - 'controller' => 'Asset', |
|
55 | - 'action' => 'download', |
|
56 | - 'forceDownload' => true, |
|
57 | - 'file' => $object->getUid(), |
|
58 | - ], |
|
59 | - ]; |
|
60 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
61 | - } |
|
46 | + /** |
|
47 | + * @param Content $object |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + protected function getDownloadUri(Content $object) |
|
51 | + { |
|
52 | + $urlParameters = [ |
|
53 | + MediaModule::getParameterPrefix() => [ |
|
54 | + 'controller' => 'Asset', |
|
55 | + 'action' => 'download', |
|
56 | + 'forceDownload' => true, |
|
57 | + 'file' => $object->getUid(), |
|
58 | + ], |
|
59 | + ]; |
|
60 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
61 | + } |
|
62 | 62 | } |