Skip to content

Commit

Permalink
[TASK] Initial commit for first public release
Browse files Browse the repository at this point in the history
  • Loading branch information
galoppi committed Sep 27, 2019
0 parents commit 701ff05
Show file tree
Hide file tree
Showing 45 changed files with 3,822 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

###############
# Source Code #
###############

# JavaScript
[*.js]
indent_style = space
indent_size = 2

# Stylesheets
[*.{css,scss}]
indent_style = space
indent_size = 4

# HTML
[*.{htm,html}]
indent_style = space
indent_size = 4

# PHP
[*.php]
indent_style = space
indent_size = 4

######################
# Configuration/Data #
######################

# JSON
[*.json]
indent_style = space
indent_size = 4

# YAML
[*.{yml,yaml,gitlabci.yml}]
indent_style = space
indent_size = 2

# Fusion, TypoScript2
[*.fusion,*.ts2]
indent_style = space
indent_size = 4

# TypoScript
[{*.ts,*.typoscript,ext_typoscript_setup.txt,constants.txt,setup.txt,ext_conf_template.txt}]
indent_style = space
indent_size = 4

# XML, XLF
[*.{xml,xlf}]
indent_style = tab

# SQL
[*.sql]
indent_style = tab

# Special files
[{package.json,.stylelintrc,.eslintrc}]
indent_style = space
indent_size = 2

# Apache configuration
[.htaccess]
indent_style = tab

######################
# Documentation/Text #
######################

# ReST
[*.rst]
indent_style = space
indent_size = 3

# Markdown
[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
145 changes: 145 additions & 0 deletions Classes/Adminpanel/Modules/TranslateLabel/TranslateLabel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?php
declare(strict_types = 1);

namespace Sitegeist\Translatelabels\Adminpanel\Modules\TranslateLabel;

/**
*
* This file is part of the "translatelabels" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
*/

use Psr\Http\Message\ServerRequestInterface;
use Sitegeist\Translatelabels\Utility\TranslationLabelUtility;
use TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule;
use TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\ContentProviderInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\ModuleData;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Adminpanel\Service\ConfigurationService;

/**
* TranslateLabel Sub Module of the AdminPanel
*/
class TranslateLabel extends AbstractSubModule implements DataProviderInterface, ContentProviderInterface, ConfigurableInterface
{

/**
* @var ConfigurationService
*/
protected $configurationService;

/**
* @var UriBuilder
*/
protected $uriBuilder;

/**
* @var Context
*/
protected $context;

/**
* TranslateLabel constructor.
*/
public function __construct()
{
$this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$this->context = GeneralUtility::makeInstance(Context::class);
}

/**
* @inheritdoc
*/
public function getDataToStore(ServerRequestInterface $request): ModuleData
{
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
return new ModuleData(
[
'labels' => $GLOBALS['T3_VAR']['ext']['translatelabels']['labels'],
'showTranslateLabels' => $this->configurationService->getConfigurationOption('translatelabels', 'showTranslationLabels'),
'saveUrl' => $this->generateBackendUrl('ajax_translatelabels_translate'),
'sysLanguageUid' => $this->context->getPropertyFromAspect('language', 'id'),
'storagePid' => TranslationLabelUtility::getStoragePid(),
'editIcon' => $iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render()
]
);
}

/**
* Generate a url to a backend route
*
* @param string $route
* @return string
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
protected function generateBackendUrl(string $route): string
{
return (string)$this->uriBuilder->buildUriFromRoute($route);
}

/**
* Creates the content for the "info" section ("module") of the Admin Panel
*
* @param \TYPO3\CMS\Adminpanel\ModuleApi\ModuleData $data
* @return string HTML content for the section. Consists of a string with table-rows with four columns.
* @see display()
*/
public function getContent(ModuleData $data): string
{
$view = GeneralUtility::makeInstance(StandaloneView::class);
$templateNameAndPath = 'EXT:translatelabels/Resources/Private/Templates/AdminPanel/Modules/TranslateLabels/TranslateLabels.html';
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);

$view->assignMultiple($data->getArrayCopy());

return $view->render();
}

/**
* Identifier for this Sub-module,
* for example "preview" or "cache"
*
* @return string
*/
public function getIdentifier(): string
{
return 'translatelabel_translatelabel';
}

/**
* @inheritdoc
*/
public function getLabel(): string
{
return $this->getLanguageService()->sL(
'LLL:EXT:translatelabels/Resources/Private/Language/locallang_adminpanel.xlf:sub.general.label'
);
}

/**
* Module is enabled
* -> should be initialized
* A module may be enabled but not shown
* -> only the initializeModule() method
* will be called
*
* @return bool
*/
public function isEnabled(): bool
{
return true;
// return (int)$this->configurationService->getConfigurationOption('translatelabels', 'showTranslationLabels') === 1;
}
}
127 changes: 127 additions & 0 deletions Classes/Adminpanel/Modules/TranslateLabel/TranslateLabelInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php
declare(strict_types = 1);

namespace Sitegeist\Translatelabels\Adminpanel\Modules\TranslateLabel;

/**
*
* This file is part of the "translatelabels" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
*/

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule;
use TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\ContentProviderInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\ModuleData;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use Sitegeist\Translatelabels\Utility\TranslationLabelUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Adminpanel\Service\ConfigurationService;

/**
* RequestInformation submodule of the admin panel
*
* @internal
*/
class TranslateLabelInfo extends AbstractSubModule implements DataProviderInterface, ContentProviderInterface, ConfigurableInterface
{
/**
* @var ConfigurationService
*/
protected $configurationService;

/**
* @var UriBuilder
*/
protected $uriBuilder;

/**
* @var Context
*/
protected $context;

/**
* TranslateLabel constructor.
*/
public function __construct()
{
$this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$this->context = GeneralUtility::makeInstance(Context::class);
}

/**
* Identifier for this Sub-module,
* for example "preview" or "cache"
*
* @return string
*/
public function getIdentifier(): string
{
return 'translatelabel_translatelabel_info';
}

/**
* @inheritdoc
*/
public function getLabel(): string
{
return $this->getLanguageService()->sL(
'Language Files'
);
}

/**
* @inheritdoc
*/
public function getDataToStore(ServerRequestInterface $request): ModuleData
{
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
return new ModuleData(
[
'labels' => $GLOBALS['T3_VAR']['ext']['translatelabels']['labels'],
'showTranslateLabels' => $this->configurationService->getConfigurationOption('translatelabels', 'showTranslationLabels'),
'editIcon' => $iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render()
]
);
}

/**
* @inheritdoc
*/
public function getContent(ModuleData $data): string
{
$view = GeneralUtility::makeInstance(StandaloneView::class);
$templateNameAndPath = 'EXT:translatelabels/Resources/Private/Templates/AdminPanel/Modules/TranslateLabels/TranslateLabelsInfo.html';
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);

$view->assignMultiple($data->getArrayCopy());

return $view->render();
}

/**
* Module is enabled
* -> should be initialized
* A module may be enabled but not shown
* -> only the initializeModule() method
* will be called
*
* @return bool
*/
public function isEnabled(): bool
{
return true;
// return (int)$this->configurationService->getConfigurationOption('translatelabels', 'showTranslationLabels') === 1;
}
}
Loading

0 comments on commit 701ff05

Please sign in to comment.