<input id="company" name="activ" type="text" class="form-control shadow-none border-0 w-100 streamInput" placeholder="quel est le nom de ton activation ?" data-company-id="5dddc305f0f0a8b36bf19b23" data-registration-number="undefined">
$variables['var3']->params()->set( 'activ', htmlspecialchars($input->getString( 'activ' )) );
$variables['var3']->params()->set( 'data-company-id', htmlspecialchars($input->getAttribute( 'data-company-id' )) );
Please Log in to join the conversation.
<input name="company-id" type="hidden" value="5dddc305f0f0a8b36bf19b23" />
Please Log in to join the conversation.
index.php?option=com_ajax&plugin=Activation&format=json
<?php
/**
* @package Joomla.Plugin
* @author Robert Mittl <info@mittl-medien.de>
* @copyright Copyright © 2019 Robert Mittl. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
* @link https://mittl-medien.de
*/
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Filesystem\File;
use Joomla\Registry\Registry;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Uri\Uri as CMSUri;
class PlgSystemActivation extends CMSPlugin
{
/**
* Affects constructor behavior. If true, language files will be loaded automatically.
*
* @var boolean
* @since 1.0
*/
protected $autoloadLanguage = true;
/**
* Application object
*
* @var CMSApplication
* @since 3.2
*/
protected $app;
public function __construct($subject, $params)
{
parent::__construct($subject, $params);
//$this->loadLanguage();
}
//Frontend
public function onBeforeCompileHead()
{
$app = JFactory::getApplication();
$doc =\JFactory::getDocument();
$doc->addScript('/media/plg_system_activation/js/main_activation.js');
}
public static function onAjaxActivation()
{
$app = JFactory::getApplication();
$array = $app->input->getArray();
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
if ($contentType === "application/json") {
//Receive the RAW post data.
$content = trim(file_get_contents("php://input"));
$receivedData = json_decode($content, true);
$folderPath = explode("/", JPATH_ROOT);
$removeLastElement = array_pop($folderPath);
$securePath = implode('/', $folderPath);
$api_key = 'xxxx';
if ($receivedData['task'] === 'getAutoCompleteLocationData') {
$curl = curl_init();
$query = $receivedData["query"];
curl_setopt_array($curl, array(
CURLOPT_URL => "https://societeinfo.com/app/rest/api/v2/places.json/autocomplete?query={$query}&key={$api_key}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response_location = curl_exec($curl);
curl_close($curl);
//TODO: Split the company name if the result false
$location = $response_location;
return json_decode($response_location);
// Save the result
}
if ($receivedData['task'] === 'getAutoCompleteCompanyData') {
$curl = curl_init();
$query = $receivedData["query"];
$locationId = $receivedData["location_id"];
curl_setopt_array($curl, array(
//correcte url for free autocomplete
CURLOPT_URL => "https://societeinfo.com/app/rest/api/v2/companies.json/autocomplete?SearchMode=autocomplete&withHighlight=true&placeId=${locationId}&query={$query}&limit=10&key={$api_key}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response_company = curl_exec($curl);
curl_close($curl);
//TODO: Split the company name if the result false
$company = $response_company;
return json_decode($response_company);
}
}
}
}
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
return array( 'My JSON Data' );
Please Log in to join the conversation.