-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.php
99 lines (89 loc) · 2.18 KB
/
script.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* @package Joomla.Plugin
* @subpackage Jea.Dpe
*
* @copyright Copyright (C) 2007 - 2019 PHILIP Sylvain. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Factory;
use Joomla\Database\DatabaseInterface;
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Install Script file of JEA component
*/
class plgjeadpeInstallerScript
{
/**
* Method to install the extension
*
* @return void
*/
function install ($parent)
{
if (!Folder::exists(JPATH_ROOT . '/images/com_jea/dpe'))
{
Folder::create(JPATH_ROOT . '/images/com_jea/dpe');
}
}
/**
* Method to uninstall the extension
*
* @return void
*/
function uninstall ($parent)
{
if (Folder::exists(JPATH_ROOT . '/images/com_jea/dpe'))
{
Folder::delete(JPATH_ROOT . '/images/com_jea/dpe');
}
}
/**
* Method to update the extension
*
* @return void
*/
function update ($parent)
{
if (!Folder::exists(JPATH_ROOT . '/images/com_jea/dpe'))
{
Folder::create(JPATH_ROOT . '/images/com_jea/dpe');
}
}
/**
* Method to run before an install/update/uninstall method
*
* @return void
*/
function preflight ($type, $parent)
{
$db = Factory::getContainer()->get(DatabaseInterface::class);
assert($db instanceof DatabaseInterface);
$db->setQuery('SHOW COLUMNS FROM #__jea_properties');
$cols = $db->loadObjectList('Field');
if (! isset($cols['dpe_energy']) && ! isset($cols['dpe_ges']))
{
$query = 'ALTER TABLE `#__jea_properties` ' . "ADD `dpe_energy` SMALLINT(4) NOT NULL DEFAULT '-1',"
. "ADD `dpe_ges` SMALLINT(4) NOT NULL DEFAULT '-1'";
$db->setQuery($query);
$db->execute();
}
elseif (isset($cols['dpe_energie']) && isset($cols['dpe_ges']))
{
$query = 'ALTER TABLE `#__jea_properties` ' . "CHANGE `dpe_energie` `dpe_energy` SMALLINT(4) NOT NULL DEFAULT '-1',"
. "CHANGE `dpe_ges` `dpe_ges` SMALLINT(4) NOT NULL DEFAULT '-1'";
$db->setQuery($query);
$db->execute();
}
}
/**
* Method to run after an install/update/uninstall method
*
* @return void
*/
function postflight ($type, $parent)
{
}
}