20. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-03-13 03:00:42 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

20.1 Files compared

#LocationFileLast Modified
1Porto v4.0.4/Porto Theme/app/code/Mageplaza/LayeredNavigation/HelperImage.php2022-04-22 07:34:10 +0000
2Porto v4.0.5/Porto Theme/app/code/Mageplaza/LayeredNavigation/HelperImage.php2022-12-08 01:34:28 +0000

20.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged1316
Changed00
Inserted00
Removed00

20.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

20.4 Active regular expressions

No regular expressions were active.

20.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Mageplaza 3  * Mageplaza
4  * 4  *
5  * NOTICE OF LICENSE 5  * NOTICE OF LICENSE
6  * 6  *
7  * This source file is subject to the Mageplaza.com license that is 7  * This source file is subject to the Mageplaza.com license that is
8  * available through the world-wide-web at this URL: 8  * available through the world-wide-web at this URL:
9  * https://www.mageplaza.com/LICENSE.txt 9  * https://www.mageplaza.com/LICENSE.txt
10  * 10  *
11  * DISCLAIMER 11  * DISCLAIMER
12  * 12  *
13  * Do not edit or add to this file if you wish to upgrade this extension to newer 13  * Do not edit or add to this file if you wish to upgrade this extension to newer
14  * version in the future. 14  * version in the future.
15  * 15  *
16  * @category    Mageplaza 16  * @category    Mageplaza
17  * @package     Mageplaza_LayeredNavigation 17  * @package     Mageplaza_LayeredNavigation
18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/) 18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
19  * @license     https://www.mageplaza.com/LICENSE.txt 19  * @license     https://www.mageplaza.com/LICENSE.txt
20  */ 20  */
21  21 
22 namespace Mageplaza\LayeredNavigation\Helper; 22 namespace Mageplaza\LayeredNavigation\Helper;
23  23 
24 use Exception; 24 use Exception;
25 use Magento\Catalog\Model\Layer\Filter\FilterInterface; 25 use Magento\Catalog\Model\Layer\Filter\FilterInterface;
26 use Magento\Framework\App\Helper\Context; 26 use Magento\Framework\App\Helper\Context;
27 use Magento\Framework\Exception\FileSystemException; 27 use Magento\Framework\Exception\FileSystemException;
28 use Magento\Framework\Exception\LocalizedException; 28 use Magento\Framework\Exception\LocalizedException;
29 use Magento\Framework\Filesystem; 29 use Magento\Framework\Filesystem;
30 use Magento\Framework\Image\AdapterFactory; 30 use Magento\Framework\Image\AdapterFactory;
31 use Magento\Framework\ObjectManagerInterface; 31 use Magento\Framework\ObjectManagerInterface;
32 use Magento\Framework\View\Asset\Repository; 32 use Magento\Framework\View\Asset\Repository;
33 use Magento\MediaStorage\Model\File\UploaderFactory; 33 use Magento\MediaStorage\Model\File\UploaderFactory;
34 use Magento\Store\Model\StoreManagerInterface; 34 use Magento\Store\Model\StoreManagerInterface;
35 use Mageplaza\Core\Helper\Media; 35 use Mageplaza\Core\Helper\Media;
36  36 
37 /** 37 /**
38  * Class Image 38  * Class Image
39  * @package Mageplaza\LayeredNavigation\Helper 39  * @package Mageplaza\LayeredNavigation\Helper
40  */ 40  */
41 class Image extends Media 41 class Image extends Media
42 { 42 {
43     const TEMPLATE_MEDIA_PATH = 'mageplaza/layernavigation'; 43     const TEMPLATE_MEDIA_PATH = 'mageplaza/layernavigation';
44     const TOOLTIP_THUMBNAIL_PATH = 'tooltip/thumbnail'; 44     const TOOLTIP_THUMBNAIL_PATH = 'tooltip/thumbnail';
45  45 
46     /** 46     /**
47      * @var Repository 47      * @var Repository
48      */ 48      */
49     protected $_assetRepo; 49     protected $_assetRepo;
50  50 
51     /** 51     /**
52      * Image constructor. 52      * Image constructor.
53      * 53      *
54      * @param Context $context 54      * @param Context $context
55      * @param ObjectManagerInterface $objectManager 55      * @param ObjectManagerInterface $objectManager
56      * @param StoreManagerInterface $storeManager 56      * @param StoreManagerInterface $storeManager
57      * @param Filesystem $filesystem 57      * @param Filesystem $filesystem
58      * @param UploaderFactory $uploaderFactory 58      * @param UploaderFactory $uploaderFactory
59      * @param AdapterFactory $imageFactory 59      * @param AdapterFactory $imageFactory
60      * @param Repository $assetRepo 60      * @param Repository $assetRepo
61      * 61      *
62      * @throws FileSystemException 62      * @throws FileSystemException
63      */ 63      */
64     public function __construct( 64     public function __construct(
65         Context $context, 65         Context $context,
66         ObjectManagerInterface $objectManager, 66         ObjectManagerInterface $objectManager,
67         StoreManagerInterface $storeManager, 67         StoreManagerInterface $storeManager,
68         Filesystem $filesystem, 68         Filesystem $filesystem,
69         UploaderFactory $uploaderFactory, 69         UploaderFactory $uploaderFactory,
70         AdapterFactory $imageFactory, 70         AdapterFactory $imageFactory,
71         Repository $assetRepo 71         Repository $assetRepo
72     ) { 72     ) {
73         $this->_assetRepo = $assetRepo; 73         $this->_assetRepo = $assetRepo;
74         parent::__construct($context, $objectManager, $storeManager, $filesystem, $uploaderFactory, $imageFactory); 74         parent::__construct($context, $objectManager, $storeManager, $filesystem, $uploaderFactory, $imageFactory);
75     } 75     }
76  76 
77     /** 77     /**
78      * @param $data 78      * @param $data
79      * @param string $fileName 79      * @param string $fileName
80      * @param null $oldImage 80      * @param null $oldImage
81      * 81      *
82      * @return $this|Media 82      * @return $this|Media
83      * @throws FileSystemException 83      * @throws FileSystemException
84      */ 84      */
85     public function uploadThumbnail(&$data, $fileName = 'image', $oldImage = null) 85     public function uploadThumbnail(&$data, $fileName = 'image', $oldImage = null)
86     { 86     {
87         $type = self::TOOLTIP_THUMBNAIL_PATH; 87         $type = self::TOOLTIP_THUMBNAIL_PATH;
88         if (isset($data[$fileName]) && isset($data[$fileName]['delete']) && $data[$fileName]['delete']) { 88         if (isset($data[$fileName]) && isset($data[$fileName]['delete']) && $data[$fileName]['delete']) {
89             if ($oldImage) { 89             if ($oldImage) {
90                 $this->removeImage($oldImage, $type); 90                 $this->removeImage($oldImage, $type);
91             } 91             }
92             $data[$fileName] = ''; 92             $data[$fileName] = '';
93         } else { 93         } else {
94             try { 94             try {
95                 $uploader = $this->uploaderFactory->create(['fileId' => $fileName]); 95                 $uploader = $this->uploaderFactory->create(['fileId' => $fileName]);
96                 $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']); 96                 $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
97                 $uploader->setAllowRenameFiles(true); 97                 $uploader->setAllowRenameFiles(true);
98                 $uploader->setFilesDispersion(true); 98                 $uploader->setFilesDispersion(true);
99                 $uploader->setAllowCreateFolders(true); 99                 $uploader->setAllowCreateFolders(true);
100  100 
101                 $path = $this->getBaseMediaPath($type); 101                 $path = $this->getBaseMediaPath($type);
102  102 
103                 $image = $uploader->save( 103                 $image = $uploader->save(
104                     $this->mediaDirectory->getAbsolutePath($path) 104                     $this->mediaDirectory->getAbsolutePath($path)
105                 ); 105                 );
106  106 
107                 if ($oldImage) { 107                 if ($oldImage) {
108                     $this->removeImage($oldImage, $type); 108                     $this->removeImage($oldImage, $type);
109                 } 109                 }
110  110 
111                 $data[$fileName] = $this->_prepareFile($image['file']); 111                 $data[$fileName] = $this->_prepareFile($image['file']);
112             } catch (Exception $e) { 112             } catch (Exception $e) {
113                 $this->_logger->critical($e); 113                 $this->_logger->critical($e);
114                 $data[$fileName] = isset($data[$fileName]['value']) ? $data[$fileName]['value'] : ''; 114                 $data[$fileName] = isset($data[$fileName]['value']) ? $data[$fileName]['value'] : '';
115             } 115             }
116         } 116         }
117  117 
118         return $this; 118         return $this;
119     } 119     }
120  120 
121     /** 121     /**
122      * @param $value 122      * @param $value
123      * 123      *
124      * @return string 124      * @return string
125      */ 125      */
126     public function getImageSrc($value) 126     public function getImageSrc($value)
127     { 127     {
128         $src = $this->getMediaPath($value, self::TOOLTIP_THUMBNAIL_PATH); 128         $src = $this->getMediaPath($value, self::TOOLTIP_THUMBNAIL_PATH);
129         if (!preg_match("/^http\:\/\/|https\:\/\//", $src)) { 129         if (!preg_match("/^http\:\/\/|https\:\/\//", $src)) {
130             $src = $this->getMediaUrl($src); 130             $src = $this->getMediaUrl($src);
131         } 131         }
132  132 
133         return $src; 133         return $src;
134     } 134     }
135  135 
136     /** 136     /**
137      * @param FilterInterface $filter 137      * @param FilterInterface $filter
138      * 138      *
139      * @return string 139      * @return string
140      */ 140      */
141     public function getTooltipThumbnail($filter) 141     public function getTooltipThumbnail($filter)
142     { 142     {
143         $url = ''; 143         $url = '';
144         try { 144         try {
145             $thumbnail = $filter->getAttributeModel()->getData('tooltip_thumbnail'); 145             $thumbnail = $filter->getAttributeModel()->getData('tooltip_thumbnail');
146  146 
147             if ($thumbnail) { 147             if ($thumbnail) {
148                 $url = $this->getImageSrc($thumbnail); 148                 $url = $this->getImageSrc($thumbnail);
149             } else { 149             } else {
150                 $url = $this->_assetRepo->getUrl('Mageplaza_LayeredNavigation::css/images/tooltip.svg'); 150                 $url = $this->_assetRepo->getUrl('Mageplaza_LayeredNavigation::css/images/tooltip.svg');
151             } 151             }
152         } catch (LocalizedException $e) { 152         } catch (LocalizedException $e) {
153             $this->_logger->error($e); 153             $this->_logger->error($e);
154         } 154         }
155  155 
156         return $url; 156         return $url;
157     } 157     }
158 } 158 }