@@ -131,7 +131,7 @@ |
||
| 131 | 131 | reset($attribute); |
| 132 | 132 | $key = key($attribute); |
| 133 | 133 | if (!is_string($key)) { |
| 134 | - throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742); |
|
| 134 | + throw new InvalidStringException('Not an associative array. Is not a key: '.$key, 1356478742); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $this->attributes[$key] = $attribute[$key]; |
@@ -18,267 +18,267 @@ |
||
| 18 | 18 | abstract class AbstractFormField implements FormFieldInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $template = ''; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - protected $value = ''; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - protected $name = ''; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - protected $id = ''; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 44 | - protected $prefix = ''; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - protected $label = ''; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Store what child element will contain this element. |
|
| 53 | - * |
|
| 54 | - * @var array |
|
| 55 | - */ |
|
| 56 | - protected $items = []; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Attributes in sense of DOM attribute, e.g. class, style, etc... |
|
| 60 | - * |
|
| 61 | - * @var array |
|
| 62 | - */ |
|
| 63 | - protected $attributes = []; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @return string |
|
| 67 | - */ |
|
| 68 | - public function render() |
|
| 69 | - { |
|
| 70 | - return $this->template; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Render the label if possible. Otherwise return an empty string. |
|
| 75 | - * |
|
| 76 | - * @return string |
|
| 77 | - */ |
|
| 78 | - public function renderLabel() |
|
| 79 | - { |
|
| 80 | - $result = ''; |
|
| 81 | - if ($this->label) { |
|
| 82 | - $template = '<label class="control-label" for="%s">%s</label>'; |
|
| 83 | - |
|
| 84 | - if (strpos($this->label, 'LLL:') === 0) { |
|
| 85 | - $this->label = LocalizationUtility::translate($this->label, ''); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $result = sprintf($template, |
|
| 89 | - $this->getId(), |
|
| 90 | - $this->label |
|
| 91 | - ); |
|
| 92 | - } |
|
| 93 | - return $result; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Render additional attribute for this DOM element. |
|
| 98 | - * |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - public function renderAttributes() |
|
| 102 | - { |
|
| 103 | - $result = ''; |
|
| 104 | - if (!empty($this->attributes)) { |
|
| 105 | - foreach ($this->attributes as $attribute => $value) { |
|
| 106 | - $result .= sprintf('%s="%s" ', |
|
| 107 | - htmlspecialchars($attribute), |
|
| 108 | - htmlspecialchars($value) |
|
| 109 | - ); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - return $result; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Add an additional (DOM) attribute to be added to this template. |
|
| 117 | - * |
|
| 118 | - * @throws InvalidStringException |
|
| 119 | - * @param array $attribute associative array that contains attribute => value |
|
| 120 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 121 | - */ |
|
| 122 | - public function addAttribute(array $attribute) |
|
| 123 | - { |
|
| 124 | - if (!empty($attribute)) { |
|
| 125 | - reset($attribute); |
|
| 126 | - $key = key($attribute); |
|
| 127 | - if (!is_string($key)) { |
|
| 128 | - throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $this->attributes[$key] = $attribute[$key]; |
|
| 132 | - } |
|
| 133 | - return $this; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - public function getTemplate() |
|
| 140 | - { |
|
| 141 | - return $this->template; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @param string $template |
|
| 146 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 147 | - */ |
|
| 148 | - public function setTemplate($template) |
|
| 149 | - { |
|
| 150 | - $this->template = $template; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @return string |
|
| 155 | - */ |
|
| 156 | - public function getLabel() |
|
| 157 | - { |
|
| 158 | - return $this->label; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * @param string $label |
|
| 163 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 164 | - */ |
|
| 165 | - public function setLabel($label) |
|
| 166 | - { |
|
| 167 | - $this->label = $label; |
|
| 168 | - return $this; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @return string |
|
| 173 | - */ |
|
| 174 | - public function getPrefix() |
|
| 175 | - { |
|
| 176 | - return $this->prefix; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * @param string $prefix |
|
| 181 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 182 | - */ |
|
| 183 | - public function setPrefix($prefix) |
|
| 184 | - { |
|
| 185 | - $this->prefix = $prefix; |
|
| 186 | - return $this; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * @return array |
|
| 191 | - */ |
|
| 192 | - public function getItems() |
|
| 193 | - { |
|
| 194 | - return $this->items; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @param array $items |
|
| 199 | - */ |
|
| 200 | - public function setItems($items) |
|
| 201 | - { |
|
| 202 | - $this->items = $items; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * @return string |
|
| 207 | - */ |
|
| 208 | - public function getValue() |
|
| 209 | - { |
|
| 210 | - return htmlspecialchars($this->value); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * @param string $value |
|
| 215 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 216 | - */ |
|
| 217 | - public function setValue($value) |
|
| 218 | - { |
|
| 219 | - $this->value = $value; |
|
| 220 | - return $this; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @return string |
|
| 225 | - */ |
|
| 226 | - public function getName() |
|
| 227 | - { |
|
| 228 | - $result = $this->name; |
|
| 229 | - if ($this->getPrefix()) { |
|
| 230 | - $result = sprintf('%s[%s]', $this->getPrefix(), $this->name); |
|
| 231 | - } |
|
| 232 | - return $result; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @param string $name |
|
| 237 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 238 | - */ |
|
| 239 | - public function setName($name) |
|
| 240 | - { |
|
| 241 | - $this->name = $name; |
|
| 242 | - return $this; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @return string |
|
| 247 | - */ |
|
| 248 | - public function getId() |
|
| 249 | - { |
|
| 250 | - if ($this->id === '') { |
|
| 251 | - $this->id = DomElement::getInstance()->formatId($this->getName()); |
|
| 252 | - } |
|
| 253 | - return $this->id; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @param string $id |
|
| 258 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 259 | - */ |
|
| 260 | - public function setId($id) |
|
| 261 | - { |
|
| 262 | - $this->id = $id; |
|
| 263 | - return $this; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @return array |
|
| 268 | - */ |
|
| 269 | - public function getAttributes() |
|
| 270 | - { |
|
| 271 | - return $this->attributes; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * @param array $attributes |
|
| 276 | - * @return \Fab\Media\Form\AbstractFormField |
|
| 277 | - */ |
|
| 278 | - public function setAttributes($attributes) |
|
| 279 | - { |
|
| 280 | - $this->attributes = $attributes; |
|
| 281 | - return $this; |
|
| 282 | - } |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $template = ''; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + protected $value = ''; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + protected $name = ''; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + protected $id = ''; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | + protected $prefix = ''; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + protected $label = ''; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Store what child element will contain this element. |
|
| 53 | + * |
|
| 54 | + * @var array |
|
| 55 | + */ |
|
| 56 | + protected $items = []; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Attributes in sense of DOM attribute, e.g. class, style, etc... |
|
| 60 | + * |
|
| 61 | + * @var array |
|
| 62 | + */ |
|
| 63 | + protected $attributes = []; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @return string |
|
| 67 | + */ |
|
| 68 | + public function render() |
|
| 69 | + { |
|
| 70 | + return $this->template; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Render the label if possible. Otherwise return an empty string. |
|
| 75 | + * |
|
| 76 | + * @return string |
|
| 77 | + */ |
|
| 78 | + public function renderLabel() |
|
| 79 | + { |
|
| 80 | + $result = ''; |
|
| 81 | + if ($this->label) { |
|
| 82 | + $template = '<label class="control-label" for="%s">%s</label>'; |
|
| 83 | + |
|
| 84 | + if (strpos($this->label, 'LLL:') === 0) { |
|
| 85 | + $this->label = LocalizationUtility::translate($this->label, ''); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $result = sprintf($template, |
|
| 89 | + $this->getId(), |
|
| 90 | + $this->label |
|
| 91 | + ); |
|
| 92 | + } |
|
| 93 | + return $result; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Render additional attribute for this DOM element. |
|
| 98 | + * |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + public function renderAttributes() |
|
| 102 | + { |
|
| 103 | + $result = ''; |
|
| 104 | + if (!empty($this->attributes)) { |
|
| 105 | + foreach ($this->attributes as $attribute => $value) { |
|
| 106 | + $result .= sprintf('%s="%s" ', |
|
| 107 | + htmlspecialchars($attribute), |
|
| 108 | + htmlspecialchars($value) |
|
| 109 | + ); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + return $result; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Add an additional (DOM) attribute to be added to this template. |
|
| 117 | + * |
|
| 118 | + * @throws InvalidStringException |
|
| 119 | + * @param array $attribute associative array that contains attribute => value |
|
| 120 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 121 | + */ |
|
| 122 | + public function addAttribute(array $attribute) |
|
| 123 | + { |
|
| 124 | + if (!empty($attribute)) { |
|
| 125 | + reset($attribute); |
|
| 126 | + $key = key($attribute); |
|
| 127 | + if (!is_string($key)) { |
|
| 128 | + throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $this->attributes[$key] = $attribute[$key]; |
|
| 132 | + } |
|
| 133 | + return $this; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + public function getTemplate() |
|
| 140 | + { |
|
| 141 | + return $this->template; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @param string $template |
|
| 146 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 147 | + */ |
|
| 148 | + public function setTemplate($template) |
|
| 149 | + { |
|
| 150 | + $this->template = $template; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @return string |
|
| 155 | + */ |
|
| 156 | + public function getLabel() |
|
| 157 | + { |
|
| 158 | + return $this->label; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * @param string $label |
|
| 163 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 164 | + */ |
|
| 165 | + public function setLabel($label) |
|
| 166 | + { |
|
| 167 | + $this->label = $label; |
|
| 168 | + return $this; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 174 | + public function getPrefix() |
|
| 175 | + { |
|
| 176 | + return $this->prefix; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * @param string $prefix |
|
| 181 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 182 | + */ |
|
| 183 | + public function setPrefix($prefix) |
|
| 184 | + { |
|
| 185 | + $this->prefix = $prefix; |
|
| 186 | + return $this; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * @return array |
|
| 191 | + */ |
|
| 192 | + public function getItems() |
|
| 193 | + { |
|
| 194 | + return $this->items; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @param array $items |
|
| 199 | + */ |
|
| 200 | + public function setItems($items) |
|
| 201 | + { |
|
| 202 | + $this->items = $items; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 208 | + public function getValue() |
|
| 209 | + { |
|
| 210 | + return htmlspecialchars($this->value); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * @param string $value |
|
| 215 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 216 | + */ |
|
| 217 | + public function setValue($value) |
|
| 218 | + { |
|
| 219 | + $this->value = $value; |
|
| 220 | + return $this; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @return string |
|
| 225 | + */ |
|
| 226 | + public function getName() |
|
| 227 | + { |
|
| 228 | + $result = $this->name; |
|
| 229 | + if ($this->getPrefix()) { |
|
| 230 | + $result = sprintf('%s[%s]', $this->getPrefix(), $this->name); |
|
| 231 | + } |
|
| 232 | + return $result; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @param string $name |
|
| 237 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 238 | + */ |
|
| 239 | + public function setName($name) |
|
| 240 | + { |
|
| 241 | + $this->name = $name; |
|
| 242 | + return $this; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @return string |
|
| 247 | + */ |
|
| 248 | + public function getId() |
|
| 249 | + { |
|
| 250 | + if ($this->id === '') { |
|
| 251 | + $this->id = DomElement::getInstance()->formatId($this->getName()); |
|
| 252 | + } |
|
| 253 | + return $this->id; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @param string $id |
|
| 258 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 259 | + */ |
|
| 260 | + public function setId($id) |
|
| 261 | + { |
|
| 262 | + $this->id = $id; |
|
| 263 | + return $this; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @return array |
|
| 268 | + */ |
|
| 269 | + public function getAttributes() |
|
| 270 | + { |
|
| 271 | + return $this->attributes; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * @param array $attributes |
|
| 276 | + * @return \Fab\Media\Form\AbstractFormField |
|
| 277 | + */ |
|
| 278 | + public function setAttributes($attributes) |
|
| 279 | + { |
|
| 280 | + $this->attributes = $attributes; |
|
| 281 | + return $this; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | } |
@@ -78,8 +78,7 @@ discard block |
||
| 78 | 78 | $selected, |
| 79 | 79 | $storage->getName(), |
| 80 | 80 | $storage->isOnline() ? |
| 81 | - '' : |
|
| 82 | - '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')' |
|
| 81 | + '' : '('.$this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline').')' |
|
| 83 | 82 | ); |
| 84 | 83 | } |
| 85 | 84 | |
@@ -87,7 +86,7 @@ discard block |
||
| 87 | 86 | $inputs = ''; |
| 88 | 87 | foreach ($parameters as $parameter => $value) { |
| 89 | 88 | list($parameter, $value) = $this->computeParameterAndValue($parameter, $value); |
| 90 | - if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') { |
|
| 89 | + if ($parameter !== $this->moduleLoader->getParameterPrefix().'[storage]') { |
|
| 91 | 90 | $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value); |
| 92 | 91 | } |
| 93 | 92 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * @return string |
|
| 47 | + * @return boolean |
|
| 48 | 48 | */ |
| 49 | 49 | protected function isDisplayed() |
| 50 | 50 | { |
@@ -19,126 +19,126 @@ |
||
| 19 | 19 | class StorageMenu extends AbstractComponentView |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var \Fab\Vidi\Module\ModuleLoader |
|
| 24 | - * @inject |
|
| 25 | - */ |
|
| 26 | - protected $moduleLoader; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Renders a dropdown menu for storage. |
|
| 30 | - * |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - public function render() |
|
| 34 | - { |
|
| 35 | - |
|
| 36 | - $output = ''; |
|
| 37 | - if ($this->isDisplayed()) { |
|
| 38 | - $this->loadRequireJsCode(); |
|
| 39 | - |
|
| 40 | - $output = $this->renderStorageMenu(); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - return $output; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - protected function isDisplayed() |
|
| 50 | - { |
|
| 51 | - $isDisplayed = !$this->getMediaModule()->hasFolderTree() || $this->getModuleLoader()->hasPlugin(); |
|
| 52 | - return $isDisplayed; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 58 | - protected function renderStorageMenu() |
|
| 59 | - { |
|
| 60 | - |
|
| 61 | - $currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
| 62 | - |
|
| 63 | - /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */ |
|
| 64 | - $options = ''; |
|
| 65 | - foreach ($this->getMediaModule()->getAllowedStorages() as $storage) { |
|
| 66 | - $selected = ''; |
|
| 67 | - if ($currentStorage->getUid() == $storage->getUid()) { |
|
| 68 | - $selected = 'selected'; |
|
| 69 | - } |
|
| 70 | - $options .= sprintf('<option value="%s" %s>%s %s</option>', |
|
| 71 | - $storage->getUid(), |
|
| 72 | - $selected, |
|
| 73 | - $storage->getName(), |
|
| 74 | - $storage->isOnline() ? |
|
| 75 | - '' : |
|
| 76 | - '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')' |
|
| 77 | - ); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - $parameters = GeneralUtility::_GET(); |
|
| 81 | - $inputs = ''; |
|
| 82 | - foreach ($parameters as $parameter => $value) { |
|
| 83 | - list($parameter, $value) = $this->computeParameterAndValue($parameter, $value); |
|
| 84 | - if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') { |
|
| 85 | - $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $template = '<form action="%s" id="form-menu-storage" method="get"> |
|
| 22 | + /** |
|
| 23 | + * @var \Fab\Vidi\Module\ModuleLoader |
|
| 24 | + * @inject |
|
| 25 | + */ |
|
| 26 | + protected $moduleLoader; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Renders a dropdown menu for storage. |
|
| 30 | + * |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + public function render() |
|
| 34 | + { |
|
| 35 | + |
|
| 36 | + $output = ''; |
|
| 37 | + if ($this->isDisplayed()) { |
|
| 38 | + $this->loadRequireJsCode(); |
|
| 39 | + |
|
| 40 | + $output = $this->renderStorageMenu(); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + return $output; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + protected function isDisplayed() |
|
| 50 | + { |
|
| 51 | + $isDisplayed = !$this->getMediaModule()->hasFolderTree() || $this->getModuleLoader()->hasPlugin(); |
|
| 52 | + return $isDisplayed; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | + protected function renderStorageMenu() |
|
| 59 | + { |
|
| 60 | + |
|
| 61 | + $currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
| 62 | + |
|
| 63 | + /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */ |
|
| 64 | + $options = ''; |
|
| 65 | + foreach ($this->getMediaModule()->getAllowedStorages() as $storage) { |
|
| 66 | + $selected = ''; |
|
| 67 | + if ($currentStorage->getUid() == $storage->getUid()) { |
|
| 68 | + $selected = 'selected'; |
|
| 69 | + } |
|
| 70 | + $options .= sprintf('<option value="%s" %s>%s %s</option>', |
|
| 71 | + $storage->getUid(), |
|
| 72 | + $selected, |
|
| 73 | + $storage->getName(), |
|
| 74 | + $storage->isOnline() ? |
|
| 75 | + '' : |
|
| 76 | + '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')' |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + $parameters = GeneralUtility::_GET(); |
|
| 81 | + $inputs = ''; |
|
| 82 | + foreach ($parameters as $parameter => $value) { |
|
| 83 | + list($parameter, $value) = $this->computeParameterAndValue($parameter, $value); |
|
| 84 | + if ($parameter !== $this->moduleLoader->getParameterPrefix() . '[storage]') { |
|
| 85 | + $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $template = '<form action="%s" id="form-menu-storage" method="get"> |
|
| 90 | 90 | %s |
| 91 | 91 | <select name="%s[storage]" class="form-control" style="padding-right: 20px" id="menu-storage" onchange="$(\'#form-menu-storage\').submit()">%s</select> |
| 92 | 92 | </form>'; |
| 93 | 93 | |
| 94 | - return sprintf( |
|
| 95 | - $template, |
|
| 96 | - $this->getModuleLoader()->getModuleUrl(), |
|
| 97 | - $inputs, |
|
| 98 | - $this->moduleLoader->getParameterPrefix(), |
|
| 99 | - $options |
|
| 100 | - ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @return void |
|
| 105 | - */ |
|
| 106 | - protected function loadRequireJsCode() |
|
| 107 | - { |
|
| 108 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 109 | - |
|
| 110 | - $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript'; |
|
| 111 | - $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 112 | - $pageRenderer->loadRequireJsModule('Fab/Media/EditStorage'); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Compute parameter and value to be correctly encoded by the browser. |
|
| 117 | - * |
|
| 118 | - * @param string $parameter |
|
| 119 | - * @param mixed $value |
|
| 120 | - * @return array |
|
| 121 | - */ |
|
| 122 | - protected function computeParameterAndValue($parameter, $value) |
|
| 123 | - { |
|
| 124 | - |
|
| 125 | - if (is_string($value)) { |
|
| 126 | - $result = array($parameter, $value); |
|
| 127 | - } else { |
|
| 128 | - $key = key($value); |
|
| 129 | - $value = current($value); |
|
| 130 | - $parameter = sprintf('%s[%s]', $parameter, $key); |
|
| 131 | - $result = $this->computeParameterAndValue($parameter, $value); |
|
| 132 | - } |
|
| 133 | - return $result; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * @return MediaModule|object |
|
| 138 | - */ |
|
| 139 | - protected function getMediaModule() |
|
| 140 | - { |
|
| 141 | - return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
| 142 | - } |
|
| 94 | + return sprintf( |
|
| 95 | + $template, |
|
| 96 | + $this->getModuleLoader()->getModuleUrl(), |
|
| 97 | + $inputs, |
|
| 98 | + $this->moduleLoader->getParameterPrefix(), |
|
| 99 | + $options |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @return void |
|
| 105 | + */ |
|
| 106 | + protected function loadRequireJsCode() |
|
| 107 | + { |
|
| 108 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 109 | + |
|
| 110 | + $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript'; |
|
| 111 | + $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 112 | + $pageRenderer->loadRequireJsModule('Fab/Media/EditStorage'); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Compute parameter and value to be correctly encoded by the browser. |
|
| 117 | + * |
|
| 118 | + * @param string $parameter |
|
| 119 | + * @param mixed $value |
|
| 120 | + * @return array |
|
| 121 | + */ |
|
| 122 | + protected function computeParameterAndValue($parameter, $value) |
|
| 123 | + { |
|
| 124 | + |
|
| 125 | + if (is_string($value)) { |
|
| 126 | + $result = array($parameter, $value); |
|
| 127 | + } else { |
|
| 128 | + $key = key($value); |
|
| 129 | + $value = current($value); |
|
| 130 | + $parameter = sprintf('%s[%s]', $parameter, $key); |
|
| 131 | + $result = $this->computeParameterAndValue($parameter, $value); |
|
| 132 | + } |
|
| 133 | + return $result; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @return MediaModule|object |
|
| 138 | + */ |
|
| 139 | + protected function getMediaModule() |
|
| 140 | + { |
|
| 141 | + return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
| 45 | 45 | ->render(); |
| 46 | 46 | |
| 47 | - $output = '<div style="float: left;">' . $button . '</div>'; |
|
| 47 | + $output = '<div style="float: left;">'.$button.'</div>'; |
|
| 48 | 48 | } |
| 49 | 49 | return $output; |
| 50 | 50 | } |
@@ -21,101 +21,101 @@ |
||
| 21 | 21 | class NewFolder extends AbstractComponentView |
| 22 | 22 | { |
| 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 | - |
|
| 35 | - $button = $this->makeLinkButton() |
|
| 36 | - ->setHref($this->getNewFolderUri()) |
|
| 37 | - ->setTitle($this->getLabel()) |
|
| 38 | - ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
| 39 | - ->render(); |
|
| 40 | - |
|
| 41 | - $output = '<div style="float: left;">' . $button . '</div>'; |
|
| 42 | - } |
|
| 43 | - return $output; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - protected function getLabel() |
|
| 50 | - { |
|
| 51 | - return $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new'); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - protected function getNewFolderUri() |
|
| 58 | - { |
|
| 59 | - return BackendUtility::getModuleUrl( |
|
| 60 | - 'file_newfolder', |
|
| 61 | - array( |
|
| 62 | - 'target' => $this->getCombineIdentifier(), |
|
| 63 | - 'returnUrl' => $this->getReturnUrl(), |
|
| 64 | - ) |
|
| 65 | - ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - protected function getCombineIdentifier() |
|
| 73 | - { |
|
| 74 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
| 75 | - return $folder->getCombinedIdentifier(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 81 | - protected function getReturnUrl() |
|
| 82 | - { |
|
| 83 | - $returnUrl = BackendUtility::getModuleUrl( |
|
| 84 | - GeneralUtility::_GP('route'), |
|
| 85 | - $this->getAdditionalParameters() |
|
| 86 | - ); |
|
| 87 | - return $returnUrl; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @return array |
|
| 92 | - */ |
|
| 93 | - protected function getAdditionalParameters() |
|
| 94 | - { |
|
| 95 | - |
|
| 96 | - $additionalParameters = []; |
|
| 97 | - if (GeneralUtility::_GP('id')) { |
|
| 98 | - $additionalParameters = [ |
|
| 99 | - 'id' => urldecode(GeneralUtility::_GP('id')), |
|
| 100 | - ]; |
|
| 101 | - } |
|
| 102 | - return $additionalParameters; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return MediaModule|object |
|
| 107 | - */ |
|
| 108 | - protected function getMediaModule() |
|
| 109 | - { |
|
| 110 | - return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return \TYPO3\CMS\Lang\LanguageService |
|
| 115 | - */ |
|
| 116 | - protected function getLanguageService() |
|
| 117 | - { |
|
| 118 | - return $GLOBALS['LANG']; |
|
| 119 | - } |
|
| 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 | + |
|
| 35 | + $button = $this->makeLinkButton() |
|
| 36 | + ->setHref($this->getNewFolderUri()) |
|
| 37 | + ->setTitle($this->getLabel()) |
|
| 38 | + ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)) |
|
| 39 | + ->render(); |
|
| 40 | + |
|
| 41 | + $output = '<div style="float: left;">' . $button . '</div>'; |
|
| 42 | + } |
|
| 43 | + return $output; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + protected function getLabel() |
|
| 50 | + { |
|
| 51 | + return $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.new'); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + protected function getNewFolderUri() |
|
| 58 | + { |
|
| 59 | + return BackendUtility::getModuleUrl( |
|
| 60 | + 'file_newfolder', |
|
| 61 | + array( |
|
| 62 | + 'target' => $this->getCombineIdentifier(), |
|
| 63 | + 'returnUrl' => $this->getReturnUrl(), |
|
| 64 | + ) |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + protected function getCombineIdentifier() |
|
| 73 | + { |
|
| 74 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
| 75 | + return $folder->getCombinedIdentifier(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | + protected function getReturnUrl() |
|
| 82 | + { |
|
| 83 | + $returnUrl = BackendUtility::getModuleUrl( |
|
| 84 | + GeneralUtility::_GP('route'), |
|
| 85 | + $this->getAdditionalParameters() |
|
| 86 | + ); |
|
| 87 | + return $returnUrl; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @return array |
|
| 92 | + */ |
|
| 93 | + protected function getAdditionalParameters() |
|
| 94 | + { |
|
| 95 | + |
|
| 96 | + $additionalParameters = []; |
|
| 97 | + if (GeneralUtility::_GP('id')) { |
|
| 98 | + $additionalParameters = [ |
|
| 99 | + 'id' => urldecode(GeneralUtility::_GP('id')), |
|
| 100 | + ]; |
|
| 101 | + } |
|
| 102 | + return $additionalParameters; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return MediaModule|object |
|
| 107 | + */ |
|
| 108 | + protected function getMediaModule() |
|
| 109 | + { |
|
| 110 | + return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return \TYPO3\CMS\Lang\LanguageService |
|
| 115 | + */ |
|
| 116 | + protected function getLanguageService() |
|
| 117 | + { |
|
| 118 | + return $GLOBALS['LANG']; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | $message = sprintf('* File "%s": %s %s', |
| 65 | 65 | $result['fileUid'], |
| 66 | 66 | $result['fileIdentifier'], |
| 67 | - empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
| 67 | + empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri'] |
|
| 68 | 68 | ); |
| 69 | 69 | $this->outputLine($message); |
| 70 | 70 | } |
@@ -21,137 +21,137 @@ |
||
| 21 | 21 | class ThumbnailCommandController extends CommandController |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException |
|
| 26 | - * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException |
|
| 27 | - */ |
|
| 28 | - protected function initializeCommandMethodArguments() |
|
| 29 | - { |
|
| 30 | - parent::initializeCommandMethodArguments(); |
|
| 31 | - if ($this->arguments->hasArgument('configuration')) { |
|
| 32 | - $propertyMappingConfiguration = $this->arguments->getArgument('configuration')->getPropertyMappingConfiguration(); |
|
| 33 | - $propertyMappingConfiguration->setTypeConverter( |
|
| 34 | - $this->objectManager->get(ConfigurationArrayConverter::class) |
|
| 35 | - ); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module. |
|
| 42 | - * |
|
| 43 | - * @param int $limit where to stop in the batch processing. |
|
| 44 | - * @param int $offset where to start in the batch processing. |
|
| 45 | - * @param array $configuration override the default thumbnail configuration. |
|
| 46 | - * @param bool $verbose will output a detail result of the thumbnail generation. |
|
| 47 | - * @return void |
|
| 48 | - */ |
|
| 49 | - public function generateCommand($limit = 0, $offset = 0, $configuration = [], $verbose = false) |
|
| 50 | - { |
|
| 51 | - |
|
| 52 | - $this->checkEnvironment(); |
|
| 53 | - |
|
| 54 | - foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
| 55 | - |
|
| 56 | - // TODO: Make me more flexible by passing thumbnail configuration. For now it will only generate thumbnails for the BE module. |
|
| 57 | - |
|
| 58 | - $this->outputLine(); |
|
| 59 | - $this->outputLine(sprintf('%s (%s)', $storage->getName(), $storage->getUid())); |
|
| 60 | - $this->outputLine('--------------------------------------------'); |
|
| 61 | - $this->outputLine(); |
|
| 62 | - |
|
| 63 | - if ($storage->isOnline()) { |
|
| 64 | - |
|
| 65 | - // For the CLI cause. |
|
| 66 | - $storage->setEvaluatePermissions(false); |
|
| 67 | - |
|
| 68 | - $thumbnailGenerator = $this->getThumbnailGenerator(); |
|
| 69 | - $thumbnailGenerator |
|
| 70 | - ->setStorage($storage) |
|
| 71 | - ->setConfiguration($configuration) |
|
| 72 | - ->generate($limit, $offset); |
|
| 73 | - |
|
| 74 | - if ($verbose) { |
|
| 75 | - $resultSet = $thumbnailGenerator->getResultSet(); |
|
| 76 | - foreach ($resultSet as $result) { |
|
| 77 | - $message = sprintf('* File "%s": %s %s', |
|
| 78 | - $result['fileUid'], |
|
| 79 | - $result['fileIdentifier'], |
|
| 80 | - empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
| 81 | - ); |
|
| 82 | - $this->outputLine($message); |
|
| 83 | - } |
|
| 84 | - $this->outputLine(); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $message = sprintf('Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.', |
|
| 88 | - $thumbnailGenerator->getNumberOfProcessedFiles(), |
|
| 89 | - $thumbnailGenerator->getNumberOfTraversedFiles(), |
|
| 90 | - $thumbnailGenerator->getTotalNumberOfFiles() |
|
| 91 | - ); |
|
| 92 | - $this->outputLine($message); |
|
| 93 | - |
|
| 94 | - // Add warning message if missing files were found along the way. |
|
| 95 | - if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) { |
|
| 96 | - |
|
| 97 | - $message = sprintf('ATTENTION! %s missing file(s) detected.', |
|
| 98 | - $thumbnailGenerator->getNumberOfMissingFiles() |
|
| 99 | - ); |
|
| 100 | - $this->outputLine($message); |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - $this->outputLine('Storage is offline!'); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @return void |
|
| 110 | - */ |
|
| 111 | - protected function checkEnvironment() |
|
| 112 | - { |
|
| 113 | - $user = $this->getDataService()->getRecord( |
|
| 114 | - 'be_users', [ |
|
| 115 | - 'username' => '_cli_lowlevel' |
|
| 116 | - ]); |
|
| 117 | - |
|
| 118 | - if (empty($user)) { |
|
| 119 | - $this->outputLine('Missing User "_cli_lowlevel" and / or its password.'); |
|
| 120 | - $this->sendAndExit(1); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $user = $this->getDataService()->getRecord( |
|
| 124 | - 'be_users', [ |
|
| 125 | - 'username' => '_cli_scheduler' |
|
| 126 | - ]); |
|
| 127 | - |
|
| 128 | - if (empty($user)) { |
|
| 129 | - $this->outputLine('Missing User "_cli_scheduler" and / or its password.'); |
|
| 130 | - $this->sendAndExit(1); |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @return object|DataService |
|
| 136 | - */ |
|
| 137 | - protected function getDataService(): DataService |
|
| 138 | - { |
|
| 139 | - return GeneralUtility::makeInstance(DataService::class); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object |
|
| 144 | - */ |
|
| 145 | - protected function getThumbnailGenerator() |
|
| 146 | - { |
|
| 147 | - return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @return StorageRepository|object |
|
| 152 | - */ |
|
| 153 | - protected function getStorageRepository() |
|
| 154 | - { |
|
| 155 | - return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class); |
|
| 156 | - } |
|
| 24 | + /** |
|
| 25 | + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException |
|
| 26 | + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException |
|
| 27 | + */ |
|
| 28 | + protected function initializeCommandMethodArguments() |
|
| 29 | + { |
|
| 30 | + parent::initializeCommandMethodArguments(); |
|
| 31 | + if ($this->arguments->hasArgument('configuration')) { |
|
| 32 | + $propertyMappingConfiguration = $this->arguments->getArgument('configuration')->getPropertyMappingConfiguration(); |
|
| 33 | + $propertyMappingConfiguration->setTypeConverter( |
|
| 34 | + $this->objectManager->get(ConfigurationArrayConverter::class) |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Generate a bunch of thumbnails in advance to speed up the output of the Media BE module. |
|
| 42 | + * |
|
| 43 | + * @param int $limit where to stop in the batch processing. |
|
| 44 | + * @param int $offset where to start in the batch processing. |
|
| 45 | + * @param array $configuration override the default thumbnail configuration. |
|
| 46 | + * @param bool $verbose will output a detail result of the thumbnail generation. |
|
| 47 | + * @return void |
|
| 48 | + */ |
|
| 49 | + public function generateCommand($limit = 0, $offset = 0, $configuration = [], $verbose = false) |
|
| 50 | + { |
|
| 51 | + |
|
| 52 | + $this->checkEnvironment(); |
|
| 53 | + |
|
| 54 | + foreach ($this->getStorageRepository()->findAll() as $storage) { |
|
| 55 | + |
|
| 56 | + // TODO: Make me more flexible by passing thumbnail configuration. For now it will only generate thumbnails for the BE module. |
|
| 57 | + |
|
| 58 | + $this->outputLine(); |
|
| 59 | + $this->outputLine(sprintf('%s (%s)', $storage->getName(), $storage->getUid())); |
|
| 60 | + $this->outputLine('--------------------------------------------'); |
|
| 61 | + $this->outputLine(); |
|
| 62 | + |
|
| 63 | + if ($storage->isOnline()) { |
|
| 64 | + |
|
| 65 | + // For the CLI cause. |
|
| 66 | + $storage->setEvaluatePermissions(false); |
|
| 67 | + |
|
| 68 | + $thumbnailGenerator = $this->getThumbnailGenerator(); |
|
| 69 | + $thumbnailGenerator |
|
| 70 | + ->setStorage($storage) |
|
| 71 | + ->setConfiguration($configuration) |
|
| 72 | + ->generate($limit, $offset); |
|
| 73 | + |
|
| 74 | + if ($verbose) { |
|
| 75 | + $resultSet = $thumbnailGenerator->getResultSet(); |
|
| 76 | + foreach ($resultSet as $result) { |
|
| 77 | + $message = sprintf('* File "%s": %s %s', |
|
| 78 | + $result['fileUid'], |
|
| 79 | + $result['fileIdentifier'], |
|
| 80 | + empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri'] |
|
| 81 | + ); |
|
| 82 | + $this->outputLine($message); |
|
| 83 | + } |
|
| 84 | + $this->outputLine(); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $message = sprintf('Done! New generated %s thumbnail(s) from %s traversed file(s) of a total of %s files.', |
|
| 88 | + $thumbnailGenerator->getNumberOfProcessedFiles(), |
|
| 89 | + $thumbnailGenerator->getNumberOfTraversedFiles(), |
|
| 90 | + $thumbnailGenerator->getTotalNumberOfFiles() |
|
| 91 | + ); |
|
| 92 | + $this->outputLine($message); |
|
| 93 | + |
|
| 94 | + // Add warning message if missing files were found along the way. |
|
| 95 | + if ($thumbnailGenerator->getNumberOfMissingFiles() > 0) { |
|
| 96 | + |
|
| 97 | + $message = sprintf('ATTENTION! %s missing file(s) detected.', |
|
| 98 | + $thumbnailGenerator->getNumberOfMissingFiles() |
|
| 99 | + ); |
|
| 100 | + $this->outputLine($message); |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + $this->outputLine('Storage is offline!'); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @return void |
|
| 110 | + */ |
|
| 111 | + protected function checkEnvironment() |
|
| 112 | + { |
|
| 113 | + $user = $this->getDataService()->getRecord( |
|
| 114 | + 'be_users', [ |
|
| 115 | + 'username' => '_cli_lowlevel' |
|
| 116 | + ]); |
|
| 117 | + |
|
| 118 | + if (empty($user)) { |
|
| 119 | + $this->outputLine('Missing User "_cli_lowlevel" and / or its password.'); |
|
| 120 | + $this->sendAndExit(1); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $user = $this->getDataService()->getRecord( |
|
| 124 | + 'be_users', [ |
|
| 125 | + 'username' => '_cli_scheduler' |
|
| 126 | + ]); |
|
| 127 | + |
|
| 128 | + if (empty($user)) { |
|
| 129 | + $this->outputLine('Missing User "_cli_scheduler" and / or its password.'); |
|
| 130 | + $this->sendAndExit(1); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @return object|DataService |
|
| 136 | + */ |
|
| 137 | + protected function getDataService(): DataService |
|
| 138 | + { |
|
| 139 | + return GeneralUtility::makeInstance(DataService::class); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @return \Fab\Media\Thumbnail\ThumbnailGenerator|object |
|
| 144 | + */ |
|
| 145 | + protected function getThumbnailGenerator() |
|
| 146 | + { |
|
| 147 | + return GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailGenerator::class); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @return StorageRepository|object |
|
| 152 | + */ |
|
| 153 | + protected function getStorageRepository() |
|
| 154 | + { |
|
| 155 | + return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | use Fab\Media\Tests\Functional\AbstractFunctionalTestCase; |
| 18 | 18 | |
| 19 | -require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php'; |
|
| 19 | +require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php'; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Test case for class \Fab\Media\Utility\Configuration. |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | use Fab\Media\Tests\Functional\AbstractFunctionalTestCase; |
| 18 | 18 | |
| 19 | -require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php'; |
|
| 19 | +require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php'; |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $preset = 'image_large'; |
| 129 | 129 | $actualWidth = rand(10, 100); |
| 130 | 130 | $actualHeight = rand(10, 100); |
| 131 | - \Fab\Media\Utility\ConfigurationUtility::getInstance()->set('image_large', $actualWidth . 'x' . $actualHeight); |
|
| 131 | + \Fab\Media\Utility\ConfigurationUtility::getInstance()->set('image_large', $actualWidth.'x'.$actualHeight); |
|
| 132 | 132 | $this->assertSame($actualWidth, $this->fixture->preset($preset)->getWidth()); |
| 133 | 133 | $this->assertSame($actualHeight, $this->fixture->preset($preset)->getHeight()); |
| 134 | 134 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function setUp() { |
| 38 | 38 | $this->fixture = new \Fab\Media\FileUpload\UploadManager(); |
| 39 | 39 | $this->fakeName = uniqid('name'); |
| 40 | - $this->fakePrefix= uniqid('prefix'); |
|
| 40 | + $this->fakePrefix = uniqid('prefix'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function tearDown() { |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | * @dataProvider propertyProvider |
| 50 | 50 | */ |
| 51 | 51 | public function testProperty($propertyName, $value) { |
| 52 | - $setter = 'set' . ucfirst($propertyName); |
|
| 53 | - $getter = 'get' . ucfirst($propertyName); |
|
| 52 | + $setter = 'set'.ucfirst($propertyName); |
|
| 53 | + $getter = 'get'.ucfirst($propertyName); |
|
| 54 | 54 | call_user_func_array(array($this->fixture, $setter), array($value)); |
| 55 | 55 | $this->assertEquals($value, call_user_func(array($this->fixture, $getter))); |
| 56 | 56 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | return array( |
| 63 | 63 | array('uploadFolder', uniqid()), |
| 64 | 64 | array('inputName', uniqid()), |
| 65 | - array('sizeLimit', rand(10,100)), |
|
| 65 | + array('sizeLimit', rand(10, 100)), |
|
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function canResolvesAPath() { |
| 32 | 32 | $resourceName = uniqid('resource'); |
| 33 | - $expected = 'media/Resources/Public/' . $resourceName; |
|
| 33 | + $expected = 'media/Resources/Public/'.$resourceName; |
|
| 34 | 34 | $actual = \Fab\Media\Utility\Path::resolvePath($resourceName); |
| 35 | 35 | |
| 36 | 36 | $this->assertTrue(strpos($actual, $expected) > 0); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function canReturnsAPublicPath() { |
| 44 | 44 | |
| 45 | 45 | $resourceName = uniqid('resource'); |
| 46 | - $expected = 'media/Resources/Public/' . $resourceName; |
|
| 46 | + $expected = 'media/Resources/Public/'.$resourceName; |
|
| 47 | 47 | $actual = \Fab\Media\Utility\Path::getRelativePath($resourceName); |
| 48 | 48 | |
| 49 | 49 | $this->assertTrue(strpos($actual, $expected) > 0); |
@@ -40,9 +40,9 @@ |
||
| 40 | 40 | |
| 41 | 41 | $pageRenderer = $this->getPageRenderer(); |
| 42 | 42 | $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
| 43 | - MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\'; |
|
| 44 | - MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\'; |
|
| 45 | - MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '; |
|
| 43 | + MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()).'\'; |
|
| 44 | + MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix().'\'; |
|
| 45 | + MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')).'; |
|
| 46 | 46 | }'); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -18,38 +18,38 @@ |
||
| 18 | 18 | class FormResultCompiler extends \TYPO3\CMS\Backend\Form\FormResultCompiler |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * JavaScript bottom code |
|
| 23 | - * |
|
| 24 | - * @param string $formname The identification of the form on the page. |
|
| 25 | - * @return string A section with JavaScript - if $update is false, embedded in <script></script> |
|
| 26 | - */ |
|
| 27 | - protected function JSbottom($formname = 'forms[0]') |
|
| 28 | - { |
|
| 29 | - |
|
| 30 | - $out = parent::JSbottom($formname); |
|
| 31 | - |
|
| 32 | - $enableMediaFilePicker = (bool)$this->getBackendUser()->getTSConfigVal('options.vidi.enableMediaFilePicker'); |
|
| 33 | - if ($enableMediaFilePicker) { |
|
| 34 | - |
|
| 35 | - $pageRenderer = $this->getPageRenderer(); |
|
| 36 | - $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
|
| 21 | + /** |
|
| 22 | + * JavaScript bottom code |
|
| 23 | + * |
|
| 24 | + * @param string $formname The identification of the form on the page. |
|
| 25 | + * @return string A section with JavaScript - if $update is false, embedded in <script></script> |
|
| 26 | + */ |
|
| 27 | + protected function JSbottom($formname = 'forms[0]') |
|
| 28 | + { |
|
| 29 | + |
|
| 30 | + $out = parent::JSbottom($formname); |
|
| 31 | + |
|
| 32 | + $enableMediaFilePicker = (bool)$this->getBackendUser()->getTSConfigVal('options.vidi.enableMediaFilePicker'); |
|
| 33 | + if ($enableMediaFilePicker) { |
|
| 34 | + |
|
| 35 | + $pageRenderer = $this->getPageRenderer(); |
|
| 36 | + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Media/MediaFormEngine', 'function(MediaFormEngine) { |
|
| 37 | 37 | MediaFormEngine.vidiModuleUrl = \'' . BackendUtility::getModuleUrl(VidiModule::getSignature()) . '\'; |
| 38 | 38 | MediaFormEngine.vidiModulePrefix = \'' . VidiModule::getParameterPrefix() . '\'; |
| 39 | 39 | MediaFormEngine.browserUrl = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '; |
| 40 | 40 | }'); |
| 41 | - } |
|
| 42 | - |
|
| 43 | - return $out; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Returns an instance of the current Backend User. |
|
| 48 | - * |
|
| 49 | - * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 50 | - */ |
|
| 51 | - protected function getBackendUser() |
|
| 52 | - { |
|
| 53 | - return $GLOBALS['BE_USER']; |
|
| 54 | - } |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + return $out; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Returns an instance of the current Backend User. |
|
| 48 | + * |
|
| 49 | + * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
| 50 | + */ |
|
| 51 | + protected function getBackendUser() |
|
| 52 | + { |
|
| 53 | + return $GLOBALS['BE_USER']; |
|
| 54 | + } |
|
| 55 | 55 | } |