@@ -20,43 +20,43 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class LinkCreatorButton extends AbstractComponentView |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Renders a "link-creator" button to be placed in the grid. |
|
| 25 | - * |
|
| 26 | - * @param Content $object |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function render(Content $object = null) |
|
| 30 | - { |
|
| 31 | - $button = ''; |
|
| 32 | - if ($this->getModuleLoader()->hasPlugin('linkCreator')) { |
|
| 33 | - $button = $this->makeLinkButton() |
|
| 34 | - ->setHref($this->getLinkCreatorUri($object)) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - ]) |
|
| 39 | - ->setClasses('btn-linkCreator') |
|
| 40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:create_link')) |
|
| 41 | - ->setIcon($this->getIconFactory()->getIcon('apps-pagetree-page-shortcut-external-root', Icon::SIZE_SMALL)) |
|
| 42 | - ->render(); |
|
| 43 | - } |
|
| 44 | - return $button; |
|
| 45 | - } |
|
| 23 | + /** |
|
| 24 | + * Renders a "link-creator" button to be placed in the grid. |
|
| 25 | + * |
|
| 26 | + * @param Content $object |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function render(Content $object = null) |
|
| 30 | + { |
|
| 31 | + $button = ''; |
|
| 32 | + if ($this->getModuleLoader()->hasPlugin('linkCreator')) { |
|
| 33 | + $button = $this->makeLinkButton() |
|
| 34 | + ->setHref($this->getLinkCreatorUri($object)) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + ]) |
|
| 39 | + ->setClasses('btn-linkCreator') |
|
| 40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:create_link')) |
|
| 41 | + ->setIcon($this->getIconFactory()->getIcon('apps-pagetree-page-shortcut-external-root', Icon::SIZE_SMALL)) |
|
| 42 | + ->render(); |
|
| 43 | + } |
|
| 44 | + return $button; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param Content $object |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - protected function getLinkCreatorUri(Content $object) |
|
| 52 | - { |
|
| 53 | - $urlParameters = array( |
|
| 54 | - MediaModule::getParameterPrefix() => array( |
|
| 55 | - 'controller' => 'LinkCreator', |
|
| 56 | - 'action' => 'show', |
|
| 57 | - 'file' => $object->getUid(), |
|
| 58 | - ), |
|
| 59 | - ); |
|
| 60 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 61 | - } |
|
| 47 | + /** |
|
| 48 | + * @param Content $object |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + protected function getLinkCreatorUri(Content $object) |
|
| 52 | + { |
|
| 53 | + $urlParameters = array( |
|
| 54 | + MediaModule::getParameterPrefix() => array( |
|
| 55 | + 'controller' => 'LinkCreator', |
|
| 56 | + 'action' => 'show', |
|
| 57 | + 'file' => $object->getUid(), |
|
| 58 | + ), |
|
| 59 | + ); |
|
| 60 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -20,43 +20,43 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class FilePickerButton extends AbstractComponentView |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Renders a "file-picker" button to be placed in the grid. |
|
| 25 | - * |
|
| 26 | - * @param Content $object |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function render(Content $object = null) |
|
| 30 | - { |
|
| 31 | - $button = ''; |
|
| 32 | - if ($this->getModuleLoader()->hasPlugin('filePicker')) { |
|
| 33 | - $button = $this->makeLinkButton() |
|
| 34 | - ->setHref($this->getFilePickerUri($object)) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - ]) |
|
| 39 | - ->setClasses('btn-filePicker') |
|
| 40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
| 41 | - ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-export', Icon::SIZE_SMALL)) |
|
| 42 | - ->render(); |
|
| 43 | - } |
|
| 44 | - return $button; |
|
| 45 | - } |
|
| 23 | + /** |
|
| 24 | + * Renders a "file-picker" button to be placed in the grid. |
|
| 25 | + * |
|
| 26 | + * @param Content $object |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function render(Content $object = null) |
|
| 30 | + { |
|
| 31 | + $button = ''; |
|
| 32 | + if ($this->getModuleLoader()->hasPlugin('filePicker')) { |
|
| 33 | + $button = $this->makeLinkButton() |
|
| 34 | + ->setHref($this->getFilePickerUri($object)) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + ]) |
|
| 39 | + ->setClasses('btn-filePicker') |
|
| 40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
| 41 | + ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-export', Icon::SIZE_SMALL)) |
|
| 42 | + ->render(); |
|
| 43 | + } |
|
| 44 | + return $button; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param Content $object |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - protected function getFilePickerUri(Content $object) |
|
| 52 | - { |
|
| 53 | - $urlParameters = array( |
|
| 54 | - MediaModule::getParameterPrefix() => array( |
|
| 55 | - 'controller' => 'Asset', |
|
| 56 | - 'action' => 'download', |
|
| 57 | - 'file' => $object->getUid(), |
|
| 58 | - ), |
|
| 59 | - ); |
|
| 60 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 61 | - } |
|
| 47 | + /** |
|
| 48 | + * @param Content $object |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + protected function getFilePickerUri(Content $object) |
|
| 52 | + { |
|
| 53 | + $urlParameters = array( |
|
| 54 | + MediaModule::getParameterPrefix() => array( |
|
| 55 | + 'controller' => 'Asset', |
|
| 56 | + 'action' => 'download', |
|
| 57 | + 'file' => $object->getUid(), |
|
| 58 | + ), |
|
| 59 | + ); |
|
| 60 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -20,43 +20,43 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class ImageEditorButton extends AbstractComponentView |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Renders a "image-editor" button to be placed in the grid. |
|
| 25 | - * |
|
| 26 | - * @param Content $object |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function render(Content $object = null) |
|
| 30 | - { |
|
| 31 | - $button = ''; |
|
| 32 | - if ($this->getModuleLoader()->hasPlugin('imageEditor')) { |
|
| 33 | - $button = $this->makeLinkButton() |
|
| 34 | - ->setHref($this->getImageEditorUri($object)) |
|
| 35 | - ->setDataAttributes([ |
|
| 36 | - 'uid' => $object->getUid(), |
|
| 37 | - 'toggle' => 'tooltip', |
|
| 38 | - ]) |
|
| 39 | - ->setClasses('btn-imageEditor') |
|
| 40 | - ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
| 41 | - ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-edit', Icon::SIZE_SMALL)) |
|
| 42 | - ->render(); |
|
| 43 | - } |
|
| 44 | - return $button; |
|
| 45 | - } |
|
| 23 | + /** |
|
| 24 | + * Renders a "image-editor" button to be placed in the grid. |
|
| 25 | + * |
|
| 26 | + * @param Content $object |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function render(Content $object = null) |
|
| 30 | + { |
|
| 31 | + $button = ''; |
|
| 32 | + if ($this->getModuleLoader()->hasPlugin('imageEditor')) { |
|
| 33 | + $button = $this->makeLinkButton() |
|
| 34 | + ->setHref($this->getImageEditorUri($object)) |
|
| 35 | + ->setDataAttributes([ |
|
| 36 | + 'uid' => $object->getUid(), |
|
| 37 | + 'toggle' => 'tooltip', |
|
| 38 | + ]) |
|
| 39 | + ->setClasses('btn-imageEditor') |
|
| 40 | + ->setTitle($this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:edit_image')) |
|
| 41 | + ->setIcon($this->getIconFactory()->getIcon('extensions-media-image-edit', Icon::SIZE_SMALL)) |
|
| 42 | + ->render(); |
|
| 43 | + } |
|
| 44 | + return $button; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param Content $object |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - protected function getImageEditorUri(Content $object) |
|
| 52 | - { |
|
| 53 | - $urlParameters = array( |
|
| 54 | - MediaModule::getParameterPrefix() => array( |
|
| 55 | - 'controller' => 'ImageEditor', |
|
| 56 | - 'action' => 'show', |
|
| 57 | - 'file' => $object->getUid(), |
|
| 58 | - ), |
|
| 59 | - ); |
|
| 60 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 61 | - } |
|
| 47 | + /** |
|
| 48 | + * @param Content $object |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + protected function getImageEditorUri(Content $object) |
|
| 52 | + { |
|
| 53 | + $urlParameters = array( |
|
| 54 | + MediaModule::getParameterPrefix() => array( |
|
| 55 | + 'controller' => 'ImageEditor', |
|
| 56 | + 'action' => 'show', |
|
| 57 | + 'file' => $object->getUid(), |
|
| 58 | + ), |
|
| 59 | + ); |
|
| 60 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -17,15 +17,15 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | class InlineJavaScript extends AbstractComponentView |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Renders a button for uploading assets. |
|
| 22 | - * |
|
| 23 | - * @return string |
|
| 24 | - */ |
|
| 25 | - public function render() |
|
| 26 | - { |
|
| 27 | - $parameterPrefix = MediaModule::getParameterPrefix(); |
|
| 28 | - $output = " |
|
| 20 | + /** |
|
| 21 | + * Renders a button for uploading assets. |
|
| 22 | + * |
|
| 23 | + * @return string |
|
| 24 | + */ |
|
| 25 | + public function render() |
|
| 26 | + { |
|
| 27 | + $parameterPrefix = MediaModule::getParameterPrefix(); |
|
| 28 | + $output = " |
|
| 29 | 29 | <script> |
| 30 | 30 | |
| 31 | 31 | window.Media = window.Media || {}; |
@@ -33,6 +33,6 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | </script>"; |
| 35 | 35 | |
| 36 | - return $output; |
|
| 37 | - } |
|
| 36 | + return $output; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -19,117 +19,117 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class StorageMenu extends AbstractComponentView |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Renders a dropdown menu for storage. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public function render() |
|
| 28 | - { |
|
| 29 | - $output = ''; |
|
| 30 | - if ($this->isDisplayed()) { |
|
| 31 | - $this->loadRequireJsCode(); |
|
| 32 | - |
|
| 33 | - $output = $this->renderStorageMenu(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - return $output; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - protected function isDisplayed() |
|
| 43 | - { |
|
| 44 | - $isDisplayed = !$this->getMediaModule()->hasFolderTree() || $this->getModuleLoader()->hasPlugin(); |
|
| 45 | - return $isDisplayed; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - protected function renderStorageMenu() |
|
| 52 | - { |
|
| 53 | - $currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
| 54 | - |
|
| 55 | - /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */ |
|
| 56 | - $options = ''; |
|
| 57 | - foreach ($this->getMediaModule()->getAllowedStorages() as $storage) { |
|
| 58 | - $selected = ''; |
|
| 59 | - if ($currentStorage->getUid() == $storage->getUid()) { |
|
| 60 | - $selected = 'selected'; |
|
| 61 | - } |
|
| 62 | - $options .= sprintf( |
|
| 63 | - '<option value="%s" %s>%s %s</option>', |
|
| 64 | - $storage->getUid(), |
|
| 65 | - $selected, |
|
| 66 | - $storage->getName(), |
|
| 67 | - $storage->isOnline() ? |
|
| 68 | - '' : |
|
| 69 | - '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')' |
|
| 70 | - ); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - $parameters = GeneralUtility::_GET(); |
|
| 74 | - $inputs = ''; |
|
| 75 | - foreach ($parameters as $parameter => $value) { |
|
| 76 | - list($parameter, $value) = $this->computeParameterAndValue($parameter, $value); |
|
| 77 | - if ($parameter !== $this->getModuleLoader()->getParameterPrefix() . '[storage]') { |
|
| 78 | - $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value); |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - $template = '<form action="%s" id="form-menu-storage" method="get"> |
|
| 22 | + /** |
|
| 23 | + * Renders a dropdown menu for storage. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public function render() |
|
| 28 | + { |
|
| 29 | + $output = ''; |
|
| 30 | + if ($this->isDisplayed()) { |
|
| 31 | + $this->loadRequireJsCode(); |
|
| 32 | + |
|
| 33 | + $output = $this->renderStorageMenu(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + return $output; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + protected function isDisplayed() |
|
| 43 | + { |
|
| 44 | + $isDisplayed = !$this->getMediaModule()->hasFolderTree() || $this->getModuleLoader()->hasPlugin(); |
|
| 45 | + return $isDisplayed; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + protected function renderStorageMenu() |
|
| 52 | + { |
|
| 53 | + $currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
| 54 | + |
|
| 55 | + /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */ |
|
| 56 | + $options = ''; |
|
| 57 | + foreach ($this->getMediaModule()->getAllowedStorages() as $storage) { |
|
| 58 | + $selected = ''; |
|
| 59 | + if ($currentStorage->getUid() == $storage->getUid()) { |
|
| 60 | + $selected = 'selected'; |
|
| 61 | + } |
|
| 62 | + $options .= sprintf( |
|
| 63 | + '<option value="%s" %s>%s %s</option>', |
|
| 64 | + $storage->getUid(), |
|
| 65 | + $selected, |
|
| 66 | + $storage->getName(), |
|
| 67 | + $storage->isOnline() ? |
|
| 68 | + '' : |
|
| 69 | + '(' . $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:offline') . ')' |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + $parameters = GeneralUtility::_GET(); |
|
| 74 | + $inputs = ''; |
|
| 75 | + foreach ($parameters as $parameter => $value) { |
|
| 76 | + list($parameter, $value) = $this->computeParameterAndValue($parameter, $value); |
|
| 77 | + if ($parameter !== $this->getModuleLoader()->getParameterPrefix() . '[storage]') { |
|
| 78 | + $inputs .= sprintf('<input type="hidden" name="%s" value="%s" />', $parameter, $value); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + $template = '<form action="%s" id="form-menu-storage" method="get"> |
|
| 83 | 83 | %s |
| 84 | 84 | <select name="%s[storage]" class="form-control" style="padding-right: 20px" id="menu-storage" onchange="$(\'#form-menu-storage\').submit()">%s</select> |
| 85 | 85 | </form>'; |
| 86 | 86 | |
| 87 | - return sprintf( |
|
| 88 | - $template, |
|
| 89 | - $this->getModuleLoader()->getModuleUrl(), |
|
| 90 | - $inputs, |
|
| 91 | - $this->getModuleLoader()->getParameterPrefix(), |
|
| 92 | - $options |
|
| 93 | - ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @return void |
|
| 98 | - */ |
|
| 99 | - protected function loadRequireJsCode() |
|
| 100 | - { |
|
| 101 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 102 | - |
|
| 103 | - $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript'; |
|
| 104 | - $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 105 | - $pageRenderer->loadRequireJsModule('Fab/Media/EditStorage'); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Compute parameter and value to be correctly encoded by the browser. |
|
| 110 | - * |
|
| 111 | - * @param string $parameter |
|
| 112 | - * @param mixed $value |
|
| 113 | - * @return array |
|
| 114 | - */ |
|
| 115 | - protected function computeParameterAndValue($parameter, $value) |
|
| 116 | - { |
|
| 117 | - if (is_string($value)) { |
|
| 118 | - $result = array($parameter, $value); |
|
| 119 | - } else { |
|
| 120 | - $key = key($value); |
|
| 121 | - $value = current($value); |
|
| 122 | - $parameter = sprintf('%s[%s]', $parameter, $key); |
|
| 123 | - $result = $this->computeParameterAndValue($parameter, $value); |
|
| 124 | - } |
|
| 125 | - return $result; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return MediaModule|object |
|
| 130 | - */ |
|
| 131 | - protected function getMediaModule() |
|
| 132 | - { |
|
| 133 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 134 | - } |
|
| 87 | + return sprintf( |
|
| 88 | + $template, |
|
| 89 | + $this->getModuleLoader()->getModuleUrl(), |
|
| 90 | + $inputs, |
|
| 91 | + $this->getModuleLoader()->getParameterPrefix(), |
|
| 92 | + $options |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @return void |
|
| 98 | + */ |
|
| 99 | + protected function loadRequireJsCode() |
|
| 100 | + { |
|
| 101 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 102 | + |
|
| 103 | + $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript'; |
|
| 104 | + $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 105 | + $pageRenderer->loadRequireJsModule('Fab/Media/EditStorage'); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Compute parameter and value to be correctly encoded by the browser. |
|
| 110 | + * |
|
| 111 | + * @param string $parameter |
|
| 112 | + * @param mixed $value |
|
| 113 | + * @return array |
|
| 114 | + */ |
|
| 115 | + protected function computeParameterAndValue($parameter, $value) |
|
| 116 | + { |
|
| 117 | + if (is_string($value)) { |
|
| 118 | + $result = array($parameter, $value); |
|
| 119 | + } else { |
|
| 120 | + $key = key($value); |
|
| 121 | + $value = current($value); |
|
| 122 | + $parameter = sprintf('%s[%s]', $parameter, $key); |
|
| 123 | + $result = $this->computeParameterAndValue($parameter, $value); |
|
| 124 | + } |
|
| 125 | + return $result; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @return MediaModule|object |
|
| 130 | + */ |
|
| 131 | + protected function getMediaModule() |
|
| 132 | + { |
|
| 133 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -19,42 +19,42 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class RecursiveCheckbox extends AbstractComponentView |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * Renders a checkbox for recursive file browsing. |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - * @throws \InvalidArgumentException |
|
| 27 | - */ |
|
| 28 | - public function render() |
|
| 29 | - { |
|
| 30 | - $output = ''; |
|
| 31 | - if ($this->isDisplayed()) { |
|
| 32 | - $this->loadRequireJsCode(); |
|
| 33 | - $output = $this->renderRecursiveCheckbox(); |
|
| 34 | - } |
|
| 22 | + /** |
|
| 23 | + * Renders a checkbox for recursive file browsing. |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + * @throws \InvalidArgumentException |
|
| 27 | + */ |
|
| 28 | + public function render() |
|
| 29 | + { |
|
| 30 | + $output = ''; |
|
| 31 | + if ($this->isDisplayed()) { |
|
| 32 | + $this->loadRequireJsCode(); |
|
| 33 | + $output = $this->renderRecursiveCheckbox(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return $output; |
|
| 37 | - } |
|
| 36 | + return $output; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return string |
|
| 41 | - * @throws \InvalidArgumentException |
|
| 42 | - */ |
|
| 43 | - protected function isDisplayed() |
|
| 44 | - { |
|
| 45 | - $isDisplayed = $this->getMediaModule()->hasFolderTree(); |
|
| 46 | - if ($this->getModuleLoader()->hasPlugin()) { |
|
| 47 | - $isDisplayed = false; |
|
| 48 | - } |
|
| 49 | - return $isDisplayed; |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * @return string |
|
| 41 | + * @throws \InvalidArgumentException |
|
| 42 | + */ |
|
| 43 | + protected function isDisplayed() |
|
| 44 | + { |
|
| 45 | + $isDisplayed = $this->getMediaModule()->hasFolderTree(); |
|
| 46 | + if ($this->getModuleLoader()->hasPlugin()) { |
|
| 47 | + $isDisplayed = false; |
|
| 48 | + } |
|
| 49 | + return $isDisplayed; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - protected function renderRecursiveCheckbox() |
|
| 56 | - { |
|
| 57 | - $template = '<form action="%s" id="form-checkbox-hasRecursiveSelection" method="get"> |
|
| 52 | + /** |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + protected function renderRecursiveCheckbox() |
|
| 56 | + { |
|
| 57 | + $template = '<form action="%s" id="form-checkbox-hasRecursiveSelection" method="get"> |
|
| 58 | 58 | <label> |
| 59 | 59 | <input type="checkbox" |
| 60 | 60 | name="%s[hasRecursiveSelection]" |
@@ -65,34 +65,34 @@ discard block |
||
| 65 | 65 | </label> |
| 66 | 66 | </form>'; |
| 67 | 67 | |
| 68 | - return sprintf( |
|
| 69 | - $template, |
|
| 70 | - $this->getModuleLoader()->getModuleUrl(), |
|
| 71 | - $this->getModuleLoader()->getParameterPrefix(), |
|
| 72 | - $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:browse_subfolders') |
|
| 73 | - ); |
|
| 74 | - } |
|
| 68 | + return sprintf( |
|
| 69 | + $template, |
|
| 70 | + $this->getModuleLoader()->getModuleUrl(), |
|
| 71 | + $this->getModuleLoader()->getParameterPrefix(), |
|
| 72 | + $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:browse_subfolders') |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @return void |
|
| 78 | - * @throws \InvalidArgumentException |
|
| 79 | - */ |
|
| 80 | - protected function loadRequireJsCode() |
|
| 81 | - { |
|
| 82 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 76 | + /** |
|
| 77 | + * @return void |
|
| 78 | + * @throws \InvalidArgumentException |
|
| 79 | + */ |
|
| 80 | + protected function loadRequireJsCode() |
|
| 81 | + { |
|
| 82 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
| 83 | 83 | |
| 84 | - $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript'; |
|
| 85 | - $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 86 | - $pageRenderer->loadRequireJsModule('Fab/Media/BrowseRecursively'); |
|
| 87 | - } |
|
| 84 | + $configuration['paths']['Fab/Media'] = '../typo3conf/ext/media/Resources/Public/JavaScript'; |
|
| 85 | + $pageRenderer->addRequireJsConfiguration($configuration); |
|
| 86 | + $pageRenderer->loadRequireJsModule('Fab/Media/BrowseRecursively'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * @return MediaModule|object |
|
| 92 | - * @throws \InvalidArgumentException |
|
| 93 | - */ |
|
| 94 | - protected function getMediaModule() |
|
| 95 | - { |
|
| 96 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 97 | - } |
|
| 90 | + /** |
|
| 91 | + * @return MediaModule|object |
|
| 92 | + * @throws \InvalidArgumentException |
|
| 93 | + */ |
|
| 94 | + protected function getMediaModule() |
|
| 95 | + { |
|
| 96 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -20,56 +20,56 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class SelectedFolderInfo extends AbstractComponentView |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - public $notAllowedMountPoints = []; |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + public $notAllowedMountPoints = []; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Renders a button for uploading assets. |
|
| 30 | - * |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - public function render() |
|
| 34 | - { |
|
| 35 | - $result = ''; |
|
| 36 | - if ($this->getMediaModule()->hasFolderTree()) { |
|
| 37 | - $folder = $this->getMediaModule()->getCurrentFolder(); |
|
| 38 | - $result = sprintf('<h1>%s</h1>', $this->getFolderName($folder)); |
|
| 39 | - } |
|
| 28 | + /** |
|
| 29 | + * Renders a button for uploading assets. |
|
| 30 | + * |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + public function render() |
|
| 34 | + { |
|
| 35 | + $result = ''; |
|
| 36 | + if ($this->getMediaModule()->hasFolderTree()) { |
|
| 37 | + $folder = $this->getMediaModule()->getCurrentFolder(); |
|
| 38 | + $result = sprintf('<h1>%s</h1>', $this->getFolderName($folder)); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return $result; |
|
| 42 | - } |
|
| 41 | + return $result; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get main headline based on active folder or storage for backend module |
|
| 46 | - * |
|
| 47 | - * Folder names are resolved to their special names like done in the tree view. |
|
| 48 | - * |
|
| 49 | - * @param Folder $folder |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - protected function getFolderName(Folder $folder) |
|
| 53 | - { |
|
| 54 | - $name = $folder->getName(); |
|
| 55 | - if ($name === '') { |
|
| 56 | - // Show storage name on storage root |
|
| 57 | - if ($folder->getIdentifier() === '/') { |
|
| 58 | - $name = $folder->getStorage()->getName(); |
|
| 59 | - } |
|
| 60 | - } else { |
|
| 61 | - $name = key(ListUtility::resolveSpecialFolderNames( |
|
| 62 | - array($name => $folder) |
|
| 63 | - )); |
|
| 64 | - } |
|
| 65 | - return $name; |
|
| 66 | - } |
|
| 44 | + /** |
|
| 45 | + * Get main headline based on active folder or storage for backend module |
|
| 46 | + * |
|
| 47 | + * Folder names are resolved to their special names like done in the tree view. |
|
| 48 | + * |
|
| 49 | + * @param Folder $folder |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + protected function getFolderName(Folder $folder) |
|
| 53 | + { |
|
| 54 | + $name = $folder->getName(); |
|
| 55 | + if ($name === '') { |
|
| 56 | + // Show storage name on storage root |
|
| 57 | + if ($folder->getIdentifier() === '/') { |
|
| 58 | + $name = $folder->getStorage()->getName(); |
|
| 59 | + } |
|
| 60 | + } else { |
|
| 61 | + $name = key(ListUtility::resolveSpecialFolderNames( |
|
| 62 | + array($name => $folder) |
|
| 63 | + )); |
|
| 64 | + } |
|
| 65 | + return $name; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @return MediaModule|object |
|
| 70 | - */ |
|
| 71 | - protected function getMediaModule() |
|
| 72 | - { |
|
| 73 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 74 | - } |
|
| 68 | + /** |
|
| 69 | + * @return MediaModule|object |
|
| 70 | + */ |
|
| 71 | + protected function getMediaModule() |
|
| 72 | + { |
|
| 73 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -23,141 +23,141 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class ConfigurationWarning extends AbstractComponentView |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - protected $notAllowedMountPoints = []; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Renders a button for uploading assets. |
|
| 33 | - * |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - public function render() |
|
| 37 | - { |
|
| 38 | - $result = ''; |
|
| 39 | - |
|
| 40 | - // Check whether storage is configured or not. |
|
| 41 | - if ($this->checkStorageNotConfigured()) { |
|
| 42 | - $this->configureStorage(); |
|
| 43 | - $result .= $this->formatMessageForStorageConfigured(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - // Check whether storage is online or not. |
|
| 47 | - if ($this->checkStorageOffline()) { |
|
| 48 | - $result .= $this->formatMessageForStorageOffline(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - // Check all mount points of the storage are available |
|
| 52 | - if (!$this->checkMountPoints()) { |
|
| 53 | - $result .= $this->formatMessageForMountPoints(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - // Check all mount points of the storage are available |
|
| 57 | - if (!$this->hasBeenWarmedUp() && !$this->checkColumnNumberOfReferences()) { |
|
| 58 | - if ($this->canBeInitializedSilently() < 2000) { |
|
| 59 | - $numberOfFiles = $this->getCacheService()->warmUp(); |
|
| 60 | - $result .= $this->formatMessageForSilentlyUpdatedColumnNumberOfReferences($numberOfFiles); |
|
| 61 | - touch($this->getWarmUpSemaphoreFile()); |
|
| 62 | - } else { |
|
| 63 | - $result .= $this->formatMessageForUpdateRequiredColumnNumberOfReferences(); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return $result; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return CacheService|object |
|
| 72 | - */ |
|
| 73 | - protected function getCacheService() |
|
| 74 | - { |
|
| 75 | - return GeneralUtility::makeInstance(CacheService::class); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - protected function configureStorage() |
|
| 79 | - { |
|
| 80 | - $tableName = 'sys_file_storage'; |
|
| 81 | - $fields = array( |
|
| 82 | - 'maximum_dimension_original_image', |
|
| 83 | - 'extension_allowed_file_type_1', |
|
| 84 | - 'extension_allowed_file_type_2', |
|
| 85 | - 'extension_allowed_file_type_3', |
|
| 86 | - 'extension_allowed_file_type_4', |
|
| 87 | - 'extension_allowed_file_type_5', |
|
| 88 | - ); |
|
| 89 | - |
|
| 90 | - $values = []; |
|
| 91 | - foreach ($fields as $field) { |
|
| 92 | - $values[$field] = Tca::table($tableName)->field($field)->getDefaultValue(); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** @var ConnectionPool $connectionPool */ |
|
| 96 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 97 | - $connection = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 98 | - $connection->getConnectionForTable($tableName)->update( |
|
| 99 | - $tableName, |
|
| 100 | - $values, |
|
| 101 | - [ 'uid' => $storage->getUid() ] |
|
| 102 | - ); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return bool |
|
| 107 | - */ |
|
| 108 | - protected function hasBeenWarmedUp() |
|
| 109 | - { |
|
| 110 | - return is_file(($this->getWarmUpSemaphoreFile())); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return string |
|
| 115 | - */ |
|
| 116 | - protected function getWarmUpSemaphoreFile() |
|
| 117 | - { |
|
| 118 | - return Environment::getPublicPath() . '/typo3temp/.media_cache_warmed_up'; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Check whether the storage is correctly configured. |
|
| 123 | - * |
|
| 124 | - * @return boolean |
|
| 125 | - */ |
|
| 126 | - protected function checkStorageNotConfigured() |
|
| 127 | - { |
|
| 128 | - $currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
| 129 | - $storageRecord = $currentStorage->getStorageRecord(); |
|
| 130 | - |
|
| 131 | - // Take the storage fields and check whether some data was initialized. |
|
| 132 | - $fields = array( |
|
| 133 | - 'extension_allowed_file_type_1', |
|
| 134 | - 'extension_allowed_file_type_2', |
|
| 135 | - 'extension_allowed_file_type_3', |
|
| 136 | - 'extension_allowed_file_type_4', |
|
| 137 | - 'extension_allowed_file_type_5', |
|
| 138 | - ); |
|
| 139 | - |
|
| 140 | - $result = true; |
|
| 141 | - foreach ($fields as $fieldName) { |
|
| 142 | - // true means the storage has data and thus was configured / saved once. |
|
| 143 | - if (!empty($storageRecord[$fieldName])) { |
|
| 144 | - $result = false; |
|
| 145 | - break; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - return $result; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Format a message whenever the storage is offline. |
|
| 153 | - * |
|
| 154 | - * @return string |
|
| 155 | - */ |
|
| 156 | - protected function formatMessageForStorageConfigured() |
|
| 157 | - { |
|
| 158 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 159 | - |
|
| 160 | - $result = <<< EOF |
|
| 26 | + /** |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + protected $notAllowedMountPoints = []; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Renders a button for uploading assets. |
|
| 33 | + * |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + public function render() |
|
| 37 | + { |
|
| 38 | + $result = ''; |
|
| 39 | + |
|
| 40 | + // Check whether storage is configured or not. |
|
| 41 | + if ($this->checkStorageNotConfigured()) { |
|
| 42 | + $this->configureStorage(); |
|
| 43 | + $result .= $this->formatMessageForStorageConfigured(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + // Check whether storage is online or not. |
|
| 47 | + if ($this->checkStorageOffline()) { |
|
| 48 | + $result .= $this->formatMessageForStorageOffline(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + // Check all mount points of the storage are available |
|
| 52 | + if (!$this->checkMountPoints()) { |
|
| 53 | + $result .= $this->formatMessageForMountPoints(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + // Check all mount points of the storage are available |
|
| 57 | + if (!$this->hasBeenWarmedUp() && !$this->checkColumnNumberOfReferences()) { |
|
| 58 | + if ($this->canBeInitializedSilently() < 2000) { |
|
| 59 | + $numberOfFiles = $this->getCacheService()->warmUp(); |
|
| 60 | + $result .= $this->formatMessageForSilentlyUpdatedColumnNumberOfReferences($numberOfFiles); |
|
| 61 | + touch($this->getWarmUpSemaphoreFile()); |
|
| 62 | + } else { |
|
| 63 | + $result .= $this->formatMessageForUpdateRequiredColumnNumberOfReferences(); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return $result; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return CacheService|object |
|
| 72 | + */ |
|
| 73 | + protected function getCacheService() |
|
| 74 | + { |
|
| 75 | + return GeneralUtility::makeInstance(CacheService::class); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + protected function configureStorage() |
|
| 79 | + { |
|
| 80 | + $tableName = 'sys_file_storage'; |
|
| 81 | + $fields = array( |
|
| 82 | + 'maximum_dimension_original_image', |
|
| 83 | + 'extension_allowed_file_type_1', |
|
| 84 | + 'extension_allowed_file_type_2', |
|
| 85 | + 'extension_allowed_file_type_3', |
|
| 86 | + 'extension_allowed_file_type_4', |
|
| 87 | + 'extension_allowed_file_type_5', |
|
| 88 | + ); |
|
| 89 | + |
|
| 90 | + $values = []; |
|
| 91 | + foreach ($fields as $field) { |
|
| 92 | + $values[$field] = Tca::table($tableName)->field($field)->getDefaultValue(); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** @var ConnectionPool $connectionPool */ |
|
| 96 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 97 | + $connection = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 98 | + $connection->getConnectionForTable($tableName)->update( |
|
| 99 | + $tableName, |
|
| 100 | + $values, |
|
| 101 | + [ 'uid' => $storage->getUid() ] |
|
| 102 | + ); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return bool |
|
| 107 | + */ |
|
| 108 | + protected function hasBeenWarmedUp() |
|
| 109 | + { |
|
| 110 | + return is_file(($this->getWarmUpSemaphoreFile())); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 116 | + protected function getWarmUpSemaphoreFile() |
|
| 117 | + { |
|
| 118 | + return Environment::getPublicPath() . '/typo3temp/.media_cache_warmed_up'; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Check whether the storage is correctly configured. |
|
| 123 | + * |
|
| 124 | + * @return boolean |
|
| 125 | + */ |
|
| 126 | + protected function checkStorageNotConfigured() |
|
| 127 | + { |
|
| 128 | + $currentStorage = $this->getMediaModule()->getCurrentStorage(); |
|
| 129 | + $storageRecord = $currentStorage->getStorageRecord(); |
|
| 130 | + |
|
| 131 | + // Take the storage fields and check whether some data was initialized. |
|
| 132 | + $fields = array( |
|
| 133 | + 'extension_allowed_file_type_1', |
|
| 134 | + 'extension_allowed_file_type_2', |
|
| 135 | + 'extension_allowed_file_type_3', |
|
| 136 | + 'extension_allowed_file_type_4', |
|
| 137 | + 'extension_allowed_file_type_5', |
|
| 138 | + ); |
|
| 139 | + |
|
| 140 | + $result = true; |
|
| 141 | + foreach ($fields as $fieldName) { |
|
| 142 | + // true means the storage has data and thus was configured / saved once. |
|
| 143 | + if (!empty($storageRecord[$fieldName])) { |
|
| 144 | + $result = false; |
|
| 145 | + break; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + return $result; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Format a message whenever the storage is offline. |
|
| 153 | + * |
|
| 154 | + * @return string |
|
| 155 | + */ |
|
| 156 | + protected function formatMessageForStorageConfigured() |
|
| 157 | + { |
|
| 158 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 159 | + |
|
| 160 | + $result = <<< EOF |
|
| 161 | 161 | <div class="alert alert-info"> |
| 162 | 162 | <div class="alert-title"> |
| 163 | 163 | Storage has been configured. |
@@ -170,29 +170,29 @@ discard block |
||
| 170 | 170 | </div> |
| 171 | 171 | EOF; |
| 172 | 172 | |
| 173 | - return $result; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Check whether the storage is online or not. |
|
| 178 | - * |
|
| 179 | - * @return boolean |
|
| 180 | - */ |
|
| 181 | - protected function checkStorageOffline() |
|
| 182 | - { |
|
| 183 | - return !$this->getMediaModule()->getCurrentStorage()->isOnline(); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Format a message whenever the storage is offline. |
|
| 188 | - * |
|
| 189 | - * @return string |
|
| 190 | - */ |
|
| 191 | - protected function formatMessageForStorageOffline() |
|
| 192 | - { |
|
| 193 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 194 | - |
|
| 195 | - $result = <<< EOF |
|
| 173 | + return $result; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Check whether the storage is online or not. |
|
| 178 | + * |
|
| 179 | + * @return boolean |
|
| 180 | + */ |
|
| 181 | + protected function checkStorageOffline() |
|
| 182 | + { |
|
| 183 | + return !$this->getMediaModule()->getCurrentStorage()->isOnline(); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Format a message whenever the storage is offline. |
|
| 188 | + * |
|
| 189 | + * @return string |
|
| 190 | + */ |
|
| 191 | + protected function formatMessageForStorageOffline() |
|
| 192 | + { |
|
| 193 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 194 | + |
|
| 195 | + $result = <<< EOF |
|
| 196 | 196 | <div class="alert alert-warning"> |
| 197 | 197 | <div class="alert-title"> |
| 198 | 198 | Storage is currently offline |
@@ -204,83 +204,83 @@ discard block |
||
| 204 | 204 | </div> |
| 205 | 205 | EOF; |
| 206 | 206 | |
| 207 | - return $result; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Check whether mount points privilege are ok. |
|
| 212 | - * |
|
| 213 | - * @return boolean |
|
| 214 | - */ |
|
| 215 | - protected function checkMountPoints() |
|
| 216 | - { |
|
| 217 | - if (!$this->getBackendUser()->isAdmin()) { |
|
| 218 | - $fileMounts = $this->getBackendUser()->getFileMountRecords(); |
|
| 219 | - |
|
| 220 | - $fileMountIdentifiers = []; |
|
| 221 | - foreach ($fileMounts as $fileMount) { |
|
| 222 | - $fileMountIdentifiers[] = $fileMount['uid']; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 226 | - $storageRecord = $storage->getStorageRecord(); |
|
| 227 | - $fieldNames = array( |
|
| 228 | - 'mount_point_file_type_1', |
|
| 229 | - 'mount_point_file_type_2', |
|
| 230 | - 'mount_point_file_type_3', |
|
| 231 | - 'mount_point_file_type_4', |
|
| 232 | - 'mount_point_file_type_5', |
|
| 233 | - ); |
|
| 234 | - foreach ($fieldNames as $fileName) { |
|
| 235 | - $fileMountIdentifier = (int)$storageRecord[$fileName]; |
|
| 236 | - if ($fileMountIdentifier > 0 && !in_array($fileMountIdentifier, $fileMountIdentifiers)) { |
|
| 237 | - $this->notAllowedMountPoints[] = $this->fetchMountPoint($fileMountIdentifier); |
|
| 238 | - } else { |
|
| 239 | - # $fileMountIdentifier |
|
| 240 | - $folder = $storage->getRootLevelFolder(); |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - return empty($this->notAllowedMountPoints); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Return a mount point according to an file mount identifier. |
|
| 249 | - * |
|
| 250 | - * @param string $identifier |
|
| 251 | - * @return array |
|
| 252 | - */ |
|
| 253 | - protected function fetchMountPoint($identifier) |
|
| 254 | - { |
|
| 255 | - /** @var QueryBuilder $queryBuilder */ |
|
| 256 | - $queryBuilder = $this->getQueryBuilder('sys_filemounts'); |
|
| 257 | - return $queryBuilder |
|
| 258 | - ->select('*') |
|
| 259 | - ->from('sys_filemounts') |
|
| 260 | - ->where('uid = ' . $identifier) |
|
| 261 | - ->execute() |
|
| 262 | - ->fetchAssociative(); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Format a message whenever mount points privilege are not OK. |
|
| 267 | - * |
|
| 268 | - * @return string |
|
| 269 | - */ |
|
| 270 | - protected function formatMessageForMountPoints() |
|
| 271 | - { |
|
| 272 | - $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 273 | - $backendUser = $this->getBackendUser(); |
|
| 274 | - |
|
| 275 | - foreach ($this->notAllowedMountPoints as $notAllowedMountPoints) { |
|
| 276 | - $list = sprintf( |
|
| 277 | - '<li>"%s" with path %s</li>', |
|
| 278 | - $notAllowedMountPoints['title'], |
|
| 279 | - $notAllowedMountPoints['path'] |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - $result = <<< EOF |
|
| 207 | + return $result; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Check whether mount points privilege are ok. |
|
| 212 | + * |
|
| 213 | + * @return boolean |
|
| 214 | + */ |
|
| 215 | + protected function checkMountPoints() |
|
| 216 | + { |
|
| 217 | + if (!$this->getBackendUser()->isAdmin()) { |
|
| 218 | + $fileMounts = $this->getBackendUser()->getFileMountRecords(); |
|
| 219 | + |
|
| 220 | + $fileMountIdentifiers = []; |
|
| 221 | + foreach ($fileMounts as $fileMount) { |
|
| 222 | + $fileMountIdentifiers[] = $fileMount['uid']; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 226 | + $storageRecord = $storage->getStorageRecord(); |
|
| 227 | + $fieldNames = array( |
|
| 228 | + 'mount_point_file_type_1', |
|
| 229 | + 'mount_point_file_type_2', |
|
| 230 | + 'mount_point_file_type_3', |
|
| 231 | + 'mount_point_file_type_4', |
|
| 232 | + 'mount_point_file_type_5', |
|
| 233 | + ); |
|
| 234 | + foreach ($fieldNames as $fileName) { |
|
| 235 | + $fileMountIdentifier = (int)$storageRecord[$fileName]; |
|
| 236 | + if ($fileMountIdentifier > 0 && !in_array($fileMountIdentifier, $fileMountIdentifiers)) { |
|
| 237 | + $this->notAllowedMountPoints[] = $this->fetchMountPoint($fileMountIdentifier); |
|
| 238 | + } else { |
|
| 239 | + # $fileMountIdentifier |
|
| 240 | + $folder = $storage->getRootLevelFolder(); |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + return empty($this->notAllowedMountPoints); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Return a mount point according to an file mount identifier. |
|
| 249 | + * |
|
| 250 | + * @param string $identifier |
|
| 251 | + * @return array |
|
| 252 | + */ |
|
| 253 | + protected function fetchMountPoint($identifier) |
|
| 254 | + { |
|
| 255 | + /** @var QueryBuilder $queryBuilder */ |
|
| 256 | + $queryBuilder = $this->getQueryBuilder('sys_filemounts'); |
|
| 257 | + return $queryBuilder |
|
| 258 | + ->select('*') |
|
| 259 | + ->from('sys_filemounts') |
|
| 260 | + ->where('uid = ' . $identifier) |
|
| 261 | + ->execute() |
|
| 262 | + ->fetchAssociative(); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Format a message whenever mount points privilege are not OK. |
|
| 267 | + * |
|
| 268 | + * @return string |
|
| 269 | + */ |
|
| 270 | + protected function formatMessageForMountPoints() |
|
| 271 | + { |
|
| 272 | + $storage = $this->getMediaModule()->getCurrentStorage(); |
|
| 273 | + $backendUser = $this->getBackendUser(); |
|
| 274 | + |
|
| 275 | + foreach ($this->notAllowedMountPoints as $notAllowedMountPoints) { |
|
| 276 | + $list = sprintf( |
|
| 277 | + '<li>"%s" with path %s</li>', |
|
| 278 | + $notAllowedMountPoints['title'], |
|
| 279 | + $notAllowedMountPoints['path'] |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + $result = <<< EOF |
|
| 284 | 284 | <div class="alert alert-warning"> |
| 285 | 285 | <div class="alert-title"> |
| 286 | 286 | File mount are wrongly configured for user "{$backendUser->user['username']}". |
@@ -295,52 +295,52 @@ discard block |
||
| 295 | 295 | </div> |
| 296 | 296 | EOF; |
| 297 | 297 | |
| 298 | - return $result; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * @return boolean |
|
| 303 | - */ |
|
| 304 | - protected function canBeInitializedSilently() |
|
| 305 | - { |
|
| 306 | - /** @var QueryBuilder $queryBuilder */ |
|
| 307 | - $queryBuilder = $this->getQueryBuilder('sys_file'); |
|
| 308 | - $count = $queryBuilder |
|
| 309 | - ->count('*') |
|
| 310 | - ->from('sys_file') |
|
| 311 | - ->execute() |
|
| 312 | - ->fetchColumn(0); |
|
| 313 | - return (int)$count; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * Check whether the column "total_of_references" has been already processed once. |
|
| 318 | - * |
|
| 319 | - * @return boolean |
|
| 320 | - */ |
|
| 321 | - protected function checkColumnNumberOfReferences() |
|
| 322 | - { |
|
| 323 | - /** @var QueryBuilder $queryBuilder */ |
|
| 324 | - $queryBuilder = $this->getQueryBuilder('sys_file'); |
|
| 325 | - $file = $queryBuilder |
|
| 326 | - ->select('*') |
|
| 327 | - ->from('sys_file') |
|
| 328 | - ->where('number_of_references > 0') |
|
| 329 | - ->execute() |
|
| 330 | - ->fetchAssociative(); |
|
| 331 | - |
|
| 332 | - return !empty($file); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * Format a message if columns "total_of_references" looks wrong. |
|
| 337 | - * |
|
| 338 | - * @param int $numberOfFile |
|
| 339 | - * @return string |
|
| 340 | - */ |
|
| 341 | - protected function formatMessageForSilentlyUpdatedColumnNumberOfReferences($numberOfFile) |
|
| 342 | - { |
|
| 343 | - $result = <<< EOF |
|
| 298 | + return $result; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * @return boolean |
|
| 303 | + */ |
|
| 304 | + protected function canBeInitializedSilently() |
|
| 305 | + { |
|
| 306 | + /** @var QueryBuilder $queryBuilder */ |
|
| 307 | + $queryBuilder = $this->getQueryBuilder('sys_file'); |
|
| 308 | + $count = $queryBuilder |
|
| 309 | + ->count('*') |
|
| 310 | + ->from('sys_file') |
|
| 311 | + ->execute() |
|
| 312 | + ->fetchColumn(0); |
|
| 313 | + return (int)$count; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * Check whether the column "total_of_references" has been already processed once. |
|
| 318 | + * |
|
| 319 | + * @return boolean |
|
| 320 | + */ |
|
| 321 | + protected function checkColumnNumberOfReferences() |
|
| 322 | + { |
|
| 323 | + /** @var QueryBuilder $queryBuilder */ |
|
| 324 | + $queryBuilder = $this->getQueryBuilder('sys_file'); |
|
| 325 | + $file = $queryBuilder |
|
| 326 | + ->select('*') |
|
| 327 | + ->from('sys_file') |
|
| 328 | + ->where('number_of_references > 0') |
|
| 329 | + ->execute() |
|
| 330 | + ->fetchAssociative(); |
|
| 331 | + |
|
| 332 | + return !empty($file); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * Format a message if columns "total_of_references" looks wrong. |
|
| 337 | + * |
|
| 338 | + * @param int $numberOfFile |
|
| 339 | + * @return string |
|
| 340 | + */ |
|
| 341 | + protected function formatMessageForSilentlyUpdatedColumnNumberOfReferences($numberOfFile) |
|
| 342 | + { |
|
| 343 | + $result = <<< EOF |
|
| 344 | 344 | <div class="alert alert-success"> |
| 345 | 345 | <div class="alert-title"> |
| 346 | 346 | Initialized column "number_of_references" for ${numberOfFile} files |
@@ -357,18 +357,18 @@ discard block |
||
| 357 | 357 | </div> |
| 358 | 358 | EOF; |
| 359 | 359 | |
| 360 | - return $result; |
|
| 361 | - } |
|
| 360 | + return $result; |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | 363 | |
| 364 | - /** |
|
| 365 | - * Format a message if columns "total_of_references" looks wrong. |
|
| 366 | - * |
|
| 367 | - * @return string |
|
| 368 | - */ |
|
| 369 | - protected function formatMessageForUpdateRequiredColumnNumberOfReferences() |
|
| 370 | - { |
|
| 371 | - $result = <<< EOF |
|
| 364 | + /** |
|
| 365 | + * Format a message if columns "total_of_references" looks wrong. |
|
| 366 | + * |
|
| 367 | + * @return string |
|
| 368 | + */ |
|
| 369 | + protected function formatMessageForUpdateRequiredColumnNumberOfReferences() |
|
| 370 | + { |
|
| 371 | + $result = <<< EOF |
|
| 372 | 372 | <div class="alert alert-warning"> |
| 373 | 373 | <div class="alert-title"> |
| 374 | 374 | Column "number_of_references" requires to be initialized. |
@@ -387,35 +387,35 @@ discard block |
||
| 387 | 387 | </div> |
| 388 | 388 | EOF; |
| 389 | 389 | |
| 390 | - return $result; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Returns an instance of the current Backend User. |
|
| 395 | - * |
|
| 396 | - * @return BackendUserAuthentication |
|
| 397 | - */ |
|
| 398 | - protected function getBackendUser() |
|
| 399 | - { |
|
| 400 | - return $GLOBALS['BE_USER']; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * @param string $tableName |
|
| 405 | - * @return object|QueryBuilder |
|
| 406 | - */ |
|
| 407 | - protected function getQueryBuilder($tableName): QueryBuilder |
|
| 408 | - { |
|
| 409 | - /** @var ConnectionPool $connectionPool */ |
|
| 410 | - $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 411 | - return $connectionPool->getQueryBuilderForTable($tableName); |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * @return MediaModule|object |
|
| 416 | - */ |
|
| 417 | - protected function getMediaModule() |
|
| 418 | - { |
|
| 419 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 420 | - } |
|
| 390 | + return $result; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Returns an instance of the current Backend User. |
|
| 395 | + * |
|
| 396 | + * @return BackendUserAuthentication |
|
| 397 | + */ |
|
| 398 | + protected function getBackendUser() |
|
| 399 | + { |
|
| 400 | + return $GLOBALS['BE_USER']; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * @param string $tableName |
|
| 405 | + * @return object|QueryBuilder |
|
| 406 | + */ |
|
| 407 | + protected function getQueryBuilder($tableName): QueryBuilder |
|
| 408 | + { |
|
| 409 | + /** @var ConnectionPool $connectionPool */ |
|
| 410 | + $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
| 411 | + return $connectionPool->getQueryBuilderForTable($tableName); |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * @return MediaModule|object |
|
| 416 | + */ |
|
| 417 | + protected function getMediaModule() |
|
| 418 | + { |
|
| 419 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 420 | + } |
|
| 421 | 421 | } |
@@ -20,44 +20,44 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class ChangeStorageMenuItem extends AbstractComponentView |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * Renders a "change storage" menu item to be placed in the grid menu of Media. |
|
| 25 | - * |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function render() |
|
| 29 | - { |
|
| 30 | - $output = ''; |
|
| 31 | - if (!$this->getMediaModule()->hasFolderTree()) { |
|
| 32 | - $output = sprintf( |
|
| 33 | - '<li><a href="%s" class="change-storage" >%s %s</a>', |
|
| 34 | - $this->getChangeStorageUri(), |
|
| 35 | - $this->getIconFactory()->getIcon('extensions-media-storage-change', Icon::SIZE_SMALL), |
|
| 36 | - $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:change_storage') |
|
| 37 | - ); |
|
| 38 | - } |
|
| 39 | - return $output; |
|
| 40 | - } |
|
| 23 | + /** |
|
| 24 | + * Renders a "change storage" menu item to be placed in the grid menu of Media. |
|
| 25 | + * |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function render() |
|
| 29 | + { |
|
| 30 | + $output = ''; |
|
| 31 | + if (!$this->getMediaModule()->hasFolderTree()) { |
|
| 32 | + $output = sprintf( |
|
| 33 | + '<li><a href="%s" class="change-storage" >%s %s</a>', |
|
| 34 | + $this->getChangeStorageUri(), |
|
| 35 | + $this->getIconFactory()->getIcon('extensions-media-storage-change', Icon::SIZE_SMALL), |
|
| 36 | + $this->getLanguageService()->sL('LLL:EXT:media/Resources/Private/Language/locallang.xlf:change_storage') |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | + return $output; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - protected function getChangeStorageUri() |
|
| 46 | - { |
|
| 47 | - $urlParameters = array( |
|
| 48 | - MediaModule::getParameterPrefix() => array( |
|
| 49 | - 'controller' => 'Asset', |
|
| 50 | - 'action' => 'editStorage', |
|
| 51 | - ), |
|
| 52 | - ); |
|
| 53 | - return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 54 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + protected function getChangeStorageUri() |
|
| 46 | + { |
|
| 47 | + $urlParameters = array( |
|
| 48 | + MediaModule::getParameterPrefix() => array( |
|
| 49 | + 'controller' => 'Asset', |
|
| 50 | + 'action' => 'editStorage', |
|
| 51 | + ), |
|
| 52 | + ); |
|
| 53 | + return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return object|MediaModule |
|
| 58 | - */ |
|
| 59 | - protected function getMediaModule() |
|
| 60 | - { |
|
| 61 | - return GeneralUtility::makeInstance(MediaModule::class); |
|
| 62 | - } |
|
| 56 | + /** |
|
| 57 | + * @return object|MediaModule |
|
| 58 | + */ |
|
| 59 | + protected function getMediaModule() |
|
| 60 | + { |
|
| 61 | + return GeneralUtility::makeInstance(MediaModule::class); |
|
| 62 | + } |
|
| 63 | 63 | } |