Skip to content

Commit

Permalink
[FEATURE] move screenshots to correct locations as preparation for v12
Browse files Browse the repository at this point in the history
Signed-off-by: Kay Strobach <info@kay-strobach.de>
  • Loading branch information
kaystrobach committed May 11, 2023
1 parent 6a321b4 commit bc1241d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
32 changes: 28 additions & 4 deletions Classes/Domain/Model/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use KayStrobach\Sitemgr\Utilities\FileSystemUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
Expand Down Expand Up @@ -70,13 +71,30 @@ public function __construct($extensionName)
$this->pathTsConfig = $path . 'Configuration/PageTS/tsconfig.txt';
}

//
$this->importExtEmConf();

$screenshotsFolder = ExtensionManagementUtility::extPath($this->getExtensionName()) . 'Resources/Public/Screenshots/';
GeneralUtility::mkdir($screenshotsFolder);

if (is_file(ExtensionManagementUtility::extPath($this->getExtensionName()) . 'Meta/Screenshots/screenshot.png')) {
$this->previewImage = PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->getExtensionName())) . 'Meta/Screenshots/screenshot.png';
} else {
$this->previewImage = PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath('themes')) . 'Resources/Public/Images/screenshot.gif';
rename(
ExtensionManagementUtility::extPath($this->getExtensionName() ). 'Meta/Screenshots/screenshot.png',
$screenshotsFolder . 'screenshot.png'
);
} elseif (is_file(ExtensionManagementUtility::extPath('themes'). 'Resources/Public/Images/screenshot.gif')) {
rename(
ExtensionManagementUtility::extPath('themes') . '/Resources/Public/Images/screenshot.gif',
$screenshotsFolder . 'screenshot.gif'
);
}

if (is_file(GeneralUtility::getFileAbsFileName('EXT:' . $this->getExtensionName() . '/Resources/Public/Screenshots/screenshot.gif'))) {
$this->previewImage = 'EXT:' . $this->getExtensionName() . '/Resources/Public/Screenshots/screenshot.gif';
}
if (is_file(GeneralUtility::getFileAbsFileName('EXT:' . $this->getExtensionName() . '/Resources/Public/Screenshots/screenshot.png'))) {
$this->previewImage = 'EXT:' . $this->getExtensionName() . '/Resources/Public/Screenshots/screenshot.png';
}

$yamlFile = ExtensionManagementUtility::extPath($this->getExtensionName()) . 'Meta/theme.yaml';
if (file_exists($yamlFile)) {
try {
Expand Down Expand Up @@ -128,6 +146,12 @@ public function getAllPreviewImages()
$buffer[$key]['file'] = $previewImage;
}
}

if (is_file(GeneralUtility::getFileAbsFileName($this->previewImage))) {
$buffer[] = [
'file' => $this->previewImage
];
}
return $buffer;
}

Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Partials/Meta/Screenshots.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="carousel-inner">
<f:for each="{screenshots}" as="screenshot" iteration="iteration">
<div class="item {f:if(condition:iteration.isFirst, then:'active')}" data-interval="3000" data-pause="hover" title="{screenshot.caption}">
<img src="{screenshot.file}" alt="{screenshot.caption}" width="600" />
<f:image src="{screenshot.file}" alt="{screenshot.caption}" width="600" />
</div>
</f:for>
</div>
Expand All @@ -24,4 +24,4 @@
</div>
</div>
</div>
</f:if>
</f:if>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Themes/ThemeSelected.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ <h2><f:translate key="{category.title}" default="{category.title}" /></h2>
</f:form>
</div>
</div>
</html>
</html>

0 comments on commit bc1241d

Please sign in to comment.