Skip to content

Commit

Permalink
Version 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnax committed Oct 5, 2021
1 parent 1df4f64 commit 37e83f3
Show file tree
Hide file tree
Showing 59 changed files with 895 additions and 103 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
5 changes: 4 additions & 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down Expand Up @@ -112,6 +112,9 @@ public function toTPL($data = [])
<div class="ox-module-version">v<?= $this->escapeHtml($data['setup_version']); ?></div>
</div>
<?php endif; ?>
<?php if (array_key_exists('pro', $data)): ?>
<a target="_blank" class="ox-pro-version" href="<?php echo $data['pro'] ?>"><?php echo __('Get Pro'); ?></a>
<?php endif; ?>
<?php if (!empty($rightBlock)): ?><div class="ox-info-block__right"><?= $rightBlock; ?></div><?php endif; ?>
</div>
<?php
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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
82 changes: 72 additions & 10 deletions Helper/Helper.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) 2019 Olegnax (http://olegnax.com/). All rights reserved.
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -14,7 +14,6 @@
use Magento\Framework\App\Area;
use Magento\Framework\App\Cache\Frontend\Pool;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\App\Helper\AbstractHelper;
Expand All @@ -23,6 +22,7 @@
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\App\State;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\DesignInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Wishlist\Helper\Data;
Expand All @@ -31,7 +31,9 @@
class Helper extends AbstractHelper
{

const CONFIG_MODULE = 'ox_core';

const XML_PATH_CORE_LAZY = 'olegnax_core_settings/general/lazyload';
const CONFIG_MODULE = 'olegnax_core_settings';
const CHILD_TEMPLATE = ChildTemplate::class;

/**
Expand All @@ -48,6 +50,22 @@ public function __construct(Context $context)
$this->objectManager = ObjectManager::getInstance();

parent::__construct($context);
if (!$this->getModuleConfig(
'general/install_date',
0,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
)
) {
$this->setModuleConfig('general/install_date', time());
}
}

/**
* @return bool
*/
public function isEnabled()
{
return true;
}

public function setModuleConfig(
Expand Down Expand Up @@ -85,31 +103,70 @@ public function _loadObject($path)
return $this->objectManager->get($path);
}

public function getModuleConfig($path = '', $storeCode = null)
/**
* @return string
*/
public function getThemeCode()
{
/** @var DesignInterface $appState */
$appState = $this->_loadObject(DesignInterface::class);
return $appState->getDesignTheme()->getCode();
}
/**
* @return bool
*/
public function isMobileTheme()
{
return (bool) preg_match('@^Olegnax\/a2m@', $this->getThemeCode());
}
/**
* @return bool
*/
public function isLazyLoadEnabled(){
return (bool) $this->getSystemValue(static::XML_PATH_CORE_LAZY);
}

/**
* @param string $path
* @param integer $storeCode
* @param string $scopeType
* @return mixed
*/
public function getModuleConfig($path = '', $storeCode = null, $scopeType = ScopeInterface::SCOPE_STORE)
{
if (empty($path)) {
$path = static::CONFIG_MODULE;
} else {
$path = static::CONFIG_MODULE . '/' . $path;
}
return $this->getSystemValue($path, $storeCode);
return $this->getSystemValue($path, $storeCode, $scopeType);
}

public function getSystemValue($path, $storeCode = null)
/**
* @param string $path
* @param integer $storeCode
* @param string $scopeType
* @return mixed
*/
public function getSystemValue($path, $storeCode = null, $scopeType = ScopeInterface::SCOPE_STORE)
{
return $this->scopeConfig->getValue(
$path,
ScopeInterface::SCOPE_STORE,
$scopeType,
$storeCode
);
}

/**
* @param string $path
* @return mixed
*/
public function getSystemDefaultValue($path)
{
return $this->scopeConfig->getValue(
return $this->getSystemValue(
$path,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
0,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
}

Expand Down Expand Up @@ -161,6 +218,11 @@ public function getLayoutTemplateHtml($block, $option_path = '', $fileName = '',
return '';
}

/**
* @param string $path
* @param integer $storeCode
* @return mixed
*/
public function getConfig($path, $storeCode = null)
{
return $this->getSystemValue($path, $storeCode);
Expand Down
17 changes: 12 additions & 5 deletions Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ public function setQuality($quality)
*/
public function resize()
{
if ($this->_width == 0 && $this->_height == 0 && !$this->getBaseFile()) {
if ($this->_width == 0
&& $this->_height == 0
|| !$this->getBaseFile()
|| !$this->_fileExists($this->getBaseFile())
) {
return $this;
}

Expand Down Expand Up @@ -439,11 +443,14 @@ public function setImageProcessor($processor)
public function getUrl()
{
$media_url = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
if (!$this->getBaseFile()) {
return $media_url . $this->__file;
if ($this->getBaseFile()) {
$resizedFile = $this->getResizedFile();
if ($resizedFile && $this->_fileExists($resizedFile)) {
return $media_url . $this->getResizedFile();
}
}
return $media_url . $this->getResizedFile();

return $media_url . $this->__file;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Helper/ModuleInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ protected function getModule($name)
'setup_version' => $this->getComposerVersion($name),
];
}
if (empty($module['setup_version'])) {
$module['setup_version'] = $this->getComposerVersion($name);
}
$module['title'] = str_replace('_', ' ', $module['name']);
return (array)$module;
}
Expand Down
Loading

0 comments on commit 37e83f3

Please sign in to comment.