Skip to content

Commit

Permalink
Version 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnax committed Mar 31, 2023
1 parent 307c89d commit 6a21116
Show file tree
Hide file tree
Showing 39 changed files with 249 additions and 199 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Modules/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/NoticeContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/NoticeContentP.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/NoticeNews.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/NoticeUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/System/Config/Form/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/ChildTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/SimpleTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Modules/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
63 changes: 32 additions & 31 deletions Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

namespace Olegnax\Core\Helper;

use Exception;
use Magento\Catalog\Helper\Product\Compare;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Customer\Model\Session;
Expand Down Expand Up @@ -194,7 +195,7 @@ public function isArea($area = Area::AREA_FRONTEND)

try {
$this->isArea[$area] = ($state->getAreaCode() == $area);
} catch (\Exception $e) {
} catch ( Exception $e) {
$this->isArea[$area] = false;
}
}
Expand Down Expand Up @@ -333,42 +334,42 @@ public function getStore()

public function isMobile()
{
$regex_match = "/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"
. "htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"
. "blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"
. "symbian|smartphone|mmp|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"
. "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"
. ")/i";
$regex_match = "/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"
. "htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"
. "blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"
. "symbian|smartphone|mmp|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"
. "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"
. ")/i";

if (preg_match($regex_match, strtolower((string)$_SERVER['HTTP_USER_AGENT']))) {
return TRUE;
}
return TRUE;
}

if ((strpos(strtolower((string)$_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
return TRUE;
}

$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');

if (in_array($mobile_ua,$mobile_agents)) {
return TRUE;
}
return TRUE;
}

$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');

if (in_array($mobile_ua,$mobile_agents)) {
return TRUE;
}

if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower((string)$_SERVER['ALL_HTTP']),'OperaMini') > 0) {
return TRUE;
}
return TRUE;
}

return FALSE;
return FALSE;
}

public function getBlockTemplateProcessor($content = '')
Expand Down
92 changes: 50 additions & 42 deletions Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\State;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
Expand Down Expand Up @@ -101,6 +102,7 @@ class Image extends AbstractHelper
* @var File
*/
protected $_file;
protected $_appState;
/**
* @var string
*/
Expand All @@ -111,12 +113,14 @@ public function __construct(
Filesystem $filesystem,
Factory $imageFactory,
File $file,
State $appState,
StoreManagerInterface $storeManager
) {
$this->_mediaDirectory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
$this->_file = $file;
$this->_storeManager = $storeManager;
$this->_appState = $appState;

parent::__construct($context);
}
Expand All @@ -135,7 +139,9 @@ public function adaptiveResize($size, $fileTemplate = null)
}
$this->resize();
} catch (Exception $e) {
$this->_logger->error("Image Resize: " . $e, [$this->_baseFile]);
if ( State::MODE_DEVELOPER == $this->_appState->getMode()) {
$this->_logger->warning("Olegnax Core. Can\'t resize image, skipping. The file does not exist or not accessible: " . $e, [$this->_baseFile]);
}
}

return $this;
Expand Down Expand Up @@ -217,45 +223,47 @@ private function getResizedFile()
$path_data = pathinfo($this->getBaseFile());

if (is_array($path_data) && !empty($path_data)) {
$filename = str_replace(
[
'{dirname}',
'{basename}',
'{extension}',
'{filename}',
'{width}',
'{height}',
'{originalWidth}',
'{originalHeight}',
'{destinationSubdir}',
'{keepFrame}',
'{constrainOnly}',
'{keepAspectRatio}',
'{crop}',
'{keepTransparency}',
'{quality}',
],
[
$path_data['dirname'],
$path_data['basename'],
$path_data['extension'],
$path_data['filename'],
$this->getWidth(),
$this->getHeight(),
$this->getOriginalWidth(),
$this->getOriginalHeight(),
$this->getDestinationSubdir(),
$this->getQuality(),
$this->_keepFrame,
$this->_constrainOnly,
$this->_keepAspectRatio,
$this->_cropOnly,
$this->_keepTransparency,
],
$this->_resizeTemplate
);

return $filename;
if(array_key_exists('extension', $path_data)){
$filename = str_replace(
[
'{dirname}',
'{basename}',
'{extension}',
'{filename}',
'{width}',
'{height}',
'{originalWidth}',
'{originalHeight}',
'{destinationSubdir}',
'{keepFrame}',
'{constrainOnly}',
'{keepAspectRatio}',
'{crop}',
'{keepTransparency}',
'{quality}',
],
[
$path_data['dirname'],
$path_data['basename'],
$path_data['extension'],
$path_data['filename'],
$this->getWidth(),
$this->getHeight(),
$this->getOriginalWidth(),
$this->getOriginalHeight(),
$this->getDestinationSubdir(),
$this->getQuality(),
$this->_keepFrame,
$this->_constrainOnly,
$this->_keepAspectRatio,
$this->_cropOnly,
$this->_keepTransparency,
],
$this->_resizeTemplate
);

return $filename;
}
}
return '';
}
Expand All @@ -278,8 +286,8 @@ public function setBaseFile($file)
{
if ($this->_fileExists($file)) {
$this->_baseFile = $file;
} else {
$this->_logger->error(__('The file does not exist: ') . $file);
} elseif ( State::MODE_DEVELOPER == $this->_appState->getMode()) {
$this->_logger->warning(__('Olegnax Core. The file does not exist or not accessible: ') . $file);
}

return $this;
Expand Down
4 changes: 2 additions & 2 deletions Helper/ModuleInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Framework\HTTP\AsyncClient\Request;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Framework\Module\ModuleListInterface;
use Zend_Http_Client;

class ModuleInfo extends Helper
{
Expand Down Expand Up @@ -215,7 +215,7 @@ protected function loadData()
'verifyhost' => 0,
]
);
$curl->write(Zend_Http_Client::GET, $this->getModuleUrl());
$curl->write(Request::METHOD_GET, $this->getModuleUrl());
$data = $curl->read();
$curl->close();
if(!empty($data)){
Expand Down
2 changes: 1 addition & 1 deletion Helper/ProductImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Source/Noyes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Source/Yesno.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
Loading

0 comments on commit 6a21116

Please sign in to comment.