-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mageplaza/develop
Develop
- Loading branch information
Showing
18 changed files
with
1,241 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,78 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_GoogleMaps | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\GoogleMaps\Block\Adminhtml\System; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Mageplaza\GoogleMaps\Helper\Data; | ||
|
||
/** | ||
* Class Coordinate | ||
* @package Mageplaza\GoogleMaps\Block\Adminhtml\System | ||
*/ | ||
class Coordinate extends Field | ||
{ | ||
/** | ||
* Template path | ||
* | ||
* @var string | ||
*/ | ||
protected $_template = 'system/config/coordinate.phtml'; | ||
|
||
/** | ||
* @var Data | ||
*/ | ||
public $helperData; | ||
|
||
/** | ||
* Coordinate constructor. | ||
* | ||
* @param Context $context | ||
* @param Data $helperData | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Data $helperData, | ||
array $data = [] | ||
) | ||
{ | ||
$this->helperData = $helperData; | ||
|
||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Render fieldset html | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
$this->setElement($element); | ||
|
||
return $this->_decorateRowHtml($element, $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,162 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_GoogleMaps | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\GoogleMaps\Block; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Widget\Block\BlockInterface; | ||
use Mageplaza\GoogleMaps\Helper\Data; | ||
|
||
/** | ||
* Class Map | ||
* @package Mageplaza\GoogleMaps\Block | ||
*/ | ||
class Map extends Template implements BlockInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'Mageplaza_GoogleMaps::map.phtml'; | ||
|
||
/** | ||
* @var Data | ||
*/ | ||
public $helperData; | ||
|
||
/** | ||
* Map constructor. | ||
* | ||
* @param Context $context | ||
* @param Data $helperData | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Data $helperData, | ||
array $data = [] | ||
) | ||
{ | ||
$this->helperData = $helperData; | ||
|
||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Get map API key from system config | ||
* | ||
* @return mixed | ||
*/ | ||
public function getMapApi() | ||
{ | ||
return $this->helperData->getMapConfig('api_key'); | ||
} | ||
|
||
/** | ||
* Get map Latitude from system config | ||
* | ||
* @return mixed | ||
*/ | ||
public function getMapLatitude() | ||
{ | ||
return $this->helperData->getMapConfig('location_setting/latitude'); | ||
} | ||
|
||
/** | ||
* Get map Longitude from system config | ||
* | ||
* @return mixed | ||
*/ | ||
public function getMapLongitude() | ||
{ | ||
return $this->helperData->getMapConfig('location_setting/longitude'); | ||
} | ||
|
||
/** | ||
* Get map Marker Icon Url from system config | ||
* | ||
* @return bool|string | ||
*/ | ||
public function getMapMarkerIcon() | ||
{ | ||
return $this->helperData->getMarkerUrl(); | ||
} | ||
|
||
/** | ||
* Get map Zoom default value from system config | ||
* | ||
* @return int | ||
*/ | ||
public function getMapZoomDefault() | ||
{ | ||
return ((int) $this->helperData->getMapConfig('zoom_default')) ?: 20; | ||
} | ||
|
||
/** | ||
* Get map Type from system config | ||
* | ||
* @return string | ||
*/ | ||
public function getMapTypeId() | ||
{ | ||
return ($this->helperData->getMapConfig('map_type')) ?: 'roadmap'; | ||
} | ||
|
||
/** | ||
* Is draggable map from system config | ||
* | ||
* @return mixed | ||
*/ | ||
public function isMapDraggable() | ||
{ | ||
return $this->helperData->getMapConfig('allow_drag'); | ||
} | ||
|
||
/** | ||
* Get map Protocol from system config | ||
* | ||
* @return mixed | ||
*/ | ||
public function getProtocol() | ||
{ | ||
return $this->helperData->getMapConfig('protocol'); | ||
} | ||
|
||
/** | ||
* Get map Embed code from system config | ||
* | ||
* @return mixed | ||
*/ | ||
public function getEmbedCode() | ||
{ | ||
return $this->helperData->getMapConfig('embed_code'); | ||
} | ||
|
||
/** | ||
* @return false|string | ||
*/ | ||
public function getMapTemplate() | ||
{ | ||
$mapStyle = $this->helperData->getMapConfig('map_style'); | ||
|
||
return json_encode($this->helperData->getMapTheme($mapStyle)); | ||
} | ||
} |
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,109 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_GoogleMaps | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\GoogleMaps\Helper; | ||
|
||
use Magento\Framework\App\Helper\Context; | ||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Mageplaza\Core\Helper\AbstractData; | ||
use Mageplaza\GoogleMaps\Model\Config\Source\System\MapStyle; | ||
|
||
/** | ||
* Class Data | ||
* @package Mageplaza\GoogleMaps\Helper | ||
*/ | ||
class Data extends AbstractData | ||
{ | ||
const CONFIG_MODULE_PATH = 'mpgooglemaps'; | ||
|
||
/** | ||
* @var MapStyle | ||
*/ | ||
protected $_mapStyleData; | ||
|
||
/** | ||
* @var Image | ||
*/ | ||
protected $_helperImage; | ||
|
||
/** | ||
* Data constructor. | ||
* | ||
* @param Context $context | ||
* @param ObjectManagerInterface $objectManager | ||
* @param StoreManagerInterface $storeManager | ||
* @param Image $helperImage | ||
* @param MapStyle $mapStyleData | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
ObjectManagerInterface $objectManager, | ||
StoreManagerInterface $storeManager, | ||
Image $helperImage, | ||
MapStyle $mapStyleData | ||
) | ||
{ | ||
$this->_helperImage = $helperImage; | ||
$this->_mapStyleData = $mapStyleData; | ||
|
||
parent::__construct($context, $objectManager, $storeManager); | ||
} | ||
|
||
/** | ||
* Get map settings system config | ||
* | ||
* @param $code | ||
* @param null $storeId | ||
* | ||
* @return mixed | ||
*/ | ||
public function getMapConfig($code, $storeId = null) | ||
{ | ||
$code = ($code !== '') ? '/' . $code : ''; | ||
|
||
return $this->getModuleConfig('map_setting' . $code, $storeId); | ||
} | ||
|
||
/** | ||
* Get custom marker icon Url | ||
* | ||
* @return bool|string | ||
*/ | ||
public function getMarkerUrl() | ||
{ | ||
if ($this->getMapConfig('marker_icon')) { | ||
return $this->_helperImage->getBaseMediaUrl() . '/' . $this->_helperImage->getMediaPath($this->getMapConfig('marker_icon'), 'marker_icon'); | ||
} else { | ||
return ''; | ||
} | ||
} | ||
|
||
/** | ||
* @param $styleName | ||
* | ||
* @return string | ||
*/ | ||
public function getMapTheme($styleName) | ||
{ | ||
return $this->_mapStyleData->getMapData($styleName); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_GoogleMaps | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\GoogleMaps\Helper; | ||
|
||
use Mageplaza\Core\Helper\Media; | ||
|
||
/** | ||
* Class Image | ||
* @package Mageplaza\GoogleMaps\Helper | ||
*/ | ||
class Image extends Media | ||
{ | ||
const TEMPLATE_MEDIA_PATH = 'mageplaza/google_maps'; | ||
} |
Oops, something went wrong.