From 84b8054e66c26850243f66873508051921f6fda8 Mon Sep 17 00:00:00 2001 From: rblaurin Date: Tue, 18 Jun 2019 09:41:38 -0300 Subject: [PATCH] Replaced "dirname(__FILE__)" with "__DIR__" .. as PHP 5.6 is required now. --- .gitignore | 3 +++ watermark.php | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e885be2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +config_* +vendor diff --git a/watermark.php b/watermark.php index f0684ea..9c854e1 100644 --- a/watermark.php +++ b/watermark.php @@ -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 ); } } @@ -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; @@ -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 ); @@ -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); } } @@ -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; }