Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
haitv282 authored Jul 25, 2019
2 parents 1ab96db + 73a8589 commit bf6099d
Show file tree
Hide file tree
Showing 30 changed files with 318 additions and 228 deletions.
13 changes: 13 additions & 0 deletions .github/no-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 7
# Label requiring a response
responseRequiredLabel: waiting-customer-response
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there has been no response
to our request for more information from the original author. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further.
8 changes: 5 additions & 3 deletions Block/Adminhtml/System/Config/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Button extends Field
/**
* Unset scope
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param AbstractElement $element
*
* @return string
*/
public function render(AbstractElement $element)
Expand All @@ -51,7 +52,8 @@ public function render(AbstractElement $element)
/**
* Get the button and scripts contents
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param AbstractElement $element
*
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
Expand All @@ -67,4 +69,4 @@ protected function _getElementHtml(AbstractElement $element)

return $this->_toHtml();
}
}
}
16 changes: 9 additions & 7 deletions Block/Adminhtml/System/Config/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\FileSystemException;
use Mageplaza\BetterPopup\Helper\Data;

/**
Expand All @@ -38,12 +39,13 @@ class Template extends Field
protected $_template = 'Mageplaza_BetterPopup::system/config/template.phtml';

/**
* @var \Mageplaza\BetterPopup\Helper\Data
* @var Data
*/
protected $_helperData;

