-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 63c2f66
Showing
21 changed files
with
1,194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\Core\Block\Adminhtml; | ||
|
||
use Magento\Backend\Block\Template; | ||
use MagePal\Core\Controller\Adminhtml\Version\Index; | ||
|
||
class Badge extends Template | ||
{ | ||
const SEARCH_URL = 'https://www.magepal.com/catalogsearch/result/?utm_source=search&utm_medium=admin&utm_campaign=core'; | ||
|
||
public function getNotificationUrl() | ||
{ | ||
return $this->getUrl('magepal/version/index'); | ||
} | ||
|
||
public function isAuthorized() | ||
{ | ||
return $this->_authorization->isAllowed(Index::ADMIN_RESOURCE); | ||
} | ||
|
||
public function getSearchUrl() | ||
{ | ||
return self::SEARCH_URL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\Core\Block\Adminhtml\System\Config\Composer; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use MagePal\Core\Model\Module; | ||
|
||
class Version extends Field | ||
{ | ||
/** | ||
* @var Module | ||
*/ | ||
private $module; | ||
|
||
/** | ||
* @param Context $context | ||
* @param Module $module | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Module $module, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->module = $module; | ||
} | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
// Remove scope label | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
return parent::render($element); | ||
} | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
return 'v' . $this->module->getInstalledVersion($this->getModuleName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\Core\Block\Adminhtml\System\Config\Field; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use MagePal\Core\Model\Module; | ||
|
||
class Extensions extends Field | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'MagePal_Core::system/config/field/extensions.phtml'; | ||
/** | ||
* @var Module | ||
*/ | ||
private $module; | ||
|
||
public function __construct( | ||
Context $context, | ||
Module $module, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->module = $module; | ||
} | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
return $this->toHtml(); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getUpdateCount() | ||
{ | ||
return $this->module->getUpdateCount(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getExtensionList() | ||
{ | ||
return $this->module->getOutDatedExtension(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* https://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\Core\Block\Adminhtml\System\Config\Field; | ||
|
||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
|
||
class Search extends Field | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'MagePal_Core::system/config/field/search.phtml'; | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
return $this->toHtml(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | [email protected] | ||
*/ | ||
|
||
namespace MagePal\Core\Controller\Adminhtml\Version; | ||
|
||
use Magento\Backend\App\Action; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use MagePal\Core\Model\Module; | ||
|
||
class Index extends Action | ||
{ | ||
public const ADMIN_RESOURCE = 'MagePal_Core::config'; | ||
/** | ||
* @var JsonFactory | ||
*/ | ||
private $resultJsonFactory; | ||
/** | ||
* @var Module | ||
*/ | ||
private $module; | ||
|
||
/** | ||
* Index constructor. | ||
* @param Context $context | ||
* @param JsonFactory $resultJsonFactory | ||
* @param Module $module | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
JsonFactory $resultJsonFactory, | ||
Module $module | ||
) { | ||
parent::__construct($context); | ||
$this->resultJsonFactory = $resultJsonFactory; | ||
$this->module = $module; | ||
} | ||
/** | ||
* Index action | ||
* | ||
* @return ResultInterface | ||
*/ | ||
public function execute() | ||
{ | ||
$date = [ | ||
'success' => 1, | ||
'count' => $this->module->getUpdateCount() | ||
]; | ||
|
||
$result = $this->resultJsonFactory->create(); | ||
$result->setHeader('Cache-Control', 'max-age=302400', true); | ||
$result->setHeader('Pragma', 'cache', true); | ||
$result->setData($date); | ||
return $result; | ||
} | ||
} |
Oops, something went wrong.