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