/**
* Template constructor.
*
* @param Context $context
* @param Data $helperData
* @param array $data
Expand All @@ -52,22 +54,22 @@ public function __construct(
Context $context,
Data $helperData,
array $data = []
)
{
) {
$this->_helperData = $helperData;

parent::__construct($context, $data);
}

/**
* @param AbstractElement $element
*
* @return string
* @throws \Magento\Framework\Exception\FileSystemException
* @throws FileSystemException
*/
protected function _getElementHtml(AbstractElement $element)
{
$originalData = $element->getOriginalData();
$buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : '';
$buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : '';
$this->addData(
[
'button_label' => __($buttonLabel),
Expand All @@ -82,7 +84,7 @@ protected function _getElementHtml(AbstractElement $element)

/**
* @return array
* @throws \Magento\Framework\Exception\FileSystemException
* @throws FileSystemException
*/
private function getOptionTemplate()
{
Expand Down Expand Up @@ -127,4 +129,4 @@ private function getOptionTemplate()

return $options;
}
}
}
3 changes: 2 additions & 1 deletion Block/Adminhtml/System/FeatureDisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
class FeatureDisplay extends Field
{
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param AbstractElement $element
*
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
Expand Down
5 changes: 3 additions & 2 deletions Block/Dashboard/Newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace Mageplaza\BetterPopup\Block\Dashboard;

use Magento\Framework\Phrase;
use Mageplaza\BetterPopup\Block\Subscriber;

/**
Expand All @@ -35,10 +36,10 @@ class Newsletter extends Subscriber
protected $_template = 'dashboard/newsletter.phtml';

/**
* @return \Magento\Framework\Phrase|string
* @return Phrase|string
*/
public function getTitle()
{
return __('Subscribers');
}
}
}
4 changes: 2 additions & 2 deletions Block/Email/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Template extends Subscriber
*/
public function getListEmailSubscriberWeek()
{
$listEmail = [];
$listEmail = [];
$subscribersCollection = $this->getSubscriberInWeek($this->_helperData->getStoreId());
foreach ($subscribersCollection as $item) {
$listEmail[] = $item->getData('subscriber_email');
Expand All @@ -56,4 +56,4 @@ public function getCurrentTime()

return date('d M Y', strtotime($date));
}
}
}
77 changes: 32 additions & 45 deletions Block/Popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Magento\Catalog\Block\Product\AbstractProduct;
use Magento\Catalog\Block\Product\Context;
use Magento\Framework\Phrase;
use Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory;
use Magento\Widget\Block\BlockInterface;
use Mageplaza\BetterPopup\Helper\Data as HelperData;
Expand All @@ -37,17 +38,18 @@
class Popup extends AbstractProduct implements BlockInterface
{
/**
* @var \Mageplaza\BetterPopup\Helper\Data
* @var HelperData
*/
protected $_helperData;

/**
* @var \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory
* @var CollectionFactory
*/
protected $_subscriberCollectionFactory;

/**
* Popup constructor.
*
* @param Context $context
* @param HelperData $helperData
* @param CollectionFactory $subscriberCollectionFactory
Expand All @@ -58,9 +60,8 @@ public function __construct(
HelperData $helperData,
CollectionFactory $subscriberCollectionFactory,
array $data = []
)
{
$this->_helperData = $helperData;
) {
$this->_helperData = $helperData;
$this->_subscriberCollectionFactory = $subscriberCollectionFactory;

parent::__construct($context, $data);
Expand Down Expand Up @@ -113,11 +114,7 @@ public function getTextColor()
*/
public function isFullScreen()
{
if ($this->_helperData->getWhatToShowConfig('responsive') == Responsive::FULLSCREEN_POPUP) {
return true;
}

return false;
return (int) $this->_helperData->getWhatToShowConfig('responsive') === Responsive::FULLSCREEN_POPUP;
}

/**
Expand All @@ -127,11 +124,7 @@ public function isFullScreen()
*/
public function isShowFireworks()
{
if ($this->_helperData->getWhatToShowConfig('popup_success/enabled_fireworks')) {
return true;
}

return false;
return $this->_helperData->getWhatToShowConfig('popup_success/enabled_fireworks');
}

/**
Expand All @@ -157,7 +150,7 @@ public function getLocationFloatButton()
/**
* Get Float button label
*
* @return \Magento\Framework\Phrase
* @return Phrase
*/
public function getFloatLabel()
{
Expand All @@ -173,7 +166,7 @@ public function getFloatLabel()
*/
public function getPopupAppear()
{
return $this->_helperData->getWhenToShowConfig('popup_appear');
return (int) $this->_helperData->getWhenToShowConfig('popup_appear');
}

/**
Expand All @@ -183,7 +176,7 @@ public function getPopupAppear()
*/
public function getDelayConfig()
{
if ($this->getPopupAppear() == Appear::AFTER_X_SECONDS) {
if ($this->getPopupAppear() === Appear::AFTER_X_SECONDS) {
return $this->_helperData->getWhenToShowConfig('delay');
}

Expand All @@ -197,11 +190,7 @@ public function getDelayConfig()
*/
public function isExitIntent()
{
if ($this->getPopupAppear() == Appear::EXIT_INTENT) {
return true;
}

return false;
return $this->getPopupAppear() === Appear::EXIT_INTENT;
}

/**
Expand All @@ -211,7 +200,7 @@ public function isExitIntent()
*/
public function getCookieConfig()
{
$cookieDays = (int)$this->_helperData->getWhenToShowConfig('cookieExp');
$cookieDays = (int) $this->_helperData->getWhenToShowConfig('cookieExp');

return ($cookieDays !== null) ? $cookieDays : 30;
}
Expand All @@ -235,7 +224,7 @@ public function getPopupContent()
{
$htmlConfig = $this->_helperData->getWhatToShowConfig('html_content');

$search = [
$search = [
'{{form_url}}',
'{{url_loader}}',
'{{email_icon_url}}',
Expand All @@ -262,9 +251,7 @@ public function getPopupContent()
$this->getViewFileUrl('Mageplaza_BetterPopup::images/template5/img-email.png')
];

$html = str_replace($search, $replace, $htmlConfig);

return $html;
return str_replace($search, $replace, $htmlConfig);
}

/**
Expand All @@ -275,10 +262,10 @@ public function getPopupContent()
public function checkIncludePages()
{
$fullActionName = $this->getRequest()->getFullActionName();
$arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('include_pages'));
$includePages = array_map('trim', $arrayPages);
$arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('include_pages'));
$includePages = array_map('trim', $arrayPages);

return in_array($fullActionName, $includePages);
return in_array($fullActionName, $includePages, true);
}

/**
Expand All @@ -293,9 +280,9 @@ public function checkIncludePaths()

if ($pathsConfig) {
$arrayPaths = explode("\n", $pathsConfig);
$pathsUrl = array_map('trim', $arrayPaths);
$pathsUrl = array_map('trim', $arrayPaths);
foreach ($pathsUrl as $path) {
if (strpos($currentPath, $path) !== false) {
if ($path && strpos($currentPath, $path) !== false) {
return true;
}
}
Expand All @@ -312,10 +299,10 @@ public function checkIncludePaths()
public function checkExcludePages()
{
$fullActionName = $this->getRequest()->getFullActionName();
$arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('exclude_pages'));
$includePages = array_map('trim', $arrayPages);
$arrayPages = explode("\n", $this->_helperData->getWhereToShowConfig('exclude_pages'));
$includePages = array_map('trim', $arrayPages);

return !in_array($fullActionName, $includePages);
return !in_array($fullActionName, $includePages, true);
}

/**
Expand All @@ -330,7 +317,7 @@ public function checkExcludePaths()

if ($pathsConfig) {
$arrayPaths = explode("\n", $pathsConfig);
$pathsUrl = array_map('trim', $arrayPaths);
$pathsUrl = array_map('trim', $arrayPaths);

foreach ($pathsUrl as $path) {
if (strpos($currentPath, $path) !== false) {
Expand Down Expand Up @@ -370,8 +357,8 @@ public function checkExclude()
public function isManuallyInsert()
{
return $this->_helperData->isEnabled()
&& $this->_helperData->getWhereToShowConfig('which_page_to_show') == PageToShow::MANUALLY_INSERT
&& $this->checkExclude();
&& (int) $this->_helperData->getWhereToShowConfig('which_page_to_show') === PageToShow::MANUALLY_INSERT
&& $this->checkExclude();
}

/**
Expand All @@ -385,11 +372,11 @@ public function checkPagesToShow()
$config = $this->_helperData->getWhereToShowConfig('which_page_to_show');

switch ($config) {
case PageToShow::SPECIFIC_PAGES :
case PageToShow::SPECIFIC_PAGES:
return ($this->checkInclude() && $this->checkExclude());
case PageToShow::ALL_PAGES :
case PageToShow::ALL_PAGES:
return $this->checkExclude();
case PageToShow::MANUALLY_INSERT :
case PageToShow::MANUALLY_INSERT:
return false;
}
}
Expand All @@ -406,9 +393,9 @@ public function getAjaxData()
{
$params = [
'url' => $this->getUrl('betterpopup/ajax/success'),
'isScroll' => $this->getPopupAppear() == Appear::AFTER_SCROLL_DOWN,
'isScroll' => $this->getPopupAppear() === Appear::AFTER_SCROLL_DOWN,
'afterSeconds' => [
'isAfterSeconds' => $this->getPopupAppear() == Appear::AFTER_X_SECONDS,
'isAfterSeconds' => $this->getPopupAppear() === Appear::AFTER_X_SECONDS,
'delay' => $this->getDelayConfig()
],
'percentage' => $this->getPercentageScroll(),
Expand Down Expand Up @@ -440,4 +427,4 @@ public function getFormActionUrl()
{
return $this->getUrl('newsletter/subscriber/new', ['_secure' => true]);
}
}
}
Loading

0 comments on commit bf6099d

Please sign in to comment.