improve code style
This commit is contained in:
parent
03119b8da9
commit
09584120f5
@ -47,7 +47,7 @@ class Loader
|
||||
$this->config = $config;
|
||||
$this->language = $language;
|
||||
|
||||
$this->configuration = oxNew( Configuration::class, $this );
|
||||
$this->configuration = oxNew(Configuration::class, $this);
|
||||
$this->configuration->build();
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ class Loader
|
||||
|
||||
try {
|
||||
$engine = $this->getTemplateRenderer()->getTemplateEngine();
|
||||
return $engine->render( '@' . Constants::OXID_MODULE_ID . '/admin/editorswitch' );
|
||||
} catch ( NotFoundExceptionInterface|ContainerExceptionInterface) {
|
||||
return $engine->render('@' . Constants::OXID_MODULE_ID . '/admin/editorswitch');
|
||||
} catch (NotFoundExceptionInterface|ContainerExceptionInterface) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@ -81,11 +81,11 @@ class Loader
|
||||
{
|
||||
try {
|
||||
/** @var ModuleSettingService $service */
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
/** @var string[] $aEnabledClasses */
|
||||
$aEnabledClasses = $service->getCollection( "aTinyMCE_classes", Constants::OXID_MODULE_ID );
|
||||
$aEnabledClasses = $service->getCollection("aTinyMCE_classes", Constants::OXID_MODULE_ID);
|
||||
|
||||
return in_array( $this->getShopConfig()->getActiveView()->getClassKey(), $aEnabledClasses );
|
||||
return in_array($this->getShopConfig()->getActiveView()->getClassKey(), $aEnabledClasses);
|
||||
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
|
||||
return false;
|
||||
}
|
||||
@ -98,7 +98,7 @@ class Loader
|
||||
{
|
||||
// D3 disabled, because isPlain method doesn't exist in OXID eShop
|
||||
return false;
|
||||
|
||||
|
||||
// /** @var BaseModel|Content $oEditObject */
|
||||
// $oEditObject = $this->getShopConfig()->getActiveView()->getViewDataElement("edit");
|
||||
// return $oEditObject instanceof Content && $oEditObject->isPlain();
|
||||
@ -140,7 +140,7 @@ class Loader
|
||||
return [
|
||||
$sCopyLongDescFromTinyMCE,
|
||||
$sUrlConverter,
|
||||
$sInit
|
||||
$sInit,
|
||||
];
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ class Loader
|
||||
Registry::getConfig()->getActiveView()->getViewConfig()->getModuleUrl(
|
||||
Constants::OXID_MODULE_ID,
|
||||
'out/tinymce/tinymce.min.js'
|
||||
)
|
||||
),
|
||||
];
|
||||
} catch (FileException) {
|
||||
return [];
|
||||
|
@ -38,19 +38,19 @@ class ExternalPlugins extends AbstractOption
|
||||
$list = implode(
|
||||
', ',
|
||||
array_filter(
|
||||
array_map(
|
||||
function (PluginInterface $plugin) {
|
||||
return $plugin->getScriptPath() ? implode(
|
||||
':',
|
||||
[
|
||||
(oxNew(Utils::class))->quote($plugin->getPluginName()),
|
||||
(oxNew(Utils::class))->quote($plugin->getScriptPath()),
|
||||
]
|
||||
) : null;
|
||||
},
|
||||
$pluginList->get()
|
||||
array_map(
|
||||
function (PluginInterface $plugin) {
|
||||
return $plugin->getScriptPath() ? implode(
|
||||
':',
|
||||
[
|
||||
(oxNew(Utils::class))->quote($plugin->getPluginName()),
|
||||
(oxNew(Utils::class))->quote($plugin->getScriptPath()),
|
||||
]
|
||||
) : null;
|
||||
},
|
||||
$pluginList->get()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return '{ '.$list.' }';
|
||||
|
@ -65,8 +65,8 @@ class FilemanagerUrl extends AbstractOption
|
||||
{
|
||||
try {
|
||||
/** @var ModuleSettingService $service */
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
|
||||
return $service->getBoolean( "blTinyMCE_filemanager", Constants::OXID_MODULE_ID );
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
return $service->getBoolean("blTinyMCE_filemanager", Constants::OXID_MODULE_ID);
|
||||
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
|
||||
return false;
|
||||
}
|
||||
|
@ -34,21 +34,21 @@ class InitInstanceCallback extends AbstractOption
|
||||
// https://github.com/tinymce/tinymce/issues/2271
|
||||
|
||||
$js = <<<JS
|
||||
function (editor) {
|
||||
editor.on('PostProcess', function (e) {
|
||||
e.content = e.content.replace(
|
||||
/(<!--mce:protected\s)(.*?)(-->)/gm,
|
||||
function(text, p1, p2, p3){
|
||||
if (unescape) {
|
||||
return unescape(p2);
|
||||
} else {
|
||||
return decodeURIComponent(p2);
|
||||
function (editor) {
|
||||
editor.on('PostProcess', function (e) {
|
||||
e.content = e.content.replace(
|
||||
/(<!--mce:protected\s)(.*?)(-->)/gm,
|
||||
function(text, p1, p2, p3){
|
||||
if (unescape) {
|
||||
return unescape(p2);
|
||||
} else {
|
||||
return decodeURIComponent(p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
JS;
|
||||
);
|
||||
});
|
||||
}
|
||||
JS;
|
||||
|
||||
return (oxNew(Utils::class))->minifyJS($js);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Language extends AbstractOption
|
||||
"ru" => "ru",
|
||||
];
|
||||
|
||||
return $aLang[ $oLang->getLanguageAbbr( (int) $oLang->getTplLanguage() ) ] ?? "en";
|
||||
return $aLang[ $oLang->getLanguageAbbr((int) $oLang->getTplLanguage()) ] ?? "en";
|
||||
} catch (LanguageNotFoundException) {
|
||||
return "en";
|
||||
}
|
||||
|
@ -36,14 +36,14 @@ class Plugins extends AbstractOption
|
||||
|
||||
return implode(' ', array_filter(
|
||||
array_map(
|
||||
function (PluginInterface $plugin) {
|
||||
function (PluginInterface $plugin) {
|
||||
return $plugin->requireRegistration() ?
|
||||
$plugin->getPluginName() :
|
||||
null
|
||||
;
|
||||
},
|
||||
$pluginList->get()
|
||||
)
|
||||
$pluginList->get()
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ class Setup extends AbstractOption
|
||||
public function get(): string
|
||||
{
|
||||
$js = <<<JS
|
||||
(editor) => {
|
||||
editor.options.register("filemanager_url", { processor: "string" });
|
||||
}
|
||||
JS;
|
||||
(editor) => {
|
||||
editor.options.register("filemanager_url", { processor: "string" });
|
||||
}
|
||||
JS;
|
||||
|
||||
return (oxNew(Utils::class))->minifyJS($js);
|
||||
}
|
||||
@ -53,8 +53,8 @@ class Setup extends AbstractOption
|
||||
{
|
||||
try {
|
||||
/** @var ModuleSettingService $service */
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
|
||||
return $service->getBoolean( "blTinyMCE_filemanager", Constants::OXID_MODULE_ID );
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
return $service->getBoolean("blTinyMCE_filemanager", Constants::OXID_MODULE_ID);
|
||||
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
|
||||
return false;
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ class Roxy extends AbstractPlugin
|
||||
{
|
||||
try {
|
||||
/** @var ModuleSettingService $service */
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get( ModuleSettingServiceInterface::class );
|
||||
return $service->getBoolean( "blTinyMCE_filemanager", Constants::OXID_MODULE_ID );
|
||||
$service = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
return $service->getBoolean("blTinyMCE_filemanager", Constants::OXID_MODULE_ID);
|
||||
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
|
||||
return false;
|
||||
}
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'Deutsch';
|
||||
|
||||
$aLang = include __DIR__."/../../de/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'Deutsch';
|
||||
|
||||
$aLang = include __DIR__."/../../de/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'Deutsch';
|
||||
|
||||
$aLang = include __DIR__."/../../de/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'Deutsch';
|
||||
|
||||
$aLang = include __DIR__."/../../de/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -29,4 +29,4 @@ $sLangName = 'English';
|
||||
|
||||
$aLang = include __DIR__."/../../en/tinymce_translations.php";
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -33,4 +33,4 @@ return [
|
||||
'HELP_SHOP_MODULE_aTinyMCE_classes' => 'für die Benutzung von TinyMCE in eigenen Admin Views muss hier die entsprechende Controllerklasse eingetragen werden, dann wird für jedes Textarea je ein Editor erzeugt',
|
||||
'SHOP_MODULE_GROUP_tinyMceSettings' => 'TinyMCE Einstellungen & Plugins',
|
||||
];
|
||||
// @codeCoverageIgnoreStart
|
||||
// @codeCoverageIgnoreStart
|
||||
|
@ -33,4 +33,4 @@ return [
|
||||
'HELP_SHOP_MODULE_aTinyMCE_classes' => 'if you want to use TinyMCE for your custom controllers, you need to enter their class names here.',
|
||||
'SHOP_MODULE_GROUP_tinyMceSettings' => 'TinyMCE Settings & Plugins',
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@ -92,7 +92,7 @@ function fixPath(string $path): string
|
||||
$path = dirname($_SERVER['SCRIPT_FILENAME']) . '/../../../../../../' . $path;
|
||||
|
||||
$re = '/\/[^\/.]*\/\.\.\//mU';
|
||||
while(preg_match($re, $path)) {
|
||||
while (preg_match($re, $path)) {
|
||||
$path = preg_replace($re, "/", $path);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ class RoxyFile
|
||||
}
|
||||
|
||||
$prev_path = substr($path, 0, strrpos($path, '/', -2) + 1);
|
||||
$return = self::CreatePath( $prev_path);
|
||||
$return = self::CreatePath($prev_path);
|
||||
return $return && is_writable($prev_path) && mkdir($path);
|
||||
}
|
||||
|
||||
@ -485,24 +485,24 @@ class RoxyImage
|
||||
string $type,
|
||||
?string $destination = '',
|
||||
int $quality = 90
|
||||
): void
|
||||
{
|
||||
): void {
|
||||
try {
|
||||
if ( is_string( $img ) ) {
|
||||
$img = self::GetImage( $img );
|
||||
if (is_string($img)) {
|
||||
$img = self::GetImage($img);
|
||||
}
|
||||
|
||||
switch ( strtolower( $type ) ) {
|
||||
switch (strtolower($type)) {
|
||||
case 'png':
|
||||
imagepng( $img, $destination );
|
||||
imagepng($img, $destination);
|
||||
break;
|
||||
case 'gif':
|
||||
imagegif( $img, $destination );
|
||||
imagegif($img, $destination);
|
||||
break;
|
||||
default:
|
||||
imagejpeg( $img, $destination, $quality );
|
||||
imagejpeg($img, $destination, $quality);
|
||||
}
|
||||
} catch ( RuntimeException $e ) {}
|
||||
} catch (RuntimeException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static function SetAlpha(GdImage $img, string $path): GdImage
|
||||
@ -544,15 +544,16 @@ class RoxyImage
|
||||
}
|
||||
|
||||
try {
|
||||
$thumbImg = imagecreatetruecolor( (int) $newWidth, (int) $newHeight );
|
||||
$img = self::GetImage( $source );
|
||||
$thumbImg = imagecreatetruecolor((int) $newWidth, (int) $newHeight);
|
||||
$img = self::GetImage($source);
|
||||
|
||||
$thumbImg = self::SetAlpha( $thumbImg, $source );
|
||||
$thumbImg = self::SetAlpha($thumbImg, $source);
|
||||
|
||||
imagecopyresampled( $thumbImg, $img, 0, 0, 0, 0, (int) $newWidth, (int) $newHeight, $w, $h );
|
||||
imagecopyresampled($thumbImg, $img, 0, 0, 0, 0, (int) $newWidth, (int) $newHeight, $w, $h);
|
||||
|
||||
self::OutputImage( $thumbImg, RoxyFile::GetExtension( basename( $source ) ), $destination, $quality );
|
||||
} catch ( RuntimeException $e ) {}
|
||||
self::OutputImage($thumbImg, RoxyFile::GetExtension(basename($source)), $destination, $quality);
|
||||
} catch (RuntimeException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -576,34 +577,35 @@ class RoxyImage
|
||||
$h = $tmp[1];
|
||||
|
||||
try {
|
||||
if ( ( $w <= $width ) &&
|
||||
( $h <= $height)
|
||||
if (($w <= $width) &&
|
||||
($h <= $height)
|
||||
) {
|
||||
self::OutputImage( self::GetImage( $source ), RoxyFile::GetExtension( basename( $source ) ), $destination, $quality );
|
||||
self::OutputImage(self::GetImage($source), RoxyFile::GetExtension(basename($source)), $destination, $quality);
|
||||
}
|
||||
$ratio = $width / $height;
|
||||
$top = $left = 0;
|
||||
|
||||
$cropWidth = floor( $h * $ratio );
|
||||
$cropHeight = floor( $cropWidth / $ratio );
|
||||
if ( $cropWidth > $w ) {
|
||||
$cropWidth = floor($h * $ratio);
|
||||
$cropHeight = floor($cropWidth / $ratio);
|
||||
if ($cropWidth > $w) {
|
||||
$cropWidth = $w;
|
||||
$cropHeight = $w / $ratio;
|
||||
}
|
||||
if ( $cropHeight > $h ) {
|
||||
if ($cropHeight > $h) {
|
||||
$cropHeight = $h;
|
||||
$cropWidth = $h * $ratio;
|
||||
}
|
||||
|
||||
if ( $cropWidth < $w ) {
|
||||
$left = floor( ( $w - $cropWidth ) / 2 );
|
||||
if ($cropWidth < $w) {
|
||||
$left = floor(($w - $cropWidth) / 2);
|
||||
}
|
||||
if ( $cropHeight < $h ) {
|
||||
$top = floor( ( $h - $cropHeight ) / 2 );
|
||||
if ($cropHeight < $h) {
|
||||
$top = floor(($h - $cropHeight) / 2);
|
||||
}
|
||||
|
||||
self::Crop( $source, $destination, (int) $left, (int) $top, $cropWidth, $cropHeight, $width, $height, $quality );
|
||||
} catch (RuntimeException $e) {}
|
||||
self::Crop($source, $destination, (int) $left, (int) $top, $cropWidth, $cropHeight, $width, $height, $quality);
|
||||
} catch (RuntimeException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,10 +71,10 @@ $aModule = [
|
||||
'type' => 'bool',
|
||||
'value' => true,
|
||||
'position' => 2,
|
||||
]
|
||||
],
|
||||
],
|
||||
'events' => [
|
||||
'onActivate' => Events::class.'::onActivate',
|
||||
'onDeactivate' => Events::class.'::onDeactivate'
|
||||
'onDeactivate' => Events::class.'::onDeactivate',
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user