Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
Replaced "dirname(__FILE__)" with "__DIR__"
Browse files Browse the repository at this point in the history
.. as PHP 5.6 is required now.
  • Loading branch information
rblaurin committed Jun 18, 2019
1 parent 6e6d1c8 commit 84b8054
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.idea
config_*
vendor
14 changes: 7 additions & 7 deletions watermark.php
Expand Up @@ -232,11 +232,11 @@ private function _postProcess()
}
$this->deleteOldWatermark($strShop);
/* Copy new watermark */
if (!copy($_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__) . '/views/img/' . $this->name . $strShop . $imageExt)) {
if (!copy($_FILES['PS_WATERMARK']['tmp_name'], __DIR__ . '/views/img/' . $this->name . $strShop . $imageExt)) {
$this->_errors[] = sprintf(
$this->trans('An error occurred while uploading watermark: %1$s to %2$s', [], 'Modules.Watermark.Admin'),
$_FILES['PS_WATERMARK']['tmp_name'],
dirname(__FILE__) . '/views/img/' . $this->name . $strShop . $imageExt
__DIR__ . '/views/img/' . $this->name . $strShop . $imageExt
);
}
}
Expand Down Expand Up @@ -337,7 +337,7 @@ public function getContent()
}
}
$html .= $this->renderForm();
$this->context->controller->addCSS(dirname(__FILE__) . '/views/css/module-addons-suggestion.css');
$this->context->controller->addCSS(__DIR__ . '/views/css/module-addons-suggestion.css');
$html .= $this->renderAddonsSuggestion();

return $html;
Expand All @@ -356,14 +356,14 @@ public function hookActionWatermark($params)
$file_org = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.jpg';

$strShop = '-' . (int) $this->context->shop->id;
if (Shop::getContext() !== Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__) . '/views/img/' . $this->name . $strShop . '.' . $this->getWatermarkExtension($strShop))) {
if (Shop::getContext() !== Shop::CONTEXT_SHOP || !Tools::file_exists_cache(__DIR__ . '/views/img/' . $this->name . $strShop . '.' . $this->getWatermarkExtension($strShop))) {
$strShop = '';
}

// First make a watermark image
$return = $this->watermarkByImage(
_PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.jpg',
dirname(__FILE__) . '/views/img/' . $this->name . $strShop . '.' . $this->getWatermarkExtension($strShop),
__DIR__ . '/views/img/' . $this->name . $strShop . '.' . $this->getWatermarkExtension($strShop),
$file
);

Expand Down Expand Up @@ -680,7 +680,7 @@ public function getConfigFieldsValues()
private function deleteOldWatermark($strShop)
{
foreach (['.jpg', '.gif', '.png'] as $extension) {
@unlink(dirname(__FILE__) . '/views/img/' . $this->name . $strShop . $extension);
@unlink(__DIR__ . '/views/img/' . $this->name . $strShop . $extension);
}
}

Expand All @@ -702,7 +702,7 @@ public function getWatermarkExtension($strShop)
// Probe image file
$imageExt = 'gif';
foreach (['png', 'jpg'] as $extension) {
if (file_exists(sprintf('%s/views/img/watermark%s.%s', dirname(__FILE__), $strShop, $extension))) {
if (file_exists(sprintf('%s/views/img/watermark%s.%s', __DIR__, $strShop, $extension))) {
$imageExt = $extension;
break;
}
Expand Down

0 comments on commit 84b8054

Please sign in to comment.