155. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2021-05-13 09:08:59 +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.

155.1 Files compared

#LocationFileLast Modified
1/Applications/Ampps/www/Porto 3.2.2/Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Porto/HelperData.php2020-11-21 09:45:24 +0000
2/Applications/Ampps/www/Porto v4.0.0/Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Porto/HelperData.php2019-10-11 14:44:30 +0000

155.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged9362
Changed819
Inserted00
Removed00

155.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

155.4 Active regular expressions

No regular expressions were active.

155.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Copyright © 2015 Magento. All rights reserved. 3  * Copyright © 2015 Magento. All rights reserved.
4  * See COPYING.txt for license details. 4  * See COPYING.txt for license details.
5  */ 5  */
6 namespace Smartwave\Porto\Helper; 6 namespace Smartwave\Porto\Helper;
7  7 
8 use Magento\Framework\Registry; 8 use Magento\Framework\Registry;
9  9 
10 class Data extends \Magento\Framework\App\Helper\AbstractHelper 10 class Data extends \Magento\Framework\App\Helper\AbstractHelper
11 { 11 {
12  12 
13     protected $_objectManager; 13     protected $_objectManager;
14     private $_registry; 14     private $_registry;
15     protected $_filterProvider; 15     protected $_filterProvider;
16     private $_checkedPurchaseCode; 16     private $_checkedPurchaseCode;
17     private $_messageManager; 17     private $_messageManager;
18     protected $_configFactory; 18     protected $_configFactory;
19      19 
20     public function __construct( 20     public function __construct(
21         \Magento\Framework\App\Helper\Context $context, 21         \Magento\Framework\App\Helper\Context $context,
22         \Magento\Framework\ObjectManagerInterface $objectManager, 22         \Magento\Framework\ObjectManagerInterface $objectManager,
23         \Magento\Store\Model\StoreManagerInterface $storeManager, 23         \Magento\Store\Model\StoreManagerInterface $storeManager,
24         \Magento\Cms\Model\Template\FilterProvider $filterProvider, 24         \Magento\Cms\Model\Template\FilterProvider $filterProvider,
25         \Magento\Framework\Message\ManagerInterface $messageManager, 25         \Magento\Framework\Message\ManagerInterface $messageManager,
26         \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, 26         \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory,
27         Registry $registry 27         Registry $registry
28     ) { 28     ) {
29         $this->_storeManager = $storeManager; 29         $this->_storeManager = $storeManager;
30         $this->_objectManager = $objectManager; 30         $this->_objectManager = $objectManager;
31         $this->_filterProvider = $filterProvider; 31         $this->_filterProvider = $filterProvider;
32         $this->_registry = $registry; 32         $this->_registry = $registry;
33         $this->_messageManager = $messageManager; 33         $this->_messageManager = $messageManager;
34         $this->_configFactory = $configFactory; 34         $this->_configFactory = $configFactory;
35          35 
36         parent::__construct($context); 36         parent::__construct($context);
37     } 37     }
38     public function checkPurchaseCode($save = false) { 38     public function checkPurchaseCode($save = false) {
39         if($this->isLocalhost()){ 39         if($this->isLocalhost()){
40             return "localhost"; 40             return "localhost";
41         } 41         }
42         if(!$this->_checkedPurchaseCode){ 42         if(!$this->_checkedPurchaseCode){
43             $code = $this->scopeConfig->getValue('porto_license/general/purchase_code'); 43             $code = $this->scopeConfig->getValue('porto_license/general/purchase_code');
44             $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'); 44             $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm');
45              45 
46             if($save) { 46             if($save) {
47                 $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); 47                 $site_url = $this->scopeConfig->getValue('web/unsecure/base_url');
48                 $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); 48                 $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url));
49                 if(strpos($domain, "/")) 49                 if(strpos($domain, "/"))
50                     $domain = substr($domain, 0, strpos($domain, "/")); 50                     $domain = substr($domain, 0, strpos($domain, "/"));
51                 if(!$code || base64_encode($code) != $code_confirm) { 51                 if(!$code || base64_encode($code) != $code_confirm) {
52                     $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); 52                     $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove");
53                 } 53                 }
54                 if($code) { 54                 if($code) {
55                     $result = $this->curlPurchaseCode($code, $domain, "add"); 55                     $result = $this->curlPurchaseCode($code, $domain, "add");
56                     if(!$result || $result['result'] == 0) { 56                     if(!$result || $result['result'] == 0) {
57                         $this->_checkedPurchaseCode = ""; 57                         $this->_checkedPurchaseCode = "";
58                         $code_confirm = ""; 58                         $code_confirm = "";
59                         $this->_messageManager->getMessages(true); 59                         $this->_messageManager->getMessages(true);
60                         $this->_messageManager->addWarning(__('Purchase code is not valid!')); 60                         $this->_messageManager->addWarning(__('Purchase code is not valid!'));
61                     } else if($result['result'] == 1) { 61                     } else if($result['result'] == 1) {
62                         $code_confirm = base64_encode($code); 62                         $code_confirm = base64_encode($code);
63                         $this->_checkedPurchaseCode = "verified"; 63                         $this->_checkedPurchaseCode = "verified";
64                     } else { 64                     } else {
65                         $this->_checkedPurchaseCode = ""; 65                         $this->_checkedPurchaseCode = "";
66                         $code_confirm = ""; 66                         $code_confirm = "";
67                         $this->_messageManager->getMessages(true); 67                         $this->_messageManager->getMessages(true);
68                         $this->_messageManager->addWarning(__($result['message'])); 68                         $this->_messageManager->addWarning(__($result['message']));
69                     } 69                     }
70                 } else { 70                 } else {
71                     $code_confirm = ""; 71                     $code_confirm = "";
72                     $this->_checkedPurchaseCode = ""; 72                     $this->_checkedPurchaseCode = "";
73                 } 73                 }
74                 $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); 74                 $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0);
75             } else { 75             } else {
76                 if($code && $code_confirm && base64_encode($code) == $code_confirm) 76                 if($code && $code_confirm && base64_encode($code) == $code_confirm)
77                     $this->_checkedPurchaseCode = "verified"; 77                     $this->_checkedPurchaseCode = "verified";
78             } 78             }
79         } 79         }
80      80 
81         return $this->_checkedPurchaseCode; 81         return $this->_checkedPurchaseCode;
82     } 82     }
83     public function curlPurchaseCode($code, $domain, $act) { 83     public function curlPurchaseCode($code, $domain, $act) {
84         $ch = curl_init(); 84         $ch = curl_init();
85  85 
86         // Set cURL options 86         // Set cURL options
87         curl_setopt($ch, CURLOPT_URL, "http://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act"); 87         curl_setopt($ch, CURLOPT_URL, "http://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act");
88         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 88         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
89         curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); 89         curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY');
90  90 
91         // Decode returned JSON 91         // Decode returned JSON
92         $result = json_decode( curl_exec($ch) , true ); 92         $result = json_decode( curl_exec($ch) , true );
93         return $result; 93         return $result;
94     } 94     }
95     public function isLocalhost() { 95     public function isLocalhost() {
96         $whitelist = array( 96         $whitelist = array(
97             '127.0.0.1', 97             '127.0.0.1',
98             '::1' 98             '::1'
99         ); 99         );
100          100 
101         return true; 101         return in_array($_SERVER['REMOTE_ADDR'], $whitelist);
102     } 102     }
103     public function isAdmin() { 103     public function isAdmin() {
104         $om = \Magento\Framework\App\ObjectManager::getInstance();  104         $om = \Magento\Framework\App\ObjectManager::getInstance();
105         $app_state = $om->get('\Magento\Framework\App\State'); 105         $app_state = $om->get('\Magento\Framework\App\State');
106         $area_code = $app_state->getAreaCode(); 106         $area_code = $app_state->getAreaCode();
107         if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) 107         if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)
108         { 108         {
109             return true; 109             return true;
110         } 110         }
111         else 111         else
112         { 112         {
113             return false; 113             return false;
114         } 114         }
115     } 115     }
116     public function getBaseUrl() 116     public function getBaseUrl()
117     { 117     {
118         return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); 118         return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
119     } 119     }
120     public function getBaseLinkUrl() 120     public function getBaseLinkUrl()
121     { 121     {
122         return $this->_storeManager->getStore()->getBaseUrl(); 122         return $this->_storeManager->getStore()->getBaseUrl();
123     } 123     }
124     public function getConfig($config_path) 124     public function getConfig($config_path)
125     { 125     {
126         return $this->scopeConfig->getValue( 126         return $this->scopeConfig->getValue(
127             $config_path, 127             $config_path,
128             \Magento\Store\Model\ScopeInterface::SCOPE_STORE 128             \Magento\Store\Model\ScopeInterface::SCOPE_STORE
129         ); 129         );
130     } 130     }
131     public function getModel($model) { 131     public function getModel($model) {
132         return $this->_objectManager->create($model); 132         return $this->_objectManager->create($model);
133     } 133     }
134     public function getCurrentStore() { 134     public function getCurrentStore() {
135         return $this->_storeManager->getStore(); 135         return $this->_storeManager->getStore();
136     } 136     }
137     public function filterContent($content) { 137     public function filterContent($content) {
138         return $this->_filterProvider->getPageFilter()->filter($content); 138         return $this->_filterProvider->getPageFilter()->filter($content);
139     } 139     }
140     public function getCategoryProductIds($current_category) { 140     public function getCategoryProductIds($current_category) {
141         $category_products = $current_category->getProductCollection() 141         $category_products = $current_category->getProductCollection()
142             ->addAttributeToSelect('*')
 142             ->addAttributeToSelect('*') 
143             ->addAttributeToFilter('is_saleable', 1, 'left')    
144             ->addAttributeToSort('position','asc'); 143             ->addAttributeToSort('position','asc');
145         $cat_prod_ids = $category_products->getAllIds(); 144         $cat_prod_ids = $category_products->getAllIds();
146          145 
147         return $cat_prod_ids; 146         return $cat_prod_ids;
148     } 147     }
149     public function getPrevProduct($product) { 148     public function getPrevProduct($product) {
150         $current_category = $product->getCategory(); 149         $current_category = $product->getCategory();
151         if(!$current_category) { 150         if(!$current_category) {
152             foreach($product->getCategoryCollection() as $parent_cat) { 151             foreach($product->getCategoryCollection() as $parent_cat) {
153                 $current_category = $parent_cat; 152                 $current_category = $parent_cat;
154             } 153             }
155         } 154         }
156         if(!$current_category) 155         if(!$current_category)
157             return false; 156             return false;
158         $cat_prod_ids = $this->getCategoryProductIds($current_category); 157         $cat_prod_ids = $this->getCategoryProductIds($current_category);
159         $_pos = array_search($product->getId(), $cat_prod_ids); 158         $_pos = array_search($product->getId(), $cat_prod_ids);
160         if (isset($cat_prod_ids[$_pos - 1])) { 159         if (isset($cat_prod_ids[$_pos - 1])) {
161             $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); 160             $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]);
162             return $prev_product; 161             return $prev_product;
163         } 162         }
164         return false; 163         return false;
165     } 164     }
166     public function getNextProduct($product) { 165     public function getNextProduct($product) {
167         $current_category = $product->getCategory(); 166         $current_category = $product->getCategory();
168         if(!$current_category) { 167         if(!$current_category) {
169             foreach($product->getCategoryCollection() as $parent_cat) { 168             foreach($product->getCategoryCollection() as $parent_cat) {
170                 $current_category = $parent_cat; 169                 $current_category = $parent_cat;
171             } 170             }
172         } 171         }
173         if(!$current_category) 172         if(!$current_category)
174             return false; 173             return false;
175         $cat_prod_ids = $this->getCategoryProductIds($current_category); 174         $cat_prod_ids = $this->getCategoryProductIds($current_category);
176         $_pos = array_search($product->getId(), $cat_prod_ids); 175         $_pos = array_search($product->getId(), $cat_prod_ids);
177         if (isset($cat_prod_ids[$_pos + 1])) { 176         if (isset($cat_prod_ids[$_pos + 1])) {
178             $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); 177             $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]);
179             return $next_product; 178             return $next_product;
180         } 179         }
181         return false; 180         return false;
182     } 181     }
183  182 
184     public function getMasonryItemClass($arr) { 183     public function getMasonryItemClass($arr) {
185         $item_class = ""; 184         $item_class = "";
186         foreach ($arr as $key => $value) { 185         foreach ($arr as $key => $value) {
187             $item_class .= ' ' . $key . '-' . $value; 186             $item_class .= ' ' . $key . '-' . $value;
188         } 187         }
189         return $item_class; 188         return $item_class;
190     } 189     }
191 } 190 }