Skip to content

Commit

Permalink
Исправления к 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriitux committed Sep 18, 2019
1 parent a043c24 commit 018961d
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 13 deletions.
6 changes: 3 additions & 3 deletions administrator/components/com_quantummanager/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@

<field name="overlay"
type="radio"
label="Накладывать водяной знак"
label="COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_LABEL"
required="true"
default="0"
class="btn-group">
<option value="1">Автоматически</option>
<option value="2">Кнопкой</option>
<option value="1">COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_AUTO_LABEL</option>
<option value="2">COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_BUTTON_LABEL</option>
<option value="0">JNO</option>
</field>

Expand Down
21 changes: 20 additions & 1 deletion administrator/components/com_quantummanager/filesystem/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,26 @@ public static function getImageForCrop($path, $scope, $file)
public static function setWatermark($path, $scope, $list)
{
JLoader::register('QuantummanagerHelper', JPATH_SITE . '/administrator/components/com_quantummanager/helpers/quantummanager.php');
$path = QuantummanagerHelper::preparePath($path, false, $scope);
JLoader::register('QuantummanagerHelperImage', JPATH_ROOT . '/administrator/components/com_quantummanager/helpers/image.php');

$path = QuantummanagerHelper::preparePath( $path, false, $scope);
$image = new QuantummanagerHelperImage;

foreach ($list as $file)
{
$pathFile = JPATH_ROOT . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file;

$info = pathinfo($pathFile);

if(isset($info['extension']) && (!in_array(mb_strtolower($info['extension']), ['jpg', 'jpeg', 'png', 'webp'])))
{
continue;
}

$image->resizeWatermark($pathFile);
$image->reloadCache($pathFile);
}

}


Expand Down
15 changes: 10 additions & 5 deletions administrator/components/com_quantummanager/helpers/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class QuantummanagerHelperImage

public $paramsComponent;

public function __construct()
{
$this->paramsComponent = ComponentHelper::getParams('com_quantummanager');
}

/**
* @param $file
* @param array $options
Expand All @@ -46,8 +51,6 @@ public function afterUpload($file, $options = [])
$defaultOptions[$key] = $value;
}

$this->paramsComponent = ComponentHelper::getParams('com_quantummanager');

if($this->paramsComponent->get('original', 0) && (int)$defaultOptions['original'])
{
$this->originalSave($file);
Expand All @@ -58,7 +61,7 @@ public function afterUpload($file, $options = [])
$this->resizeFit($file);
}

if($this->paramsComponent->get('overlay', 0) && (int)$defaultOptions['overlay'])
if((int)$this->paramsComponent->get('overlay', 0) === 1 && (int)$defaultOptions['overlay'])
{
$this->resizeWatermark($file);
}
Expand Down Expand Up @@ -128,9 +131,11 @@ public function resizeWatermark($file)
$watermark = $manager->make($logo);
$image->insert($watermark, $position);

$image->save($file);

}

$image->save($file);

}
catch (Exception $e) {
echo $e->getMessage();
Expand Down Expand Up @@ -202,7 +207,7 @@ public function reloadCache($file)
{
try
{
$cacheSource = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images/com_quantummanager/cache';
$cacheSource = JPATH_ROOT . DIRECTORY_SEPARATOR . 'cache/com_quantummanager';
$cache = $cacheSource . DIRECTORY_SEPARATOR . str_replace(JPATH_SITE . DIRECTORY_SEPARATOR,'', $file);
if(file_exists($cache))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ COM_QUANTUMMANAGER_CONFIG_IMAGE_RESIZE_DESC="If the param enabled, the images wi
COM_QUANTUMMANAGER_CONFIG_IMAGE_RESIZE_MAXWIDTH_LABEL="Maximum width <br /> in pixels"
COM_QUANTUMMANAGER_CONFIG_IMAGE_RESIZE_MAXHEIGHT_LABEL="Maximum height <br /> in pixels"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_LABEL="Add watermark"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_AUTO_LABEL="Auto"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_BUTTON_LABEL="Button"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_FILE_LABEL="Watermark image"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_PERCENT_LABEL="Watermark image resizing in percents"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_PERCENT_VALUE_LABEL="How many percents from the original image the watermark should take?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ COM_QUANTUMMANAGER_CONFIG_IMAGE_RESIZE_DESC="При включеном пара
COM_QUANTUMMANAGER_CONFIG_IMAGE_RESIZE_MAXWIDTH_LABEL="Максимальная ширина <br /> в пикселях"
COM_QUANTUMMANAGER_CONFIG_IMAGE_RESIZE_MAXHEIGHT_LABEL="Максимальная высота <br /> в пикселях"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_LABEL="Накладывать водяной знак"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_AUTO_LABEL="Автоматически"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_BUTTON_LABEL="Кнопой"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_FILE_LABEL="Файл водяного знака"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_PERCENT_LABEL="Ресайзинг водяного знака в процентах"
COM_QUANTUMMANAGER_CONFIG_IMAGE_OVERLAY_PERCENT_VALUE_LABEL="Сколько процентов от исходного изображения занимать"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
}

HTMLHelper::_('stylesheet', 'com_quantummanager/modal.css', [
//'version' => filemtime(__FILE__),
'version' => rand(111111, 999999),
'version' => filemtime(__FILE__),
'relative' => true
]);

Expand Down
5 changes: 3 additions & 2 deletions media/com_quantummanager/js/modalcontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ document.addEventListener('DOMContentLoaded', function () {
fm.Quantumtoolbar.buttonsList['insertFileEditor'].classList.add('btn-hide');

let form = fm.Quantumviewfiles.element.querySelector('.modal-form-insert');

if(form !== null) {
form.classList.add('active');
form.classList.remove('active');
}

});
Expand All @@ -162,7 +163,7 @@ document.addEventListener('DOMContentLoaded', function () {

let form = fm.Quantumviewfiles.element.querySelector('.modal-form-insert');
if(form !== null) {
form.classList.add('active');
form.classList.remove('active');
}

});
Expand Down
4 changes: 4 additions & 0 deletions media/com_quantummanager/js/quantumcropperjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ window.Quantumcropperjs = function(Filemanager, QuantumCropperjsElement, options
fm.Quantumtoolbar.buttonsList['cropperjsEdit'].classList.remove('btn-hide');
});

Filemanager.events.add(this, 'reloadPaths', function (fm, el, target) {
fm.Quantumtoolbar.buttonsList['cropperjsEdit'].classList.add('btn-hide');
});

Filemanager.events.add(this, 'updatePath', function (fm, el, target) {
fm.Quantumtoolbar.buttonsList['cropperjsEdit'].classList.add('btn-hide');
});
Expand Down

0 comments on commit 018961d

Please sign in to comment.