-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
18f255e
commit e94190e
Showing
12 changed files
with
977 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,43 @@ | ||
<?php | ||
namespace Optipic\Optipic\Block\Adminhtml\Form\Field; | ||
|
||
//use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray; | ||
//use Magento\Framework\DataObject; | ||
//use Magento\Framework\Exception\LocalizedException; | ||
//use Vendor\Module\Block\Adminhtml\Form\Field\TaxColumn; | ||
//use Magento\Framework\Data\Form\Element\AbstractElement; | ||
|
||
use Magento\Backend\Block\AbstractBlock; | ||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface; | ||
use Magento\Framework\App\ObjectManager; | ||
|
||
/** | ||
* Class Statscript | ||
*/ | ||
class Statscript extends \Magento\Backend\Block\AbstractBlock implements | ||
\Magento\Framework\Data\Form\Element\Renderer\RendererInterface | ||
{ | ||
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) | ||
{ | ||
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | ||
|
||
$moduleInfo = $objectManager->get('Magento\Framework\Module\ModuleList')->getOne('Optipic_Optipic'); | ||
$moduleVersion = $moduleInfo['setup_version']; | ||
|
||
$optipic = $objectManager->get('Optipic\Optipic\Model\Optipic'); | ||
$settings = $optipic->getSettings(); | ||
$siteId = $settings['site_id']; | ||
|
||
//$currentUrl = Mage::helper('core/url')->getCurrentUrl(); | ||
//$url = Mage::getSingleton('core/url')->parseUrl($currentUrl); | ||
//$domain = $objectManager->get('Magento\Framework\Url')->getCurrentUrl(); | ||
//$domain = $objectManager->get('Zend\Uri\Http')->parse($domain);//->getQueryAsArray(); | ||
|
||
return sprintf('<script src="https://optipic.io/api/cp/stat?domain=%s&sid=%s&cms=magento&stype=cdn&append_to=%s&version=%s"></script>', | ||
urlencode($_SERVER["HTTP_HOST"]), | ||
urlencode($siteId), | ||
urlencode(".section-config:first"), | ||
urlencode($moduleVersion) | ||
); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace Optipic\Optipic\Helper; | ||
|
||
use Magento\Framework\App\Helper\AbstractHelper; | ||
use Magento\Store\Model\ScopeInterface; | ||
|
||
class Data extends AbstractHelper | ||
{ | ||
|
||
const XML_PATH_OPTIPIC = 'optipic/'; | ||
|
||
public function getConfigValue($field, $storeId = null) | ||
{ | ||
return $this->scopeConfig->getValue( | ||
$field, ScopeInterface::SCOPE_STORE, $storeId | ||
); | ||
} | ||
|
||
public function getGeneralConfig($code, $storeId = null) | ||
{ | ||
|
||
return $this->getConfigValue(self::XML_PATH_OPTIPIC .'general/'. $code, $storeId); | ||
} | ||
|
||
} |
Oops, something went wrong.