Skip to content

Commit

Permalink
Merge pull request #35 from Delo-Design/dev
Browse files Browse the repository at this point in the history
Version 1.4.1
  • Loading branch information
dmitriitux authored Jan 15, 2020
2 parents 03a164a + 0b86487 commit e99981a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 47 deletions.
46 changes: 17 additions & 29 deletions administrator/components/com_quantummanager/helpers/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,49 +86,34 @@ public function resizeWatermark($file)
{
JLoader::register('JInterventionimage', JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'jinterventionimage' . DIRECTORY_SEPARATOR . 'jinterventionimage.php');
$manager = JInterventionimage::getInstance(['driver' => $this->getNameDriver()]);
$fileString = imagecreatefromstring(file_get_contents($file));
$image = $manager->make($fileString);
$logo = imagecreatefromstring(file_get_contents($fileWatermark));
$logoWidth = imagesx($logo);
$logoHeight = imagesy($logo);
$imageWidth = imagesx($fileString);
$imageHeight = imagesy($fileString);
$image = $manager->make($file);

$managerForWatermark = JInterventionimage::getInstance(['driver' => $this->getNameDriver()]);
$watermark = $managerForWatermark->make($fileWatermark);

$logoWidth = $watermark->width();
$logoHeight = $watermark->height();
$imageWidth = $image->width();
$imageHeight = $image->height();

if((int)$this->paramsComponent->get('overlaypercent', 0))
{
//сжимаем водяной знак по процентному соотношению от изображения на который накладывается
$precent = (double)$this->paramsComponent->get('overlaypercentvalue', 10);
$logoWidthMax = $imageWidth / 100 * $precent;
$logoHeightMax = $imageHeight / 100 * $precent;

$ratio = $logoHeight / $logoWidth;
$tmpWidth = $logoWidthMax;
$tmpHeight = $tmpWidth * $ratio;

if ($tmpHeight > $logoHeightMax)
{
$tmpHeight = $logoHeightMax;
$tmpWidth = $tmpHeight / $ratio;
}

$logoNew = imagecreatetruecolor($tmpWidth, $tmpHeight);
imagesavealpha($logoNew, true);
imagefill($logoNew,0,0,0x7fff0000);
imagecopyresampled($logoNew, $logo, 0, 0, 0, 0, $tmpWidth, $tmpHeight, $logoWidth, $logoHeight);
$logo = $logoNew;
$logoWidth = $tmpWidth;
$logoHeight = $tmpHeight;
unset($logoNew);
$watermark->resize((int)$logoWidthMax, (int)$logoHeightMax, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}

if($logoWidth > $imageWidth && $logoHeight > $imageHeight)
{
return false;
}

$watermark = $manager->make($logo);
$image->insert($watermark, $position, $padding, $padding);

$image->save($file);

}
Expand Down Expand Up @@ -168,7 +153,10 @@ public function resizeFit($file)

$manager = JInterventionimage::getInstance(['driver' => $this->getNameDriver()]);
$manager->make($file)
->fit($newWidth, $newHeight)
->resize($newWidth, $newHeight, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})
->save($file);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,31 +363,35 @@ public static function getFolderRoot()
/**
* @param $name
* @param string $default
* @param bool $withProfiles
*
* @return mixed
* @return mixed|string
*
* @since version
*/
public static function getParamsComponentValue($name, $default = '')
public static function getParamsComponentValue($name, $default = '', $withProfiles = true)
{
$componentParams = ComponentHelper::getParams('com_quantummanager');
$profiles = $componentParams->get('profiles', '');
$value = $componentParams->get($name, $default);
$groups = Factory::getUser()->groups;

if(!empty($profiles))
if($withProfiles)
{
foreach ($profiles as $key => $profile)
if(!empty($profiles))
{
if(in_array((int)$profile->group, $groups) && ($name === $profile->config))
foreach ($profiles as $key => $profile)
{
$value = trim($profile->value);
if(in_array((int)$profile->group, $groups) && ($name === $profile->config))
{
$value = trim($profile->value);

if(is_array($default)) {
$value = json_decode($value, true);
}
if(is_array($default)) {
$value = json_decode($value, true);
}

break;
break;
}
}
}
}
Expand Down Expand Up @@ -545,7 +549,7 @@ public static function getAllScope($enabled = 1)

public static function checkScopes()
{
$scopesCustom = self::getParamsComponentValue('scopescustom', []);
$scopesCustom = self::getParamsComponentValue('scopescustom', [], false);
$scopeFail = false;
$lang = Factory::getLanguage();

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

}



/**
*
* @return array
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.4.1
- [исправлено] Затирание кастомных областей из переопределений в профиле
- [исправлено] Ошибка ресурсов для библиотеки (некорректно отрабатывало, когда работает imagemagick), которая обрабатывает изображения

1.4.0
- [исправлено] заменены иконки файлов и папок, теперь используется svg спрайт
- [исправлено] повторный клик на выбранном файле снимает выделение
Expand Down
10 changes: 4 additions & 6 deletions media/com_quantummanager/js/quantumtreecatalogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ window.Quantumtreecatalogs = function(Filemanager, QuantumTreeCatalogsElement, o
reload = false;
}


if (Filemanager.data.path === undefined || Filemanager.data.path !== path) {
//Filemanager.data.path = path;
}

jQuery.get(QuantumUtils.getFullUrl("/administrator/index.php?option=com_quantummanager&task=quantumtreecatalogs.getDirectories&path=" + encodeURIComponent(path) + '&root=' + encodeURIComponent(self.options.directory))).done(function (response) {

response = JSON.parse(response);
Expand Down Expand Up @@ -106,7 +101,10 @@ window.Quantumtreecatalogs = function(Filemanager, QuantumTreeCatalogsElement, o
};

this.treePathsDblclick = function (element, qte) {
element.closest('li').querySelector('.tree-caret').click();
let carret = element.closest('li').querySelector('.tree-caret');
if(carret !== null) {
carret.click();
}
};

this.treePathsClick = function (element, qte) {
Expand Down
2 changes: 1 addition & 1 deletion quantummanager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<authorUrl>https://www.norrnext.com</authorUrl>
<copyright>Copyright © 2019 Delo Design &amp; NorrNext. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see license.txt</license>
<version>1.4.0</version>
<version>1.4.1</version>
<description>COM_QUANTUMMANAGER_XML_DESCRIPTION</description>

<scriptfile>script.php</scriptfile>
Expand Down

0 comments on commit e99981a

Please sign in to comment.