Skip to content

Commit 76659f3

Browse files
committed
add module files
0 parents  commit 76659f3

File tree

137 files changed

+49736
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+49736
-0
lines changed

Block/Adminhtml/License.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Landofcoder.com
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Landofcoder.com.com license that is
8+
* available through the world-wide-web at this URL:
9+
* https://www.landofcoder.com/license-agreement.html
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Landofcoder.com
17+
* @package Lof_All
18+
* @copyright Copyright (c) 2016 Landofcoder.com (https://www.landofcoder.com/)
19+
* @license https://www.landofcoder.com/LICENSE-1.0.html
20+
*/
21+
namespace Lof\All\Block\Adminhtml;
22+
23+
class License extends \Magento\Framework\View\Element\Template
24+
{
25+
protected function _toHtml() {
26+
$extension = $this->getData('extension');
27+
if ($extension) {
28+
$this->_eventManager->dispatch(
29+
'lof_check_license',
30+
['obj' => $this,'ex'=>$extension]
31+
);
32+
$extension = str_replace("_", " ", $extension);
33+
if (!$this->getData('is_valid')) {
34+
return '<div style="margin-top: 5px;"><div class="messages error"><div class="message message-error" style="margin-bottom: 0;"><div>Module <b>' . $extension . '</b> is not yet registered! Go to <b>Backend > Landofcoder > Licenses</b> to register the module. Please login to your account in <a target="_blank" href="https://landofcoder.com">landofcoder.com</a>, then go to <b>Dashboard > My Downloadable Products</b>, enter your domains to get a new license. Next go to <b>Backend > Landofcoder > Licenses</b> to save the license.</div></div></div></div>';
35+
}
36+
}
37+
return parent::_toHtml();
38+
}
39+
}

Block/Adminhtml/System/ListLicense.php

+397
Large diffs are not rendered by default.

Block/Adminhtml/System/Market.php

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<?php
2+
/**
3+
* Landofcoder
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the venustheme.com license that is
8+
* available through the world-wide-web at this URL:
9+
* http://landofcoder.com/license
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Landofcoder
17+
* @package Lof_All
18+
* @copyright Copyright (c) 2017 Landofcoder (https://www.landofcoder.com/)
19+
* @license https://www.landofcoder.com/LICENSE-1.0.html
20+
*/
21+
22+
namespace Lof\All\Block\Adminhtml\System;
23+
24+
use Magento\Framework\App\Filesystem\DirectoryList;
25+
use Lof\All\Block\Adminhtml\System\ListLicense;
26+
27+
class Market extends \Magento\Config\Block\System\Config\Form\Field
28+
{
29+
30+
/**
31+
* @var \Magento\Framework\App\ResourceConnection
32+
*/
33+
protected $_resource;
34+
35+
protected $_key_path;
36+
37+
/**
38+
* [__construct description]
39+
* @param \Magento\Backend\Block\Template\Context $context
40+
* @param \Magento\Framework\App\ResourceConnection $resource
41+
* @param \Lof\All\Helper\Data $helper
42+
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
43+
*/
44+
public function __construct(
45+
\Magento\Backend\Block\Template\Context $context,
46+
\Magento\Framework\App\ResourceConnection $resource,
47+
\Lof\All\Helper\Data $helper,
48+
\Lof\All\Model\License $license,
49+
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
50+
)
51+
{
52+
parent::__construct($context);
53+
$this->_resource = $resource;
54+
$this->_helper = $helper;
55+
$this->_remoteAddress = $remoteAddress;
56+
$this->_license = $license;
57+
}
58+
59+
/**
60+
* Retrieve HTML markup for given form element
61+
*
62+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
63+
* @return string
64+
*/
65+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
66+
{
67+
/*
68+
if (!extension_loaded('soap')) {
69+
throw new \Magento\Framework\Webapi\Exception(
70+
__('SOAP extension is not loaded.'),
71+
0,
72+
\Magento\Framework\Webapi\Exception::HTTP_INTERNAL_ERROR
73+
);
74+
}
75+
$products = array();
76+
try{
77+
$opts = array(
78+
'ssl' => array(
79+
'verify_peer' => false,
80+
'verify_peer_name' => false
81+
)
82+
);
83+
$context = stream_context_create($opts);
84+
$params = array('soap_version'=>SOAP_1_2,
85+
'verifypeer' => false,
86+
'verifyhost' => false,
87+
'exceptions' => 1,
88+
'stream_context'=>$context);
89+
90+
$proxy = new \SoapClient(ListLicense::API_URL, $params);
91+
92+
$sessionId = $proxy->login(ListLicense::API_USERNAME, ListLicense::API_PASSWORD);
93+
94+
$products = $proxy->call($sessionId, 'veslicense.productlist1');
95+
} catch(SoapFault $e){
96+
97+
}*/
98+
$list_products = $this->getProductList();
99+
$products = isset($list_products['products'])?$list_products['products']:[];
100+
$total = 12;
101+
$column = 2;
102+
$x = 0;
103+
$html = '';
104+
$html .= '<div id="lof-elist">';
105+
$html .= '<h1><a href="https://landofcoder.com">Landofcoder.com - Opensource Marketplace for magento, opencart</a></h1>';
106+
foreach ($products as $_product) {
107+
if( $column == 1 || $x%$column == 0){
108+
$html .= '<div class="erow">';
109+
}
110+
$class = '';
111+
if( $column == 1 || ($x+1)%$column == 0 || $x == ($total-1) ) {
112+
$class = ' last';
113+
}
114+
115+
if ($_product['price']==0 || $_product['price']=="" ||$_product['price']=="0.00" || $_product['price']=="$0.00" || !$_product['price']) {
116+
$price = 'FREE';
117+
} else {
118+
$price = $_product['price_currency'];
119+
}
120+
121+
$html .= '<div class="extend-card ' . $class . '">';
122+
$html .= '<div class="extend-card-top">';
123+
$html .= '<div class="extend-card-image"><a href="' . $_product['purl'] . '" title="' . $_product['name'] . '"><img src="' . $_product['pimg'] . '" class="plugin-icon" alt=""></a></div>';
124+
$html .= '<div class="extend-card-desc"><a href="' . $_product['purl'] . '" title="' . $_product['name'] . '"><h3>' . $_product['name'] . '</h3></a><div class="extend-price">' . $price . '</div></div><div class="extend-des"> <div class="extend-des-inner"> ' . $_product['short_description'] . '</div> <a href="' . $_product['purl'] . '" title="' . $_product['name'] . '" class="extend-buynow" style="float: left;">Buy Now</a></div>';
125+
$html .= '</div>';
126+
$html .= '</div>';
127+
if( $column == 1 || ($x+1)%$column == 0 || $x == ($total-1) ) {
128+
$html .= '</div>';
129+
}
130+
$x++;
131+
}
132+
$html .= '</div>';
133+
134+
return $this->_decorateRowHtml($element, $html);
135+
}
136+
public function getProductList() {
137+
//Authentication rest API magento2, get access token
138+
$url = ListLicense::getListUrl();
139+
$key_path = $this->getKeyPath();
140+
$data = array();
141+
$crl = curl_init();
142+
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, TRUE);
143+
curl_setopt($crl, CURLOPT_CAPATH, $key_path);
144+
curl_setopt($crl, CURLOPT_SSL_VERIFYHOST, 2);
145+
curl_setopt($crl, CURLOPT_URL, $url);
146+
curl_setopt($crl, CURLOPT_HEADER, 0);
147+
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
148+
curl_setopt($crl, CURLOPT_POST, 1);
149+
curl_setopt($crl, CURLOPT_POSTFIELDS, $data);
150+
$response = curl_exec($crl);
151+
if ($response) {
152+
}
153+
else {
154+
echo 'An error has occurred: ' . curl_error($crl);
155+
return[];
156+
}
157+
curl_close($crl);
158+
159+
return json_decode($response, true);
160+
}
161+
162+
public function getKeyPath(){
163+
if(!$this->_key_path){
164+
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
165+
$directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
166+
$base_url = $directory->getRoot();
167+
$this->_key_path = $base_url."/veslicense/cacert.pem";
168+
}
169+
return $this->_key_path;
170+
}
171+
public function getDomain($domain) {
172+
$domain = strtolower($domain);
173+
$domain = str_replace(['www.','WWW.','https://','http://','https','http'], [''], $domain);
174+
if($this->endsWith($domain, '/')){
175+
$domain = substr_replace($domain ,"",-1);
176+
}
177+
return $domain;
178+
}
179+
public function endsWith($haystack, $needle) {
180+
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);
181+
}
182+
}

