Skip to content

Commit e99981a

Browse files
authored
Merge pull request #35 from Delo-Design/dev
Version 1.4.1
2 parents 03a164a + 0b86487 commit e99981a

File tree

5 files changed

+43
-47
lines changed

5 files changed

+43
-47
lines changed

administrator/components/com_quantummanager/helpers/image.php

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -86,49 +86,34 @@ public function resizeWatermark($file)
8686
{
8787
JLoader::register('JInterventionimage', JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'jinterventionimage' . DIRECTORY_SEPARATOR . 'jinterventionimage.php');
8888
$manager = JInterventionimage::getInstance(['driver' => $this->getNameDriver()]);
89-
$fileString = imagecreatefromstring(file_get_contents($file));
90-
$image = $manager->make($fileString);
91-
$logo = imagecreatefromstring(file_get_contents($fileWatermark));
92-
$logoWidth = imagesx($logo);
93-
$logoHeight = imagesy($logo);
94-
$imageWidth = imagesx($fileString);
95-
$imageHeight = imagesy($fileString);
89+
$image = $manager->make($file);
90+
91+
$managerForWatermark = JInterventionimage::getInstance(['driver' => $this->getNameDriver()]);
92+
$watermark = $managerForWatermark->make($fileWatermark);
93+
94+
$logoWidth = $watermark->width();
95+
$logoHeight = $watermark->height();
96+
$imageWidth = $image->width();
97+
$imageHeight = $image->height();
9698

9799
if((int)$this->paramsComponent->get('overlaypercent', 0))
98100
{
99101
//сжимаем водяной знак по процентному соотношению от изображения на который накладывается
100102
$precent = (double)$this->paramsComponent->get('overlaypercentvalue', 10);
101103
$logoWidthMax = $imageWidth / 100 * $precent;
102104
$logoHeightMax = $imageHeight / 100 * $precent;
103-
104-
$ratio = $logoHeight / $logoWidth;
105-
$tmpWidth = $logoWidthMax;
106-
$tmpHeight = $tmpWidth * $ratio;
107-
108-
if ($tmpHeight > $logoHeightMax)
109-
{
110-
$tmpHeight = $logoHeightMax;
111-
$tmpWidth = $tmpHeight / $ratio;
112-
}
113-
114-
$logoNew = imagecreatetruecolor($tmpWidth, $tmpHeight);
115-
imagesavealpha($logoNew, true);
116-
imagefill($logoNew,0,0,0x7fff0000);
117-
imagecopyresampled($logoNew, $logo, 0, 0, 0, 0, $tmpWidth, $tmpHeight, $logoWidth, $logoHeight);
118-
$logo = $logoNew;
119-
$logoWidth = $tmpWidth;
120-
$logoHeight = $tmpHeight;
121-
unset($logoNew);
105+
$watermark->resize((int)$logoWidthMax, (int)$logoHeightMax, function ($constraint) {
106+
$constraint->aspectRatio();
107+
$constraint->upsize();
108+
});
122109
}
123110

124111
if($logoWidth > $imageWidth && $logoHeight > $imageHeight)
125112
{
126113
return false;
127114
}
128115

129-
$watermark = $manager->make($logo);
130116
$image->insert($watermark, $position, $padding, $padding);
131-
132117
$image->save($file);
133118

134119
}
@@ -168,7 +153,10 @@ public function resizeFit($file)
168153

169154
$manager = JInterventionimage::getInstance(['driver' => $this->getNameDriver()]);
170155
$manager->make($file)
171-
->fit($newWidth, $newHeight)
156+
->resize($newWidth, $newHeight, function ($constraint) {
157+
$constraint->aspectRatio();
158+
$constraint->upsize();
159+
})
172160
->save($file);
173161
}
174162

