Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Rework of the whole module #5

Merged
merged 18 commits into from Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion backward_compatibility
Submodule backward_compatibility deleted from 35e345
99 changes: 99 additions & 0 deletions classes/GAdwordsModuleManagement.php
@@ -0,0 +1,99 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA
* @version Release: $Revision: 17142 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class GAdwordsModuleManagement
{
/**
* Manage the module and return the module configuration link if it is installed
*
* @param string $moduleName
* @param int $moduleId
*
* @return bool
*/
public function moduleManagement(string $moduleName, int $moduleId)
Quetzacoalt91 marked this conversation as resolved.
Show resolved Hide resolved
{
// Is the module is installed ?
if (Module::isInstalled($moduleName)) {
return true;
}

if (!$this->isModuleOnDisk($moduleName, $moduleId)) {
return false;
}

$modulePrestashopAds = Module::getInstanceByName($moduleName);

if (!$modulePrestashopAds) {
return false;
}

return $modulePrestashopAds->install();
}

/**
* Check if a module is on the disk
*
* @param string $moduleName
* @param int $moduleId
*
* @return bool
*/
private function isModuleOnDisk(string $moduleName, int $moduleId)
Quetzacoalt91 marked this conversation as resolved.
Show resolved Hide resolved
{
$modulesOnDisk = Module::getModulesDirOnDisk();

if (in_array($moduleName, $modulesOnDisk)) {
return true;
}

return $this->downloadModule($moduleName, $moduleId);
}

/**
* Download module from Addons
*
* @param string $moduleName
* @param int $moduleId
*
* @return bool
*/
public function downloadModule(string $moduleName, int $moduleId)
Quetzacoalt91 marked this conversation as resolved.
Show resolved Hide resolved
{
$length = file_put_contents(
_PS_MODULE_DIR_.basename($moduleName).'.zip',
Tools::addonsRequest('module', array('id_module' => $moduleId))
);

if (!empty($length) && Tools::ZipExtract(_PS_MODULE_DIR_.basename($moduleName).'.zip', _PS_MODULE_DIR_)) {
@unlink(_PS_MODULE_DIR_.basename($moduleName).'.zip');
return true;
}

return false;
}
}
File renamed without changes.
18 changes: 9 additions & 9 deletions config.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>gadwords</name>
<displayName><![CDATA[Google AdWords]]></displayName>
<version><![CDATA[1.3.6]]></version>
<description><![CDATA[You want to be more visible on Google and attract new clients ? Use our 75&euro; promo code on Google Adwords !]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[advertising_marketing]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<name>gadwords</name>
<displayName><![CDATA[Google AdWords]]></displayName>
<version><![CDATA[2.0.0]]></version>
<description><![CDATA[You want to be more visible on Google and attract new clients ? Use our 75&euro; promo code on Google Adwords !]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[advertising_marketing]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
</module>
53 changes: 53 additions & 0 deletions controllers/admin/AdminModuleManagerController.php
@@ -0,0 +1,53 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA
* @version Release: $Revision: 17142 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

require_once dirname(__FILE__).'/../../classes/GAdwordsModuleManagement.php';

class AdminModuleManagerController extends ModuleAdminController
{
/**
* Install the module PRESTASHOP_ADS_MODULE_NAME on ajax call
*
* @return void
*/
public function ajaxProcessInstallModule()
{
$moduleAds = new GAdwordsModuleManagement();

$installModule = $moduleAds->moduleManagement(
$this->module::PRESTASHOP_ADS_MODULE_NAME,
$this->module::PRESTASHOP_ADS_MODULE_ID
);

$returnJson = array(
'installed' => $installModule,
'moduleLink' => $this->module->getModulePrestashopAdsLink($installModule),
);

$this->ajaxDie(\Tools::jsonEncode($returnJson));
}
}
35 changes: 35 additions & 0 deletions controllers/admin/index.php
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
35 changes: 35 additions & 0 deletions controllers/index.php
@@ -0,0 +1,35 @@
<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
74 changes: 0 additions & 74 deletions css/gadwords-nobootstrap.css

This file was deleted.