Helper/Data.php

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?php
2+
/**
3+
* Landofcoder
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the venustheme.com license that is
8+
* available through the world-wide-web at this URL:
9+
* http://landofcoder.com/license
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Landofcoder
17+
* @package Lof_All
18+
* @copyright Copyright (c) 2017 Landofcoder (https://www.landofcoder.com/)
19+
* @license https://www.landofcoder.com/LICENSE-1.0.html
20+
*/
21+
22+
namespace Lof\All\Helper;
23+
24+
use Magento\Framework\App\Filesystem\DirectoryList;
25+
use Magento\Framework\Module\Dir;
26+
27+
class Data extends \Magento\Framework\App\Helper\AbstractHelper
28+
{
29+
/**
30+
* @var \Magento\Store\Model\StoreManagerInterface
31+
*/
32+
protected $_storeManager;
33+
34+
/**
35+
* @var array
36+
*/
37+
protected $_config = [];
38+
39+
/**
40+
* Template filter factory
41+
*
42+
* @var \Magento\Catalog\Model\Template\Filter\Factory
43+
*/
44+
protected $_templateFilterFactory;
45+
46+
/**
47+
* @var \Magento\Cms\Model\Template\FilterProvider
48+
*/
49+
protected $_filterProvider;
50+
51+
/**
52+
* @var \Magento\Framework\Registry
53+
*/
54+
protected $_filesystem;
55+
56+
/**
57+
* @var \Magento\Framework\Registry
58+
*/
59+
protected $_coreRegistry;
60+
61+
public function __construct(
62+
\Magento\Framework\App\Helper\Context $context,
63+
\Magento\Store\Model\StoreManagerInterface $storeManager,
64+
\Magento\Cms\Model\Template\FilterProvider $filterProvider,
65+
\Magento\Framework\Filesystem $filesystem,
66+
\Magento\Framework\Registry $registry,
67+
\Magento\Framework\Module\Dir\Reader $moduleReader,
68+
\Lof\All\Model\License $licnese
69+
) {
70+
parent::__construct($context);
71+
$this->_storeManager = $storeManager;
72+
$this->_filterProvider = $filterProvider;
73+
$this->_filesystem = $filesystem;
74+
$this->_coreRegistry = $registry;
75+
$this->_license = $licnese;
76+
$this->_remoteAddress = $context->getRemoteAddress();
77+
$this->_moduleReader = $moduleReader;
78+
}
79+
80+
/**
81+
* Return brand config value by key and store
82+
*
83+
* @param string $key
84+
* @param \Magento\Store\Model\Store|int|string $store
85+
* @return string|null
86+
*/
87+
public function getConfig($key, $group = "lofall/general", $store = null)
88+
{
89+
$store = $this->_storeManager->getStore($store);
90+
$websiteId = $store->getWebsiteId();
91+
if ($this->_storeManager->isSingleStoreMode()) {
92+
$result = $this->scopeConfig->getValue(
93+
$group . '/' .$key,
94+
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES
95+
);
96+
} else {
97+
$result = $this->scopeConfig->getValue(
98+
$group . '/' .$key,
99+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
100+
$store);
101+
}
102+
if(!$result){
103+
$result = $this->scopeConfig->getValue(
104+
$group . '/' .$key,
105+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
106+
null);
107+
}
108+
if(!$result){
109+
$result = $this->scopeConfig->getValue(
110+
$group . '/' .$key);
111+
}
112+
113+
return $result;
114+
}
115+
116+
public function filter($str)
117+
{
118+
$html = $this->_filterProvider->getPageFilter()->filter($str);
119+
return $html;
120+
}
121+
122+
public function getLicense($module_name) {
123+
$ip = $this->_remoteAddress->getRemoteAddress();
124+
$file = $this->_moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, $module_name) . '/license.xml';
125+
if(file_exists($file)) {
126+
$xmlObj = new \Magento\Framework\Simplexml\Config($file);
127+
$xmlData = $xmlObj->getNode();
128+
if ($xmlData) {
129+
$code = $xmlData->code;
130+
$license = $this->_license->load($code);
131+
return $license;
132+
}
133+
return false;
134+
} else {
135+
return true;
136+
}
137+
}
138+
}

0 commit comments

Comments
 (0)