administrator/components/com_quantummanager/helpers/quantummanager.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,31 +363,35 @@ public static function getFolderRoot()
363363
/**
364364
* @param $name
365365
* @param string $default
366+
* @param bool $withProfiles
366367
*
367-
* @return mixed
368+
* @return mixed|string
368369
*
369370
* @since version
370371
*/
371-
public static function getParamsComponentValue($name, $default = '')
372+
public static function getParamsComponentValue($name, $default = '', $withProfiles = true)
372373
{
373374
$componentParams = ComponentHelper::getParams('com_quantummanager');
374375
$profiles = $componentParams->get('profiles', '');
375376
$value = $componentParams->get($name, $default);
376377
$groups = Factory::getUser()->groups;
377378

378-
if(!empty($profiles))
379+
if($withProfiles)
379380
{
380-
foreach ($profiles as $key => $profile)
381+
if(!empty($profiles))
381382
{
382-
if(in_array((int)$profile->group, $groups) && ($name === $profile->config))
383+
foreach ($profiles as $key => $profile)
383384
{
384-
$value = trim($profile->value);
385+
if(in_array((int)$profile->group, $groups) && ($name === $profile->config))
386+
{
387+
$value = trim($profile->value);
385388

386-
if(is_array($default)) {
387-
$value = json_decode($value, true);
388-
}
389+
if(is_array($default)) {
390+
$value = json_decode($value, true);
391+
}
389392

390-
break;
393+
break;
394+
}
391395
}
392396
}
393397
}
@@ -545,7 +549,7 @@ public static function getAllScope($enabled = 1)
545549

546550
public static function checkScopes()
547551
{
548-
$scopesCustom = self::getParamsComponentValue('scopescustom', []);
552+
$scopesCustom = self::getParamsComponentValue('scopescustom', [], false);
549553
$scopeFail = false;
550554
$lang = Factory::getLanguage();
551555

@@ -565,6 +569,8 @@ public static function checkScopes()
565569

566570
}
567571

572+
573+
568574
/**
569575
*
570576
* @return array

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.4.1
2+
- [исправлено] Затирание кастомных областей из переопределений в профиле
3+
- [исправлено] Ошибка ресурсов для библиотеки (некорректно отрабатывало, когда работает imagemagick), которая обрабатывает изображения
4+
15
1.4.0
26
- [исправлено] заменены иконки файлов и папок, теперь используется svg спрайт
37
- [исправлено] повторный клик на выбранном файле снимает выделение

media/com_quantummanager/js/quantumtreecatalogs.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ window.Quantumtreecatalogs = function(Filemanager, QuantumTreeCatalogsElement, o
3030
reload = false;
3131
}
3232

33-
34-
if (Filemanager.data.path === undefined || Filemanager.data.path !== path) {
35-
//Filemanager.data.path = path;
36-
}
37-
3833
jQuery.get(QuantumUtils.getFullUrl("/administrator/index.php?option=com_quantummanager&task=quantumtreecatalogs.getDirectories&path=" + encodeURIComponent(path) + '&root=' + encodeURIComponent(self.options.directory))).done(function (response) {
3934

4035
response = JSON.parse(response);
@@ -106,7 +101,10 @@ window.Quantumtreecatalogs = function(Filemanager, QuantumTreeCatalogsElement, o
106101
};
107102

108103
this.treePathsDblclick = function (element, qte) {
109-
element.closest('li').querySelector('.tree-caret').click();
104+
let carret = element.closest('li').querySelector('.tree-caret');
105+
if(carret !== null) {
106+
carret.click();
107+
}
110108
};
111109

112110
this.treePathsClick = function (element, qte) {

quantummanager.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<authorUrl>https://www.norrnext.com</authorUrl>
88
<copyright>Copyright © 2019 Delo Design &amp; NorrNext. All rights reserved.</copyright>
99
<license>GNU General Public License version 3 or later; see license.txt</license>
10-
<version>1.4.0</version>
10+
<version>1.4.1</version>
1111
<description>COM_QUANTUMMANAGER_XML_DESCRIPTION</description>
1212

1313
<scriptfile>script.php</scriptfile>

0 commit comments

Comments
 (0)