This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
executable file
·111 lines (92 loc) · 3.23 KB
/
install.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* @package Gantry 5 Theme
* @author RocketTheme http://www.rockettheme.com
* @copyright Copyright (C) 2007 - 2017 RocketTheme, LLC
* @license GNU/GPLv2 and later
*
* http://www.gnu.org/licenses/gpl-2.0.html
*/
defined('_JEXEC') or die;
class G5_HeliumInstallerScript
{
public $requiredGantryVersion = '5.4.0';
/**
* @param string $type
* @param object $parent
* @return bool
* @throws Exception
*/
public function preflight($type, $parent)
{
if ($type === 'uninstall') {
return true;
}
$manifest = $parent->getManifest();
$name = JText::_($manifest->name);
// Prevent installation if Gantry 5 isn't enabled or is too old for this template.
try {
if (!class_exists('Gantry5\Loader')) {
throw new RuntimeException(sprintf('Please install Gantry 5 Framework before installing %s template!', $name));
}
Gantry5\Loader::setup();
$gantry = Gantry\Framework\Gantry::instance();
if (!method_exists($gantry, 'isCompatible') || !$gantry->isCompatible($this->requiredGantryVersion)) {
throw new \RuntimeException(sprintf('Please upgrade Gantry 5 Framework to v%s (or later) before installing %s template!', strtoupper($this->requiredGantryVersion), $name));
}
} catch (Exception $e) {
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf($e->getMessage()), 'error');
return false;
}
return true;
}
/**
* @param string $type
* @param JInstallerAdapterTemplate $parent
* @throws Exception
*/
public function postflight($type, $parent)
{
// Delete previous jQuery overrides, those just break things.
$search = JPATH_ROOT . "/templates/{$parent->getName()}/js/jui";
if (JFolder::exists($search)) {
JFolder::delete($search);
}
$installer = new Gantry\Framework\ThemeInstaller($parent);
$installer->initialize();
// Install sample data on first install.
if (in_array($type, array('install', 'discover_install'))) {
try {
$installer->installDefaults();
echo $installer->render('install.html.twig');
} catch (Exception $e) {
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf($e->getMessage()), 'error');
}
} else {
echo $installer->render('update.html.twig');
}
$installer->finalize();
}
/**
* Called by TemplateInstaller to customize post-installation.
*
* @param \Gantry\Framework\ThemeInstaller $installer
*/
public function installDefaults(Gantry\Framework\ThemeInstaller $installer)
{
// Create default outlines etc.
$installer->createDefaults();
}
/**
* Called by TemplateInstaller to customize sample data creation.
*
* @param \Gantry\Framework\ThemeInstaller $installer
*/
public function installSampleData(Gantry\Framework\ThemeInstaller $installer)
{
// Create sample data.
$installer->createSampleData();
}
}