Produced by Araxis Merge on 2023-11-23 04:31:23 +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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | /Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.6/app/code/Smartwave/Porto/Helper | Data.php | 2023-04-19 01:29:57 +0000 |
| 2 | /Users/coca/Documents/www/Porto v4.0.2/Theme Files/Magento 2.x/Porto Theme 4.0.7/app/code/Smartwave/Porto/Helper | Data.php | 2023-10-25 04:39:44 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 430 |
| Changed | 1 | 2 |
| Inserted | 3 | 6 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 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 | protected $_storeManager; | 19 | protected $_storeManager; | |||
| 20 | 20 | |||||
| 21 | public function __construct( | 21 | public function __construct( | |||
| 22 | \Magento\Framework\App\Helper\Context $context, | 22 | \Magento\Framework\App\Helper\Context $context, | |||
| 23 | \Magento\Framework\ObjectManagerInterface $objectManager, | 23 | \Magento\Framework\ObjectManagerInterface $objectManager, | |||
| 24 | \Magento\Store\Model\StoreManagerInterface $storeManager, | 24 | \Magento\Store\Model\StoreManagerInterface $storeManager, | |||
| 25 | \Magento\Cms\Model\Template\FilterProvider $filterProvider, | 25 | \Magento\Cms\Model\Template\FilterProvider $filterProvider, | |||
| 26 | \Magento\Framework\Message\ManagerInterface $messageManager, | 26 | \Magento\Framework\Message\ManagerInterface $messageManager, | |||
| 27 | \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, | 27 | \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, | |||
| 28 | Registry $registry | 28 | Registry $registry | |||
| 29 | ) { | 29 | ) { | |||
| 30 | $this->_storeManager = $storeManager; | 30 | $this->_storeManager = $storeManager; | |||
| 31 | $this->_objectManager = $objectManager; | 31 | $this->_objectManager = $objectManager; | |||
| 32 | $this->_filterProvider = $filterProvider; | 32 | $this->_filterProvider = $filterProvider; | |||
| 33 | $this->_registry = $registry; | 33 | $this->_registry = $registry; | |||
| 34 | $this->_messageManager = $messageManager; | 34 | $this->_messageManager = $messageManager; | |||
| 35 | $this->_configFactory = $configFactory; | 35 | $this->_configFactory = $configFactory; | |||
| 36 | 36 | |||||
| 37 | parent::__construct($context); | 37 | parent::__construct($context); | |||
| 38 | } | 38 | } | |||
| 39 | public function checkPurchaseCode($save = false) { | 39 | public function checkPurchaseCode($save = false) { | |||
| 40 | if($this->isLocalhost()){ | 40 | if($this->isLocalhost()){ | |||
| 41 | return "localhost"; | 41 | return "localhost"; | |||
| 42 | } | 42 | } | |||
| 43 | if(!$this->_checkedPurchaseCode){ | 43 | if(!$this->_checkedPurchaseCode){ | |||
| 44 | $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):''; | 44 | $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):''; | |||
| 45 | $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):''; | 45 | $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):''; | |||
| 46 | 46 | |||||
| 47 | if($save) { | 47 | if($save) { | |||
| 48 | $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); | 48 | $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); | |||
| 49 | $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); | 49 | $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); | |||
| 50 | if(strpos($domain, "/")) | 50 | if(strpos($domain, "/")) | |||
| 51 | $domain = substr($domain, 0, strpos($domain, "/")); | 51 | $domain = substr($domain, 0, strpos($domain, "/")); | |||
| 52 | if(!$code || base64_encode($code) != $code_confirm) { | 52 | if(!$code || base64_encode($code) != $code_confirm) { | |||
| 53 | $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); | 53 | $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); | |||
| 54 | } | 54 | } | |||
| 55 | if($code) { | 55 | if($code) { | |||
| 56 | $result = $this->curlPurchaseCode($code, $domain, "add"); | 56 | $result = $this->curlPurchaseCode($code, $domain, "add"); | |||
| 57 | if(!$result || $result['result'] == 0) { | 57 | if(!$result || $result['result'] == 0) { | |||
| 58 | $this->_checkedPurchaseCode = ""; | 58 | $this->_checkedPurchaseCode = ""; | |||
| 59 | $code_confirm = ""; | 59 | $code_confirm = ""; | |||
| 60 | $this->_messageManager->getMessages(true); | 60 | $this->_messageManager->getMessages(true); | |||
| 61 | $this->_messageManager->addWarning(__('Purchase code is not valid!')); | 61 | $this->_messageManager->addWarning(__('Purchase code is not valid!')); | |||
| 62 | } else if($result['result'] == 1) { | 62 | } else if($result['result'] == 1) { | |||
| 63 | $code_confirm = base64_encode($code); | 63 | $code_confirm = base64_encode($code); | |||
| 64 | $this->_checkedPurchaseCode = "verified"; | 64 | $this->_checkedPurchaseCode = "verified"; | |||
| 65 | } else { | 65 | } else { | |||
| 66 | $this->_checkedPurchaseCode = ""; | 66 | $this->_checkedPurchaseCode = ""; | |||
| 67 | $code_confirm = ""; | 67 | $code_confirm = ""; | |||
| 68 | $this->_messageManager->getMessages(true); | 68 | $this->_messageManager->getMessages(true); | |||
| 69 | $this->_messageManager->addWarning(__($result['message'])); | 69 | $this->_messageManager->addWarning(__($result['message'])); | |||
| 70 | } | 70 | } | |||
| 71 | } else { | 71 | } else { | |||
| 72 | $code_confirm = ""; | 72 | $code_confirm = ""; | |||
| 73 | $this->_checkedPurchaseCode = ""; | 73 | $this->_checkedPurchaseCode = ""; | |||
| 74 | } | 74 | } | |||
| 75 | $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); | 75 | $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); | |||
| 76 | } else { | 76 | } else { | |||
| 77 | if($code && $code_confirm && base64_encode($code) == $code_confirm) | 77 | if($code && $code_confirm && base64_encode($code) == $code_confirm) | |||
| 78 | $this->_checkedPurchaseCode = "verified"; | 78 | $this->_checkedPurchaseCode = "verified"; | |||
| 79 | } | 79 | } | |||
| 80 | } | 80 | } | |||
| 81 | 81 | |||||
| 82 | return $this->_checkedPurchaseCode; | 82 | return $this->_checkedPurchaseCode; | |||
| 83 | } | 83 | } | |||
| 84 | public function curlPurchaseCode($code, $domain, $act) { | 84 | public function curlPurchaseCode($code, $domain, $act) { | |||
| 85 | $ch = curl_init(); | 85 | $ch = curl_init(); | |||
| 86 | 86 | |||||
| 87 | // Set cURL options | 87 | // Set cURL options | |||
| 88 | 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_URL, "https://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act"); | |||
| 89 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 89 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |||
| 90 | curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); | 90 | curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); | |||
| 91 | 91 | |||||
| 92 | // Decode returned JSON | 92 | // Decode returned JSON | |||
| 93 | $result = json_decode( curl_exec($ch) , true ); | 93 | $result = json_decode( curl_exec($ch) , true ); | |||
| 94 | return $result; | 94 | return $result; | |||
| 95 | } | 95 | } | |||
| 96 | public function isLocalhost() { | 96 | public function isLocalhost() { | |||
| 97 | $whitelist = array( | 97 | $whitelist = array( | |||
| 98 | '127.0.0.1', | 98 | '127.0.0.1', | |||
| 99 | '::1' | 99 | '::1' | |||
| 100 | ); | 100 | ); | |||
| 101 | 101 | |||||
| 102 | return in_array($_SERVER['REMOTE_ADDR'], $whitelist); | 102 | return in_array($_SERVER['REMOTE_ADDR'], $whitelist); | |||
| 103 | } | 103 | } | |||
| 104 | public function isAdmin() { | 104 | public function isAdmin() { | |||
| 105 | $om = \Magento\Framework\App\ObjectManager::getInstance(); | 105 | $om = \Magento\Framework\App\ObjectManager::getInstance(); | |||
| 106 | $app_state = $om->get('\Magento\Framework\App\State'); | 106 | $app_state = $om->get('\Magento\Framework\App\State'); | |||
| 107 | $area_code = $app_state->getAreaCode(); | 107 | $area_code = $app_state->getAreaCode(); | |||
| 108 | if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) | 108 | if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) | |||
| 109 | { | 109 | { | |||
| 110 | return true; | 110 | return true; | |||
| 111 | } | 111 | } | |||
| 112 | else | 112 | else | |||
| 113 | { | 113 | { | |||
| 114 | return false; | 114 | return false; | |||
| 115 | } | 115 | } | |||
| 116 | } | 116 | } | |||
| 117 | public function getBaseUrl() | 117 | public function getBaseUrl() | |||
| 118 | { | 118 | { | |||
| 119 | return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); | 119 | return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); | |||
| 120 | } | 120 | } | |||
| 121 | public function getBaseLinkUrl() | 121 | public function getBaseLinkUrl() | |||
| 122 | { | 122 | { | |||
| 123 | return $this->_storeManager->getStore()->getBaseUrl(); | 123 | return $this->_storeManager->getStore()->getBaseUrl(); | |||
| 124 | } | 124 | } | |||
| 125 | public function getConfig($config_path) | 125 | public function getConfig($config_path) | |||
| 126 | { | 126 | { | |||
| 127 | return $this->scopeConfig->getValue( | 127 | return $this->scopeConfig->getValue( | |||
| 128 | $config_path, | 128 | $config_path, | |||
| 129 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | 129 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | |||
| 130 | ); | 130 | ); | |||
| 131 | } | 131 | } | |||
| 132 | public function getModel($model) { | 132 | public function getModel($model) { | |||
| 133 | return $this->_objectManager->create($model); | 133 | return $this->_objectManager->create($model); | |||
| 134 | } | 134 | } | |||
| 135 | public function getCurrentStore() { | 135 | public function getCurrentStore() { | |||
| 136 | return $this->_storeManager->getStore(); | 136 | return $this->_storeManager->getStore(); | |||
| 137 | } | 137 | } | |||
| 138 | public function filterContent($content) { | 138 | public function filterContent($content) { | |||
| 139 | return $this->_filterProvider->getPageFilter()->filter($content); | 139 | return $this->_filterProvider->getPageFilter()->filter($content); | |||
| 140 | } | 140 | } | |||
| 141 | public function getCategoryProductIds($current_category) { | 141 | public function getCategoryProductIds($current_category) { | |||
| 142 | $category_products = $current_category->getProductCollection() | 142 | $category_products = $current_category->getProductCollection() | |||
| 143 | ->addAttributeToSelect('*') | 143 | ->addAttributeToSelect('*') | |||
| 144 | ->addAttributeToSort('position','asc'); | 144 | ->addAttributeToSort('position','asc'); | |||
| 145 | $cat_prod_ids = $category_products->getAllIds(); | 145 | $cat_prod_ids = $category_products->getAllIds(); | |||
| 146 | 146 | |||||
| 147 | return $cat_prod_ids; | 147 | return $cat_prod_ids; | |||
| 148 | } | 148 | } | |||
| 149 | public function getPercentage(\Magento\Catalog\Model\Product $product) | 149 | public function getPercentage(\Magento\Catalog\Model\Product $product) | |||
| 150 | { | 150 | { | |||
| 151 | $baseprice = 0; | 151 | $baseprice = 0; | |||
| 152 | $finalprice = 0; | 152 | $finalprice = 0; | |||
| 153 | $percentage = 0; | 153 | $percentage = 0; | |||
| 154 | 154 | |||||
| 155 | if ($product->getTypeId() == 'configurable') { | 155 | if ($product->getTypeId() == 'configurable') { | |||
| 156 | $baseprice = $product->getPriceInfo() | 156 | $baseprice = $product->getPriceInfo() | |||
| 157 | ->getPrice('regular_price') | 157 | ->getPrice('regular_price') | |||
| 158 | ->getValue(); | 158 | ->getValue(); | |||
| 159 | 159 | |||||
| 160 | $finalprice = $product->getPriceInfo() | 160 | $finalprice = $product->getPriceInfo() | |||
| 161 | ->getPrice('final_price') | 161 | ->getPrice('final_price') | |||
| 162 | ->getValue(); | 162 | ->getValue(); | |||
| 163 | } else { | 163 | } else { | |||
| 164 | $baseprice = $product->getPrice(); | 164 | $baseprice = $product->getPrice(); | |||
| 165 | $finalprice = $product->getFinalPrice(); | 165 | $finalprice = $product->getFinalPrice(); | |||
| 166 | } | 166 | } | |||
| 167 | 167 | |||||
| 168 | $specialfromdate = $product->getSpecialFromDate(); | |||||
| 169 | $specialtodate = $product->getSpecialToDate(); | |||||
| 170 | $today = time(); | |||||
| 171 | ||||||
| 168 | if ($finalprice < $baseprice) { | 172 | if ($finalprice < $baseprice) { | |||
| 173 | if((is_null($specialfromdate) && is_null($specialtodate)) || ($today >= strtotime($specialfromdate) && is_null($specialtodate)) || ($today <= strtotime($specialtodate) && is_null($specialfromdate)) || ($today >= strtotime($specialfromdate) && $today <= strtotime($specialtodate))){ | |||||
| 169 | $percentage = round(-100 * (1 - ($finalprice / $baseprice))); | 174 | $percentage = round(-100 * (1 - ($finalprice / $baseprice))); | |||
| 170 | } | 175 | } | |||
| 176 | } | |||||
| 171 | 177 | |||||
| 172 | return $percentage; | 178 | return $percentage; | |||
| 173 | } | 179 | } | |||
| 174 | public function getPrevProduct($product) { | 180 | public function getPrevProduct($product) { | |||
| 175 | $current_category = $product->getCategory(); | 181 | $current_category = $product->getCategory(); | |||
| 176 | if(!$current_category) { | 182 | if(!$current_category) { | |||
| 177 | foreach($product->getCategoryCollection() as $parent_cat) { | 183 | foreach($product->getCategoryCollection() as $parent_cat) { | |||
| 178 | $current_category = $parent_cat; | 184 | $current_category = $parent_cat; | |||
| 179 | } | 185 | } | |||
| 180 | } | 186 | } | |||
| 181 | if(!$current_category) | 187 | if(!$current_category) | |||
| 182 | return false; | 188 | return false; | |||
| 183 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | 189 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | |||
| 184 | $_pos = array_search($product->getId(), $cat_prod_ids); | 190 | $_pos = array_search($product->getId(), $cat_prod_ids); | |||
| 185 | if (isset($cat_prod_ids[$_pos - 1])) { | 191 | if (isset($cat_prod_ids[$_pos - 1])) { | |||
| 186 | $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); | 192 | $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); | |||
| 187 | return $prev_product; | 193 | return $prev_product; | |||
| 188 | } | 194 | } | |||
| 189 | return false; | 195 | return false; | |||
| 190 | } | 196 | } | |||
| 191 | public function getNextProduct($product) { | 197 | public function getNextProduct($product) { | |||
| 192 | $current_category = $product->getCategory(); | 198 | $current_category = $product->getCategory(); | |||
| 193 | if(!$current_category) { | 199 | if(!$current_category) { | |||
| 194 | foreach($product->getCategoryCollection() as $parent_cat) { | 200 | foreach($product->getCategoryCollection() as $parent_cat) { | |||
| 195 | $current_category = $parent_cat; | 201 | $current_category = $parent_cat; | |||
| 196 | } | 202 | } | |||
| 197 | } | 203 | } | |||
| 198 | if(!$current_category) | 204 | if(!$current_category) | |||
| 199 | return false; | 205 | return false; | |||
| 200 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | 206 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | |||
| 201 | $_pos = array_search($product->getId(), $cat_prod_ids); | 207 | $_pos = array_search($product->getId(), $cat_prod_ids); | |||
| 202 | if (isset($cat_prod_ids[$_pos + 1])) { | 208 | if (isset($cat_prod_ids[$_pos + 1])) { | |||
| 203 | $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); | 209 | $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); | |||
| 204 | return $next_product; | 210 | return $next_product; | |||
| 205 | } | 211 | } | |||
| 206 | return false; | 212 | return false; | |||
| 207 | } | 213 | } | |||
| 208 | 214 | |||||
| 209 | public function getMasonryItemClass($arr) { | 215 | public function getMasonryItemClass($arr) { | |||
| 210 | $item_class = ""; | 216 | $item_class = ""; | |||
| 211 | foreach ($arr as $key => $value) { | 217 | foreach ($arr as $key => $value) { | |||
| 212 | $item_class .= ' ' . $key . '-' . $value; | 218 | $item_class .= ' ' . $key . '-' . $value; | |||
| 213 | } | 219 | } | |||
| 214 | return $item_class; | 220 | return $item_class; | |||
| 215 | } | 221 | } | |||
| 216 | } | 222 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.