100 lines
2.1 KiB
PHP
100 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\I18nBundle\Admin\Actions;
|
|
|
|
use KupShop\AdminBundle\Admin\Actions\AbstractAction;
|
|
use KupShop\AdminBundle\Admin\Actions\ActionResult;
|
|
use KupShop\AdminBundle\Admin\Actions\IAction;
|
|
use KupShop\KupShopBundle\Context\LanguageContext;
|
|
|
|
class TranslateObjectAction extends AbstractAction implements IAction
|
|
{
|
|
/**
|
|
* @var LanguageContext
|
|
*/
|
|
protected $languageContext;
|
|
|
|
public function getTypes(): array
|
|
{
|
|
return [
|
|
'articles',
|
|
'products',
|
|
'sections',
|
|
'parameters',
|
|
'producers',
|
|
'productsUnits',
|
|
'photos',
|
|
'sliders',
|
|
'templates',
|
|
'IndexedFiltersContent',
|
|
'menulinks',
|
|
'preorders',
|
|
'preordersDates',
|
|
'Label',
|
|
'InfoPanel',
|
|
'news',
|
|
'Recommenders',
|
|
];
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return 'Přeložit';
|
|
}
|
|
|
|
public function execute(&$data, array $config, string $type): ActionResult
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function getVars(): array
|
|
{
|
|
$vars = parent::getVars();
|
|
|
|
$vars['type'] = $this->getType(getVal('s'));
|
|
|
|
return $vars;
|
|
}
|
|
|
|
public function getType($type)
|
|
{
|
|
$type = str_replace('.php', '', $type);
|
|
|
|
if ($type == 'menulinks') {
|
|
$type = 'MenuLinks';
|
|
}
|
|
|
|
if ($type == 'news') {
|
|
$type = 'Articles';
|
|
}
|
|
|
|
$type = explode('_', $type);
|
|
$type = array_map('ucfirst', $type);
|
|
|
|
return implode('', $type);
|
|
}
|
|
|
|
public function isEnabled()
|
|
{
|
|
return count($this->languageContext->getSupported()) > 1;
|
|
}
|
|
|
|
/**
|
|
* @required
|
|
*/
|
|
public function setLanguageContext(LanguageContext $languageContext): void
|
|
{
|
|
$this->languageContext = $languageContext;
|
|
}
|
|
|
|
public function getIcon()
|
|
{
|
|
return 'fc icons_translate';
|
|
}
|
|
|
|
public function getDialogHrefAttributes()
|
|
{
|
|
return 'data-modal-class="modal-translations" data-modal-hide-buttons="true"';
|
|
}
|
|
}
|