improve code style
This commit is contained in:
@ -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;
|
||||
}
|
||||
@ -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 [];
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
|
Reference in New Issue
Block a user